프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 23a96932

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

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

    
42
            T instance = Activator.CreateInstance<T>();
43

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

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

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

    
80
        public TextBox Gui { get; private set; }
81

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

    
95
        public void WriteLine(string line)
96
        {
97
            if (!Gui.Dispatcher.CheckAccess())
98
            {
99
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
100
                return;
101
            }
102

    
103
            Gui.Text += line + Environment.NewLine;
104
        }
105
    }
106

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

    
146
        public InkPresenter _InkBoard = null;
147
        Stroke stroke;
148
        Boolean IsDrawing = false;
149
        StylusPointCollection strokePoints;
150
        StylusPointCollection erasePoints;
151
        RenderTargetBitmap canvasImage;
152
        Point Sync_Offset_Point;
153

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

    
169
                }
170
            }
171
        }
172

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

    
197
        public bool IsSyncPDFMode { get; set; }
198

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

    
223
        #endregion
224

    
225

    
226
        public MainMenu()
227
        {
228
            InitializeComponent();
229
            this.Loaded += MainMenu_Loaded;
230
        }
231
        private void SetCursor()
232
        {
233
            this.Cursor = cursor;
234
        }
235

    
236
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
237
        {
238
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
239
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
240
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
241
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
242
            {
243
                return true;
244
            }
245

    
246
            return false;
247
        }
248

    
249
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
250
        {
251
            if (rotate.Angle == 90 || rotate.Angle == 270)
252
            {
253
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
254
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
255
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
256
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
257
                {
258
                    return true;
259
                }
260
            }
261
            else
262
            {
263
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
264
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
265
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
266
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
267
                {
268
                    return true;
269
                }
270
            }               
271

    
272
            return false;
273
        }
274

    
275
       
276
        public void DeleteItem(MarkupInfoItem item)
277
        {
278
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
279
            {
280
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
281
            }
282

    
283
            ViewerDataModel.Instance._markupInfoList.Remove(item);
284

    
285
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
286
            {
287
                ViewerDataModel.Instance.MarkupControls.Remove(a);
288
            });
289

    
290
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
291
            {
292
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
293
            });
294

    
295
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
296
            {
297
                ComingNewBieEnd = false;
298
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
299
            });
300

    
301
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
302
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
303
            {
304
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
305
                {
306
                    var infoId = Events.Save.shortGuid();
307
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
308
                    {
309
                        CreateTime = DateTime.Now,
310
                        Depatment = userData.DEPARTMENT,
311
                        UpdateTime = DateTime.Now,
312
                        DisplayColor = "#FFFF0000",
313
                        UserID = userData.ID,
314
                        UserName = userData.NAME,
315
                        PageCount = 1,
316
                        Description = "",
317
                        MarkupInfoID = infoId,
318
                        MarkupList = null,
319
                        MarkupVersionID = Events.Save.shortGuid(),
320
                        Consolidate = 0,
321
                        PartConsolidate = 0,
322
                        userDelete = true,
323
                        AvoidConsolidate = 0,
324
                        IsPreviewUser = true
325
                    };
326
                    App.Custom_ViewInfoId = infoId;
327
                }
328
            }
329
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
330
        }
331

    
332
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
333
        {
334
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
335
            this.ReleaseAdorner();
336

    
337
            Button content = (sender as Button);
338
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
339

    
340
            DeleteItem(item);
341
        }
342

    
343
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
344

    
345
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
346
        {
347
            if (App.ParameterMode)
348
            {
349
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
350
                imageViewer_Compare = new Image();
351

    
352
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
353
                ViewerDataModel.Instance.Capture_Opacity = 0;
354

    
355
                da.From = 0.8;
356
                da.To = 0;
357
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
358
                da.AutoReverse = true;
359
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;                
360
            }
361
        }        
362

    
363
        public void ReleaseAdorner()
364
        {
365
            if (SelectLayer.Children.Count > 0)
366
            {
367
                foreach (var item in SelectLayer.Children)
368
                {
369
                    if (item.GetType().Name == "AdornerFinal")
370
                    {
371
                        (item as AdornerFinal).unRegister();
372

    
373
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
374
                        {
375
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
376
                            {
377
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
378
                                {
379
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
380
                                    {
381
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
382
                                    }
383
                                }
384

    
385
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
386
                            }
387
                        }
388
                    }
389
                }
390
                SelectLayer.Children.Clear();
391
            }
392
        }
393

    
394
        public List<CommentUserInfo> AddAdorner()
395
        {
396
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
397

    
398
            if (SelectLayer.Children.Count > 0)
399
            {
400
                foreach (var item in SelectLayer.Children)
401
                {
402
                    if (item.GetType().Name == "AdornerFinal")
403
                    {
404
                        (item as AdornerFinal).unRegister();
405

    
406
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
407
                        {
408
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
409
                            {
410
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
411
                            }
412

    
413
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
414

    
415
                            UndoData.Markup_List.Add(multi_Undo_Data);
416
                            multi_Undo_Data = new Multi_Undo_data();
417
                        }
418
                    }
419
                }
420
                SelectLayer.Children.Clear();
421
            }
422
            return adornerSet;
423
        }
424

    
425
        public void ChangeCommentReact()
426
        {
427
            bool isComingNewBie = false;
428

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

    
435
                   
436
                        var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
437
                        if (existItem != null) //신규 추가 된 코멘트
438
                        {
439
                            if (existItem.Data != root.ConvertData) //코멘트가 같은지
440
                            {
441
                                existItem.Data = root.ConvertData;
442
                                existItem.IsUpdate = true;
443
                            }
444
                        }
445
                        else
446
                        {
447
                            if (root.CommentID != null)
448
                            {
449
                                isComingNewBie = true;
450
                                var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
451
                                if (currentCommentCheck != null)
452
                                {
453
                                    currentCommentCheck.Data = root.ConvertData;
454
                                }
455
                                else
456
                                {
457
                                    ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
458
                                    {
459
                                        ID = control.CommentID,
460
                                        Data = root.ConvertData,
461
                                        Data_Type = root.DATA_TYPE,
462
                                        MarkupInfoID = App.Custom_ViewInfoId,
463
                                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
464
                                    });
465
                                }
466
                            }
467
                        }
468
                    
469

    
470
                    
471
                }
472
            }
473

    
474
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
475
            {
476
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
477
                {
478
                    ComingNewBieEnd = true;
479
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
480
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
481
                    gridViewMarkup.ItemsSource = null;
482
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
483
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
484
                }
485
            }
486

    
487
        }
488

    
489
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
490
        bool ComingNewBieEnd = false;
491

    
492
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
493
        {            
494
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
495
            {   
496
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
497
            }
498

    
499
            ViewerDataModel.Instance.UndoDataList.Clear();
500

    
501
            InkControl_Convert();
502

    
503
            ReleaseAdorner();
504
            ChangeCommentReact();
505
            CompareMode.IsChecked = false;
506
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
507

    
508

    
509
            #region 페이지가 벗어난 경우
510

    
511
            if (BalancePoint < 1)
512
            {
513
                BalancePoint = 1;
514
                ViewerDataModel.Instance.PageBalanceNumber = 0;
515
            }
516

    
517
            if (pageNavigator.PageCount < BalancePoint)
518
            {
519
                BalancePoint = pageNavigator.PageCount;
520
                ViewerDataModel.Instance.PageBalanceNumber = 0;
521
            }
522

    
523
            #endregion
524

    
525
            ViewerDataModel.Instance.PageNumber = BalancePoint;
526

    
527
            string uri = "";
528
            if (userData.COMPANY != "EXT")
529
            {
530
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
531
            }
532
            else
533
            {
534
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
535
            }
536

    
537
            var defaultBitmapImage = new BitmapImage(new Uri(uri));
538

    
539
            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
540
            ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
541
            ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
542

    
543
            if (defaultBitmapImage.IsDownloading)
544
            {
545
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
546
                {
547
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
548
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
549
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
550
                };
551
            }
552

    
553
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
554
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
555

    
556

    
557
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
558
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
559
            inkBoard.Width = zoomAndPanCanvas.Width;
560
            inkBoard.Height = zoomAndPanCanvas.Height;
561

    
562

    
563
            if (!testPanel2.IsHidden)
564
            {
565
                //PDF모드일때 잠시 대기(강인구)
566
                if (IsSyncPDFMode)
567
                {
568
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
569
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
570

    
571
                    if (pdfpath.IsDownloading)
572
                    {
573
                        pdfpath.DownloadCompleted += (ex, arg) =>
574
                        {
575
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
576
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
577
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
578
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
579
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
580
                        };
581
                    }
582
                    else
583
                    {
584
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
585
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
586
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
587

    
588
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
589
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
590
                    }
591
                }
592
                else
593
                {
594
                    string uri2 = "";
595
                    if (userData.COMPANY != "EXT")
596
                    {
597
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
598
                    }
599
                    else
600
                    {
601
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
602
                    }
603

    
604

    
605
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
606

    
607
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
608
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
609
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
610
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
611
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
612

    
613
                    zoomAndPanControl.ZoomTo(new Rect
614
                    {
615
                        X = 0,
616
                        Y = 0,
617
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
618
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
619
                    });
620

    
621
                    if (defaultBitmapImage_Compare.IsDownloading)
622
                    {
623
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
624
                        {
625

    
626
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
627
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
628
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
629

    
630
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
631
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
632

    
633
                            zoomAndPanControl.ZoomTo(new Rect
634
                            {
635
                                X = 0,
636
                                Y = 0,
637
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
638
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
639
                            });
640
                        };
641
                    }
642
                }
643
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
644
            }
645

    
646
            this.pageNavigator.SetNextPage();
647

    
648
            if (zoomAndPanCanvas2.Width.IsNaN())
649
            {
650
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
651
            }
652

    
653
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
654
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
655

    
656
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
657
 
658
            foreach (var item in gridSelectionItem)
659
            {
660
                if (item.UserID == App.ViewInfo.UserID)
661
                {
662
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
663
                    {
664
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
665
                    });
666
                }
667
                else
668
                {
669
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
670
                    {
671
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
672
                    });
673
                }
674
            }
675

    
676
            if (!testPanel2.IsHidden)
677
            {
678
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
679
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
680
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
681

    
682
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
683
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
684

    
685

    
686
                foreach (var item in gridSelectionRevItem)
687
                {
688
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
689
                    {
690
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
691
                    });
692
                }
693

    
694
            }
695

    
696
            var instanceMain = this.ParentOfType<MainWindow>();
697
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
698
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
699

    
700
            //강인구 추가
701
            instanceMain.dzTopMenu.rotateOffSet = 0;
702
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
703
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
704

    
705
            //}
706
            SetCommentPages(true);
707
        }
708

    
709
        private void SetCommentPages(bool onlyMe = false)
710
        {
711

    
712
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
713
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
714
            {
715
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
716
                instance.UserName = item.UserName;
717
                instance.Depart = item.Depatment;
718
                instance.MarkupInfoID = item.MarkupInfoID;
719
                instance.IsSelected = true;
720
                instance.isConSolidation = item.Consolidate;
721
                instance.SetColor = item.DisplayColor;
722
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
723
                {
724
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
725
                }
726
                else
727
                {
728
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
729
                }
730
                _pages.Add(instance);
731
            }
732
            this.pageNavigator.SetCommentList(_pages.ToList());
733
        }
734

    
735
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
736
        {
737
            if (e.MiddleButton == MouseButtonState.Pressed)
738
            {
739

    
740
            }
741
            e.Handled = true;
742
            if (e.Delta > 0)
743
            {
744
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
745
                ZoomIn(currentContentMousePoint);
746
            }
747
            else
748
            {
749
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
750
                ZoomOut(currentContentMousePoint);
751
            }
752
        }
753

    
754
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
755
        {
756
            e.Handled = true;
757
            if (e.Delta > 0)
758
            {
759
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
760
                ZoomIn_Sync(currentContentMousePoint);
761
            }
762
            else
763
            {
764
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
765
                ZoomOut_Sync(currentContentMousePoint);
766
            }
767
        }
768

    
769
        #region ZoomIn & ZoomOut
770

    
771
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
772
        {
773
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
774
                zoomAndPanControl.ContentZoomFocusY));
775
        }
776

    
777
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
778
        {
779
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
780
                zoomAndPanControl.ContentZoomFocusY));
781
        }
782

    
783

    
784
        //강인구 추가 (줌 인아웃 수치 변경)
785
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
786
        private void ZoomOut(Point contentZoomCenter)
787
        {
788
            if (zoomAndPanControl.ContentScale > 0.39)
789
            {
790
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
791
            }
792
            else
793
            {
794
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
795
            }
796

    
797
            if (zoomAndPanControl2 != null && Sync.IsChecked)
798
            {
799
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
800
            }
801
        }
802

    
803
        private void ZoomIn(Point contentZoomCenter)
804
        {
805
            if (zoomAndPanControl.ContentScale > 0.19)
806
            {
807
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
808
            }
809
            else
810
            {
811
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
812
            }
813

    
814
            if (zoomAndPanControl2 != null && Sync.IsChecked)
815
            {
816
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
817
            }
818

    
819
        }
820

    
821
        private void ZoomOut_Sync(Point contentZoomCenter)
822
        {
823
            if (zoomAndPanControl2.ContentScale > 0.39)
824
            {
825
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
826
            }
827
            else
828
            {
829
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
830
            }
831

    
832
            if (Sync.IsChecked)
833
            {
834
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
835
            }
836
        }
837

    
838
        private void ZoomIn_Sync(Point contentZoomCenter)
839
        {
840
            if (zoomAndPanControl2.ContentScale > 0.19)
841
            {
842
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
843
            }
844
            else
845
            {
846
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
847
            }
848

    
849
            if (Sync.IsChecked)
850
            {
851
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
852
            }
853
        }
854

    
855
        private void ZoomOut()
856
        {
857
            zoomAndPanControl.ContentScale -= 0.1;
858
            //if (zoomAndPanControl2 != null)
859
            //{
860
            //    zoomAndPanControl2.ContentScale -= 0.1;
861
            //}
862
        }
863

    
864
        private void ZoomIn()
865
        {
866
            zoomAndPanControl.ContentScale += 0.1;
867
            //if (zoomAndPanControl2 != null)
868
            //{
869
            //    zoomAndPanControl2.ContentScale += 0.1;
870
            //}
871
        }
872

    
873
        #endregion
874

    
875
        private void init()
876
        {
877
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
878
            {
879

    
880
                ControlList.Clear();
881
                listBox.Items.Clear();
882
                selected_item.Clear();
883

    
884
                (item as IMarkupCommonData).IsSelected = false;
885
            }
886

    
887
        }
888

    
889
        private HitTestResultBehavior MyCallback(HitTestResult result)
890
        {
891
            //this.cursor = Cursors.UpArrow;
892
            var element = result.VisualHit;
893
            while (element != null && !(element is CommentUserInfo))
894
                element = VisualTreeHelper.GetParent(element);
895

    
896
            if (element == null)
897
            {
898
                return HitTestResultBehavior.Stop;
899
            }
900
            else
901
            {
902
                if (element is CommentUserInfo)
903
                {
904
                    if (!hitList.Contains(element))
905
                    {
906
                        hitList.Add((CommentUserInfo)element);
907
                    }
908
                    else
909
                    {
910
                        return HitTestResultBehavior.Stop;
911
                    }
912
                    //IntersectionDetail intersectionDetail =
913
                    //((GeometryHitTestResult)result).IntersectionDetail;
914
                    //switch (intersectionDetail)
915
                    //{
916
                    //    case IntersectionDetail.FullyContains:
917
                    //        // Add the hit test result to the list:
918
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
919
                    //        return HitTestResultBehavior.Continue;
920
                    //    case IntersectionDetail.Intersects:
921
                    //        // Set the behavior to return visuals at all z-order levels:
922
                    //        return HitTestResultBehavior.Continue;
923
                    //    case IntersectionDetail.FullyInside:
924
                    //        // Set the behavior to return visuals at all z-order levels:
925
                    //        return HitTestResultBehavior.Continue;
926
                    //    default:
927
                    //        return HitTestResultBehavior.Stop;
928
                    //}
929
                }
930
            }
931
            return HitTestResultBehavior.Continue;
932
        }
933

    
934
        public void ReleaseSelectPath()
935
        {
936
            if (SelectionPath == null)
937
            {
938
                SelectionPath = new Path();
939
                SelectionPath.Name = "";
940
            }
941
            if (SelectionPath.Name != "")
942
            {
943
                SelectionPath.Name = "None";
944
            }
945
            SelectionPath.Opacity = 0.01;
946
            SelectionPath.RenderTransform = null;
947
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
948
        }
949

    
950
        #region 컨트롤 초기화 
951
        public void Control_Init(object control)
952
        {
953
            if (L_Size != 0 && (control as IPath) != null)
954
            {
955
                (control as IPath).LineSize = L_Size;
956
                L_Size = 0;
957
            }
958

    
959
            switch (control.GetType().Name)
960
            {
961
                case "RectangleControl":
962
                    {
963
                        (control as RectangleControl).StrokeColor = Brushes.Red;
964
                    }
965
                    break;
966
                case "CircleControl":
967
                    {
968
                        (control as CircleControl).StrokeColor = Brushes.Red;
969
                    }
970
                    break;
971
                case "TriControl":
972
                    {
973
                        (control as TriControl).StrokeColor = Brushes.Red;
974
                    }
975
                    break;
976
                case "RectCloudControl":
977
                    {
978
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
979
                    }
980
                    break;
981
                case "CloudControl":
982
                    {
983
                        (control as CloudControl).StrokeColor = Brushes.Red;
984
                    }
985
                    break;
986
                case "PolygonControl":
987
                    {
988
                        (control as PolygonControl).StrokeColor = Brushes.Red;
989
                    }
990
                    break;
991
                case "ArcControl":
992
                    {
993
                        (control as ArcControl).StrokeColor = Brushes.Red;
994
                    }
995
                    break;
996
                case "LineControl":
997
                    {
998
                        (control as LineControl).StrokeColor = Brushes.Red;
999
                    }
1000
                    break;
1001
                case "ArrowControl_Multi":
1002
                    {
1003
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1004
                    }
1005
                    break;
1006
                case "TextControl":
1007
                    {
1008
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1009
                    }
1010
                    break;
1011
                case "ArrowTextControl":
1012
                    {
1013
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1014
                    }
1015
                    break;
1016
            }
1017
        }
1018
        #endregion
1019

    
1020
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1021
        {
1022
            //Control_Init(e.Source);
1023
        }
1024

    
1025
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1026
        {
1027
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1028
            {
1029
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1030

    
1031
                Point currentPos = e.GetPosition(rect);
1032
                
1033
                floatingTip.HorizontalOffset = currentPos.X + 20;
1034
                floatingTip.VerticalOffset = currentPos.Y;
1035

    
1036

    
1037
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1038
                //tool.Content = "ToolTip";
1039
                //panel.ToolTip = tool;
1040
            }
1041

    
1042
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1043
            {
1044
                #region 마우스 오버 시 색상 변경
1045
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1046
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1047

    
1048
                //if (firstCondition != null)
1049
                //{
1050
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1051

    
1052
                //    if (firstCondition.GetType().Name == "TextControl")
1053
                //    {
1054
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1055
                //        return;
1056
                //    }
1057
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1058
                //    {
1059
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1060
                //        return;
1061
                //    }
1062

    
1063
                //    if (L_Size == 0)
1064
                //    {
1065
                //        L_Size = (firstCondition as IPath).LineSize;
1066
                //        (firstCondition as IPath).LineSize *= 4;
1067
                //    }
1068
                //    switch (firstCondition.GetType().Name)
1069
                //    {
1070
                //        case "RectangleControl":
1071
                //            {
1072
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1073
                //            }
1074
                //            break;
1075
                //        case "CircleControl":
1076
                //            {
1077
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1078
                //            }
1079
                //            break;
1080
                //        case "TriControl":
1081
                //            {
1082
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1083
                //            }
1084
                //            break;
1085
                //        case "RectCloudControl":
1086
                //            {
1087
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1088
                //            }
1089
                //            break;
1090
                //        case "CloudControl":
1091
                //            {
1092
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1093
                //            }
1094
                //            break;
1095
                //        case "PolygonControl":
1096
                //            {
1097
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1098
                //            }
1099
                //            break;
1100
                //        case "ArcControl":
1101
                //            {
1102
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1103
                //            }
1104
                //            break;
1105
                //        case "LineControl":
1106
                //            {
1107
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1108
                //            }
1109
                //            break;
1110
                //        case "ArrowControl_Multi":
1111
                //            {
1112
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1113
                //            }
1114
                //            break;
1115

    
1116
                //        default:
1117
                //            {
1118

    
1119
                //            }
1120
                //            break;
1121
                //    }
1122
                //} 
1123
                #endregion
1124
            }
1125

    
1126
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1127

    
1128
            //if (mouseButtonDown == MouseButton.Middle)
1129
            //{
1130
            //    SetCursor();
1131
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1132
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1133

    
1134
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1135
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1136
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1137

    
1138
            //    //SetCursor();
1139
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1140
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1141

    
1142
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1143

    
1144
            //    //zoomAndPanControl.ContentOffsetX += 1;
1145
            //    //zoomAndPanControl.ContentOffsetY += 1;
1146

    
1147
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1148
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1149
            //}
1150
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1151
            {
1152
                SetCursor();
1153
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1154
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1155

    
1156
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1157
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1158
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1159

    
1160
                if (Sync.IsChecked)
1161
                {
1162
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1163
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1164
                }
1165
            }
1166

    
1167

    
1168
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1169
            {
1170
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1171
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1172
                SetCursor();
1173

    
1174
                if (IsDrawing)
1175
                {
1176
                    if (currentControl == null)
1177
                    {
1178
                        switch (controlType)
1179
                        {
1180
                            case ControlType.PenControl:
1181
                                {
1182
                                    if (inkBoard.Tag.ToString() == "Ink")
1183
                                    {
1184
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1185
                                    }
1186
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1187
                                    {
1188
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1189
                                    }
1190
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1191
                                    {
1192
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1193
                                    }
1194

    
1195
                                    //inkBoard.Strokes.Add(stroke);
1196
                                }
1197
                                break;
1198
                        }
1199
                        return;
1200
                    }
1201
                }
1202

    
1203
                if (currentControl != null)
1204
                {
1205
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1206
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1207
                    //강인구 추가
1208
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1209

    
1210
                    if ((currentControl as IPath) != null)
1211
                    {
1212
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1213
                    }
1214
                    if ((currentControl as LineControl) != null)
1215
                    {
1216
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1217
                    }
1218

    
1219
                    if ((currentControl as IShapeControl) != null)
1220
                    {
1221
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1222
                    }
1223
                    if ((currentControl as TextControl) != null)
1224
                    {
1225
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1226
                        {
1227
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1228
                        }
1229
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1230
                        {
1231
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1232
                        }
1233
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1234
                        {
1235
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1236
                        }
1237
                    }
1238
                    else if ((currentControl as ArrowTextControl) != null)
1239
                    {
1240
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1241
                        {
1242
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1243
                        }
1244
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1245
                        {
1246
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1247
                        }
1248
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1249
                        {
1250
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1251
                        }
1252
                    }
1253
                    else if ((currentControl as RectCloudControl) != null)
1254
                    {
1255
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1256
                    }
1257
                    else if ((currentControl as CloudControl) != null)
1258
                    {
1259
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1260
                    }
1261

    
1262
                    switch (controlType)
1263
                    {
1264
                        case ControlType.Rectangle:
1265
                            {
1266
                                var control = currentControl as RectangleControl;
1267

    
1268
                                if (control != null)
1269
                                {
1270
                                    if (move.mousemode == MouseMode.Drawing)
1271
                                    {
1272
                                        //move.control_Move(ControlList, true, moveX, moveY);
1273
                                    }
1274
                                    else
1275
                                    {
1276
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1277
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1278
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1279
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1280

    
1281

    
1282
                                        if (ViewerDataModel.Instance.IsPressShift)
1283
                                        {
1284
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1285
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1286
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1287
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1288
                                        }
1289

    
1290
                                        control.PointSet = new List<Point>
1291
                                        {
1292
                                            control.StartPoint,
1293
                                            control.LeftBottomPoint,
1294
                                            control.EndPoint,
1295
                                            control.TopRightPoint,
1296
                                        };
1297
                                        control.updateControl();
1298
                                    }
1299

    
1300
                                    //강인구 추가
1301
                                    control.ControlType = controlType;
1302
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1303
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1304
                                }
1305
                            }
1306
                            break;
1307

    
1308
                        case ControlType.RectCloud:
1309
                            {
1310
                                var control = currentControl as RectCloudControl;
1311

    
1312
                                if (control != null)
1313
                                {
1314
                                    if (move.mousemode == MouseMode.Drawing)
1315
                                    {
1316
                                        //move.control_Move(ControlList, true, moveX, moveY);
1317
                                    }
1318
                                    else
1319
                                    {
1320
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1321
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1322
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1323
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1324

    
1325
                                        if (ViewerDataModel.Instance.IsPressShift)
1326
                                        {
1327
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1328
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1329
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1330
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1331
                                        }
1332

    
1333
                                        control.PointSet = new List<Point>
1334
                                        {
1335
                                            control.StartPoint,
1336
                                            control.LeftBottomPoint,
1337
                                            control.EndPoint,
1338
                                            control.TopRightPoint,
1339
                                        };
1340
                                    }
1341
                                    //강인구 추가
1342
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1343
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1344
                                }
1345
                            }
1346
                            break;
1347

    
1348
                        case ControlType.SingleLine:
1349
                            {
1350
                                if (currentControl != null)
1351
                                {
1352
                                    var control = currentControl as LineControl;
1353
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1354
                                    control.ControlType = controlType;
1355
                                    if (control != null)
1356
                                    {
1357
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1358
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1359
                                        Point tempPoint = control.EndPoint;
1360

    
1361
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1362
                                        {
1363
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1364
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1365
                                            control.EndPoint = tempPoint;
1366
                                        }
1367
                                        else
1368
                                        {
1369
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1370
                                        }
1371

    
1372
                                        control.PointSet = new List<Point>
1373
                                        {
1374
                                            control.StartPoint,
1375
                                            control.EndPoint,
1376
                                        };
1377
                                        //강인구 추가
1378
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1379
                                    }
1380
                                }
1381

    
1382
                            }
1383
                            break;
1384

    
1385
                        case ControlType.CancelLine:
1386
                            {
1387
                                if (currentControl != null)
1388
                                {
1389
                                    var control = currentControl as LineControl;
1390
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1391
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1392
                                    control.ControlType = controlType;
1393
                                    if (control != null)
1394
                                    {
1395
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1396
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1397
                                        Point tempPoint = control.EndPoint;
1398

    
1399
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1400
                                        {
1401
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1402
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1403
                                            control.EndPoint = tempPoint;
1404
                                        }
1405
                                        else
1406
                                        {
1407
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1408
                                        }
1409

    
1410

    
1411
                                        control.PointSet = new List<Point>
1412
                                            {
1413
                                                control.StartPoint,
1414
                                                control.EndPoint,
1415
                                            };
1416
                                    }
1417
                                    //강인구 추가
1418
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1419
                                }
1420
                            }
1421
                            break;
1422

    
1423
                        case ControlType.ArrowLine:
1424
                            {
1425
                                if (currentControl != null)
1426
                                {
1427
                                    var control = currentControl as LineControl;
1428
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1429
                                    control.ControlType = controlType;
1430
                                    if (control != null)
1431
                                    {
1432
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1433
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1434
                                        Point tempPoint = control.EndPoint;
1435

    
1436
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1437
                                        {
1438
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1439
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1440
                                            control.EndPoint = tempPoint;
1441
                                        }
1442
                                        else
1443
                                        {
1444
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1445
                                        }
1446

    
1447

    
1448
                                        control.PointSet = new List<Point>
1449
                                            {
1450
                                                control.StartPoint,
1451
                                                control.EndPoint,
1452
                                            };
1453
                                    }
1454
                                    //강인구 추가
1455
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1456
                                }
1457

    
1458
                            }
1459
                            break;
1460

    
1461
                        case ControlType.TwinLine:
1462
                            {
1463
                                if (currentControl != null)
1464
                                {
1465
                                    var control = currentControl as LineControl;
1466
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1467
                                    control.ControlType = controlType;
1468
                                    if (control != null)
1469
                                    {
1470
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1471
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1472
                                        Point tempPoint = control.EndPoint;
1473

    
1474
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1475
                                        {
1476
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1477
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1478
                                            control.EndPoint = tempPoint;
1479
                                        }
1480
                                        else
1481
                                        {
1482
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1483
                                        }
1484

    
1485

    
1486
                                        control.PointSet = new List<Point>
1487
                                            {
1488
                                                control.StartPoint,
1489
                                                control.EndPoint,
1490
                                            };
1491
                                    }
1492
                                    //강인구 추가
1493
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1494
                                }
1495

    
1496
                            }
1497
                            break;
1498

    
1499
                        case ControlType.DimLine:
1500
                            {
1501
                                if (currentControl != null)
1502
                                {
1503
                                    var control = currentControl as LineControl;
1504
                                    control.LineStyleSet = LineStyleSet.DimLine;
1505
                                    control.ControlType = controlType;
1506
                                    if (control != null)
1507
                                    {
1508
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1509
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1510
                                        Point tempPoint = control.EndPoint;
1511

    
1512
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1513
                                        {
1514
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1515
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1516
                                            control.EndPoint = tempPoint;
1517
                                        }
1518
                                        else
1519
                                        {
1520
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1521
                                        }
1522

    
1523
                                        control.PointSet = new List<Point>
1524
                                            {
1525
                                                control.StartPoint,
1526
                                                control.EndPoint,
1527
                                            };
1528
                                    }
1529
                                    //강인구 추가
1530
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1531
                                }
1532

    
1533
                            }
1534
                            break;
1535

    
1536
                        case ControlType.ChainLine:
1537
                            {
1538
                                var control = currentControl as PolygonControl;
1539

    
1540
                                if (control != null)
1541
                                {
1542

    
1543
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1544
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1545

    
1546
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1547

    
1548
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1549
                                    {
1550
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1551
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1552
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1553
                                        //control.EndPoint = tempPoint;
1554
                                    }
1555
                                    else
1556
                                    {
1557
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1558
                                    }
1559

    
1560
                                    control.SetPolyPath();
1561
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1562
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1563
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1564

    
1565
                                    //강인구 추가
1566
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1567
                                }
1568
                            }
1569
                            break;
1570

    
1571
                        case ControlType.ArcLine:
1572
                            {
1573
                                if (currentControl != null)
1574
                                {
1575
                                    var control = currentControl as ArcControl;
1576
                                    control.isTransOn = false;
1577
                                    control.ControlType = controlType;
1578

    
1579
                                    if (control != null)
1580
                                    {
1581
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1582
                                        control.MidPoint = new Point(0, 0);
1583
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1584
                                        Point tempPoint = control.EndPoint;
1585

    
1586
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1587
                                        {
1588
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1589
                                            control.EndPoint = tempPoint;
1590
                                        }
1591
                                        else
1592
                                        {
1593
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1594
                                        }
1595

    
1596

    
1597
                                        control.PointSet = new List<Point>
1598
                                            {
1599
                                                control.StartPoint,
1600
                                                control.MidPoint,
1601
                                                control.EndPoint,
1602
                                            };
1603
                                    }
1604
                                    //강인구 추가
1605
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1606
                                }
1607

    
1608
                            }
1609
                            break;
1610

    
1611
                        case ControlType.ArcArrow:
1612
                            {
1613
                                if (currentControl != null)
1614
                                {
1615
                                    var control = currentControl as ArcControl;
1616
                                    control.isTransOn = true;
1617
                                    control.ControlType = controlType;
1618

    
1619
                                    if (control != null)
1620
                                    {
1621
                                        if (move.mousemode == MouseMode.Drawing)
1622
                                        {
1623
                                            //move.control_Move(ControlList, true, moveX, moveY);
1624
                                        }
1625
                                        else
1626
                                        {
1627
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1628
                                            control.MidPoint = new Point(0, 0);
1629
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1630
                                        }
1631

    
1632
                                        control.PointSet = new List<Point>
1633
                                            {
1634
                                                control.StartPoint,
1635
                                                control.MidPoint,
1636
                                                control.EndPoint,
1637
                                            };
1638
                                    }
1639
                                    //강인구 추가
1640
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1641
                                }
1642
                            }
1643
                            break;
1644

    
1645
                        case ControlType.ArrowMultiLine:
1646
                            {
1647
                                if (currentControl != null)
1648
                                {
1649
                                    var control = currentControl as ArrowControl_Multi;
1650

    
1651
                                    if (control != null)
1652
                                    {
1653
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1654
                                        Point tempPoint = control.EndPoint;
1655
                                        if (control.MiddlePoint == new Point(0, 0))
1656
                                        {
1657
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1658
                                            {
1659
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1660
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1661
                                                control.EndPoint = tempPoint;
1662
                                            }
1663
                                            else
1664
                                            {
1665
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1666
                                            }
1667
                                        }
1668
                                        else
1669
                                        {
1670
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1671
                                            {
1672
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1673
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1674
                                                control.EndPoint = tempPoint;
1675
                                            }
1676
                                            else
1677
                                            {
1678
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1679
                                            }
1680

    
1681
                                        }
1682

    
1683
                                        control.PointSet = new List<Point>
1684
                                            {
1685
                                                control.StartPoint,
1686
                                                control.MiddlePoint,
1687
                                                control.EndPoint,
1688
                                            };
1689

    
1690
                                    }
1691
                                    //강인구 추가
1692
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1693
                                }
1694

    
1695
                            }
1696
                            break;
1697

    
1698
                        case ControlType.Circle:
1699
                            {
1700
                                var control = currentControl as CircleControl;
1701

    
1702
                                if (control != null)
1703
                                {
1704
                                    if (move.mousemode == MouseMode.Drawing)
1705
                                    {
1706
                                        //move.control_Move(ControlList, true, moveX, moveY);
1707
                                    }
1708
                                    else
1709
                                    {
1710
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1711
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1712
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1713
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1714

    
1715
                                        if (ViewerDataModel.Instance.IsPressShift)
1716
                                        {
1717
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1718
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1719
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1720
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1721
                                        }
1722

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

    
1735
                                }
1736
                            }
1737
                            break;
1738

    
1739
                        case ControlType.PolygonCloud:
1740
                            {
1741
                                var control = currentControl as CloudControl;
1742

    
1743
                                if (control != null)
1744
                                {
1745
                                    control.isTransOn = true;
1746
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1747

    
1748
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1749

    
1750
                                    control.SetCloud();
1751
                                    //강인구 추가
1752
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1753
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1754
                                }
1755
                            }
1756
                            break;
1757

    
1758
                        case ControlType.Triangle:
1759
                            {
1760
                                var control = currentControl as TriControl;
1761

    
1762
                                if (control != null)
1763
                                {
1764
                                    if (move.mousemode == MouseMode.Drawing)
1765
                                    {
1766
                                        //move.control_Move(ControlList, true, moveX, moveY);
1767
                                    }
1768
                                    else
1769
                                    {
1770
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1771
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1772

    
1773
                                        if (ViewerDataModel.Instance.checkAxis)
1774
                                        {
1775
                                            Point tempPoint = control.EndPoint;
1776
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1777
                                            control.EndPoint = tempPoint;
1778
                                        }
1779

    
1780

    
1781
                                        if (ViewerDataModel.Instance.IsPressShift)
1782
                                        {
1783
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1784
                                            if (2 == Points.Count())
1785
                                            {
1786
                                                control.MidPoint = Points[0];
1787
                                                control.EndPoint = Points[1];
1788
                                            }
1789
                                        }
1790

    
1791
                                        control.PointSet = new List<Point>
1792
                                            {
1793
                                                control.StartPoint,
1794
                                                control.MidPoint,
1795
                                                control.EndPoint,
1796
                                            };
1797
                                    }
1798
                                    //강인구 추가
1799
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1800
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1801
                                }
1802
                            }
1803
                            break;
1804

    
1805
                        case ControlType.ImgControl:
1806
                            {
1807
                                var control = currentControl as ImgControl;
1808

    
1809
                                if (control != null)
1810
                                {
1811
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1812
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1813
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1814
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1815

    
1816
                                    control.PointSet = new List<Point>
1817
                                        {
1818
                                            control.StartPoint,
1819
                                            control.LeftBottomPoint,
1820
                                            control.EndPoint,
1821
                                            control.TopRightPoint,
1822
                                        };
1823
                                }
1824
                            }
1825
                            break;
1826

    
1827
                        case ControlType.Date:
1828
                            {
1829
                                var control = currentControl as DateControl;
1830

    
1831
                                if (control != null)
1832
                                {
1833
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1834
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1835
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1836
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1837
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1838

    
1839
                                    control.PointSet = new List<Point>
1840
                                        {
1841
                                            control.StartPoint,
1842
                                            control.LeftBottomPoint,
1843
                                            control.EndPoint,
1844
                                            control.TopRightPoint,
1845
                                        };
1846
                                }
1847
                            }
1848
                            break;
1849

    
1850
                        case ControlType.ArrowTextControl:
1851
                            {
1852
                                var control = currentControl as ArrowTextControl;
1853

    
1854
                                if (control != null)
1855
                                {
1856
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1857
                                    Point tempPoint = control.EndPoint;
1858

    
1859
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1860

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

    
1872
                                    control.PointSet = new List<Point>
1873
                                            {
1874
                                                control.StartPoint,
1875
                                                control.MidPoint,
1876
                                                control.EndPoint,
1877
                                            };
1878
                                }
1879
                            }
1880
                            break;
1881

    
1882
                        case ControlType.ArrowTransTextControl:
1883
                            {
1884
                                var control = currentControl as ArrowTextControl;
1885

    
1886
                                if (control != null)
1887
                                {
1888
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1889
                                    Point tempPoint = control.EndPoint;
1890
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1891

    
1892
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1893
                                    {
1894
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1895
                                        control.EndPoint = tempPoint;
1896
                                    }
1897
                                    else
1898
                                    {
1899
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1900
                                    }
1901
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1902
                                    control.isFixed = true;
1903

    
1904
                                    control.PointSet = new List<Point>
1905
                                            {
1906
                                                control.StartPoint,
1907
                                                control.MidPoint,
1908
                                                control.EndPoint,
1909
                                            };
1910
                                }
1911
                            }
1912
                            break;
1913

    
1914
                        case ControlType.ArrowTextBorderControl:
1915
                            {
1916
                                var control = currentControl as ArrowTextControl;
1917

    
1918
                                if (control != null)
1919
                                {
1920
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1921
                                    Point tempPoint = control.EndPoint;
1922
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1923
                                    {
1924
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1925
                                        control.EndPoint = tempPoint;
1926
                                    }
1927
                                    else
1928
                                    {
1929
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1930
                                    }
1931
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1932
                                    control.PointSet = new List<Point>
1933
                                            {
1934
                                                control.StartPoint,
1935
                                                control.MidPoint,
1936
                                                control.EndPoint,
1937
                                            };
1938
                                }
1939

    
1940
                            }
1941
                            break;
1942
                        case ControlType.ArrowTransTextBorderControl:
1943
                            {
1944
                                var control = currentControl as ArrowTextControl;
1945

    
1946
                                if (control != null)
1947
                                {
1948
                                    control.isFixed = true;
1949
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1950
                                    Point tempPoint = control.EndPoint;
1951
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1952
                                    {
1953
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1954
                                        control.EndPoint = tempPoint;
1955
                                    }
1956
                                    else
1957
                                    {
1958
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1959
                                    }
1960

    
1961
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1962
                                    control.PointSet = new List<Point>
1963
                                            {
1964
                                                control.StartPoint,
1965
                                                control.MidPoint,
1966
                                                control.EndPoint,
1967
                                            };
1968
                                }
1969

    
1970
                            }
1971
                            break;
1972
                        case ControlType.ArrowTextCloudControl:
1973
                            {
1974
                                var control = currentControl as ArrowTextControl;
1975

    
1976
                                if (control != null)
1977
                                {
1978
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1979
                                    Point tempPoint = control.EndPoint;
1980
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1981
                                    {
1982
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1983
                                        control.EndPoint = tempPoint;
1984
                                    }
1985
                                    else
1986
                                    {
1987
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1988
                                    }
1989
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1990
                                    control.PointSet = new List<Point>
1991
                                            {
1992
                                                control.StartPoint,
1993
                                                control.MidPoint,
1994
                                                control.EndPoint,
1995
                                            };
1996
                                }
1997

    
1998
                            }
1999
                            break;
2000
                        case ControlType.ArrowTransTextCloudControl:
2001
                            {
2002
                                var control = currentControl as ArrowTextControl;
2003

    
2004
                                if (control != null)
2005
                                {
2006
                                    control.isFixed = true;
2007
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2008
                                    Point tempPoint = control.EndPoint;
2009
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2010
                                    {
2011
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2012
                                        control.EndPoint = tempPoint;
2013
                                    }
2014
                                    else
2015
                                    {
2016
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2017
                                    }
2018
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2019
                                    control.PointSet = new List<Point>
2020
                                            {
2021
                                                control.StartPoint,
2022
                                                control.MidPoint,
2023
                                                control.EndPoint,
2024
                                            };
2025
                                }
2026

    
2027
                            }
2028
                            break;
2029
                        case ControlType.PolygonControl:
2030
                            {
2031

    
2032
                                var control = currentControl as PolygonControl;
2033

    
2034
                                if (control != null)
2035
                                {
2036
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2037
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2038
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2039
                                    control.SetPolyPath();
2040
                                    //강인구 추가
2041
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2042
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2043
                                }
2044
                            }
2045
                            break;
2046
                        //강인구 추가
2047
                        case ControlType.Sign:
2048
                            {
2049
                                var control = currentControl as SignControl;
2050

    
2051
                                if (control != null)
2052
                                {
2053
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2054
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2055
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2056
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2057

    
2058
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2059
                                    {
2060
                                        GetUserSign getUser = new GetUserSign();
2061
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2062
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2063
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2064
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2065
                                        stream.Position = 0;
2066
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2067
                                        BitmapImage returnImage = new BitmapImage();
2068
                                        returnImage.BeginInit();
2069
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2070
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2071
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2072
                                        returnImage.StreamSource = ms;
2073
                                        returnImage.EndInit();
2074
                                        stream.Close();
2075

    
2076
                                        control.SignImage = returnImage;
2077
                                    }
2078
                                    control.PointSet = new List<Point>
2079
                                        {
2080
                                            control.StartPoint,
2081
                                            control.LeftBottomPoint,
2082
                                            control.EndPoint,
2083
                                            control.TopRightPoint,
2084
                                        };
2085
                                }
2086
                            }
2087
                            break;
2088
                        //TODO: 강인구 추가
2089
                        case ControlType.Symbol:
2090
                            {
2091
                                var control = currentControl as SymControl;
2092

    
2093
                                if (control != null)
2094
                                {
2095
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2096
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2097
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2098
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2099
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2100
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2101

    
2102
                                    if (control.StartPoint != control.EndPoint)
2103
                                    {
2104
                                        if (control.PathData == null)
2105
                                        {
2106
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2107
                                            {
2108
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2109
                                            }
2110
                                        }
2111
                                    }
2112

    
2113
                                    control.PointSet = new List<Point>
2114
                                        {
2115
                                            control.StartPoint,
2116
                                            control.LeftBottomPoint,
2117
                                            control.EndPoint,
2118
                                            control.TopRightPoint,
2119
                                        };
2120
                                }
2121
                            }
2122
                            break;
2123
                        ///TODO: 
2124
                        case ControlType.Stamp:
2125
                            {
2126
                                var control = currentControl as SymControlN;
2127

    
2128
                                if (control != null)
2129
                                {
2130

    
2131
                                    if (control.StartPoint == control.EndPoint)
2132
                                    {
2133
                                        string appovalData = "";
2134

    
2135
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2136
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2137

    
2138

    
2139
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2140

    
2141
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2142
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2143
                                        writer.Write(xamlData);
2144
                                        writer.Flush();
2145
                                        stream.Position = 0;
2146

    
2147
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2148
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2149
                                        UIElement ob = obj as UIElement;
2150

    
2151
                                        //control.ApplyTemplate();
2152

    
2153
                                        control.SetViewBox();
2154
                                        control.PathXathData = App.SystemInfo.STAMP;
2155
                                        control.Base_ViewBox.Child = ob;
2156
                                    }
2157

    
2158
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2159
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2160
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2161
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2162
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2163

    
2164

    
2165
                                    control.PointSet = new List<Point>
2166
                                    {
2167
                                        control.StartPoint,
2168
                                        control.LeftBottomPoint,
2169
                                        control.EndPoint,
2170
                                        control.TopRightPoint,
2171
                                    };
2172
                                }
2173
                            }
2174
                            break;
2175
                        case ControlType.Mark:
2176
                            {
2177
                                var control = currentControl as RectangleControl;
2178

    
2179
                                if (control != null)
2180
                                {
2181
                                    if (move.mousemode == MouseMode.Drawing)
2182
                                    {
2183
                                        //move.control_Move(ControlList, true, moveX, moveY);
2184
                                    }
2185
                                    else
2186
                                    {
2187
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2188
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2189
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2190
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2191

    
2192

    
2193
                                        control.PointSet = new List<Point>
2194
                                    {
2195
                                        control.StartPoint,
2196
                                        control.LeftBottomPoint,
2197
                                        control.EndPoint,
2198
                                        control.TopRightPoint,
2199
                                    };
2200
                                    }
2201

    
2202
                                    //강인구 추가
2203
                                    control.Paint = PaintSet.Fill;
2204
                                }
2205
                            }
2206
                            break;
2207
                        case ControlType.PenControl:
2208
                            {
2209
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2210
                                //inkBoard.Strokes.Add(stroke);
2211
                            }
2212
                            break;
2213
                        default:
2214
                            break;
2215
                    }
2216
                }
2217
            }
2218
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2219
            {
2220
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2221

    
2222
                if (isDraggingSelectionRect)
2223
                {
2224
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2225

    
2226
                    e.Handled = true;
2227
                }
2228
                else if (isLeftMouseButtonDownOnWindow)
2229
                {
2230
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2231
                    double dragDistance = Math.Abs(dragDelta.Length);
2232

    
2233
                    if (dragDistance > DragThreshold)
2234
                    {
2235
                        isDraggingSelectionRect = true;
2236

    
2237
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2238
                    }
2239

    
2240
                    e.Handled = true;
2241
                }
2242

    
2243

    
2244
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2245
                {
2246
                    //SelectionPath = new Path();
2247
                    //PathFigure pathFigure = new PathFigure();
2248
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2249
                    //SelectionPath.Opacity = 0.5;
2250
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2251
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2252
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2253
                }
2254
                else
2255
                {
2256
                    //List<Stroke> removingStroke = new List<Stroke>();
2257
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2258
                    //StrokeCollection stC = new StrokeCollection();
2259
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2260
                    //{
2261
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2262
                    //    p1.Intersect(p2);
2263
                    //    if (p1.IsEmpty)
2264
                    //    {
2265

    
2266

    
2267
                    //        p1 = SelectionPath.Data.Bounds;
2268
                    //        bool intersectCheck = false;
2269
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2270
                    //        {
2271
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2272
                    //            p1.Intersect(p3);
2273
                    //            if (!p1.IsEmpty)
2274
                    //            {
2275
                    //                intersectCheck = true;
2276
                    //            }
2277
                    //        }
2278
                    //        if (intersectCheck)
2279
                    //        {
2280
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2281
                    //        }
2282

    
2283
                    //    }
2284
                    //    else
2285
                    //    {
2286
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2287
                    //    }
2288
                    //}
2289

    
2290
                    e.Handled = true;
2291
                }
2292
            }
2293
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2294
            {
2295
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2296
                if (control != null)
2297
                {
2298
                    this.cursor = Cursors.Hand;
2299
                    SetCursor();
2300
                }
2301
                else
2302
                {
2303
                    this.cursor = Cursors.Arrow;
2304
                    SetCursor();
2305
                }
2306
            }
2307
            else
2308
            {
2309
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2310

    
2311
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2312
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2313

    
2314
                //if (hitList.Count > 0)
2315
                //{
2316

    
2317
                //}
2318

    
2319
                #region 조건 설정 : firstCondition
2320
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2321
                //pnts = generalTransform.Transform(pnts);
2322
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2323
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2324
                //                               this.DeepLayer._BaseLayer).ToObservable()
2325
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2326
                //                      select kkk).FirstOrDefault();
2327

    
2328
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2329
                //if (canvas !=null)
2330
                //{
2331
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2332
                //    {
2333
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2334
                //        if (uiElement!=null)
2335
                //        {
2336
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2337
                //        }
2338
                //    }
2339
                //}
2340

    
2341
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2342
                //hitResultsList.Clear();
2343

    
2344
                #endregion
2345
            }
2346
        }
2347

    
2348
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2349
        {
2350
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2351
            {
2352
                SetCursor();
2353
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2354
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2355

    
2356
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2357

    
2358
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2359
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2360

    
2361
                if (Sync.IsChecked)
2362
                {
2363
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2364
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2365
                }
2366
            }
2367
        }
2368

    
2369
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2370

    
2371
        private EllipseGeometry hitArea = new EllipseGeometry();
2372

    
2373
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2374
        {
2375
            IsDrawing = false;
2376

    
2377
            if (mouseHandlingMode != MouseHandlingMode.None)
2378
            {
2379
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2380
                {
2381
                    this.cursor = Cursors.Arrow;
2382

    
2383
                    SetCursor();
2384

    
2385
                    switch (controlType)
2386
                    {
2387
                        case ControlType.None:
2388
                            break;
2389
                        case ControlType.Rectangle:
2390
                            {
2391

    
2392
                            }
2393
                            break;
2394
                        case ControlType.PenControl:
2395
                            {
2396

    
2397
                            }
2398
                            break;
2399
                        default:
2400
                            break;
2401
                    }
2402
                }
2403
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2404
                {
2405
                    if (isLeftMouseButtonDownOnWindow)
2406
                    {
2407
                        bool wasDragSelectionApplied = false;
2408

    
2409
                        if (isDraggingSelectionRect)
2410
                        {
2411
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2412
                            {
2413
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2414
                                mouseHandlingMode = MouseHandlingMode.None;
2415
                                Set_Capture();
2416

    
2417
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2418
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2419
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2420
                            }
2421
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2422
                            {
2423
                                ApplyDragSelectionRect();
2424
                            }
2425
                            else
2426
                            {
2427
                                double x = Canvas.GetLeft(dragZoomBorder);
2428
                                double y = Canvas.GetTop(dragZoomBorder);
2429
                                double width = dragZoomBorder.Width;
2430
                                double height = dragZoomBorder.Height;
2431
                                Rect dragRect = new Rect(x, y, width, height);
2432

    
2433
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2434

    
2435
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2436
                            }
2437

    
2438
                            isDraggingSelectionRect = false;
2439
                            e.Handled = true;
2440
                            wasDragSelectionApplied = true;
2441
                        }
2442

    
2443
                        if (isLeftMouseButtonDownOnWindow)
2444
                        {
2445
                            isLeftMouseButtonDownOnWindow = false;
2446
                            this.ReleaseMouseCapture();
2447
                            e.Handled = true;
2448
                        }
2449

    
2450
                        if (!wasDragSelectionApplied)
2451
                        {
2452
                            init();
2453
                        }
2454
                    }
2455
                }
2456
                else if (mouseButtonDown == MouseButton.Right)
2457
                {
2458
                    this.cursor = Cursors.Arrow;
2459
                    SetCursor();
2460
                }
2461

    
2462
                zoomAndPanControl.ReleaseMouseCapture();
2463

    
2464

    
2465
                e.Handled = true;
2466
            }
2467
            else
2468
            {
2469
                this.cursor = Cursors.Arrow;
2470
                SetCursor();
2471
            }
2472
            mouseButtonDown = MouseButton.Left;
2473

    
2474
            //controlType = ControlType.SingleLine;
2475
        }
2476

    
2477
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2478
        {
2479
            mouseButtonDown = MouseButton.Left;
2480
        }
2481

    
2482
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2483
        {
2484
            mouseButtonDown = MouseButton.Left;
2485
            this.Cursor = Cursors.Arrow;
2486
        }
2487

    
2488
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2489
        {
2490

    
2491
        }
2492

    
2493
        /// <summary>
2494
        /// select item which's bouding rectangle is equal to given rectangle
2495
        /// </summary>
2496
        /// <author>humkyung</author>
2497
        /// <date>2018.06.14</date>
2498
        /// <param name="rect"></param>
2499
        public void SelecteItemByRect(Rect rect)
2500
        {
2501
            multi_Undo_Data = new Multi_Undo_data();
2502

    
2503
            UndoData = new Undo_data()
2504
            {
2505
                IsUndo = false,
2506
                Event = Event_Type.Select,
2507
                EventTime = DateTime.Now,
2508
                Markup_List = new List<Multi_Undo_data>()
2509
            };
2510
           
2511
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2512

    
2513
            CommentUserInfo selected = null;
2514
            double dMinDiff = double.MaxValue;
2515
            Move tmp = new Move();
2516
            foreach (var item in Items)
2517
            {
2518
                Rect boundingBox = tmp.ItemRect(item);
2519
                double dx = rect.X - boundingBox.X;
2520
                double dy = rect.Y - boundingBox.Y;
2521
                double dxx = rect.Right - boundingBox.Right;
2522
                double dyy = rect.Bottom - boundingBox.Bottom;
2523
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
2524
                if (dDiff < dMinDiff)
2525
                {
2526
                    dMinDiff = dDiff;
2527
                    selected = item;
2528
                }
2529
            }
2530

    
2531
            if (selected != null)
2532
            {
2533
                this.ReleaseAdorner();
2534

    
2535
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2536
                adornerSet.Add(selected);
2537
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
2538

    
2539
                Control_Style(selected);
2540
                UndoData.Markup_List.Add(multi_Undo_Data);
2541
                multi_Undo_Data = new Multi_Undo_data();
2542

    
2543
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2544
                {
2545
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2546
                });
2547
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2548

    
2549
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2550
                SelectLayer.Children.Add(final);
2551
            }
2552
        }
2553

    
2554
        private void ApplyDragSelectionRect()
2555
        {
2556
            multi_Undo_Data = new Multi_Undo_data();
2557

    
2558
            UndoData = new Undo_data()
2559
            {
2560
                IsUndo = false,
2561
                Event = Event_Type.Select,
2562
                EventTime = DateTime.Now,
2563
                Markup_List = new List<Multi_Undo_data>()
2564
            };
2565

    
2566
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2567

    
2568
            double x = Canvas.GetLeft(dragSelectionBorder);
2569
            double y = Canvas.GetTop(dragSelectionBorder);
2570
            double width = dragSelectionBorder.Width;
2571
            double height = dragSelectionBorder.Height;
2572
            Rect dragRect = new Rect(x, y, width, height);
2573
            Boolean Flag = false;
2574
            dragRect.Inflate(width / 10, height / 10);
2575
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2576
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2577

    
2578
            dragRect = new Rect(x, y, width, height);
2579
            dragRect.Inflate(width / 10, height / 10);
2580

    
2581
            foreach (var item in Items)
2582
            {
2583
                Flag = move.control_Select(item, dragRect);
2584

    
2585
                if (Flag)
2586
                {
2587
                    adornerSet.Add(item);
2588
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2589

    
2590
                    Control_Style(item);
2591
                    UndoData.Markup_List.Add(multi_Undo_Data);
2592
                    multi_Undo_Data = new Multi_Undo_data();
2593
                }
2594
            }
2595
            if (adornerSet.Count > 0)
2596
            {
2597
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2598
                {
2599
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2600
                });
2601
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2602

    
2603
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2604
                SelectLayer.Children.Add(final);
2605
            }
2606
        }
2607

    
2608
        private void InitDragSelectionRect(Point pt1, Point pt2)
2609
        {
2610
            //캡쳐 중
2611
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2612
            {
2613
                dragCaptureBorder.Visibility = Visibility.Visible;
2614
            }
2615
            //선택 중
2616
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2617
            {
2618

    
2619
                dragSelectionBorder.Visibility = Visibility.Visible;
2620
            }
2621
            else
2622
            {
2623
                dragZoomBorder.Visibility = Visibility.Visible;
2624
            }
2625
            UpdateDragSelectionRect(pt1, pt2);
2626
        }
2627

    
2628
        /// <summary>
2629
        /// Update the position and size of the rectangle used for drag selection.
2630
        /// </summary>
2631
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2632
        {
2633
            double x, y, width, height;
2634

    
2635
            //
2636
            // Determine x,y,width and height of the rect inverting the points if necessary.
2637
            // 
2638

    
2639
            if (pt2.X < pt1.X)
2640
            {
2641
                x = pt2.X;
2642
                width = pt1.X - pt2.X;
2643
            }
2644
            else
2645
            {
2646
                x = pt1.X;
2647
                width = pt2.X - pt1.X;
2648
            }
2649

    
2650
            if (pt2.Y < pt1.Y)
2651
            {
2652
                y = pt2.Y;
2653
                height = pt1.Y - pt2.Y;
2654
            }
2655
            else
2656
            {
2657
                y = pt1.Y;
2658
                height = pt2.Y - pt1.Y;
2659
            }
2660

    
2661
            //
2662
            // Update the coordinates of the rectangle used for drag selection.
2663
            //
2664
            //캡쳐 중
2665
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2666
            {
2667
                Canvas.SetLeft(dragCaptureBorder, x);
2668
                Canvas.SetTop(dragCaptureBorder, y);
2669
                dragCaptureBorder.Width = width;
2670
                dragCaptureBorder.Height = height;
2671
            }
2672
            //선택 중
2673
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2674
            {
2675
                Canvas.SetLeft(dragSelectionBorder, x);
2676
                Canvas.SetTop(dragSelectionBorder, y);
2677
                dragSelectionBorder.Width = width;
2678
                dragSelectionBorder.Height = height;
2679
            }
2680
            else
2681
            {
2682
                Canvas.SetLeft(dragZoomBorder, x);
2683
                Canvas.SetTop(dragZoomBorder, y);
2684
                dragZoomBorder.Width = width;
2685
                dragZoomBorder.Height = height;
2686
            }
2687
        }
2688

    
2689
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2690
        {
2691
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2692

    
2693
            bool result = false;
2694
            if (dragRect.Contains(controlRect))
2695
            {
2696
                result = true;
2697
                //잡은 객체들을 담은 리스트
2698
                try
2699
                {
2700
                    selected_item.Add(OverViewPathData, type.ToString());
2701
                }
2702
                catch (Exception)
2703
                {
2704

    
2705
                }
2706
            }
2707
            return result;
2708
        }
2709

    
2710
        private void drawingPannelRotate(double angle)
2711
        {
2712
            rotate.Angle = angle;
2713
            var rotationNum = Math.Abs((rotate.Angle / 90));
2714

    
2715
            if (angle == 90 || angle == 270)
2716
            {
2717
                double emptySize = zoomAndPanCanvas.Width;
2718
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2719
                zoomAndPanCanvas.Height = emptySize;
2720
            }
2721
            if (angle == 0)
2722
            {
2723
                translate.X = 0;
2724
                translate.Y = 0;
2725
            }
2726
            else if (angle == 90)
2727
            {
2728
                translate.X = zoomAndPanCanvas.Width;
2729
                translate.Y = 0;
2730
            }
2731
            else if (angle == 180)
2732
            {
2733
                translate.X = zoomAndPanCanvas.Width;
2734
                translate.Y = zoomAndPanCanvas.Height;
2735
            }
2736
            else
2737
            {
2738
                translate.X = 0;
2739
                translate.Y = zoomAndPanCanvas.Height;
2740
            }
2741

    
2742
            zoomAndPanControl.RotationAngle = rotate.Angle;
2743

    
2744

    
2745
            if (!testPanel2.IsHidden)
2746
            {
2747
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2748
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2749
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2750
            }
2751

    
2752
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2753
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2754
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2755
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2756
            ViewerDataModel.Instance.Angle = rotate.Angle;
2757
        }
2758

    
2759
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2760
        {
2761
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2762
            if (set_option != null)
2763
            {
2764
                set_option.Value = double.Parse(set_option.ContentText);
2765
            }
2766

    
2767
            InkControl_Convert();
2768

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

    
2772
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2773
            {
2774
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2775
            }
2776

    
2777
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2778
            {
2779
                if (arrow_text as ArrowTextControl != null)
2780
                {
2781
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2782
                }
2783
            }
2784

    
2785
            mouseButtonDown = e.ChangedButton;
2786
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
2787

    
2788
            //if (currentControl != null)
2789
            {
2790
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2791
                if (text_item_ != null)
2792
                {
2793
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2794
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2795
                    (text_item_ as TextControl).IsEditing = false;
2796
                    (text_item_ as TextControl).EnableEditing = false;
2797
                    currentControl = null;
2798
                }
2799

    
2800
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2801
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2802
                {
2803
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2804
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2805
                    currentControl = null;
2806
                }
2807
            }
2808

    
2809
            double Ang = 0;                                          
2810
            if (rotate.Angle != 0)
2811
            {
2812
                Ang = 360 - rotate.Angle;
2813
            }
2814
            move = new Move();
2815

    
2816
            if (e.OriginalSource is System.Windows.Controls.Image)
2817
            {
2818
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2819
            }
2820

    
2821
            if (mouseButtonDown == MouseButton.Left)
2822
            {
2823
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2824
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2825

    
2826
                this.cursor = Cursors.Arrow;
2827
                SetCursor();
2828

    
2829
                if (!ViewerDataModel.Instance.IsPressCtrl)
2830
                {
2831
                    ReleaseAdorner();
2832
                }
2833
            }
2834
            if (mouseButtonDown == MouseButton.Middle)
2835
            {
2836
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2837
                cursor = Cursors.SizeAll;
2838
                SetCursor();
2839
            }
2840
            if (mouseButtonDown == MouseButton.Right)
2841
            {
2842
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2843
                cursor = Cursors.SizeAll;
2844
                SetCursor();
2845
            }
2846
            else if (mouseButtonDown == MouseButton.XButton1)
2847
            {
2848
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2849
                {
2850
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2851
                }
2852

    
2853
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2854

    
2855
            }
2856
            else if (mouseButtonDown == MouseButton.XButton2)
2857
            {
2858
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2859
                {
2860
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2861
                }
2862
            }
2863

    
2864
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2865
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2866
            {
2867
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2868
                {
2869
                    if (SelectLayer.Children.Count == 0)
2870
                    {
2871
                        isLeftMouseButtonDownOnWindow = true;
2872
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2873
                    }
2874

    
2875
                    if (controlType == ControlType.None)
2876
                    {
2877
                        isLeftMouseButtonDownOnWindow = true;
2878
                    }
2879
                }
2880

    
2881
                //캡쳐 모드 설정
2882
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2883
                {
2884
                    dragCaptureBorder.Visibility = Visibility.Visible;
2885
                    isLeftMouseButtonDownOnWindow = true;
2886
                }
2887

    
2888
                //줌 모드 설정
2889
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2890
                {
2891
                    //dragSelectionBorder.Visibility = Visibility.Visible;
2892
                    isLeftMouseButtonDownOnWindow = true;
2893
                }
2894

    
2895

    
2896
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2897
                if (control != null)
2898
                {
2899
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2900
                    AdornerFinal final;
2901
                    List<Point> p_set = new List<Point>();
2902
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2903
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2904
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2905
                    multi_Undo_Data = new Multi_Undo_data();
2906

    
2907
                    //강인구 Undo/Redo 보류
2908
                    UndoData = new Undo_data()
2909
                    {
2910
                        IsUndo = false,
2911
                        Event = Event_Type.Select,
2912
                        EventTime = DateTime.Now,
2913
                        Markup_List = new List<Multi_Undo_data>()
2914
                    };
2915

    
2916
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2917
                    {
2918
                        ReleaseAdorner();
2919
                        final = new AdornerFinal(control);
2920
                        //단일 컨트롤 언두 저장
2921

    
2922
                        Control_Style(control);
2923
                        UndoData.Markup_List.Add(multi_Undo_Data);
2924

    
2925
                        if ((control as IPath) != null)
2926
                        {
2927
                            if ((control as IPath).LineSize != 0)
2928
                            {
2929
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2930
                            }
2931
                        }
2932
                        if ((control as IShapeControl) != null)
2933
                        {
2934
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2935
                            {
2936
                                ViewerDataModel.Instance.checkHatchShape = true;
2937
                            }
2938
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2939
                            {
2940
                                ViewerDataModel.Instance.checkFillShape = true;
2941
                            }
2942
                            else
2943
                            {
2944
                                ViewerDataModel.Instance.checkHatchShape = false;
2945
                                ViewerDataModel.Instance.checkFillShape = false;
2946
                            }
2947
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2948
                        }
2949

    
2950
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2951

    
2952
                        if ((control as TextControl) != null)
2953
                        {
2954
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2955
                            {
2956
                                ViewerDataModel.Instance.checkTextStyle = true;
2957
                            }
2958
                            else
2959
                            {
2960
                                ViewerDataModel.Instance.checkTextStyle = false;
2961
                            }
2962

    
2963
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2964
                            {
2965
                                ViewerDataModel.Instance.checkTextStyle = true;
2966
                            }
2967
                            else
2968
                            {
2969
                                ViewerDataModel.Instance.checkTextStyle = false;
2970
                            }
2971
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2972
                            {
2973
                                ViewerDataModel.Instance.checkTextWeight = true;
2974
                            }
2975
                            else
2976
                            {
2977
                                ViewerDataModel.Instance.checkTextWeight = false;
2978
                            }
2979
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2980
                            {
2981
                                ViewerDataModel.Instance.checkUnderLine = true;
2982
                            }
2983
                            else
2984
                            {
2985
                                ViewerDataModel.Instance.checkUnderLine = false;
2986
                            }
2987
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2988
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2989

    
2990
                        }
2991
                        else if ((control as ArrowTextControl) != null)
2992
                        {
2993
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2994
                            {
2995
                                ViewerDataModel.Instance.checkTextStyle = true;
2996
                            }
2997
                            else
2998
                            {
2999
                                ViewerDataModel.Instance.checkTextStyle = false;
3000
                            }
3001

    
3002
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3003
                            {
3004
                                ViewerDataModel.Instance.checkTextStyle = true;
3005
                            }
3006
                            else
3007
                            {
3008
                                ViewerDataModel.Instance.checkTextStyle = false;
3009
                            }
3010
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3011
                            {
3012
                                ViewerDataModel.Instance.checkTextWeight = true;
3013
                            }
3014
                            else
3015
                            {
3016
                                ViewerDataModel.Instance.checkTextWeight = false;
3017
                            }
3018
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3019
                            {
3020
                                ViewerDataModel.Instance.checkUnderLine = true;
3021
                            }
3022
                            else
3023
                            {
3024
                                ViewerDataModel.Instance.checkUnderLine = false;
3025
                            }
3026
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3027
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3028
                        }
3029
                        else if ((control as RectCloudControl) != null)
3030
                        {
3031
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3032
                        }
3033
                        else if ((control as CloudControl) != null)
3034
                        {
3035
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3036
                        }
3037

    
3038
                    }
3039
                    else
3040
                    {
3041
                        comment = AddAdorner();
3042
                        comment.Add(control);
3043

    
3044
                        Control_Style(control);
3045
                        UndoData.Markup_List.Add(multi_Undo_Data);
3046

    
3047
                        final = new AdornerFinal(comment);
3048
                        //다중 컨트롤 언두 저장
3049
                    }
3050

    
3051
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3052
                    {
3053
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3054
                    });
3055

    
3056
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3057

    
3058
                    SelectLayer.Children.Add(final);
3059
                }
3060
            }
3061

    
3062
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3063
            {
3064
                init();
3065
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3066
                if (cursor != Cursors.SizeAll)
3067
                {
3068
                    cursor = Cursors.Cross;
3069
                    SetCursor();
3070
                }
3071
                bool init_user = false;
3072
                foreach (var user in gridViewMarkup.Items)
3073
                {
3074
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3075
                    {
3076
                        init_user = true;
3077
                    }
3078
                }
3079
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3080
                {
3081
                    RadWindow.Alert(new DialogParameters
3082
                    {
3083
                        Theme = new VisualStudio2013Theme(),
3084
                        Header = "안내",
3085
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3086
                    });
3087
                    return;
3088
                }
3089
                else
3090
                {
3091
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3092
                    if (item != null)
3093
                    {
3094
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3095
                    }
3096
                }
3097

    
3098
                multi_Undo_Data = new Multi_Undo_data();
3099
                //강인구 Undo/Redo 보류
3100
                UndoData = new Undo_data()
3101
                {
3102
                    IsUndo = false,
3103
                    Event = Event_Type.Create,
3104
                    EventTime = DateTime.Now,
3105
                    Markup_List = new List<Multi_Undo_data>()
3106
                };
3107

    
3108
                 switch (controlType)
3109
                {
3110
                    case ControlType.Rectangle:
3111
                        {
3112
                            if (mouseButtonDown == MouseButton.Left)
3113
                            {
3114
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3115
                                //{
3116
                                    if (currentControl is RectangleControl)
3117
                                    {
3118
                                        //20180906 LJY TEST IsRotationDrawingEnable
3119
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3120
                                        {
3121
                                            return;
3122
                                        }
3123

    
3124
                                        CreateControl();
3125

    
3126
                                        (currentControl as RectangleControl).ApplyOverViewData();
3127
                                        currentControl = null;
3128
                                        this.cursor = Cursors.Arrow;
3129
                                    }
3130
                                    else
3131
                                    {
3132
                                        currentControl = new RectangleControl
3133
                                        {
3134
                                            Background = new SolidColorBrush(Colors.Black),
3135
                                            ControlType = ControlType.Rectangle
3136
                                        };
3137

    
3138
                                        currentControl.CommentID = Save.shortGuid();
3139
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3140
                                        currentControl.IsNew = true;
3141
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3142

    
3143
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3144
                                    }
3145
                                //}
3146
                            }
3147
                        }
3148
                        break;
3149
                    case ControlType.RectCloud:
3150
                        {
3151
                            if (mouseButtonDown == MouseButton.Left)
3152
                            {
3153
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3154
                                //{
3155
                                    if (currentControl is RectCloudControl)
3156
                                    {
3157
                                        //20180906 LJY TEST IsRotationDrawingEnable
3158
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3159
                                        {
3160
                                            return;
3161
                                        }
3162

    
3163
                                        CreateControl();
3164

    
3165
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3166
                                        currentControl = null;
3167
                                        this.cursor = Cursors.Arrow;
3168
                                    }
3169
                                    else
3170
                                    {
3171
                                        currentControl = new RectCloudControl
3172
                                        {
3173
                                            Background = new SolidColorBrush(Colors.Black)
3174
                                        };
3175

    
3176
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3177
                                        currentControl.CommentID = Save.shortGuid();
3178
                                        currentControl.IsNew = true;
3179
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3180
                                    }
3181
                                //}
3182
                            }
3183
                        }
3184
                        break;
3185
                    case ControlType.Circle:
3186
                        {
3187
                            if (mouseButtonDown == MouseButton.Left)
3188
                            {
3189
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3190
                                //{
3191
                                    if (currentControl is CircleControl)
3192
                                    {
3193
                                        //20180906 LJY TEST IsRotationDrawingEnable
3194
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3195
                                        {
3196
                                            return;
3197
                                        }
3198

    
3199
                                        CreateControl();
3200

    
3201
                                        (currentControl as CircleControl).ApplyOverViewData();
3202
                                        currentControl = null;
3203
                                    }
3204
                                    else
3205
                                    {
3206
                                        currentControl = new CircleControl
3207
                                        {
3208
                                            Background = new SolidColorBrush(Colors.Black)
3209
                                        };
3210

    
3211
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3212
                                        currentControl.CommentID = Save.shortGuid();
3213
                                        currentControl.IsNew = true;
3214
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3215
                                    }
3216
                                //}
3217
                            }
3218
                        }
3219
                        break;
3220
                    case ControlType.Triangle:
3221
                        {
3222
                            if (mouseButtonDown == MouseButton.Left)
3223
                            {
3224
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3225
                                //{
3226
                                    if (currentControl is TriControl)
3227
                                    {
3228
                                        var content = currentControl as TriControl;
3229
                                        if (content.MidPoint == new Point(0, 0))
3230
                                        {
3231
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3232
                                        }
3233
                                        else
3234
                                        {
3235
                                            //20180906 LJY TEST IsRotationDrawingEnable
3236
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3237
                                            {
3238
                                                return;
3239
                                            }
3240

    
3241
                                            CreateControl();
3242

    
3243
                                            (currentControl as TriControl).ApplyOverViewData();
3244
                                            currentControl = null;
3245
                                        }
3246
                                    }
3247
                                    else
3248
                                    {
3249
                                        currentControl = new TriControl
3250
                                        {
3251
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3252
                                            Background = new SolidColorBrush(Colors.Black),
3253
                                        };
3254

    
3255
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3256
                                        currentControl.CommentID = Save.shortGuid();
3257
                                        currentControl.IsNew = true;
3258
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3259
                                    }
3260
                                //}
3261
                            }
3262
                        }
3263
                        break;
3264
                    case ControlType.SingleLine:
3265
                        {
3266
                            if (mouseButtonDown == MouseButton.Left)
3267
                            {
3268
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3269
                                //{
3270
                                    if (currentControl is LineControl)
3271
                                    {
3272
                                        //20180906 LJY TEST IsRotationDrawingEnable
3273
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3274
                                        {
3275
                                            return;
3276
                                        }
3277

    
3278
                                        CreateControl();
3279

    
3280
                                        (currentControl as LineControl).ApplyOverViewData();
3281
                                        currentControl = null;
3282
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3283
                                    }
3284
                                    else
3285
                                    {
3286
                                        currentControl = new LineControl
3287
                                        {
3288
                                            Background = new SolidColorBrush(Colors.Black)
3289
                                        };
3290

    
3291
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3292
                                        currentControl.CommentID = Save.shortGuid();
3293
                                        currentControl.IsNew = true;
3294
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3295
                                        this.MainAngle.Visibility = Visibility.Visible;
3296
                                    }
3297
                                //}
3298
                            }
3299
                        }
3300
                        break;
3301
                    case ControlType.CancelLine:
3302
                        {
3303
                            if (mouseButtonDown == MouseButton.Left)
3304
                            {
3305
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3306
                                //{
3307
                                    if (currentControl is LineControl)
3308
                                    {
3309
                                        //20180906 LJY TEST IsRotationDrawingEnable
3310
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3311
                                        {
3312
                                            return;
3313
                                        }
3314

    
3315
                                        CreateControl();
3316

    
3317
                                        (currentControl as LineControl).ApplyOverViewData();
3318
                                        currentControl = null;
3319
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3320
                                    }
3321
                                    else
3322
                                    {
3323
                                        currentControl = new LineControl
3324
                                        {
3325
                                            Background = new SolidColorBrush(Colors.Black)
3326
                                        };
3327

    
3328
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3329
                                        currentControl.CommentID = Save.shortGuid();
3330
                                        currentControl.IsNew = true;
3331
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3332
                                        this.MainAngle.Visibility = Visibility.Visible;
3333
                                    }
3334
                                //}
3335
                            }
3336
                        }
3337
                        break;
3338
                    case ControlType.ArrowLine:
3339
                        {
3340
                            if (mouseButtonDown == MouseButton.Left)
3341
                            {
3342
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3343
                                //{
3344
                                    if (currentControl is LineControl)
3345
                                    {
3346
                                        //20180906 LJY TEST IsRotationDrawingEnable
3347
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3348
                                        {
3349
                                            return;
3350
                                        }
3351

    
3352
                                        CreateControl();
3353

    
3354
                                        (currentControl as LineControl).ApplyOverViewData();
3355
                                        currentControl = null;
3356
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3357
                                    }
3358
                                    else
3359
                                    {
3360
                                        currentControl = new LineControl
3361
                                        {
3362
                                            Background = new SolidColorBrush(Colors.Black)
3363
                                        };
3364

    
3365
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3366
                                        currentControl.CommentID = Save.shortGuid();
3367
                                        currentControl.IsNew = true;
3368
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3369
                                        this.MainAngle.Visibility = Visibility.Visible;
3370
                                    }
3371
                                //}
3372
                            }
3373
                        }
3374
                        break;
3375
                    case ControlType.TwinLine:
3376
                        {
3377
                            if (mouseButtonDown == MouseButton.Left)
3378
                            {
3379
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3380
                                //{
3381
                                    if (currentControl is LineControl)
3382
                                    {
3383
                                        //20180906 LJY TEST IsRotationDrawingEnable
3384
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3385
                                        {
3386
                                            return;
3387
                                        }
3388

    
3389
                                        CreateControl();
3390

    
3391
                                        (currentControl as LineControl).ApplyOverViewData();
3392
                                        currentControl = null;
3393
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3394
                                    }
3395
                                    else
3396
                                    {
3397
                                        currentControl = new LineControl
3398
                                        {
3399
                                            Background = new SolidColorBrush(Colors.Black)
3400
                                        };
3401
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3402
                                        currentControl.CommentID = Save.shortGuid();
3403
                                        currentControl.IsNew = true;
3404
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3405
                                        this.MainAngle.Visibility = Visibility.Visible;
3406
                                    }
3407
                                //}
3408
                            }
3409
                        }
3410
                        break;
3411
                    case ControlType.DimLine:
3412
                        {
3413
                            if (mouseButtonDown == MouseButton.Left)
3414
                            {
3415
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3416
                                //{
3417
                                    if (currentControl is LineControl)
3418
                                    {
3419
                                        //20180906 LJY TEST IsRotationDrawingEnable
3420
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3421
                                        {
3422
                                            return;
3423
                                        }
3424
                                        CreateControl();
3425

    
3426
                                        (currentControl as LineControl).ApplyOverViewData();
3427
                                        currentControl = null;
3428
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3429
                                    }
3430
                                    else
3431
                                    {
3432
                                        currentControl = new LineControl
3433
                                        {
3434
                                            Background = new SolidColorBrush(Colors.Black)
3435
                                        };
3436
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3437
                                        currentControl.CommentID = Save.shortGuid();
3438
                                        currentControl.IsNew = true;
3439
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3440
                                        this.MainAngle.Visibility = Visibility.Visible;
3441
                                    }
3442
                                //}
3443
                            }
3444
                        }
3445
                        break;
3446
                    case ControlType.ChainLine:
3447
                        {
3448
                            if (currentControl is PolygonControl)
3449
                            {
3450
                                var control = currentControl as PolygonControl;
3451

    
3452
                                if (mouseButtonDown == MouseButton.Right)
3453
                                {
3454
                                    //20180906 LJY TEST IsRotationDrawingEnable
3455
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3456
                                    {
3457
                                        return;
3458
                                    }
3459

    
3460
                                    CreateControl();
3461

    
3462
                                    (currentControl as PolygonControl).ApplyOverViewData();
3463
                                    currentControl = null;
3464
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3465
                                    return;
3466
                                }
3467

    
3468
                                if (!control.IsCompleted)
3469
                                {
3470
                                    control.PointSet.Add(control.EndPoint);
3471
                                    this.MainAngle.Visibility = Visibility.Visible;
3472
                                }
3473
                            }
3474
                            else
3475
                            {
3476
                                if (mouseButtonDown == MouseButton.Left)
3477
                                {
3478
                                    MainAngle.Visibility = Visibility.Visible;
3479
                                    currentControl = new PolygonControl
3480
                                    {
3481
                                        PointSet = new List<Point>(),
3482
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3483
                                        ControlType = ControlType.ChainLine,
3484
                                        DashSize = ViewerDataModel.Instance.DashSize,
3485
                                        LineSize = ViewerDataModel.Instance.LineSize,
3486
                                        //PointC = new StylusPointSet()
3487
                                    };
3488

    
3489
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3490
                                    //{
3491
                                        var polygonControl = (currentControl as PolygonControl);
3492
                                        currentControl.CommentID = Save.shortGuid();
3493
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3494
                                        currentControl.IsNew = true;
3495
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3496
                                        //currentControl.OnApplyTemplate();
3497
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3498
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3499
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3500
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3501
                                    //}
3502
                                }
3503
                            }
3504
                        }
3505
                        break;
3506
                    case ControlType.ArcLine:
3507
                        {
3508
                            if (mouseButtonDown == MouseButton.Left)
3509
                            {
3510
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3511
                                //{
3512
                                    if (currentControl is ArcControl)
3513
                                    {
3514
                                        //20180906 LJY TEST IsRotationDrawingEnable
3515
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3516
                                        {
3517
                                            return;
3518
                                        }
3519

    
3520
                                        CreateControl();
3521

    
3522
                                        (currentControl as ArcControl).ApplyOverViewData();
3523
                                        currentControl = null;
3524
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3525
                                    }
3526
                                    else
3527
                                    {
3528
                                        currentControl = new ArcControl
3529
                                        {
3530
                                            Background = new SolidColorBrush(Colors.Black)
3531
                                        };
3532
                                        currentControl.CommentID = Save.shortGuid();
3533
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3534
                                        currentControl.IsNew = true;
3535
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3536
                                        this.MainAngle.Visibility = Visibility.Visible;
3537
                                    }
3538
                                //}
3539
                            }
3540
                            else if (mouseButtonDown == MouseButton.Right)
3541
                            {
3542
                                if (currentControl != null)
3543
                                {
3544
                                    (currentControl as ArcControl).setClock();
3545
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3546
                                    //(currentControl as ArcControl).ApplyTemplate();
3547
                                }
3548
                            }
3549
                        }
3550
                        break;
3551
                    case ControlType.ArcArrow:
3552
                        {
3553
                            if (mouseButtonDown == MouseButton.Left)
3554
                            {
3555
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3556
                                //{
3557
                                    if (currentControl is ArcControl)
3558
                                    {
3559
                                        //20180906 LJY TEST IsRotationDrawingEnable
3560
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3561
                                        {
3562
                                            return;
3563
                                        }
3564

    
3565
                                        CreateControl();
3566

    
3567
                                        (currentControl as ArcControl).ApplyOverViewData();
3568
                                        currentControl = null;
3569
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3570
                                    }
3571
                                    else
3572
                                    {
3573
                                        currentControl = new ArcControl
3574
                                        {
3575
                                            Background = new SolidColorBrush(Colors.Red),
3576
                                        };
3577
                                        currentControl.CommentID = Save.shortGuid();
3578
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3579
                                        currentControl.IsNew = true;
3580
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3581
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3582
                                        this.MainAngle.Visibility = Visibility.Visible;
3583
                                    }
3584
                                //}
3585
                            }
3586
                            else if (mouseButtonDown == MouseButton.Right)
3587
                            {
3588
                                (currentControl as ArcControl).setClock();
3589
                            }
3590
                        }
3591
                        break;
3592
                    case ControlType.ArrowMultiLine:
3593
                        {
3594
                            if (mouseButtonDown == MouseButton.Left)
3595
                            {
3596
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3597
                                //{
3598

    
3599
                                    if (currentControl is ArrowControl_Multi)
3600
                                    {
3601
                                        var content = currentControl as ArrowControl_Multi;
3602
                                        if (content.MiddlePoint == new Point(0, 0))
3603
                                        {
3604
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3605
                                            {
3606
                                                content.MiddlePoint = content.EndPoint;
3607
                                            }
3608
                                            else
3609
                                            {
3610
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3611
                                            }
3612
                                        }
3613
                                        else
3614
                                        {
3615
                                            //20180906 LJY TEST IsRotationDrawingEnable
3616
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3617
                                            {
3618
                                                return;
3619
                                            }
3620

    
3621
                                            CreateControl();
3622

    
3623
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3624
                                            currentControl = null;
3625
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3626
                                        }
3627
                                    }
3628
                                    else
3629
                                    {
3630
                                        currentControl = new ArrowControl_Multi
3631
                                        {
3632
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3633
                                            Background = new SolidColorBrush(Colors.Black)
3634
                                        };
3635
                                        currentControl.CommentID = Save.shortGuid();
3636
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3637
                                        currentControl.IsNew = true;
3638
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3639
                                        this.MainAngle.Visibility = Visibility.Visible;
3640
                                    }
3641
                                //}
3642
                            }
3643
                        }
3644
                        break;
3645
                    case ControlType.PolygonCloud:
3646
                        {
3647
                            if (currentControl is CloudControl)
3648
                            {
3649
                                var control = currentControl as CloudControl;
3650
                                if (mouseButtonDown == MouseButton.Right)
3651
                                {
3652
                                    control.IsCompleted = true;
3653
                                }
3654

    
3655
                                if (!control.IsCompleted)
3656
                                {
3657
                                    control.PointSet.Add(control.EndPoint);
3658
                                }
3659
                                else
3660
                                {
3661
                                    //20180906 LJY TEST IsRotationDrawingEnable
3662
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3663
                                    {
3664
                                        return;
3665
                                    }
3666

    
3667
                                    CreateControl();
3668

    
3669
                                    control.isTransOn = true;
3670
                                    var firstPoint = control.PointSet.First();
3671

    
3672
                                    control.PointSet.Add(firstPoint);
3673
                                    control.DrawingCloud();
3674
                                    control.ApplyOverViewData();
3675

    
3676
                                    currentControl = null;
3677
                                }
3678
                            }
3679
                            else
3680
                            {
3681
                                if (mouseButtonDown == MouseButton.Left)
3682
                                {
3683
                                    currentControl = new CloudControl
3684
                                    {
3685
                                        PointSet = new List<Point>(),
3686
                                        PointC = new StylusPointSet()
3687
                                    };
3688

    
3689
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3690
                                    //{
3691
                                        var polygonControl = (currentControl as CloudControl);
3692
                                        currentControl.CommentID = Save.shortGuid();
3693
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3694
                                        currentControl.IsNew = true;
3695
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3696

    
3697
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3698
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3699
                                    //}
3700
                                }
3701
                            }
3702
                        }
3703
                        break;
3704
                    case ControlType.ImgControl:
3705
                        {
3706
                            if (mouseButtonDown == MouseButton.Left)
3707
                            {
3708
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3709
                                //{
3710
                                    if (currentControl is ImgControl)
3711
                                    {
3712
                                        //20180906 LJY TEST IsRotationDrawingEnable
3713
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3714
                                        {
3715
                                            return;
3716
                                        }
3717

    
3718
                                        CreateControl();
3719
                                        (currentControl as ImgControl).ApplyOverViewData();
3720

    
3721
                                        currentControl = null;
3722
                                    }
3723
                                    else
3724
                                    {
3725
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3726
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3727
                                        {
3728
                                            Image img = new Image();
3729
                                            img.Source = new BitmapImage(new Uri(filename));
3730

    
3731
                                            currentControl = new ImgControl
3732
                                            {
3733
                                                Background = new SolidColorBrush(Colors.Black),
3734
                                                PointSet = new List<Point>(),
3735
                                                FilePath = filename,
3736
                                                ImageData = img.Source,
3737
                                                StartPoint = canvasDrawingMouseDownPoint,
3738
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3739
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3740
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3741
                                            };
3742

    
3743
                                            currentControl.CommentID = Save.shortGuid();
3744
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3745
                                            currentControl.IsNew = true;
3746
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3747

    
3748
                                            //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3749
                                            (currentControl as ImgControl).Angle -= rotate.Angle;
3750
                                    }
3751
                                    }
3752
                                //}
3753
                            }
3754
                        }
3755
                        break;
3756
                    case ControlType.Date:
3757
                        {
3758
                            if (mouseButtonDown == MouseButton.Left)
3759
                            {
3760
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3761
                                //{
3762
                                    if (currentControl is DateControl)
3763
                                    {
3764
                                        //20180906 LJY TEST IsRotationDrawingEnable
3765
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3766
                                        {
3767
                                            return;
3768
                                        }
3769

    
3770
                                        CreateControl();
3771
                                        (currentControl as DateControl).ApplyOverViewData();
3772
                                        currentControl = null;
3773

    
3774
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3775
                                        {
3776
                                            controlType = ControlType.None;
3777
                                            IsSwingMode = false;
3778
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3779
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3780
                                            mouseHandlingMode = MouseHandlingMode.None;
3781
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3782
                                            txtBatch.Visibility = Visibility.Collapsed;
3783

    
3784
                                        }
3785
                                    }
3786
                                    else
3787
                                    {
3788
                                        currentControl = new DateControl
3789
                                        {
3790
                                            Background = new SolidColorBrush(Colors.Black)
3791
                                        };
3792
                                        currentControl.CommentID = Save.shortGuid();
3793
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3794
                                        currentControl.IsNew = true;
3795
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3796

    
3797
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3798
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3799
                                }
3800
                                //}
3801
                            }
3802
                        }
3803
                        break;
3804
                    case ControlType.TextControl:
3805
                        {
3806
                            if (mouseButtonDown == MouseButton.Left)
3807
                            {
3808
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3809
                                {
3810
                                    currentControl = new TextControl
3811
                                    {
3812
                                        ControlType = controlType
3813
                                    };
3814
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3815
                                    currentControl.CommentID = Save.shortGuid();
3816
                                    currentControl.IsNew = true;
3817
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3818
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3819
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
3820
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3821
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3822
                                    currentControl.Focus();
3823
                                    (currentControl as TextControl).ApplyOverViewData();
3824
                                    (currentControl as TextControl).ControlType_No = 0;
3825
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3826
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3827

    
3828
                                    CreateControl();
3829

    
3830
                                    //currentControl = null;
3831
                                }
3832
                            }
3833
                        }
3834
                        break;
3835
                    case ControlType.TextBorder:
3836
                        {
3837
                            if (mouseButtonDown == MouseButton.Left)
3838
                            {
3839
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3840
                                {
3841
                                    currentControl = new TextControl
3842
                                    {
3843
                                        ControlType = controlType
3844
                                    };
3845

    
3846
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3847
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3848
                                    currentControl.CommentID = Save.shortGuid();
3849
                                    currentControl.IsNew = true;
3850
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3851
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3852
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3853
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3854
                                    currentControl.Focus();
3855
                                    (currentControl as TextControl).ControlType_No = 1;
3856
                                    (currentControl as TextControl).Angle = Ang;
3857
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3858
                                    CreateControl();
3859

    
3860
                                    //currentControl = null;
3861
                                }
3862
                            }
3863
                        }
3864
                        break;
3865
                    case ControlType.TextCloud:
3866
                        {
3867
                            if (mouseButtonDown == MouseButton.Left)
3868
                            {
3869
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3870
                                {
3871
                                    currentControl = new TextControl
3872
                                    {
3873
                                        ControlType = controlType
3874
                                    };
3875

    
3876
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3877
                                    currentControl.CommentID = Save.shortGuid();
3878
                                    currentControl.IsNew = true;
3879
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3880
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3881

    
3882
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3883
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3884
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3885
                                    currentControl.Focus();
3886

    
3887
                                    (currentControl as TextControl).Angle = Ang;
3888
                                    (currentControl as TextControl).ControlType_No = 2;
3889
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3890

    
3891
                                    CreateControl();
3892
                                    //currentControl = null;
3893
                                }
3894
                            }
3895
                        }
3896
                        break;
3897
                    case ControlType.ArrowTextControl:
3898
                         {
3899
                            if (mouseButtonDown == MouseButton.Left)
3900
                            {
3901
                                if (currentControl is ArrowTextControl)
3902
                                {
3903
                                    //20180906 LJY TEST IsRotationDrawingEnable
3904
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3905
                                    {
3906
                                        return;
3907
                                    }                                    
3908

    
3909
                                    CreateControl();
3910

    
3911
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3912
                                    (currentControl as ArrowTextControl).IsEditing = false;
3913
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3914
                                    (currentControl as ArrowTextControl).IsNew = false;
3915
                                    currentControl = null;
3916
                                }
3917
                                else
3918
                                {
3919
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3920
                                    //{
3921
                                        currentControl = new ArrowTextControl();
3922
                                        currentControl.CommentID = Save.shortGuid();
3923
                                        currentControl.IsNew = true;
3924
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3925
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3926

    
3927
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3928
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3929
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3930
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3931
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3932

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

    
3936
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3937
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3938
                                        this.MainAngle.Visibility = Visibility.Visible;
3939

    
3940
                                    
3941
                                    //}
3942
                                }
3943
                            }
3944
                        }
3945
                        break;
3946
                    case ControlType.ArrowTransTextControl:
3947
                        {
3948
                            if (mouseButtonDown == MouseButton.Left)
3949
                            {
3950
                                if (currentControl is ArrowTextControl)
3951
                                {
3952
                                    //20180906 LJY TEST IsRotationDrawingEnable
3953
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3954
                                    {
3955
                                        return;
3956
                                    }                                    
3957

    
3958
                                    CreateControl();
3959
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3960
                                    currentControl.IsNew = false;
3961
                                    currentControl = null;
3962
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3963
                                }
3964
                                else
3965
                                {
3966
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3967
                                    //{
3968
                                         currentControl = new ArrowTextControl();
3969
                                        currentControl.CommentID = Save.shortGuid();
3970
                                        currentControl.IsNew = true;
3971
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3972
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3973
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3974
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3975
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3976
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3977
                                        (currentControl as ArrowTextControl).isFixed = true;
3978
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3979

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

    
3983
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3984
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3985
                                        (currentControl as ArrowTextControl).isTrans = true;
3986
                                }
3987
                            }
3988
                        }
3989
                        break;
3990
                    case ControlType.ArrowTextBorderControl:
3991
                         {
3992
                            if (mouseButtonDown == MouseButton.Left)
3993
                            {
3994
                                if (currentControl is ArrowTextControl)
3995
                                {
3996
                                    //20180906 LJY TEST IsRotationDrawingEnable
3997
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3998
                                    {
3999
                                        return;
4000
                                    }
4001

    
4002
                                    CreateControl();
4003
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4004
                                    currentControl.IsNew = false;
4005
                                    currentControl = null;
4006
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4007
                                }
4008
                                else
4009
                                {
4010
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4011
                                    //{
4012
                                        currentControl = new ArrowTextControl()
4013
                                        {
4014
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4015
                                        };
4016
                                        currentControl.CommentID = Save.shortGuid();
4017
                                        currentControl.IsNew = true;
4018
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4019
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4020

    
4021
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4022

    
4023
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4024

    
4025
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4026
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4027
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4028

    
4029
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4030
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4031
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4032
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4033
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4034
                                    //}
4035
                                }
4036
                            }
4037
                        }
4038
                        break;
4039
                    case ControlType.ArrowTransTextBorderControl:
4040
                        {
4041
                            if (mouseButtonDown == MouseButton.Left)
4042
                            {
4043
                                if (currentControl is ArrowTextControl)
4044
                                {
4045
                                    //20180906 LJY TEST IsRotationDrawingEnable
4046
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4047
                                    {
4048
                                        return;
4049
                                    }
4050
                                    CreateControl();
4051
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4052
                                    currentControl.IsNew = false;
4053
                                    currentControl = null;
4054
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4055
                                }
4056
                                else
4057
                                {
4058
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4059
                                    //{
4060
                                    
4061

    
4062
                                    currentControl = new ArrowTextControl()
4063
                                        {
4064
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4065
                                        };
4066
                                        currentControl.CommentID = Save.shortGuid();
4067
                                        currentControl.IsNew = true;
4068
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4069
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4070

    
4071
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4072

    
4073
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4074
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4075
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4076
                                        (currentControl as ArrowTextControl).isFixed = true;
4077
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4078
                                     
4079
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4080
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4081
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4082

    
4083
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4084
                                        this.MainAngle.Visibility = Visibility.Visible;
4085
                                    
4086
                                    //20180911 LJY
4087
                                        (currentControl as ArrowTextControl).isTrans = true;
4088
                                    
4089

    
4090
                                    //}
4091
                                }
4092
                            }
4093
                        }
4094
                        break;
4095
                    case ControlType.ArrowTextCloudControl:
4096
                        {
4097
                            if (mouseButtonDown == MouseButton.Left)
4098
                            {
4099
                                if (currentControl is ArrowTextControl)
4100
                                {
4101
                                    //20180906 LJY TEST IsRotationDrawingEnable
4102
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4103
                                    {
4104
                                        return;
4105
                                    }
4106
                                    CreateControl();
4107
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4108
                                    currentControl.IsNew = false;
4109
                                    currentControl = null;
4110
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4111
                                }
4112
                                else
4113
                                {
4114
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4115
                                    //{
4116
                                        currentControl = new ArrowTextControl()
4117
                                        {
4118
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4119
                                        };
4120
                                        currentControl.CommentID = Save.shortGuid();
4121
                                        currentControl.IsNew = true;
4122
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4123
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4124

    
4125
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4126
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4127
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4128
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4129
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4130

    
4131
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4132
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4133
                                    
4134
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4135
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4136
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4137
                                    //}
4138
                                }
4139
                            }
4140
                        }
4141
                        break;
4142
                    case ControlType.ArrowTransTextCloudControl:
4143
                        {
4144
                            if (mouseButtonDown == MouseButton.Left)
4145
                            {
4146
                                if (currentControl is ArrowTextControl)
4147
                                {
4148
                                    //20180906 LJY TEST IsRotationDrawingEnable
4149
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4150
                                    {
4151
                                        return;
4152
                                    }
4153
                                    CreateControl();
4154
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4155
                                    currentControl.IsNew = false;
4156
                                    currentControl = null;
4157
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4158
                                }
4159
                                else
4160
                                {
4161
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4162
                                    //{
4163
                                        currentControl = new ArrowTextControl()
4164
                                        {
4165
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4166
                                        };
4167
                                        currentControl.CommentID = Save.shortGuid();
4168
                                        currentControl.IsNew = true; 
4169
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4170
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4171
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4172

    
4173
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4174
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4175
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4176
                                        (currentControl as ArrowTextControl).isFixed = true;
4177
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4178

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

    
4182
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4183
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4184
                                        this.MainAngle.Visibility = Visibility.Visible;  
4185
                                    
4186
                                    //20180911 LJY
4187
                                        (currentControl as ArrowTextControl).isTrans = true;
4188
                                    //}
4189
                                }
4190
                            }
4191
                        }
4192
                        break;
4193
                    case ControlType.PolygonControl:
4194
                        {
4195
                            if (currentControl is PolygonControl)
4196
                            {
4197
                                var control = currentControl as PolygonControl;
4198

    
4199
                                if (mouseButtonDown == MouseButton.Right)
4200
                                {
4201
                                    control.IsCompleted = true;
4202
                                }
4203

    
4204
                                if (!control.IsCompleted)
4205
                                {
4206
                                    control.PointSet.Add(control.EndPoint);
4207
                                }
4208
                                else
4209
                                {
4210
                                    //20180906 LJY TEST IsRotationDrawingEnable
4211
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4212
                                    {
4213
                                        return;
4214
                                    }
4215

    
4216
                                    var firstPoint = control.PointSet.First();
4217
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4218
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4219
                                    control.PointSet.Add(firstPoint);
4220

    
4221
                                    control.SetPolyPath();
4222

    
4223
                                    control.ApplyOverViewData();
4224

    
4225
                                    CreateControl();
4226

    
4227
                                    currentControl = null;
4228
                                }
4229
                            }
4230
                            else
4231
                            {
4232
                                if (mouseButtonDown == MouseButton.Left)
4233
                                {
4234
                                    currentControl = new PolygonControl
4235
                                    {
4236
                                        PointSet = new List<Point>(),
4237
                                        //PointC = new StylusPointSet()
4238
                                    };
4239

    
4240
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4241
                                    //{
4242
                                        var polygonControl = (currentControl as PolygonControl);
4243
                                        currentControl.CommentID = Save.shortGuid();
4244
                                        currentControl.IsNew = true;
4245
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4246
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4247
                                        //currentControl.OnApplyTemplate();
4248
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4249
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4250
                                    //}
4251
                                }
4252
                            }
4253
                        }
4254
                        break;
4255
                    //강인구 추가
4256
                    case ControlType.Sign:
4257
                        {
4258
                            if (mouseButtonDown == MouseButton.Left)
4259
                            {
4260
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4261
                                //{
4262
                                    GetUserSign getUser = new GetUserSign();
4263
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4264

    
4265
                                    if (_sign == null)
4266
                                    {
4267
                                        txtBatch.Visibility = Visibility.Collapsed;
4268
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4269
                                        controlType = ControlType.None;
4270

    
4271
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4272
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4273
                                        return;
4274
                                    }
4275

    
4276
                                    if (currentControl is SignControl)
4277
                                    {
4278
                                        //20180906 LJY TEST IsRotationDrawingEnable
4279
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4280
                                        {
4281
                                            return;
4282
                                        }
4283

    
4284
                                        CreateControl();
4285
                                        currentControl = null;
4286
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4287
                                        {
4288
                                            txtBatch.Text = "Place Date";
4289
                                            controlType = ControlType.Date;
4290
                                        }
4291
                                    }
4292
                                    else
4293
                                    {
4294
                                        currentControl = new SignControl
4295
                                        {
4296
                                            Background = new SolidColorBrush(Colors.Black),
4297
                                            UserNumber = App.ViewInfo.UserID,
4298
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4299
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4300
                                            ControlType = ControlType.Sign
4301
                                        };
4302

    
4303
                                        currentControl.CommentID = Save.shortGuid();
4304
                                        currentControl.IsNew = true;
4305
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4306
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4307

    
4308
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4309
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4310
                                }
4311
                                //}
4312
                            }
4313
                        }
4314
                        break;
4315
                    case ControlType.Mark:
4316
                        {
4317
                            if (mouseButtonDown == MouseButton.Left)
4318
                            {
4319
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4320
                                //{
4321
                                    if (currentControl is RectangleControl)
4322
                                    {
4323
                                        //20180906 LJY TEST IsRotationDrawingEnable
4324
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4325
                                        {
4326
                                            return;
4327
                                        }
4328

    
4329
                                        CreateControl();
4330
                                        (currentControl as RectangleControl).ApplyOverViewData();
4331
                                        currentControl = null;
4332
                                        this.cursor = Cursors.Arrow;
4333

    
4334
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4335
                                        {
4336
                                            txtBatch.Text = "Place Signature";
4337
                                            controlType = ControlType.Sign;
4338
                                        }
4339
                                    }
4340
                                    else
4341
                                    {
4342
                                        currentControl = new RectangleControl
4343
                                        {
4344
                                            Background = new SolidColorBrush(Colors.Black),
4345
                                            Paint = PaintSet.Fill
4346
                                        };
4347

    
4348
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4349
                                        currentControl.CommentID = Save.shortGuid();
4350
                                        currentControl.IsNew = true;
4351
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4352
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4353
                                    }
4354
                                //}
4355
                            }
4356
                        }
4357
                        break;
4358
                    case ControlType.Symbol:
4359
                        {
4360
                            if (mouseButtonDown == MouseButton.Left)
4361
                            {
4362
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4363
                                //{
4364
                                    if (currentControl is SymControl)
4365
                                    {
4366
                                        //20180906 LJY TEST IsRotationDrawingEnable
4367
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4368
                                        {
4369
                                            return;
4370
                                        }
4371
                                        CreateControl();
4372
                                        currentControl = null;
4373
                                        this.cursor = Cursors.Arrow;
4374
                                    }
4375
                                    else
4376
                                    {
4377
                                        currentControl = new SymControl
4378
                                        {
4379
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4380
                                            Background = new SolidColorBrush(Colors.Black),
4381
                                            ControlType = ControlType.Symbol
4382
                                        };
4383

    
4384
                                        currentControl.IsNew = true;
4385
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4386
                                        currentControl.CommentID = Save.shortGuid();
4387
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4388

    
4389
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4390
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4391
                                }
4392
                                //}
4393
                            }
4394
                        }
4395
                        break;
4396
                    case ControlType.Stamp:
4397
                        {
4398
                            if (mouseButtonDown == MouseButton.Left)
4399
                            {
4400
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4401
                                //{
4402
                                    if (currentControl is SymControlN)
4403
                                    {
4404
                                        //20180906 LJY TEST IsRotationDrawingEnable
4405
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4406
                                        {
4407
                                            return;
4408
                                        }
4409

    
4410
                                        CreateControl();
4411
                                        currentControl = null;
4412
                                        this.cursor = Cursors.Arrow;
4413
                                    }
4414
                                    else
4415
                                    {
4416
                                        currentControl = new SymControlN
4417
                                        {
4418
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4419
                                            Background = new SolidColorBrush(Colors.Black),
4420
                                            ControlType = ControlType.Stamp
4421
                                        };
4422

    
4423
                                        currentControl.IsNew = true;
4424
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4425
                                        currentControl.CommentID = Save.shortGuid();
4426
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4427
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4428
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4429
                                }                                    
4430
                                //}
4431
                            }
4432
                        }
4433
                        break;
4434
                    case ControlType.PenControl:
4435
                        {
4436
                            if (inkBoard.Tag.ToString() == "Ink")
4437
                            {
4438
                                inkBoard.IsEnabled = true;
4439
                                StartNewStroke(canvasDrawingMouseDownPoint);
4440
                            }
4441
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4442
                            {
4443
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4444
                            }
4445
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4446
                            {
4447
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4448
                            }
4449
                            IsDrawing = true;
4450

    
4451
                            temp.AddTemp(currentControl);
4452
                            return;
4453
                        }
4454
                    default:
4455
                        if (currentControl != null)
4456
                        {
4457
                            currentControl.CommentID = null;
4458
                            currentControl.IsNew = false;
4459
                        }
4460
                        break;
4461
                }
4462
            }
4463
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4464
            {
4465
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4466
                {
4467
                    bool mouseOff = false;
4468
                    foreach (var item in SelectLayer.Children)
4469
                    {
4470
                        if (item is AdornerFinal)
4471
                        {
4472

    
4473
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4474
                            if (over != null)
4475
                            {
4476
                                mouseOff = true;
4477
                            }
4478
                        }
4479
                    }
4480

    
4481
                    if (!mouseOff)
4482
                    {
4483
                        ReleaseAdorner();
4484
                    }
4485
                }
4486
                zoomAndPanControl.CaptureMouse();
4487
                e.Handled = true;
4488
            }
4489
        }
4490

    
4491
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4492
        {
4493
            mouseButtonDown = e.ChangedButton;
4494
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4495
        }
4496

    
4497
        private void RemoveLineStroke(Point P)
4498
        {
4499
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4500
            if (control != null)
4501
            {
4502
                UndoData = new Undo_data()
4503
                {
4504
                    IsUndo = false,
4505
                    Event = Event_Type.Delete,
4506
                    EventTime = DateTime.Now,
4507
                    Markup_List = new List<Multi_Undo_data>()
4508
                };
4509

    
4510

    
4511
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4512
                UndoData.Markup_List.Add(multi_Undo_Data);
4513
                multi_Undo_Data = new Multi_Undo_data();
4514

    
4515
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4516
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4517
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4518

    
4519

    
4520
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4521
                {
4522
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4523
                });
4524
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4525

    
4526
            }
4527
        }
4528

    
4529
        private void RemovePointStroke(Point P)
4530
        {
4531
            foreach (Stroke hits in inkBoard.Strokes)
4532
            {
4533
                foreach (StylusPoint sty in hits.StylusPoints)
4534
                {
4535

    
4536
                }
4537
                if (hits.HitTest(P))
4538
                {
4539
                    inkBoard.Strokes.Remove(hits);
4540
                    return;
4541
                }
4542
            }
4543
        }
4544

    
4545
        private void StartNewStroke(Point P)
4546
        {
4547
            strokePoints = new StylusPointCollection();
4548
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4549
            strokePoints.Add(segment1Start);
4550
            stroke = new Stroke(strokePoints);
4551

    
4552
            stroke.DrawingAttributes.Color = Colors.Red;
4553
            stroke.DrawingAttributes.Width = 4;
4554
            stroke.DrawingAttributes.Height = 4;
4555

    
4556
            inkBoard.Strokes.Add(stroke);
4557

    
4558
        }
4559

    
4560
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4561
        {
4562
            ConsolidationMethod();
4563
        }
4564

    
4565
        public void TeamConsolidationMethod()
4566
        {
4567
            ChangeCommentReact();
4568
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4569
            {
4570
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4571
            }
4572
            else
4573
            {
4574
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4575
                {
4576
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4577
                    {
4578
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4579
                        return;
4580
                    }                    
4581
                }
4582
                ViewerDataModel.Instance.IsConsolidate = true;
4583
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4584
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4585

    
4586
                string project_no = App.ViewInfo.ProjectNO;
4587
                string doc_id = _DocInfo.ID;
4588
                string user_id = App.ViewInfo.UserID;
4589
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4590
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4591
                {                    
4592
                    markupInfoItems.Add(item);
4593
                }
4594
                this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
4595

    
4596
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4597
            }
4598
        }
4599
        public void ConsolidationMethod()
4600
        {
4601
            ChangeCommentReact();
4602

    
4603
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4604
            {
4605
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4606
            }
4607
            else
4608
            {                                
4609
                ViewerDataModel.Instance.IsConsolidate = true;
4610
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4611
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4612

    
4613
                string project_no = App.ViewInfo.ProjectNO;
4614
                string doc_id = _DocInfo.ID;
4615
                string user_id = App.ViewInfo.UserID;
4616
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4617
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4618
                {
4619
                    markupInfoItems.Add(item);
4620
                }
4621
                this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4622
                
4623
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4624
                
4625
            }
4626
        }
4627

    
4628
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4629
        {
4630
            if (App.ViewInfo != null)
4631
            {
4632
                btnConsolidate = (sender as RadRibbonButton);
4633
                if (!App.ViewInfo.NewCommentPermission)
4634
                {
4635
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4636
                }
4637
            }
4638
        }
4639

    
4640
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4641
        {
4642
            TeamConsolidationMethod();
4643
        }
4644

    
4645
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4646
        {
4647
            btnTeamConsolidate = sender as RadRibbonButton;
4648
            if (App.ViewInfo != null)
4649
            {
4650
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4651
                {
4652
                    if (btnConsolidate != null)
4653
                    {
4654
                        btnConsolidate.Visibility = Visibility.Collapsed;
4655
                    }
4656

    
4657
                    if (!App.ViewInfo.NewCommentPermission)
4658
                    {
4659
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4660
                    }
4661
                }
4662
                else
4663
                {
4664
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4665
                }
4666
            }
4667
        }
4668

    
4669
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4670
        {
4671
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4672
            if (item != null)
4673
            {
4674
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4675
            }
4676
            else
4677
            {
4678
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4679
            }
4680
        }
4681

    
4682
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4683
        {
4684
            btnFinalPDF = sender as RadRibbonButton;
4685
            if (App.ViewInfo != null)
4686
            {
4687
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4688
                {
4689
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4690
                    if (btnConsolidate != null)
4691
                    {
4692
                        btnConsolidate.Visibility = Visibility.Collapsed;
4693
                    }
4694
                }
4695
            }
4696
        }
4697

    
4698
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4699
        {
4700
            if (CompareMode.IsChecked)
4701
            {
4702
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4703
                {
4704
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4705
                }
4706
                if (ViewerDataModel.Instance.PageNumber == 0)
4707
                {
4708
                    ViewerDataModel.Instance.PageNumber = 1;
4709
                }
4710

    
4711
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4712
            }
4713
            else
4714
            {
4715
                da.From = 1;
4716
                da.To = 1;
4717
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4718
                da.AutoReverse = false;
4719
                canvas_compareBorder.Children.Clear();
4720
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4721
            }
4722
        }
4723

    
4724
        private void Sync_Click(object sender, RoutedEventArgs e)
4725
        {
4726
            if (Sync.IsChecked)
4727
            {
4728
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4729
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4730
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4731
            }
4732
        }
4733

    
4734
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4735
        {
4736
            if (UserList.IsChecked)
4737
            {
4738
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4739
            }
4740
            else
4741
            {
4742
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4743
            }
4744
        }
4745

    
4746
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4747
        {
4748

    
4749
            if (BalanceMode.IsChecked)
4750
            {
4751
                ViewerDataModel.Instance.PageBalanceMode = true;
4752
            }
4753
            else
4754
            {
4755
                ViewerDataModel.Instance.PageBalanceMode = false;
4756
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4757
            }
4758
        }
4759

    
4760
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4761
        {
4762
            //초기화
4763
            testPanel2.IsHidden = true;
4764
            ViewerDataModel.Instance.PageBalanceMode = false;
4765
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4766
            ViewerDataModel.Instance.PageNumber = 0;
4767
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4768
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4769
            UserList.IsChecked = false;
4770
            BalanceMode.IsChecked = false;
4771
        }
4772

    
4773
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4774
        {
4775
            if ((sender as System.Windows.Controls.Control).Tag != null)
4776
            {
4777
                //Compare 초기화
4778
                CompareMode.IsChecked = false;
4779
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4780

    
4781
                if (ViewerDataModel.Instance.PageNumber == 0)
4782
                {
4783
                    ViewerDataModel.Instance.PageNumber = 1;
4784
                }
4785

    
4786
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4787
                {
4788
                }
4789
                else
4790
                {
4791
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4792
                }
4793

    
4794
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4795
                {
4796

    
4797
                }
4798
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4799
                {
4800
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4801
                }
4802

    
4803
                if (!testPanel2.IsHidden)
4804
                {
4805
                    if (IsSyncPDFMode)
4806
                    {
4807
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4808
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4809

    
4810
                        if (pdfpath.IsDownloading)
4811
                        {
4812
                            pdfpath.DownloadCompleted += (ex, arg) =>
4813
                            {
4814
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4815
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4816
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4817
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4818
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4819
                            };
4820
                        }
4821
                        else
4822
                        {
4823
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4824
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4825
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4826

    
4827
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4828
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4829
                        }
4830

    
4831
                    }
4832
                    else
4833
                    {
4834
                        string uri = "";
4835

    
4836
                        if (userData.COMPANY != "EXT")
4837
                        {
4838
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4839
                        }
4840
                        else
4841
                        {
4842
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4843
                        }
4844

    
4845
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4846

    
4847
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4848
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4849
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4850

    
4851
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4852
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4853

    
4854
                        if (defaultBitmapImage_Compare.IsDownloading)
4855
                        {
4856
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4857
                            {
4858
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4859
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4860
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4861

    
4862
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4863
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4864
                            };
4865
                        }
4866
                    }
4867

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

    
4872
                    foreach (var item in gridSelectionRevItem)
4873
                    {
4874
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4875
                        {
4876
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4877
                        });
4878
                    }
4879

    
4880
                    //강인구 추가
4881
                    zoomAndPanControl2.ZoomTo(new Rect
4882
                    {
4883
                        X = 0,
4884
                        Y = 0,
4885
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4886
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4887
                    });
4888

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

    
4891
                }
4892
            }
4893
        }
4894

    
4895
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4896
        {
4897
            if (MarkupMode.IsChecked)
4898
            {
4899
                IsSyncPDFMode = true;
4900

    
4901
                var uri = CurrentRev.TO_VENDOR;
4902

    
4903
                if (ViewerDataModel.Instance.PageNumber == 0)
4904
                {
4905
                    ViewerDataModel.Instance.PageNumber = 1;
4906
                }
4907

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

    
4912
                if (pdfpath.IsDownloading)
4913
                {
4914
                    pdfpath.DownloadCompleted += (ex, arg) =>
4915
                    {
4916
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4917
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4918
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4919
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4920
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4921
                    };
4922
                }
4923
                else
4924
                {
4925
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4926
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4927
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4928

    
4929
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4930
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4931
                }
4932
            }
4933
            else
4934
            {
4935
                IsSyncPDFMode = false;
4936
                string uri = "";
4937
                if (userData.COMPANY != "EXT")
4938
                {
4939
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4940
                }
4941
                else
4942
                {
4943
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4944
                }
4945

    
4946
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4947

    
4948
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4949
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4950
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4951

    
4952
                if (defaultBitmapImage_Compare.IsDownloading)
4953
                {
4954
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4955
                    {
4956
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4957
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4958
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4959
                    };
4960
                }
4961
                zoomAndPanControl2.ApplyTemplate();
4962
                zoomAndPanControl2.UpdateLayout();
4963
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4964
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4965
            }
4966
        }
4967

    
4968
        private void RadButton_Click(object sender, RoutedEventArgs e)
4969
        {
4970
            gridViewHistory_Busy.IsBusy = true;
4971

    
4972
            RadButton instance = sender as RadButton;
4973
            if (instance.CommandParameter != null)
4974
            {
4975
                CurrentRev = instance.CommandParameter as VPRevision;
4976
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4977
                {
4978
                    if (ea.Error == null && ea.Result != null)
4979
                    {
4980
                        testPanel2.IsHidden = false;
4981

    
4982
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4983
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4984

    
4985
                        string uri = "";
4986
                        if (userData.COMPANY != "EXT")
4987
                        {
4988
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4989
                        }
4990
                        else
4991
                        {
4992
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4993
                        }
4994

    
4995
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4996

    
4997
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4998

    
4999
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5000
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5001
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5002

    
5003
                        if (defaultBitmapImage_Compare.IsDownloading)
5004
                        {
5005
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5006
                            {
5007
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5008
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5009
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5010
                            };
5011
                        }
5012

    
5013
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5014
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5015
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5016
                        zoomAndPanControl2.ApplyTemplate();
5017
                        zoomAndPanControl2.UpdateLayout();
5018

    
5019
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5020
                        {
5021
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5022
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5023
                        }
5024

    
5025
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5026
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5027
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5028

    
5029
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5030
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5031
                        gridViewHistory_Busy.IsBusy = false;
5032
                    }
5033
                };
5034
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5035
            }
5036
        }
5037

    
5038
        public void Sync_Event(VPRevision Currnet_Rev)
5039
        {
5040
            CurrentRev = Currnet_Rev;
5041

    
5042
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5043
            {
5044
                if (ea.Error == null && ea.Result != null)
5045
                {
5046
                    testPanel2.IsHidden = false;
5047

    
5048
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5049
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5050

    
5051
                    string uri = "";
5052
                    if (userData.COMPANY != "EXT")
5053
                    {
5054
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5055
                    }
5056
                    else
5057
                    {
5058
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5059
                    }
5060

    
5061
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5062

    
5063
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5064

    
5065
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5066
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5067
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5068

    
5069
                    if (defaultBitmapImage_Compare.IsDownloading)
5070
                    {
5071
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5072
                        {
5073
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5074
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5075
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5076
                        };
5077
                    }
5078
                    
5079
                    
5080
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5081
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5082
                    zoomAndPanControl2.ApplyTemplate();
5083
                    zoomAndPanControl2.UpdateLayout();
5084

    
5085
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5086
                    {
5087
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5088
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5089
                    }
5090
                    //}
5091

    
5092
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5093
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5094
                    gridViewHistory_Busy.IsBusy = false;
5095
                }
5096
            };
5097
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5098

    
5099

    
5100
        }
5101

    
5102
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5103
        {
5104
            if (sender is Image)
5105
            {
5106
                if ((sender as Image).Tag != null)
5107
                {
5108
                    var pdfUrl = (sender as Image).Tag.ToString();
5109
                    System.Diagnostics.Process.Start(pdfUrl);
5110
                }
5111
                else
5112
                {
5113
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5114
                }
5115
            }
5116
        }
5117

    
5118
        private void Create_Symbol(object sender, RoutedEventArgs e)
5119
        {
5120
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5121
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5122

    
5123
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5124
            {
5125
                DialogMessage_Alert("Please Select Controls", "Alert");
5126
            }
5127
            else //선택된 것이 있으면
5128
            {
5129
                string MarkupData = "";
5130
                adorner_ = new AdornerFinal();
5131

    
5132
                foreach (var item in SelectLayer.Children)
5133
                {
5134
                    if (item.GetType().Name == "AdornerFinal")
5135
                    {
5136
                        adorner_ = (item as Controls.AdornerFinal);
5137
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5138
                        {
5139
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5140
                            {
5141
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5142
                                MarkupData += markupReturn.ConvertData;
5143
                            }
5144
                        }
5145
                    }
5146
                }
5147
                DialogParameters parameters = new DialogParameters()
5148
                {
5149
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5150
                    DefaultPromptResultValue = "Custom State",
5151
                    Content = "Name :",
5152
                    Header = "Insert Custom Symbol Name",
5153
                    Theme = new VisualStudio2013Theme(),
5154
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5155
                };
5156
                RadWindow.Prompt(parameters);
5157
            }
5158

    
5159
        }
5160

    
5161
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5162
        {
5163
            Save save = new Save();
5164

    
5165
            if (args.DialogResult.Value)
5166
            {
5167
                PngBitmapEncoder _Encoder = symImage(data);
5168

    
5169
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5170
                _Encoder.Save(fs);
5171
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5172

    
5173
                byte[] Img_byte = fs.ToArray();
5174

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

    
5178
                save.SymbolSave(args.PromptResult, filename, data);
5179
            }
5180
        }
5181

    
5182
        public PngBitmapEncoder symImage(string data)
5183
        {
5184

    
5185
            Canvas _canvas = new Canvas();
5186
            _canvas.Background = Brushes.White;
5187
            _canvas.Width = adorner_.BorderSize.Width;
5188
            _canvas.Height = adorner_.BorderSize.Height;
5189
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5190

    
5191
            BitmapEncoder encoder = new PngBitmapEncoder();
5192

    
5193

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

    
5196
            DrawingVisual dv = new DrawingVisual();
5197

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

    
5201
            using (DrawingContext ctx = dv.RenderOpen())
5202
            {
5203
                VisualBrush vb = new VisualBrush(_canvas);
5204
                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)));
5205
            }
5206

    
5207
            try
5208
            {
5209
                renderBitmap.Render(dv);
5210

    
5211
                GC.Collect();
5212
                GC.WaitForPendingFinalizers();
5213
                GC.Collect();
5214
                // encode png data
5215
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5216
                // puch rendered bitmap into it
5217
                pngEncoder.Interlace = PngInterlaceOption.Off;
5218
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5219
                return pngEncoder;
5220

    
5221
            }
5222
            catch (Exception ex)
5223
            {
5224
                return null;
5225
            }
5226

    
5227
        }
5228

    
5229
        public void DialogMessage_Alert(string content, string header)
5230
        {
5231
            var box = new TextBlock();
5232
            box.MinWidth = 400;
5233
            box.FontSize = 11;
5234
            //box.FontSize = 12;
5235
            box.Text = content;
5236
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5237

    
5238
            DialogParameters parameters = new DialogParameters()
5239
            {
5240
                Content = box,
5241
                Header = header,
5242
                Theme = new VisualStudio2013Theme(),
5243
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5244
            };
5245
            RadWindow.Alert(parameters);
5246
        }
5247

    
5248
        #region 캡쳐 기능
5249

    
5250
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5251
        {
5252
            if (x < 0)
5253
            {
5254
                width += x;
5255
                x = 0;
5256
            }
5257
            if (y < 0)
5258
            {
5259
                height += y;
5260
                y = 0;
5261

    
5262
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5263
            }
5264
            if (x + width > zoomAndPanCanvas.ActualWidth)
5265
            {
5266
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5267
            }
5268
            if (y + height > zoomAndPanCanvas.ActualHeight)
5269
            {
5270
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5271
            }
5272

    
5273
            byte[] pixels = CopyPixels(x, y, width, height);
5274

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

    
5277
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5278
        }
5279

    
5280
        public byte[] CopyPixels(int x, int y, int width, int height)
5281
        {
5282
            byte[] pixels = new byte[width * height * 4];
5283
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5284

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

    
5288
            return pixels;
5289
        }
5290

    
5291
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5292
        {
5293
            DrawingVisual drawingVisual = new DrawingVisual();
5294
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5295

    
5296
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5297
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5298
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5299
            drawingContext.Close();
5300

    
5301
            // 비트맵으로 변환합니다.
5302
            RenderTargetBitmap target =
5303
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5304
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5305

    
5306
            target.Render(drawingVisual);
5307
            return target;
5308
        }
5309

    
5310
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5311
        {
5312
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5313
            KCOMDataModel.DataModel.CHECK_LIST check_;
5314
            string Result = streamToBase64.ImageToBase64(source);
5315
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5316
            string projectno = App.ViewInfo.ProjectNO;
5317
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5318
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5319
            if (Item == null)
5320
            {
5321
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5322
                {
5323
                    ID = Save.shortGuid(),
5324
                    USER_ID = App.ViewInfo.UserID,
5325
                    IMAGE_URL = Result,
5326
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5327
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5328
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5329
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5330
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5331
                    STATUS = "False",
5332
                    CREATE_TIME = DateTime.Now,
5333
                    UPDATE_TIME = DateTime.Now,
5334
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5335
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5336
                };
5337
                this.BaseClient.AddCheckList(projectno, check_);
5338
            }
5339
            else
5340
            {
5341
                Item.IMAGE_URL = Result;
5342
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5343
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5344
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5345
            }
5346
            
5347
        }
5348

    
5349
        public void Set_Capture()
5350
        {            
5351
            double x = canvasDrawingMouseDownPoint.X;
5352
            double y = canvasDrawingMouseDownPoint.Y;
5353
            double width = dragCaptureBorder.Width;
5354
            double height = dragCaptureBorder.Height;
5355

    
5356
            if (width > 5 || height > 5)
5357
            {
5358
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5359
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5360
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5361
            }
5362
        }
5363
        #endregion
5364

    
5365
        TempFile temp = new TempFile();
5366
        //MarkupInfoItem
5367
        public void CreateControl()
5368
        {
5369
            
5370
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5371
            {
5372
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5373
            });
5374
            multi_Undo_Data.Markup = currentControl;
5375
            UndoData.Markup_List.Add(multi_Undo_Data);
5376
           
5377
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5378

    
5379
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5380

    
5381
            temp.AddTemp(currentControl);
5382
        }
5383

    
5384
        
5385
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5386
        {
5387
            multi_Undo_Data = new Multi_Undo_data();
5388

    
5389
            multi_Undo_Data.Markup = control;
5390

    
5391
            if ((control as IShapeControl) != null)
5392
            {
5393
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5394
            }
5395
            if ((control as IDashControl) != null)
5396
            {
5397
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5398
            }
5399
            if ((control as IPath) != null)
5400
            {
5401
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5402
            }
5403
            if ((control as UIElement) != null)
5404
            {
5405
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5406
            }
5407

    
5408
            return multi_Undo_Data;
5409
        }
5410

    
5411
        public void Undo()
5412
        {
5413
            if (ViewerDataModel.Instance.IsPressCtrl)
5414
            {
5415
                ViewerDataModel.Instance.IsPressCtrl = false;
5416
            }
5417
            Undo_data undo = new Undo_data();
5418
            AdornerFinal final;
5419
            ReleaseAdorner();
5420

    
5421
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5422
            if (undo == null)
5423
                return;
5424

    
5425
            
5426

    
5427
            switch (undo.Event)
5428
            {
5429
                case (Event_Type.Create):
5430
                    {
5431
                        foreach (var item in undo.Markup_List)
5432
                        {
5433
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5434
                            //임시파일에서도 삭제한다.
5435
                            temp.DataDel(item.Markup.CommentID);
5436
                        }
5437
                    }
5438
                    break;
5439
                case (Event_Type.Delete):
5440
                    {
5441
                        foreach (var item in undo.Markup_List)
5442
                        {
5443
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5444
                        }
5445
                    }
5446
                    break;
5447
                case (Event_Type.Thumb):
5448
                    {
5449
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5450

    
5451
                        foreach (var item in undo.Markup_List)
5452
                        {
5453
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5454

    
5455
                            if ((item.Markup as IViewBox) != null)
5456
                            {
5457
                                (item.Markup as IViewBox).Angle = item.Angle;
5458
                            }
5459
                            if ((item.Markup as TextControl) != null)
5460
                            {
5461
                                (item.Markup as TextControl).Angle = item.Angle;
5462
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5463
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5464
                            }
5465
                            else
5466
                            {
5467
                                (item.Markup as IPath).PointSet = item.PointSet;
5468
                                (item.Markup as IPath).updateControl();
5469
                            }
5470

    
5471
                            comment.Add(item.Markup);
5472
                        }
5473
                        final = new AdornerFinal(comment);
5474
                        SelectLayer.Children.Add(final);
5475
                        ReleaseAdorner();
5476
                    }
5477
                    break;
5478
                case (Event_Type.Select):
5479
                    {
5480
                        ReleaseAdorner();
5481
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5482

    
5483
                        foreach (var item in undo.Markup_List)
5484
                        {
5485
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5486

    
5487
                            if ((item.Markup as IPath) != null)
5488
                            {
5489
                                (item.Markup as IPath).LineSize = item.LineSize;
5490
                            }
5491
                            if ((item.Markup as UIElement) != null)
5492
                            {
5493
                                (item.Markup as UIElement).Opacity = item.Opacity;
5494
                            }
5495
                            if ((item.Markup as IDashControl) != null)
5496
                            {
5497
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5498
                            }
5499
                            if ((item.Markup as IShapeControl) != null)
5500
                            {
5501
                                (item.Markup as IShapeControl).Paint = item.paint;
5502
                            }
5503

    
5504
                            comment.Add(item.Markup);
5505
                        }
5506

    
5507
                        final = new AdornerFinal(comment);
5508
                        SelectLayer.Children.Add(final);
5509
                    }
5510
                    break;
5511
                case (Event_Type.Option):
5512
                    {
5513
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5514

    
5515
                        foreach (var item in undo.Markup_List)
5516
                        {
5517
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5518

    
5519
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5520
                            {
5521
                                (item.Markup as IPath).LineSize = undo.LineSize;
5522
                            }
5523
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5524
                            {
5525
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5526
                            }
5527
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5528
                            {
5529
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5530
                            }
5531
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5532
                            {
5533
                                (item.Markup as LineControl).Interval = undo.Interval;
5534
                            }
5535
                            else if (item.Markup as IShapeControl != null)
5536
                            {
5537
                                (item.Markup as IShapeControl).Paint = undo.paint;
5538
                            }
5539
                            comment.Add(item.Markup);
5540
                        }
5541
                        final = new AdornerFinal(comment);
5542
                        SelectLayer.Children.Add(final);
5543
                    }
5544
                    break;
5545
            }
5546
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5547
           {
5548
               i.IsUndo = true;
5549
           });
5550
        }
5551

    
5552
        public void Redo()
5553
        {
5554
            if (ViewerDataModel.Instance.IsPressCtrl)
5555
            {
5556
                ViewerDataModel.Instance.IsPressCtrl = false;
5557
            }
5558
            AdornerFinal final;
5559
            Undo_data redo = new Undo_data();
5560
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5561
            ReleaseAdorner();
5562
            if (redo == null)
5563
                return;
5564

    
5565
            switch (redo.Event)
5566
            {
5567
                case (Event_Type.Create):
5568
                    {
5569
                        foreach (var item in redo.Markup_List)
5570
                        {
5571
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5572
                            temp.AddTemp(item.Markup);
5573
                        }
5574
                    }
5575
                    break;
5576
                case (Event_Type.Delete):
5577
                    {
5578
                        foreach (var item in redo.Markup_List)
5579
                        {
5580
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5581
                        }
5582
                    }
5583
                    break;
5584
                case (Event_Type.Thumb):
5585
                    {
5586
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5587

    
5588
                        foreach (var item in redo.Markup_List)
5589
                        {
5590
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5591

    
5592
                            if ((item.Markup as IViewBox) != null)
5593
                            {
5594
                                (item.Markup as IViewBox).Angle = item.Angle;
5595
                            }
5596
                            if ((item.Markup as TextControl) != null)
5597
                            {
5598
                                (item.Markup as TextControl).Angle = item.Angle;
5599

    
5600
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5601
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5602
                            }
5603
                            else
5604
                            {
5605
                                (item.Markup as IPath).PointSet = item.PointSet;
5606
                                (item.Markup as IPath).updateControl();
5607
                            }
5608
                            comment.Add(item.Markup);
5609
                        }
5610
                        final = new AdornerFinal(comment);
5611
                        SelectLayer.Children.Add(final);
5612
                        ReleaseAdorner();
5613
                    }
5614
                    break;
5615
                case (Event_Type.Select):
5616
                    {
5617
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5618

    
5619
                        foreach (var item in redo.Markup_List)
5620
                        {
5621
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5622

    
5623
                            if ((item.Markup as IPath) != null)
5624
                            {
5625
                                (item.Markup as IPath).LineSize = item.LineSize;
5626
                            }
5627
                            if ((item.Markup as UIElement) != null)
5628
                            {
5629
                                (item.Markup as UIElement).Opacity = item.Opacity;
5630
                            }
5631
                            if ((item.Markup as IDashControl) != null)
5632
                            {
5633
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5634
                            }
5635
                            if ((item.Markup as IShapeControl) != null)
5636
                            {
5637
                                (item.Markup as IShapeControl).Paint = item.paint;
5638
                            }
5639

    
5640
                            comment.Add(item.Markup);
5641
                        }
5642
                        final = new AdornerFinal(comment);
5643
                        SelectLayer.Children.Add(final);
5644
                    }
5645
                    break;
5646
                case (Event_Type.Option):
5647
                    {
5648
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5649

    
5650
                        foreach (var item in redo.Markup_List)
5651
                        {
5652
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5653
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5654
                            {
5655
                                (item.Markup as IPath).LineSize = redo.LineSize;
5656
                            }
5657
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5658
                            {
5659
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5660
                            }
5661
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5662
                            {
5663
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5664
                            }
5665
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
5666
                            {
5667
                                (item.Markup as LineControl).Interval = redo.Interval;
5668
                            }
5669
                            else if (item.Markup as IShapeControl != null)
5670
                            {
5671
                                (item.Markup as IShapeControl).Paint = redo.paint;
5672
                            }
5673
                            comment.Add(item.Markup);
5674
                        }
5675
                        final = new AdornerFinal(comment);
5676
                        SelectLayer.Children.Add(final);
5677
                    }
5678
                    break;
5679
            }
5680

    
5681
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5682
            {
5683
                i.IsUndo = false;
5684
            });
5685
        }
5686

    
5687
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5688
        {
5689
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5690
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5691
            {
5692
                if (items.UserID == Select_ID)
5693
                {
5694
                    foreach (var item in items.MarkupList)
5695
                    {
5696
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5697
                        {
5698
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5699
                        }
5700
                    }
5701
                }
5702
            }
5703
        }
5704
        public void EmptyControlCheck()
5705
        {
5706
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
5707
            {
5708
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
5709
                {
5710
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
5711
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
5712
                    {
5713
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
5714
                    }
5715
                }
5716
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
5717
                {
5718
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
5719
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
5720
                    {
5721
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
5722
                    }
5723
                }
5724
            }
5725
        }
5726
        public void InkControl_Convert()
5727
        {
5728
            if (inkBoard.Strokes.Count > 0)
5729
            {
5730
                inkBoard.Strokes.ToList().ForEach(stroke =>
5731
                {
5732
                    List<Stroke> removingStroke = new List<Stroke>();
5733
                    StrokeCollection stC = new StrokeCollection();
5734

    
5735
                    removingStroke.Add(stroke);
5736

    
5737
                    InkToPath ip = new InkToPath();
5738
                    List<Point> inkPointSet = new List<Point>();
5739
                    PolygonControl pc = null;
5740
                    pc = new PolygonControl()
5741
                    {
5742
                        Angle = 0,
5743
                        PointSet = new List<Point>(),
5744
                        ControlType = ControlType.Ink
5745
                    };
5746
                    foreach (var item in removingStroke)
5747
                    {
5748
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5749
                        inkBoard.Strokes.Remove(item);
5750
                    }
5751
                    if (inkPointSet.Count != 0)
5752
                    {
5753
                        //강인구 추가(PenControl Undo Redo 추가)
5754
                        UndoData = new Undo_data()
5755
                        {
5756
                            IsUndo = false,
5757
                            Event = Event_Type.Create,
5758
                            EventTime = DateTime.Now,
5759
                            Markup_List = new List<Multi_Undo_data>()
5760
                        };
5761

    
5762
                        pc.StartPoint = inkPointSet[0];
5763
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5764
                        pc.PointSet = inkPointSet;
5765
                        pc.LineSize = 3;
5766
                        pc.CommentID = Save.shortGuid();
5767
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5768
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5769
                        pc.SetPolyPath();
5770

    
5771
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5772
                        {
5773
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5774
                        });
5775
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5776
                        UndoData.Markup_List.Add(multi_Undo_Data);
5777
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5778
                    }
5779
                });
5780
            }
5781
        }
5782

    
5783
        /// <summary>
5784
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5785
        /// </summary>
5786
        /// <param name="StartP">StartPoint</param>
5787
        /// <param name="EndP">EndPoint</param>
5788
        /// <returns>Return_EndPoint</returns>
5789
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5790
        {
5791
            Point Return_Point = new Point();
5792

    
5793
            double dx = EndP.X - StartP.X;
5794
            double dy = EndP.Y - StartP.Y;
5795
            double length;
5796

    
5797
            switch (controlType)
5798
            {
5799
                case ControlType.Triangle:
5800
                    {
5801
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5802
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5803
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5804
                    }
5805
                    break;
5806
                default:
5807
                    {
5808
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5809
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5810
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5811
                    }
5812
                    break;
5813
            }
5814

    
5815
            return Return_Point;
5816
        }
5817

    
5818
        /// <summary>
5819
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5820
        /// </summary>
5821
        /// <author>humkyung</author>
5822
        /// <date>2018.04.26</date>
5823
        /// <param name="StartP"></param>
5824
        /// <param name="EndP"></param>
5825
        /// <returns></returns>
5826
        /// <history>humkyung 2018.05.11 apply axis lock</history>
5827
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
5828
        {
5829
            List<Point> res = new List<Point>();
5830

    
5831
            double dx = EndP.X - StartP.X;
5832
            double dy = EndP.Y - StartP.Y;
5833
            double length = Math.Sqrt(dx * dx + dy * dy);
5834
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
5835
            dx /= length;
5836
            dy /= length;
5837
            double tmp = dx;
5838
            dx = -dy; dy = tmp; /// rotate by 90 degree
5839

    
5840
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5841
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5842

    
5843
            return res;
5844
        }
5845

    
5846
        /// <summary>
5847
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5848
        /// </summary>
5849
        /// <author>ingu</author>
5850
        /// <date>2018.06.05</date>
5851
        /// <param name="getPoint"></param>
5852
        /// <returns></returns>
5853
        private bool IsGetoutpoint(Point getPoint)
5854
        {
5855
            if (getPoint == new Point())
5856
            {
5857
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5858
                currentControl = null;
5859
                return true;
5860
            }
5861

    
5862
            return false;
5863
        }
5864

    
5865
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5866
        {
5867
            e.Effects = DragDropEffects.Copy;
5868
        }
5869

    
5870
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5871
        {
5872
            e.Effects = DragDropEffects.Copy;
5873
        }
5874

    
5875
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5876
        {
5877
            e.Effects = DragDropEffects.None;
5878
        }
5879

    
5880
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5881
        {
5882
            if (e.Data.GetDataPresent(typeof(string)))
5883
            {
5884
                this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5885
                string dragData = e.Data.GetData(typeof(string)) as string;
5886
                Move_Symbol(sender, dragData);
5887
            }
5888
        }
5889

    
5890
        private void Move_Symbol(object sender, string dragData)
5891
        {
5892
            if (dragData.Contains("|DZ|"))
5893
            {
5894
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
5895

    
5896
                string[] delimiterChars = { "|DZ|" };
5897
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
5898

    
5899
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
5900

    
5901
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
5902

    
5903
                //강인구 Undo/Redo 보류
5904
                UndoData = new Undo_data()
5905
                {
5906
                    IsUndo = false,
5907
                    Event = Event_Type.Create,
5908
                    EventTime = DateTime.Now,
5909
                    Markup_List = new List<Multi_Undo_data>()
5910
                };
5911

    
5912
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
5913
                {
5914
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5915
                });
5916

    
5917
                foreach (string parse in data)
5918
                {
5919
                    if (parse != "")
5920
                    {
5921
                        System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
5922
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
5923

    
5924
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
5925
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
5926

    
5927
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
5928

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

    
5931
                        UndoData.Markup_List.Add(multi_Undo_Data);
5932
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5933
                    }
5934
                }
5935
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
5936

    
5937
                /// move symbol to current mouse point
5938
                double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
5939
                double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
5940
                final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
5941

    
5942
                if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
5943
                {
5944
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
5945
                }
5946
                /// up to here
5947
                
5948
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
5949
            }
5950
        }
5951
    }
5952
}
클립보드 이미지 추가 (최대 크기: 500 MB)