프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 32b8c570

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

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

    
40
            T instance = Activator.CreateInstance<T>();
41

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

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

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

    
78
        public TextBox Gui { get; private set; }
79

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

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

    
101
            Gui.Text += line + Environment.NewLine;
102
        }
103
    }
104

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

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

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

    
168
                }
169
            }
170
        }
171

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

    
196
        public bool IsSyncPDFMode { get; set; }
197

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

    
222
        #endregion
223

    
224

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

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

    
245
            return false;
246
        }
247

    
248
        public void DeleteItem(MarkupInfoItem item)
249
        {
250
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
251
            {
252
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
253
            }
254

    
255
            ViewerDataModel.Instance._markupInfoList.Remove(item);
256

    
257
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
258
            {
259
                ViewerDataModel.Instance.MarkupControls.Remove(a);
260
            });
261

    
262
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
263
            {
264
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
265
            });
266

    
267
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
268
            {
269
                ComingNewBieEnd = false;
270
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
271
            });
272

    
273
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
274
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
275
            {
276
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
277
                {
278
                    var infoId = Events.Save.shortGuid();
279
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
280
                    {
281
                        CreateTime = DateTime.Now,
282
                        Depatment = userData.DEPARTMENT,
283
                        DisplayColor = "#FFFF0000",
284
                        UserID = userData.ID,
285
                        UserName = userData.NAME,
286
                        PageCount = 1,
287
                        Description = "",
288
                        MarkupInfoID = infoId,
289
                        MarkupList = null,
290
                        MarkupVersionID = Events.Save.shortGuid(),
291
                        Consolidate = 0,
292
                        PartConsolidate = 0,
293
                        userDelete = true,
294
                        AvoidConsolidate = 0,
295
                        IsPreviewUser = true
296
                    };
297
                    App.Custom_ViewInfoId = infoId;
298
                }
299
            }
300
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
301
        }
302

    
303
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
304
        {
305
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
306
            this.ReleaseAdorner();
307

    
308
            Button content = (sender as Button);
309
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
310

    
311
            DeleteItem(item);
312
        }
313

    
314
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
315

    
316
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
317
        {
318
            if (App.ParameterMode)
319
            {
320
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
321
                imageViewer_Compare = new Image();
322
                
323
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
324
                ViewerDataModel.Instance.Capture_Opacity = 0;
325

    
326
                da.From = 0.8;
327
                da.To = 0;
328
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
329
                da.AutoReverse = true;
330
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
331
            }
332

    
333

    
334
        }
335

    
336
        public void ReleaseAdorner()
337
        {
338
            if (SelectLayer.Children.Count > 0)
339
            {
340
                foreach (var item in SelectLayer.Children)
341
                {
342
                    if (item.GetType().Name == "AdornerFinal")
343
                    {
344
                        (item as AdornerFinal).unRegister();
345

    
346
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
347
                        {
348
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
349
                            {
350
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
351
                                {
352
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
353
                                    {
354
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
355
                                    }
356
                                }
357

    
358
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
359
                            }
360
                        }
361
                    }
362
                }
363
                SelectLayer.Children.Clear();
364
            }
365
        }
366

    
367
        public List<CommentUserInfo> AddAdorner()
368
        {
369
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
370

    
371
            if (SelectLayer.Children.Count > 0)
372
            {
373
                foreach (var item in SelectLayer.Children)
374
                {
375
                    if (item.GetType().Name == "AdornerFinal")
376
                    {
377
                        (item as AdornerFinal).unRegister();
378

    
379
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
380
                        {
381
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
382
                            {
383
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
384
                            }
385

    
386
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
387

    
388
                            UndoData.Markup_List.Add(multi_Undo_Data);
389
                            multi_Undo_Data = new Multi_Undo_data();
390
                        }
391
                    }
392
                }
393
                SelectLayer.Children.Clear();
394
            }
395
            return adornerSet;
396
        }
397

    
398
        public void ChangeCommentReact()
399
        {
400
            bool isComingNewBie = false;
401

    
402
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
403
            {
404
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
405
                {
406
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
407
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
408
                    if (existItem != null) //신규 추가 된 코멘트
409
                    {
410
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
411
                        {
412
                            existItem.Data = root.ConvertData;
413
                            existItem.IsUpdate = true;
414
                        }
415
                    }
416
                    else
417
                    {
418
                        if (root.CommentID != null)
419
                        {
420
                            isComingNewBie = true;
421
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
422
                            if (currentCommentCheck != null)
423
                            {
424
                                currentCommentCheck.Data = root.ConvertData;
425
                            }
426
                            else
427
                            {
428
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
429
                                {
430
                                    ID = control.CommentID,
431
                                    Data = root.ConvertData,
432
                                    Data_Type = root.DATA_TYPE,
433
                                    MarkupInfoID = App.Custom_ViewInfoId,
434
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
435
                                });
436
                            }
437
                        }
438
                    }
439
                }
440
            }
441

    
442
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
443
            {
444
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
445
                {
446
                    ComingNewBieEnd = true;
447
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
448
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
449
                    gridViewMarkup.ItemsSource = null;
450
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
451
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
452
                }
453
            }
454

    
455
        }
456

    
457
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
458
        bool ComingNewBieEnd = false;
459

    
460
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
461
        {
462
            ViewerDataModel.Instance.UndoDataList.Clear();
463

    
464
            InkControl_Convert();
465

    
466
            ReleaseAdorner();
467
            ChangeCommentReact();
468
            CompareMode.IsChecked = false;
469
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
470

    
471

    
472
            #region 페이지가 벗어난 경우
473

    
474
            if (BalancePoint < 1)
475
            {
476
                BalancePoint = 1;
477
                ViewerDataModel.Instance.PageBalanceNumber = 0;
478
            }
479

    
480
            if (pageNavigator.PageCount < BalancePoint)
481
            {
482
                BalancePoint = pageNavigator.PageCount;
483
                ViewerDataModel.Instance.PageBalanceNumber = 0;
484
            }
485

    
486
            #endregion
487

    
488
            ViewerDataModel.Instance.PageNumber = BalancePoint;
489

    
490
            var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
491

    
492
            var defaultBitmapImage = new BitmapImage(new Uri(uri));
493

    
494
            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
495
            ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
496
            ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
497

    
498
            if (defaultBitmapImage.IsDownloading)
499
            {
500
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
501
                {
502
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
503
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
504
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
505
                };
506
            }
507

    
508
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
509
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
510

    
511

    
512
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
513
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
514
            inkBoard.Width = zoomAndPanCanvas.Width;
515
            inkBoard.Height = zoomAndPanCanvas.Height;
516

    
517

    
518
            if (!testPanel2.IsHidden)
519
            {
520
                //PDF모드일때 잠시 대기(강인구)
521
                if (IsSyncPDFMode)
522
                {
523
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
524
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
525

    
526
                    if (pdfpath.IsDownloading)
527
                    {
528
                        pdfpath.DownloadCompleted += (ex, arg) =>
529
                        {
530
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
531
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
532
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
533
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
534
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
535
                        };
536
                    }
537
                    else
538
                    {
539
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
540
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
541
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
542

    
543
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
544
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
545
                    }
546
                }
547
                else
548
                {
549
                    var uri2 = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
550

    
551
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
552

    
553
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
554
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
555
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
556
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
557
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
558

    
559
                    zoomAndPanControl.ZoomTo(new Rect
560
                    {
561
                        X = 0,
562
                        Y = 0,
563
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
564
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
565
                    });
566

    
567
                    if (defaultBitmapImage_Compare.IsDownloading)
568
                    {
569
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
570
                        {
571

    
572
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
573
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
574
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
575

    
576
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
577
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
578

    
579
                            zoomAndPanControl.ZoomTo(new Rect
580
                            {
581
                                X = 0,
582
                                Y = 0,
583
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
584
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
585
                            });
586
                        };
587
                    }
588
                }
589
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
590
            }
591

    
592
            this.pageNavigator.SetNextPage();
593

    
594
            if (zoomAndPanCanvas2.Width.IsNaN())
595
            {
596
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
597
            }
598

    
599
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
600
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
601

    
602
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
603
            foreach (var item in gridSelectionItem)
604
            {
605
                if (item.UserID == App.ViewInfo.UserID)
606
                {
607
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
608
                    {
609
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
610
                    });
611
                }
612
                else
613
                {
614
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
615
                    {
616
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
617
                    });
618
                }
619
            }
620

    
621

    
622
            if (!testPanel2.IsHidden)
623
            {
624
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
625
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
626

    
627

    
628
                foreach (var item in gridSelectionRevItem)
629
                {
630
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
631
                    {
632
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
633
                    });
634
                }
635

    
636
            }
637

    
638

    
639

    
640
            var instanceMain = this.ParentOfType<MainWindow>();
641
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
642

    
643
            //강인구 추가
644
            instanceMain.dzTopMenu.rotateOffSet = 0;
645
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
646
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
647

    
648
            //}
649
            SetCommentPages(true);
650
        }
651

    
652
        private void SetCommentPages(bool onlyMe = false)
653
        {
654

    
655
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
656
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
657
            {
658
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
659
                instance.UserName = item.UserName;
660
                instance.Depart = item.Depatment;
661
                instance.MarkupInfoID = item.MarkupInfoID;
662
                instance.IsSelected = true;
663
                instance.isConSolidation = item.Consolidate;
664
                instance.SetColor = item.DisplayColor;
665
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
666
                {
667
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
668
                }
669
                else
670
                {
671
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
672
                }
673
                _pages.Add(instance);
674
            }
675
            this.pageNavigator.SetCommentList(_pages.ToList());
676
        }
677

    
678
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
679
        {
680
            if (e.MiddleButton == MouseButtonState.Pressed)
681
            {
682

    
683
            }
684
            e.Handled = true;
685
            if (e.Delta > 0)
686
            {
687
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
688
                ZoomIn(currentContentMousePoint);
689
            }
690
            else
691
            {
692
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
693
                ZoomOut(currentContentMousePoint);
694
            }
695
        }
696

    
697
        #region ZoomIn & ZoomOut
698

    
699
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
700
        {
701
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
702
                zoomAndPanControl.ContentZoomFocusY));
703
        }
704

    
705
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
706
        {
707
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
708
                zoomAndPanControl.ContentZoomFocusY));
709
        }
710

    
711

    
712
        //강인구 추가 (줌 인아웃 수치 변경)
713
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
714
        private void ZoomOut(Point contentZoomCenter)
715
        {
716
            if (zoomAndPanControl.ContentScale > 0.39)
717
            {
718
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
719
            }
720
            else
721
            {
722
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
723
            }
724

    
725
            if (zoomAndPanControl2 != null)
726
            {
727
                if (zoomAndPanControl2.ContentScale > 0.39)
728
                {
729
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
730
                }
731
                else
732
                {
733
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
734
                }
735
            }
736
        }
737

    
738
        private void ZoomIn(Point contentZoomCenter)
739
        {
740
            if (zoomAndPanControl.ContentScale > 0.19)
741
            {
742
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
743
            }
744
            else
745
            {
746
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
747
            }
748

    
749
            if (zoomAndPanControl2 != null)
750
            {
751
                if (zoomAndPanControl2.ContentScale > 0.19)
752
                {
753
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
754
                }
755
                else
756
                {
757
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
758
                }
759
            }
760
        }
761

    
762
        private void ZoomOut()
763
        {
764
            zoomAndPanControl.ContentScale -= 0.1;
765
            //if (zoomAndPanControl2 != null)
766
            //{
767
            //    zoomAndPanControl2.ContentScale -= 0.1;
768
            //}
769
        }
770

    
771
        private void ZoomIn()
772
        {
773
            zoomAndPanControl.ContentScale += 0.1;
774
            //if (zoomAndPanControl2 != null)
775
            //{
776
            //    zoomAndPanControl2.ContentScale += 0.1;
777
            //}
778
        }
779

    
780
        #endregion
781

    
782
        private void init()
783
        {
784
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
785
            {
786

    
787
                ControlList.Clear();
788
                listBox.Items.Clear();
789
                selected_item.Clear();
790

    
791
                (item as IMarkupCommonData).IsSelected = false;
792
            }
793

    
794
        }
795

    
796
        private HitTestResultBehavior MyCallback(HitTestResult result)
797
        {
798
            //this.cursor = Cursors.UpArrow;
799
            var element = result.VisualHit;
800
            while (element != null && !(element is CommentUserInfo))
801
                element = VisualTreeHelper.GetParent(element);
802

    
803
            if (element == null)
804
            {
805
                return HitTestResultBehavior.Stop;
806
            }
807
            else
808
            {
809
                if (element is CommentUserInfo)
810
                {
811
                    if (!hitList.Contains(element))
812
                    {
813
                        hitList.Add((CommentUserInfo)element);
814
                    }
815
                    else
816
                    {
817
                        return HitTestResultBehavior.Stop;
818
                    }
819
                    //IntersectionDetail intersectionDetail =
820
                    //((GeometryHitTestResult)result).IntersectionDetail;
821
                    //switch (intersectionDetail)
822
                    //{
823
                    //    case IntersectionDetail.FullyContains:
824
                    //        // Add the hit test result to the list:
825
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
826
                    //        return HitTestResultBehavior.Continue;
827
                    //    case IntersectionDetail.Intersects:
828
                    //        // Set the behavior to return visuals at all z-order levels:
829
                    //        return HitTestResultBehavior.Continue;
830
                    //    case IntersectionDetail.FullyInside:
831
                    //        // Set the behavior to return visuals at all z-order levels:
832
                    //        return HitTestResultBehavior.Continue;
833
                    //    default:
834
                    //        return HitTestResultBehavior.Stop;
835
                    //}
836
                }
837
            }
838
            return HitTestResultBehavior.Continue;
839
        }
840

    
841
        public void ReleaseSelectPath()
842
        {
843
            if (SelectionPath == null)
844
            {
845
                SelectionPath = new Path();
846
                SelectionPath.Name = "";
847
            }
848
            if (SelectionPath.Name != "")
849
            {
850
                SelectionPath.Name = "None";
851
            }
852
            SelectionPath.Opacity = 0.01;
853
            SelectionPath.RenderTransform = null;
854
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
855
        }
856

    
857
        #region 컨트롤 초기화 
858
        public void Control_Init(object control)
859
        {
860
            if (L_Size != 0 && (control as IPath) != null)
861
            {
862
                (control as IPath).LineSize = L_Size;
863
                L_Size = 0;
864
            }
865

    
866
            switch (control.GetType().Name)
867
            {
868
                case "RectangleControl":
869
                    {
870
                        (control as RectangleControl).StrokeColor = Brushes.Red;
871
                    }
872
                    break;
873
                case "CircleControl":
874
                    {
875
                        (control as CircleControl).StrokeColor = Brushes.Red;
876
                    }
877
                    break;
878
                case "TriControl":
879
                    {
880
                        (control as TriControl).StrokeColor = Brushes.Red;
881
                    }
882
                    break;
883
                case "RectCloudControl":
884
                    {
885
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
886
                    }
887
                    break;
888
                case "CloudControl":
889
                    {
890
                        (control as CloudControl).StrokeColor = Brushes.Red;
891
                    }
892
                    break;
893
                case "PolygonControl":
894
                    {
895
                        (control as PolygonControl).StrokeColor = Brushes.Red;
896
                    }
897
                    break;
898
                case "ArcControl":
899
                    {
900
                        (control as ArcControl).StrokeColor = Brushes.Red;
901
                    }
902
                    break;
903
                case "LineControl":
904
                    {
905
                        (control as LineControl).StrokeColor = Brushes.Red;
906
                    }
907
                    break;
908
                case "ArrowControl_Multi":
909
                    {
910
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
911
                    }
912
                    break;
913
                case "TextControl":
914
                    {
915
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
916
                    }
917
                    break;
918
                case "ArrowTextControl":
919
                    {
920
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
921
                    }
922
                    break;
923
            }
924
        }
925
        #endregion
926

    
927
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
928
        {
929
            //Control_Init(e.Source);
930
        }
931

    
932
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
933
        {
934
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
935
            {
936
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
937

    
938
                Point currentPos = e.GetPosition(rect);
939

    
940
                floatingTip.HorizontalOffset = currentPos.X + 20;
941
                floatingTip.VerticalOffset = currentPos.Y;
942

    
943

    
944
                //ToolTip tool = new System.Windows.Controls.ToolTip();
945
                //tool.Content = "ToolTip";
946
                //panel.ToolTip = tool;
947
            }
948

    
949
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
950
            {
951
                #region 마우스 오버 시 색상 변경
952
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
953
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
954

    
955
                //if (firstCondition != null)
956
                //{
957
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
958

    
959
                //    if (firstCondition.GetType().Name == "TextControl")
960
                //    {
961
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
962
                //        return;
963
                //    }
964
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
965
                //    {
966
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
967
                //        return;
968
                //    }
969

    
970
                //    if (L_Size == 0)
971
                //    {
972
                //        L_Size = (firstCondition as IPath).LineSize;
973
                //        (firstCondition as IPath).LineSize *= 4;
974
                //    }
975
                //    switch (firstCondition.GetType().Name)
976
                //    {
977
                //        case "RectangleControl":
978
                //            {
979
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
980
                //            }
981
                //            break;
982
                //        case "CircleControl":
983
                //            {
984
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
985
                //            }
986
                //            break;
987
                //        case "TriControl":
988
                //            {
989
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
990
                //            }
991
                //            break;
992
                //        case "RectCloudControl":
993
                //            {
994
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
995
                //            }
996
                //            break;
997
                //        case "CloudControl":
998
                //            {
999
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1000
                //            }
1001
                //            break;
1002
                //        case "PolygonControl":
1003
                //            {
1004
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1005
                //            }
1006
                //            break;
1007
                //        case "ArcControl":
1008
                //            {
1009
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1010
                //            }
1011
                //            break;
1012
                //        case "LineControl":
1013
                //            {
1014
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1015
                //            }
1016
                //            break;
1017
                //        case "ArrowControl_Multi":
1018
                //            {
1019
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1020
                //            }
1021
                //            break;
1022

    
1023
                //        default:
1024
                //            {
1025

    
1026
                //            }
1027
                //            break;
1028
                //    }
1029
                //} 
1030
                #endregion
1031
            }
1032

    
1033
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1034

    
1035
            if (mouseButtonDown == MouseButton.Middle)
1036
            {
1037
                SetCursor();
1038
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1039
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1040

    
1041
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1042
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1043
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1044

    
1045
                //SetCursor();
1046
                //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1047
                //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1048

    
1049
                //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1050

    
1051
                //zoomAndPanControl.ContentOffsetX += 1;
1052
                //zoomAndPanControl.ContentOffsetY += 1;
1053

    
1054
                //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1055
                //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1056
            }
1057

    
1058
            if (mouseButtonDown == MouseButton.Right)
1059
            {
1060
                SetCursor();
1061
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1062
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1063

    
1064
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1065
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1066
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1067
            }
1068
            //else if (currentControl != null && mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1069
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1070
            {
1071
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1072
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1073
                SetCursor();
1074

    
1075
                if (IsDrawing)
1076
                {
1077
                    if (currentControl == null)
1078
                    {
1079
                        switch (controlType)
1080
                        {
1081
                            case ControlType.PenControl:
1082
                                {
1083
                                    if (inkBoard.Tag.ToString() == "Ink")
1084
                                    {
1085
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1086
                                    }
1087
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1088
                                    {
1089
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1090
                                    }
1091
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1092
                                    {
1093
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1094
                                    }
1095

    
1096
                                    //inkBoard.Strokes.Add(stroke);
1097
                                }
1098
                                break;
1099
                        }
1100
                        return;
1101
                    }
1102
                }
1103

    
1104
                if (currentControl != null)
1105
                {
1106
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1107
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1108
                    //강인구 추가
1109
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1110

    
1111
                    if ((currentControl as IPath) != null)
1112
                    {
1113
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1114
                    }
1115
                    if ((currentControl as LineControl) != null)
1116
                    {
1117
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1118
                    }
1119

    
1120
                    if ((currentControl as IShapeControl) != null)
1121
                    {
1122
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1123
                    }
1124
                    if ((currentControl as TextControl) != null)
1125
                    {
1126
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1127
                        {
1128
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1129
                        }
1130
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1131
                        {
1132
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1133
                        }
1134
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1135
                        {
1136
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1137
                        }
1138
                    }
1139
                    else if ((currentControl as ArrowTextControl) != null)
1140
                    {
1141
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1142
                        {
1143
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1144
                        }
1145
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1146
                        {
1147
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1148
                        }
1149
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1150
                        {
1151
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1152
                        }
1153
                    }
1154
                    else if ((currentControl as RectCloudControl) != null)
1155
                    {
1156
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1157
                    }
1158
                    else if ((currentControl as CloudControl) != null)
1159
                    {
1160
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1161
                    }
1162

    
1163
                    switch (controlType)
1164
                    {
1165
                        case ControlType.Rectangle:
1166
                            {
1167
                                var control = currentControl as RectangleControl;
1168

    
1169
                                if (control != null)
1170
                                {
1171
                                    if (move.mousemode == MouseMode.Drawing)
1172
                                    {
1173
                                        //move.control_Move(ControlList, true, moveX, moveY);
1174
                                    }
1175
                                    else
1176
                                    {
1177
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1178
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1179
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1180
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1181

    
1182

    
1183
                                        if (ViewerDataModel.Instance.IsPressShift)
1184
                                        {
1185
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1186
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1187
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1188
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1189
                                        }
1190
                                        
1191
                                        control.PointSet = new List<Point>
1192
                                        {
1193
                                            control.StartPoint,
1194
                                            control.LeftBottomPoint,
1195
                                            control.EndPoint,
1196
                                            control.TopRightPoint,
1197
                                        };
1198
                                        control.updateControl();
1199
                                    }
1200

    
1201
                                    //강인구 추가
1202
                                    control.ControlType = controlType;
1203
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1204
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1205
                                }
1206
                            }
1207
                            break;
1208

    
1209
                        case ControlType.RectCloud:
1210
                            {
1211
                                var control = currentControl as RectCloudControl;
1212

    
1213
                                if (control != null)
1214
                                {
1215
                                    if (move.mousemode == MouseMode.Drawing)
1216
                                    {
1217
                                        //move.control_Move(ControlList, true, moveX, moveY);
1218
                                    }
1219
                                    else
1220
                                    {
1221
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1222
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1223
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1224
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1225

    
1226
                                        if (ViewerDataModel.Instance.IsPressShift)
1227
                                        {
1228
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1229
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1230
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1231
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1232
                                        }
1233

    
1234
                                        control.PointSet = new List<Point>
1235
                                        {
1236
                                            control.StartPoint,
1237
                                            control.LeftBottomPoint,
1238
                                            control.EndPoint,
1239
                                            control.TopRightPoint,
1240
                                        };
1241
                                    }
1242
                                    //강인구 추가
1243
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1244
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1245
                                }
1246
                            }
1247
                            break;
1248

    
1249
                        case ControlType.SingleLine:
1250
                            {
1251
                                if (currentControl != null)
1252
                                {
1253
                                    var control = currentControl as LineControl;
1254
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1255
                                    control.ControlType = controlType;
1256
                                    if (control != null)
1257
                                    {
1258
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1259
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1260
                                        Point tempPoint = control.EndPoint;
1261

    
1262
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1263
                                        {
1264
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1265
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1266
                                            control.EndPoint = tempPoint;
1267
                                        }
1268
                                        else
1269
                                        {
1270
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1271
                                        }
1272

    
1273
                                       control.PointSet = new List<Point>
1274
                                        {
1275
                                            control.StartPoint,
1276
                                            control.EndPoint,
1277
                                        };
1278
                                        //강인구 추가
1279
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1280
                                    }
1281
                                }
1282

    
1283
                            }
1284
                            break;
1285

    
1286
                        case ControlType.CancelLine:
1287
                            {
1288
                                if (currentControl != null)
1289
                                {
1290
                                    var control = currentControl as LineControl;
1291
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1292
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1293
                                    control.ControlType = controlType;
1294
                                    if (control != null)
1295
                                    {
1296
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1297
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1298
                                        Point tempPoint = control.EndPoint;
1299

    
1300
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1301
                                        {
1302
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1303
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1304
                                            control.EndPoint = tempPoint;
1305
                                        }
1306
                                        else
1307
                                        {
1308
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1309
                                        }
1310

    
1311

    
1312
                                        control.PointSet = new List<Point>
1313
                                            {
1314
                                                control.StartPoint,
1315
                                                control.EndPoint,
1316
                                            };
1317
                                    }
1318
                                    //강인구 추가
1319
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1320
                                }
1321
                            }
1322
                            break;
1323

    
1324
                        case ControlType.ArrowLine:
1325
                            {
1326
                                if (currentControl != null)
1327
                                {
1328
                                    var control = currentControl as LineControl;
1329
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1330
                                    control.ControlType = controlType;
1331
                                    if (control != null)
1332
                                    {
1333
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1334
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1335
                                        Point tempPoint = control.EndPoint;
1336

    
1337
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1338
                                        {
1339
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1340
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1341
                                            control.EndPoint = tempPoint;
1342
                                        }
1343
                                        else
1344
                                        {
1345
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1346
                                        }
1347

    
1348

    
1349
                                        control.PointSet = new List<Point>
1350
                                            {
1351
                                                control.StartPoint,
1352
                                                control.EndPoint,
1353
                                            };
1354
                                    }
1355
                                    //강인구 추가
1356
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1357
                                }
1358

    
1359
                            }
1360
                            break;
1361

    
1362
                        case ControlType.TwinLine:
1363
                            {
1364
                                if (currentControl != null)
1365
                                {
1366
                                    var control = currentControl as LineControl;
1367
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1368
                                    control.ControlType = controlType;
1369
                                    if (control != null)
1370
                                    {
1371
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1372
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1373
                                        Point tempPoint = control.EndPoint;
1374

    
1375
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1376
                                        {
1377
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1378
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1379
                                            control.EndPoint = tempPoint;
1380
                                        }
1381
                                        else
1382
                                        {
1383
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1384
                                        }
1385

    
1386

    
1387
                                        control.PointSet = new List<Point>
1388
                                            {
1389
                                                control.StartPoint,
1390
                                                control.EndPoint,
1391
                                            };
1392
                                    }
1393
                                    //강인구 추가
1394
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1395
                                }
1396

    
1397
                            }
1398
                            break;
1399

    
1400
                        case ControlType.DimLine:
1401
                            {
1402
                                if (currentControl != null)
1403
                                {
1404
                                    var control = currentControl as LineControl;
1405
                                    control.LineStyleSet = LineStyleSet.DimLine;
1406
                                    control.ControlType = controlType;
1407
                                    if (control != null)
1408
                                    {
1409
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1410
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1411
                                        Point tempPoint = control.EndPoint;
1412

    
1413
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1414
                                        {
1415
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1416
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1417
                                            control.EndPoint = tempPoint;
1418
                                        }
1419
                                        else
1420
                                        {
1421
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1422
                                        }
1423

    
1424
                                        control.PointSet = new List<Point>
1425
                                            {
1426
                                                control.StartPoint,
1427
                                                control.EndPoint,
1428
                                            };
1429
                                    }
1430
                                    //강인구 추가
1431
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1432
                                }
1433

    
1434
                            }
1435
                            break;
1436

    
1437
                        case ControlType.ChainLine:
1438
                            {
1439
                                var control = currentControl as PolygonControl;
1440

    
1441
                                if (control != null)
1442
                                {
1443

    
1444
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1445
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1446

    
1447
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1448

    
1449
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1450
                                    {
1451
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1452
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count-2], ref tempPoint, true);
1453
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1454
                                        //control.EndPoint = tempPoint;
1455
                                    }
1456
                                    else
1457
                                    {
1458
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1459
                                    }
1460

    
1461
                                    control.SetPolyPath();
1462
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1463
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1464
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1465

    
1466
                                    //강인구 추가
1467
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1468
                                }
1469
                            }
1470
                            break;
1471

    
1472
                        case ControlType.ArcLine:
1473
                            {
1474
                                if (currentControl != null)
1475
                                {
1476
                                    var control = currentControl as ArcControl;
1477
                                    control.isTransOn = false;
1478
                                    control.ControlType = controlType;
1479

    
1480
                                    if (control != null)
1481
                                    {
1482
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1483
                                        control.MidPoint = new Point(0, 0);
1484
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1485
                                        Point tempPoint = control.EndPoint;
1486

    
1487
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1488
                                        {
1489
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1490
                                            control.EndPoint = tempPoint;
1491
                                        }
1492
                                        else
1493
                                        {
1494
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1495
                                        }
1496

    
1497

    
1498
                                        control.PointSet = new List<Point>
1499
                                            {
1500
                                                control.StartPoint,
1501
                                                control.MidPoint,
1502
                                                control.EndPoint,
1503
                                            };
1504
                                    }
1505
                                    //강인구 추가
1506
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1507
                                }
1508

    
1509
                            }
1510
                            break;
1511

    
1512
                        case ControlType.ArcArrow:
1513
                            {
1514
                                if (currentControl != null)
1515
                                {
1516
                                    var control = currentControl as ArcControl;
1517
                                    control.isTransOn = true;
1518
                                    control.ControlType = controlType;
1519

    
1520
                                    if (control != null)
1521
                                    {
1522
                                        if (move.mousemode == MouseMode.Drawing)
1523
                                        {
1524
                                            //move.control_Move(ControlList, true, moveX, moveY);
1525
                                        }
1526
                                        else
1527
                                        {
1528
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1529
                                            control.MidPoint = new Point(0, 0);
1530
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1531
                                        }
1532

    
1533
                                        control.PointSet = new List<Point>
1534
                                            {
1535
                                                control.StartPoint,
1536
                                                control.MidPoint,
1537
                                                control.EndPoint,
1538
                                            };
1539
                                    }
1540
                                    //강인구 추가
1541
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1542
                                }
1543
                            }
1544
                            break;
1545

    
1546
                        case ControlType.ArrowMultiLine:
1547
                            {
1548
                                if (currentControl != null)
1549
                                {
1550
                                    var control = currentControl as ArrowControl_Multi;
1551

    
1552
                                    if (control != null)
1553
                                    {
1554
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1555
                                        Point tempPoint = control.EndPoint;
1556
                                        if (control.MiddlePoint == new Point(0, 0))
1557
                                        {
1558
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1559
                                            {
1560
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1561
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1562
                                                control.EndPoint = tempPoint;
1563
                                            }
1564
                                            else
1565
                                            {
1566
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1567
                                            }
1568
                                        }
1569
                                        else
1570
                                        {
1571
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1572
                                            {
1573
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1574
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1575
                                                control.EndPoint = tempPoint;
1576
                                            }
1577
                                            else
1578
                                            {
1579
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1580
                                            }
1581

    
1582
                                        }
1583

    
1584
                                        control.PointSet = new List<Point>
1585
                                            {
1586
                                                control.StartPoint,
1587
                                                control.MiddlePoint,
1588
                                                control.EndPoint,
1589
                                            };
1590

    
1591
                                    }
1592
                                    //강인구 추가
1593
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1594
                                }
1595

    
1596
                            }
1597
                            break;
1598

    
1599
                        case ControlType.Circle:
1600
                            {
1601
                                var control = currentControl as CircleControl;
1602

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

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

    
1624
                                        control.PointSet = new List<Point>
1625
                                        {
1626
                                            control.StartPoint,
1627
                                            control.LeftBottomPoint,
1628
                                            control.EndPoint,
1629
                                            control.TopRightPoint,
1630
                                        };
1631
                                    }
1632
                                    //강인구 추가
1633
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1634
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1635

    
1636
                                }
1637
                            }
1638
                            break;
1639

    
1640
                        case ControlType.PolygonCloud:
1641
                            {
1642
                                var control = currentControl as CloudControl;
1643

    
1644
                                if (control != null)
1645
                                {
1646
                                    control.isTransOn = true;
1647
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1648

    
1649
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1650

    
1651
                                    control.SetCloud();
1652
                                    //강인구 추가
1653
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1654
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1655
                                }
1656
                            }
1657
                            break;
1658

    
1659
                        case ControlType.Triangle:
1660
                            {
1661
                                var control = currentControl as TriControl;
1662

    
1663
                                if (control != null)
1664
                                {
1665
                                    if (move.mousemode == MouseMode.Drawing)
1666
                                    {
1667
                                        //move.control_Move(ControlList, true, moveX, moveY);
1668
                                    }
1669
                                    else
1670
                                    {
1671
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1672
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1673

    
1674

    
1675
                                        if (ViewerDataModel.Instance.IsPressShift)
1676
                                        {
1677
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1678
                                            if (2 == Points.Count())
1679
                                            {
1680
                                                control.MidPoint = Points[0];
1681
                                                control.EndPoint = Points[1];
1682
                                            }
1683
                                        }
1684

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

    
1699
                        case ControlType.ImgControl:
1700
                            {
1701
                                var control = currentControl as ImgControl;
1702

    
1703
                                if (control != null)
1704
                                {
1705
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1706
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1707
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1708
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1709

    
1710
                                    control.PointSet = new List<Point>
1711
                                        {
1712
                                            control.StartPoint,
1713
                                            control.LeftBottomPoint,
1714
                                            control.EndPoint,
1715
                                            control.TopRightPoint,
1716
                                        };
1717
                                }
1718
                            }
1719
                            break;
1720

    
1721
                        case ControlType.Date:
1722
                            {
1723
                                var control = currentControl as DateControl;
1724

    
1725
                                if (control != null)
1726
                                {
1727
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1728
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1729
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1730
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1731
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1732

    
1733
                                    control.PointSet = new List<Point>
1734
                                        {
1735
                                            control.StartPoint,
1736
                                            control.LeftBottomPoint,
1737
                                            control.EndPoint,
1738
                                            control.TopRightPoint,
1739
                                        };
1740
                                }
1741
                            }
1742
                            break;
1743

    
1744
                        case ControlType.ArrowTextControl:
1745
                            {
1746
                                var control = currentControl as ArrowTextControl;
1747

    
1748
                                if (control != null)
1749
                                {
1750
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1751
                                    Point tempPoint = control.EndPoint;
1752

    
1753
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1754

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

    
1766
                                    control.PointSet = new List<Point>
1767
                                            {
1768
                                                control.StartPoint,
1769
                                                control.MidPoint,
1770
                                                control.EndPoint,
1771
                                            };
1772
                                }
1773
                            }
1774
                            break;
1775

    
1776
                        case ControlType.ArrowTransTextControl:
1777
                            {
1778
                                var control = currentControl as ArrowTextControl;
1779

    
1780
                                if (control != null)
1781
                                {
1782
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1783
                                    Point tempPoint = control.EndPoint;
1784
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1785

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

    
1798
                                    control.PointSet = new List<Point>
1799
                                            {
1800
                                                control.StartPoint,
1801
                                                control.MidPoint,
1802
                                                control.EndPoint,
1803
                                            };
1804
                                }
1805
                            }
1806
                            break;
1807

    
1808
                        case ControlType.ArrowTextBorderControl:
1809
                            {
1810
                                var control = currentControl as ArrowTextControl;
1811

    
1812
                                if (control != null)
1813
                                {
1814
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1815
                                    Point tempPoint = control.EndPoint;
1816
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1817
                                    {
1818
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1819
                                        control.EndPoint = tempPoint;
1820
                                    }
1821
                                    else
1822
                                    {
1823
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1824
                                    }
1825
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1826
                                    control.PointSet = new List<Point>
1827
                                            {
1828
                                                control.StartPoint,
1829
                                                control.MidPoint,
1830
                                                control.EndPoint,
1831
                                            };
1832
                                }
1833

    
1834
                            }
1835
                            break;
1836
                        case ControlType.ArrowTransTextBorderControl:
1837
                            {
1838
                                var control = currentControl as ArrowTextControl;
1839

    
1840
                                if (control != null)
1841
                                {
1842
                                    control.isFixed = true;
1843
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1844
                                    Point tempPoint = control.EndPoint;
1845
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1846
                                    {
1847
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1848
                                        control.EndPoint = tempPoint;
1849
                                    }
1850
                                    else
1851
                                    {
1852
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1853
                                    }
1854

    
1855
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1856
                                    control.PointSet = new List<Point>
1857
                                            {
1858
                                                control.StartPoint,
1859
                                                control.MidPoint,
1860
                                                control.EndPoint,
1861
                                            };
1862
                                }
1863

    
1864
                            }
1865
                            break;
1866
                        case ControlType.ArrowTextCloudControl:
1867
                            {
1868
                                var control = currentControl as ArrowTextControl;
1869

    
1870
                                if (control != null)
1871
                                {
1872
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1873
                                    Point tempPoint = control.EndPoint;
1874
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1875
                                    {
1876
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1877
                                        control.EndPoint = tempPoint;
1878
                                    }
1879
                                    else
1880
                                    {
1881
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1882
                                    }
1883
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1884
                                    control.PointSet = new List<Point>
1885
                                            {
1886
                                                control.StartPoint,
1887
                                                control.MidPoint,
1888
                                                control.EndPoint,
1889
                                            };
1890
                                }
1891

    
1892
                            }
1893
                            break;
1894
                        case ControlType.ArrowTransTextCloudControl:
1895
                            {
1896
                                var control = currentControl as ArrowTextControl;
1897

    
1898
                                if (control != null)
1899
                                {
1900
                                    control.isFixed = true;
1901
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1902
                                    Point tempPoint = control.EndPoint;
1903
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1904
                                    {
1905
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1906
                                        control.EndPoint = tempPoint;
1907
                                    }
1908
                                    else
1909
                                    {
1910
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1911
                                    }
1912
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1913
                                    control.PointSet = new List<Point>
1914
                                            {
1915
                                                control.StartPoint,
1916
                                                control.MidPoint,
1917
                                                control.EndPoint,
1918
                                            };
1919
                                }
1920

    
1921
                            }
1922
                            break;
1923
                        case ControlType.PolygonControl:
1924
                            {
1925
                                
1926
                                var control = currentControl as PolygonControl;
1927

    
1928
                                if (control != null)
1929
                                {
1930
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1931
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1932
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1933
                                    control.SetPolyPath();
1934
                                    //강인구 추가
1935
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1936
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1937
                                }
1938
                            }
1939
                            break;
1940
                        //강인구 추가
1941
                        case ControlType.Sign:
1942
                            {
1943
                                var control = currentControl as SignControl;
1944

    
1945
                                if (control != null)
1946
                                {
1947
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1948
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1949
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1950
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1951

    
1952
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
1953
                                    {
1954
                                        GetUserSign getUser = new GetUserSign();
1955
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
1956
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
1957
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
1958
                                        stream.Write(imageBytes, 0, imageBytes.Length);
1959
                                        stream.Position = 0;
1960
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
1961
                                        BitmapImage returnImage = new BitmapImage();
1962
                                        returnImage.BeginInit();
1963
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
1964
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
1965
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
1966
                                        returnImage.StreamSource = ms;
1967
                                        returnImage.EndInit();
1968
                                        stream.Close();
1969

    
1970
                                        control.SignImage = returnImage;
1971
                                    }
1972
                                    control.PointSet = new List<Point>
1973
                                        {
1974
                                            control.StartPoint,
1975
                                            control.LeftBottomPoint,
1976
                                            control.EndPoint,
1977
                                            control.TopRightPoint,
1978
                                        };
1979
                                }
1980
                            }
1981
                            break;
1982
                        //강인구 추가
1983
                        case ControlType.Symbol:
1984
                            {
1985
                                var control = currentControl as SymControl;
1986

    
1987
                                if (control != null)
1988
                                {
1989
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1990
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1991
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1992
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1993
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1994
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
1995

    
1996
                                    if (control.StartPoint != control.EndPoint)
1997
                                    {
1998
                                        if (control.PathData == null)
1999
                                        {
2000
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2001
                                            {
2002
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2003
                                            }
2004
                                        }
2005
                                    }
2006

    
2007
                                    control.PointSet = new List<Point>
2008
                                        {
2009
                                            control.StartPoint,
2010
                                            control.LeftBottomPoint,
2011
                                            control.EndPoint,
2012
                                            control.TopRightPoint,
2013
                                        };
2014
                                }
2015
                            }
2016
                            break;
2017
                        case ControlType.Stamp:
2018
                            {
2019
                                var control = currentControl as SymControlN;
2020

    
2021
                                if (control != null)
2022
                                {
2023

    
2024
                                    if (control.StartPoint == control.EndPoint)
2025
                                    {
2026
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2027

    
2028
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2029
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2030

    
2031

    
2032
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2033

    
2034
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2035
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2036
                                        writer.Write(xamlData);
2037
                                        writer.Flush();
2038
                                        stream.Position = 0;
2039

    
2040
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2041
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2042
                                        UIElement ob = obj as UIElement;
2043

    
2044
                                        //control.ApplyTemplate();
2045

    
2046
                                        control.SetViewBox();
2047
                                        control.PathXathData = appovalData;
2048
                                        control.Base_ViewBox.Child = ob;
2049
                                    }
2050

    
2051
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2052
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2053
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2054
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2055
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2056

    
2057

    
2058
                                    control.PointSet = new List<Point>
2059
                                    {
2060
                                        control.StartPoint,
2061
                                        control.LeftBottomPoint,
2062
                                        control.EndPoint,
2063
                                        control.TopRightPoint,
2064
                                    };
2065
                                }
2066
                            }
2067
                            break;
2068
                        case ControlType.Mark:
2069
                            {
2070
                                var control = currentControl as RectangleControl;
2071

    
2072
                                if (control != null)
2073
                                {
2074
                                    if (move.mousemode == MouseMode.Drawing)
2075
                                    {
2076
                                        //move.control_Move(ControlList, true, moveX, moveY);
2077
                                    }
2078
                                    else
2079
                                    {
2080
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2081
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2082
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2083
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2084

    
2085

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

    
2095
                                    //강인구 추가
2096
                                    control.Paint = PaintSet.Fill;
2097
                                }
2098
                            }
2099
                            break;
2100
                        case ControlType.PenControl:
2101
                            {
2102
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2103
                                //inkBoard.Strokes.Add(stroke);
2104
                            }
2105
                            break;
2106
                        default:
2107
                            break;
2108
                    }
2109
                }
2110
            }
2111
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2112
            {
2113
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2114

    
2115
                if (isDraggingSelectionRect)
2116
                {
2117
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2118

    
2119
                    e.Handled = true;
2120
                }
2121
                else if (isLeftMouseButtonDownOnWindow)
2122
                {
2123
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2124
                    double dragDistance = Math.Abs(dragDelta.Length);
2125

    
2126
                    if (dragDistance > DragThreshold)
2127
                    {
2128
                        isDraggingSelectionRect = true;
2129

    
2130
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2131
                    }
2132

    
2133
                    e.Handled = true;
2134
                }
2135

    
2136

    
2137
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2138
                {
2139
                    //SelectionPath = new Path();
2140
                    //PathFigure pathFigure = new PathFigure();
2141
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2142
                    //SelectionPath.Opacity = 0.5;
2143
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2144
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2145
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2146
                }
2147
                else
2148
                {
2149
                    //List<Stroke> removingStroke = new List<Stroke>();
2150
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2151
                    //StrokeCollection stC = new StrokeCollection();
2152
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2153
                    //{
2154
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2155
                    //    p1.Intersect(p2);
2156
                    //    if (p1.IsEmpty)
2157
                    //    {
2158

    
2159

    
2160
                    //        p1 = SelectionPath.Data.Bounds;
2161
                    //        bool intersectCheck = false;
2162
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2163
                    //        {
2164
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2165
                    //            p1.Intersect(p3);
2166
                    //            if (!p1.IsEmpty)
2167
                    //            {
2168
                    //                intersectCheck = true;
2169
                    //            }
2170
                    //        }
2171
                    //        if (intersectCheck)
2172
                    //        {
2173
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2174
                    //        }
2175

    
2176
                    //    }
2177
                    //    else
2178
                    //    {
2179
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2180
                    //    }
2181
                    //}
2182

    
2183
                    e.Handled = true;
2184
                }
2185
            }
2186
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2187
            {
2188
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2189
                if (control != null)
2190
                {
2191
                    this.cursor = Cursors.Hand;
2192
                    SetCursor();
2193
                }
2194
                else
2195
                {
2196
                    this.cursor = Cursors.Arrow;
2197
                    SetCursor();
2198
                }
2199
            }
2200
            else
2201
            {
2202
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2203

    
2204
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2205
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2206

    
2207
                //if (hitList.Count > 0)
2208
                //{
2209

    
2210
                //}
2211

    
2212
                #region 조건 설정 : firstCondition
2213
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2214
                //pnts = generalTransform.Transform(pnts);
2215
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2216
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2217
                //                               this.DeepLayer._BaseLayer).ToObservable()
2218
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2219
                //                      select kkk).FirstOrDefault();
2220

    
2221
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2222
                //if (canvas !=null)
2223
                //{
2224
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2225
                //    {
2226
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2227
                //        if (uiElement!=null)
2228
                //        {
2229
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2230
                //        }
2231
                //    }
2232
                //}
2233

    
2234
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2235
                //hitResultsList.Clear();
2236

    
2237
                #endregion
2238
            }
2239
        }
2240

    
2241
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2242

    
2243
        private EllipseGeometry hitArea = new EllipseGeometry();
2244

    
2245
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2246
        {
2247
            IsDrawing = false;
2248

    
2249
            if (mouseHandlingMode != MouseHandlingMode.None)
2250
            {
2251
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2252
                {
2253
                    this.cursor = Cursors.Arrow;
2254

    
2255
                    SetCursor();
2256

    
2257
                    switch (controlType)
2258
                    {
2259
                        case ControlType.None:
2260
                            break;
2261
                        case ControlType.Rectangle:
2262
                            {
2263

    
2264
                            }
2265
                            break;
2266
                        case ControlType.PenControl:
2267
                            {
2268

    
2269
                            }
2270
                            break;
2271
                        default:
2272
                            break;
2273
                    }
2274
                }
2275
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2276
                {
2277
                    if (isLeftMouseButtonDownOnWindow)
2278
                    {
2279
                        bool wasDragSelectionApplied = false;
2280

    
2281
                        if (isDraggingSelectionRect)
2282
                        {
2283
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2284
                            {
2285
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2286
                                mouseHandlingMode = MouseHandlingMode.None;
2287
                                Set_Capture();
2288

    
2289
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2290
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2291
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2292
                            }
2293
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2294
                            {
2295
                                ApplyDragSelectionRect();
2296
                            }
2297
                            else
2298
                            {
2299
                                double x = Canvas.GetLeft(dragZoomBorder);
2300
                                double y = Canvas.GetTop(dragZoomBorder);
2301
                                double width = dragZoomBorder.Width;
2302
                                double height = dragZoomBorder.Height;
2303
                                Rect dragRect = new Rect(x, y, width, height);
2304

    
2305
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2306

    
2307
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2308
                            }
2309

    
2310
                            isDraggingSelectionRect = false;
2311
                            e.Handled = true;
2312
                            wasDragSelectionApplied = true;
2313
                        }
2314

    
2315
                        if (isLeftMouseButtonDownOnWindow)
2316
                        {
2317
                            isLeftMouseButtonDownOnWindow = false;
2318
                            this.ReleaseMouseCapture();
2319
                            e.Handled = true;
2320
                        }
2321

    
2322
                        if (!wasDragSelectionApplied)
2323
                        {
2324
                            init();
2325
                        }
2326
                    }
2327
                }
2328
                else if (mouseButtonDown == MouseButton.Right)
2329
                {
2330
                    this.cursor = Cursors.Arrow;
2331
                    SetCursor();
2332
                }
2333

    
2334
                zoomAndPanControl.ReleaseMouseCapture();
2335

    
2336

    
2337
                e.Handled = true;
2338
            }
2339
            else
2340
            {
2341
                this.cursor = Cursors.Arrow;
2342
                SetCursor();
2343
            }
2344
            mouseButtonDown = MouseButton.Left;
2345

    
2346
            //controlType = ControlType.SingleLine;
2347
        }
2348

    
2349
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2350
        {
2351
            mouseButtonDown = MouseButton.Left;
2352
            this.Cursor = Cursors.Arrow;
2353
        }
2354

    
2355
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2356
        {
2357

    
2358
        }
2359

    
2360
        private void ApplyDragSelectionRect()
2361
        {
2362
            multi_Undo_Data = new Multi_Undo_data();
2363

    
2364
            UndoData = new Undo_data()
2365
            {
2366
                IsUndo = false,
2367
                Event = Event_Type.Select,
2368
                EventTime = DateTime.Now,
2369
                Markup_List = new List<Multi_Undo_data>()
2370
            };
2371

    
2372
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2373

    
2374
            double x = Canvas.GetLeft(dragSelectionBorder);
2375
            double y = Canvas.GetTop(dragSelectionBorder);
2376
            double width = dragSelectionBorder.Width;
2377
            double height = dragSelectionBorder.Height;
2378
            Rect dragRect = new Rect(x, y, width, height);
2379
            Boolean Flag = false;
2380
            dragRect.Inflate(width / 10, height / 10);
2381
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2382
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2383

    
2384
            dragRect = new Rect(x, y, width, height);
2385
            dragRect.Inflate(width / 10, height / 10);
2386

    
2387
            foreach (var item in Items)
2388
            {
2389
                Flag = move.control_Select(item, dragRect);
2390

    
2391
                if (Flag)
2392
                {
2393
                    adornerSet.Add(item);
2394
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2395

    
2396
                    Control_Style(item);
2397
                    UndoData.Markup_List.Add(multi_Undo_Data);
2398
                    multi_Undo_Data = new Multi_Undo_data();
2399
                }
2400
            }
2401
            if (adornerSet.Count > 0)
2402
            {
2403
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2404
                {
2405
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2406
                });
2407
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2408

    
2409
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2410
                SelectLayer.Children.Add(final);
2411
            }
2412
        }
2413

    
2414
        private void InitDragSelectionRect(Point pt1, Point pt2)
2415
        {
2416
            //캡쳐 중
2417
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2418
            {
2419
                dragCaptureBorder.Visibility = Visibility.Visible;
2420
            }
2421
            //선택 중
2422
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2423
            {
2424
                
2425
                dragSelectionBorder.Visibility = Visibility.Visible;
2426
            }
2427
            else
2428
            {
2429
                dragZoomBorder.Visibility = Visibility.Visible;
2430
            }
2431
            UpdateDragSelectionRect(pt1, pt2);
2432
        }
2433

    
2434
        /// <summary>
2435
        /// Update the position and size of the rectangle used for drag selection.
2436
        /// </summary>
2437
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2438
        {
2439
            double x, y, width, height;
2440

    
2441
            //
2442
            // Determine x,y,width and height of the rect inverting the points if necessary.
2443
            // 
2444

    
2445
            if (pt2.X < pt1.X)
2446
            {
2447
                x = pt2.X;
2448
                width = pt1.X - pt2.X;
2449
            }
2450
            else
2451
            {
2452
                x = pt1.X;
2453
                width = pt2.X - pt1.X;
2454
            }
2455

    
2456
            if (pt2.Y < pt1.Y)
2457
            {
2458
                y = pt2.Y;
2459
                height = pt1.Y - pt2.Y;
2460
            }
2461
            else
2462
            {
2463
                y = pt1.Y;
2464
                height = pt2.Y - pt1.Y;
2465
            }
2466

    
2467
            //
2468
            // Update the coordinates of the rectangle used for drag selection.
2469
            //
2470
            //캡쳐 중
2471
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2472
            {
2473
                Canvas.SetLeft(dragCaptureBorder, x);
2474
                Canvas.SetTop(dragCaptureBorder, y);
2475
                dragCaptureBorder.Width = width;
2476
                dragCaptureBorder.Height = height;
2477
            }
2478
            //선택 중
2479
            else if(mouseHandlingMode == MouseHandlingMode.Selecting)
2480
            {
2481
                Canvas.SetLeft(dragSelectionBorder, x);
2482
                Canvas.SetTop(dragSelectionBorder, y);
2483
                dragSelectionBorder.Width = width;
2484
                dragSelectionBorder.Height = height;
2485
            }
2486
            else
2487
            {
2488
                Canvas.SetLeft(dragZoomBorder, x);
2489
                Canvas.SetTop(dragZoomBorder, y);
2490
                dragZoomBorder.Width = width;
2491
                dragZoomBorder.Height = height;
2492
            }
2493

    
2494

    
2495
        }
2496

    
2497
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2498
        {
2499
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2500

    
2501
            bool result = false;
2502
            if (dragRect.Contains(controlRect))
2503
            {
2504
                result = true;
2505
                //잡은 객체들을 담은 리스트
2506
                try
2507
                {
2508
                    selected_item.Add(OverViewPathData, type.ToString());
2509
                }
2510
                catch (Exception)
2511
                {
2512

    
2513
                }
2514
            }
2515
            return result;
2516
        }
2517

    
2518
        private void drawingPannelRotate(double angle)
2519
        {
2520
            rotate.Angle = angle;
2521
            var rotationNum = Math.Abs((rotate.Angle / 90));
2522

    
2523
            if (angle == 90 || angle == 270)
2524
            {
2525
                double emptySize = zoomAndPanCanvas.Width;
2526
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2527
                zoomAndPanCanvas.Height = emptySize;
2528
            }
2529
            if (angle == 0)
2530
            {
2531
                translate.X = 0;
2532
                translate.Y = 0;
2533
            }
2534
            else if (angle == 90)
2535
            {
2536
                translate.X = zoomAndPanCanvas.Width;
2537
                translate.Y = 0;
2538
            }
2539
            else if (angle == 180)
2540
            {
2541
                translate.X = zoomAndPanCanvas.Width;
2542
                translate.Y = zoomAndPanCanvas.Height;
2543
            }
2544
            else
2545
            {
2546
                translate.X = 0;
2547
                translate.Y = zoomAndPanCanvas.Height;
2548
            }
2549

    
2550
            zoomAndPanControl.RotationAngle = rotate.Angle;
2551

    
2552

    
2553
            if (!testPanel2.IsHidden)
2554
            {
2555
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2556
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2557
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2558
            }
2559

    
2560
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2561
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2562
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2563
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2564
            ViewerDataModel.Instance.Angle = rotate.Angle;
2565

    
2566

    
2567
        }
2568

    
2569
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2570
        {
2571

    
2572
            InkControl_Convert();
2573

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

    
2577
            if(text_item != null && (currentControl as ArrowTextControl) == null)
2578
            {
2579
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2580
            }
2581

    
2582
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2583
            {
2584
                if (arrow_text as ArrowTextControl != null)
2585
                {
2586
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2587
                }
2588
            }
2589

    
2590
            if(currentControl == null)
2591
            {
2592
                //Keyboard.ClearFocus();
2593

    
2594

    
2595
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2596
                if (text_item_ != null)
2597
                {
2598
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2599
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2600
                    (text_item_ as TextControl).IsEditing = false;
2601
                    (text_item_ as TextControl).EnableEditing = false;
2602
                }
2603

    
2604
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2605
                if (Arrowtext_item_ != null)
2606
                {
2607
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2608
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2609
                }
2610
            }
2611

    
2612
            double Ang = 0;
2613
            if (rotate.Angle != 0)
2614
            {
2615
                Ang = 360 - rotate.Angle;
2616
            }
2617
            move = new Move();
2618

    
2619
            if (e.OriginalSource is System.Windows.Controls.Image)
2620
            {
2621
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2622
            }
2623

    
2624
            mouseButtonDown = e.ChangedButton;
2625
            if (mouseButtonDown == MouseButton.Left)
2626
            {
2627
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2628
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2629

    
2630
                this.cursor = Cursors.Arrow;
2631
                SetCursor();
2632

    
2633
                if (!ViewerDataModel.Instance.IsPressCtrl)
2634
                {
2635
                    ReleaseAdorner();
2636
                }
2637
            }
2638
            if (mouseButtonDown == MouseButton.Middle)
2639
            {
2640
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2641
                cursor = Cursors.SizeAll;
2642
                SetCursor();
2643
            }
2644
            if (mouseButtonDown == MouseButton.Right)
2645
            {
2646
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2647
                cursor = Cursors.SizeAll;
2648
                SetCursor();
2649
            }
2650
            else if (mouseButtonDown == MouseButton.XButton1)
2651
            {
2652
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2653
                {
2654
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2655
                }
2656

    
2657
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2658

    
2659
            }
2660
            else if (mouseButtonDown == MouseButton.XButton2)
2661
            {
2662
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2663
                {
2664
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2665
                }
2666
            }
2667

    
2668
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2669
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2670
            {
2671

    
2672
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2673
                {
2674
                    if (SelectLayer.Children.Count == 0)
2675
                    {
2676
                        isLeftMouseButtonDownOnWindow = true;
2677
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2678
                    }
2679

    
2680
                    if (controlType == ControlType.None)
2681
                    {
2682
                        isLeftMouseButtonDownOnWindow = true;
2683
                    }
2684
                }
2685

    
2686
                //캡쳐 모드 설정
2687
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2688
                {
2689
                    dragCaptureBorder.Visibility = Visibility.Visible;
2690
                    isLeftMouseButtonDownOnWindow = true;
2691
                }
2692

    
2693
                //줌 모드 설정
2694
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2695
                {
2696
                    //dragSelectionBorder.Visibility = Visibility.Visible;
2697
                    isLeftMouseButtonDownOnWindow = true;
2698
                }
2699

    
2700

    
2701
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2702
                if (control != null)
2703
                {
2704
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2705
                    AdornerFinal final;
2706
                    List<Point> p_set = new List<Point>();
2707
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2708
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2709
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2710
                    multi_Undo_Data = new Multi_Undo_data();
2711

    
2712
                    //강인구 Undo/Redo 보류
2713
                    UndoData = new Undo_data()
2714
                    {
2715
                        IsUndo = false,
2716
                        Event = Event_Type.Select,
2717
                        EventTime = DateTime.Now,
2718
                        Markup_List = new List<Multi_Undo_data>()
2719
                    };
2720

    
2721
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2722
                    {
2723
                        ReleaseAdorner();
2724
                        final = new AdornerFinal(control);
2725
                        //단일 컨트롤 언두 저장
2726

    
2727
                        Control_Style(control);
2728
                        UndoData.Markup_List.Add(multi_Undo_Data);
2729

    
2730
                        if ((control as IPath) != null)
2731
                        {
2732
                            if ((control as IPath).LineSize != 0)
2733
                            {
2734
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2735
                            }
2736
                        }
2737
                        if ((control as IShapeControl) != null)
2738
                        {
2739
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2740
                            {
2741
                                ViewerDataModel.Instance.checkHatchShape = true;
2742
                            }
2743
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2744
                            {
2745
                                ViewerDataModel.Instance.checkFillShape = true;
2746
                            }
2747
                            else
2748
                            {
2749
                                ViewerDataModel.Instance.checkHatchShape = false;
2750
                                ViewerDataModel.Instance.checkFillShape = false;
2751
                            }
2752
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2753
                        }
2754

    
2755
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2756

    
2757
                        if ((control as TextControl) != null)
2758
                        {
2759
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2760
                            {
2761
                                ViewerDataModel.Instance.checkTextStyle = true;
2762
                            }
2763
                            else
2764
                            {
2765
                                ViewerDataModel.Instance.checkTextStyle = false;
2766
                            }
2767

    
2768
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2769
                            {
2770
                                ViewerDataModel.Instance.checkTextStyle = true;
2771
                            }
2772
                            else
2773
                            {
2774
                                ViewerDataModel.Instance.checkTextStyle = false;
2775
                            }
2776
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2777
                            {
2778
                                ViewerDataModel.Instance.checkTextWeight = true;
2779
                            }
2780
                            else
2781
                            {
2782
                                ViewerDataModel.Instance.checkTextWeight = false;
2783
                            }
2784
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2785
                            {
2786
                                ViewerDataModel.Instance.checkUnderLine = true;
2787
                            }
2788
                            else
2789
                            {
2790
                                ViewerDataModel.Instance.checkUnderLine = false;
2791
                            }
2792
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2793
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2794
                            
2795
                        }
2796
                        else if ((control as ArrowTextControl) != null)
2797
                        {
2798
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2799
                            {
2800
                                ViewerDataModel.Instance.checkTextStyle = true;
2801
                            }
2802
                            else
2803
                            {
2804
                                ViewerDataModel.Instance.checkTextStyle = false;
2805
                            }
2806

    
2807
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2808
                            {
2809
                                ViewerDataModel.Instance.checkTextStyle = true;
2810
                            }
2811
                            else
2812
                            {
2813
                                ViewerDataModel.Instance.checkTextStyle = false;
2814
                            }
2815
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2816
                            {
2817
                                ViewerDataModel.Instance.checkTextWeight = true;
2818
                            }
2819
                            else
2820
                            {
2821
                                ViewerDataModel.Instance.checkTextWeight = false;
2822
                            }
2823
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2824
                            {
2825
                                ViewerDataModel.Instance.checkUnderLine = true;
2826
                            }
2827
                            else
2828
                            {
2829
                                ViewerDataModel.Instance.checkUnderLine = false;
2830
                            }
2831
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2832
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2833
                        }
2834
                        else if ((control as RectCloudControl) != null)
2835
                        {
2836
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2837
                        }
2838
                        else if ((control as CloudControl) != null)
2839
                        {
2840
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2841
                        }
2842

    
2843
                    }
2844
                    else
2845
                    {
2846
                        comment = AddAdorner();
2847
                        comment.Add(control);
2848

    
2849
                        Control_Style(control);
2850
                        UndoData.Markup_List.Add(multi_Undo_Data);
2851

    
2852
                        final = new AdornerFinal(comment);
2853
                        //다중 컨트롤 언두 저장
2854
                    }
2855

    
2856
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2857
                    {
2858
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2859
                    });
2860

    
2861
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2862

    
2863
                    SelectLayer.Children.Add(final);
2864

    
2865
                    //Control_Init(control);
2866

    
2867

    
2868
                    
2869

    
2870

    
2871
                    //강인구 폰트 변경 보류
2872

    
2873
                    //if ((currentControl as TextControl) != null)
2874
                    //{
2875
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2876
                    //    {
2877
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2878
                    //    }
2879
                    //    else
2880
                    //    {
2881
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2882
                    //    }
2883

    
2884
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2885
                    //    {
2886

    
2887
                    //    }
2888
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
2889
                    //    {
2890

    
2891
                    //    }
2892
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2893
                    //    {
2894

    
2895
                    //    }
2896
                    //}
2897
                    //else if ((currentControl as ArrowTextControl) != null)
2898
                    //{
2899
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2900
                    //    {
2901
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
2902
                    //    }
2903
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2904
                    //    {
2905
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
2906
                    //    }
2907
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2908
                    //    {
2909
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
2910
                    //    }
2911
                    //}
2912

    
2913
                    //mouseHandlingMode = MouseHandlingMode.Adorner;
2914
                }
2915
            }
2916

    
2917
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2918
            {
2919
                init();
2920
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2921
                if (cursor != Cursors.SizeAll)
2922
                {
2923
                    cursor = Cursors.Cross;
2924
                    SetCursor();
2925
                }
2926
                bool init_user = false;
2927
                foreach (var user in gridViewMarkup.Items)
2928
                {
2929
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2930
                    {
2931
                        init_user = true;
2932
                    }
2933
                }
2934
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2935
                {
2936
                    RadWindow.Alert(new DialogParameters
2937
                    {
2938
                        Theme = new VisualStudio2013Theme(),
2939
                        Header = "안내",
2940
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2941
                    });
2942
                    return;
2943
                }
2944
                else
2945
                {
2946
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2947
                    if (item != null)
2948
                    {
2949
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2950
                    }
2951
                }
2952

    
2953
                multi_Undo_Data = new Multi_Undo_data();
2954
                //강인구 Undo/Redo 보류
2955
                UndoData = new Undo_data()
2956
                {
2957
                    IsUndo = false,
2958
                    Event = Event_Type.Create,
2959
                    EventTime = DateTime.Now,
2960
                    Markup_List = new List<Multi_Undo_data>()
2961
                };
2962

    
2963
                switch (controlType)
2964
                {
2965
                    case ControlType.Rectangle:
2966
                        {
2967
                            if (mouseButtonDown == MouseButton.Left)
2968
                            {
2969
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2970
                                {
2971
                                    if (currentControl is RectangleControl)
2972
                                    {
2973
                                        CreateControl();
2974

    
2975
                                        (currentControl as RectangleControl).ApplyOverViewData();
2976
                                        currentControl = null;
2977
                                        this.cursor = Cursors.Arrow;
2978
                                    }
2979
                                    else
2980
                                    {
2981
                                        currentControl = new RectangleControl
2982
                                        {
2983
                                            Background = new SolidColorBrush(Colors.Black),
2984
                                            ControlType = ControlType.Rectangle
2985
                                        };
2986

    
2987
                                        currentControl.CommentID = Save.shortGuid();
2988
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2989
                                        currentControl.IsNew = true;
2990
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2991

    
2992
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2993
                                    }
2994
                                }
2995
                            }
2996
                        }
2997
                        break;
2998
                    case ControlType.RectCloud:
2999
                        {
3000
                            if (mouseButtonDown == MouseButton.Left)
3001
                            {
3002
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3003
                                {
3004
                                    if (currentControl is RectCloudControl)
3005
                                    {
3006
                                        CreateControl();
3007

    
3008
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3009
                                        currentControl = null;
3010
                                        this.cursor = Cursors.Arrow;
3011
                                    }
3012
                                    else
3013
                                    {
3014
                                        currentControl = new RectCloudControl
3015
                                        {
3016
                                            Background = new SolidColorBrush(Colors.Black)
3017
                                        };
3018

    
3019
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3020
                                        currentControl.CommentID = Save.shortGuid();
3021
                                        currentControl.IsNew = true;
3022
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3023
                                    }
3024
                                }
3025
                            }
3026
                        }
3027
                        break;
3028
                    case ControlType.Circle:
3029
                        {
3030
                            if (mouseButtonDown == MouseButton.Left)
3031
                            {
3032
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3033
                                {
3034
                                    if (currentControl is CircleControl)
3035
                                    {
3036
                                        CreateControl();
3037

    
3038
                                        (currentControl as CircleControl).ApplyOverViewData();
3039
                                        currentControl = null;
3040
                                    }
3041
                                    else
3042
                                    {
3043
                                        currentControl = new CircleControl
3044
                                        {
3045
                                            Background = new SolidColorBrush(Colors.Black)
3046
                                        };
3047

    
3048
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3049
                                        currentControl.CommentID = Save.shortGuid();
3050
                                        currentControl.IsNew = true;
3051
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3052
                                    }
3053
                                }
3054
                            }
3055
                        }
3056
                        break;
3057
                    case ControlType.Triangle:
3058
                        {
3059
                            if (mouseButtonDown == MouseButton.Left)
3060
                            {
3061
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3062
                                {
3063
                                    if (currentControl is TriControl)
3064
                                    {
3065
                                        var content = currentControl as TriControl;
3066
                                        if (content.MidPoint == new Point(0, 0))
3067
                                        {
3068
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3069
                                        }
3070
                                        else
3071
                                        {
3072
                                            CreateControl();
3073

    
3074
                                            (currentControl as TriControl).ApplyOverViewData();
3075
                                            currentControl = null;
3076
                                        }
3077
                                    }
3078
                                    else
3079
                                    {
3080
                                        currentControl = new TriControl
3081
                                        {
3082
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3083
                                            Background = new SolidColorBrush(Colors.Black),
3084
                                        };
3085

    
3086
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3087
                                        currentControl.CommentID = Save.shortGuid();
3088
                                        currentControl.IsNew = true;
3089
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3090
                                    }
3091
                                }
3092
                            }
3093
                        }
3094
                        break;
3095
                    case ControlType.SingleLine:
3096
                        {
3097
                            if (mouseButtonDown == MouseButton.Left)
3098
                            {
3099
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3100
                                {
3101
                                    if (currentControl is LineControl)
3102
                                    {
3103
                                        CreateControl();
3104

    
3105
                                        (currentControl as LineControl).ApplyOverViewData();
3106
                                        currentControl = null;
3107
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3108
                                    }
3109
                                    else
3110
                                    {
3111
                                        currentControl = new LineControl
3112
                                        {
3113
                                            Background = new SolidColorBrush(Colors.Black)
3114
                                        };
3115

    
3116
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3117
                                        currentControl.CommentID = Save.shortGuid();
3118
                                        currentControl.IsNew = true;
3119
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3120
                                        this.MainAngle.Visibility = Visibility.Visible;
3121
                                    }
3122
                                }
3123
                            }
3124
                        }
3125
                        break;
3126
                    case ControlType.CancelLine:
3127
                        {
3128
                            if (mouseButtonDown == MouseButton.Left)
3129
                            {
3130
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3131
                                {
3132
                                    if (currentControl is LineControl)
3133
                                    {
3134
                                        CreateControl();
3135

    
3136
                                        (currentControl as LineControl).ApplyOverViewData();
3137
                                        currentControl = null;
3138
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3139
                                    }
3140
                                    else
3141
                                    {
3142
                                        currentControl = new LineControl
3143
                                        {
3144
                                            Background = new SolidColorBrush(Colors.Black)
3145
                                        };
3146

    
3147
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3148
                                        currentControl.CommentID = Save.shortGuid();
3149
                                        currentControl.IsNew = true;
3150
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3151
                                        this.MainAngle.Visibility = Visibility.Visible;
3152
                                    }
3153
                                }
3154
                            }
3155
                        }
3156
                        break;
3157
                    case ControlType.ArrowLine:
3158
                        {
3159
                            if (mouseButtonDown == MouseButton.Left)
3160
                            {
3161
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3162
                                {
3163
                                    if (currentControl is LineControl)
3164
                                    {
3165
                                        CreateControl();
3166

    
3167
                                        (currentControl as LineControl).ApplyOverViewData();
3168
                                        currentControl = null;
3169
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3170
                                    }
3171
                                    else
3172
                                    {
3173
                                        currentControl = new LineControl
3174
                                        {
3175
                                            Background = new SolidColorBrush(Colors.Black)
3176
                                        };
3177

    
3178
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3179
                                        currentControl.CommentID = Save.shortGuid();
3180
                                        currentControl.IsNew = true;
3181
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3182
                                        this.MainAngle.Visibility = Visibility.Visible;
3183
                                    }
3184
                                }
3185
                            }
3186
                        }
3187
                        break;
3188
                    case ControlType.TwinLine:
3189
                        {
3190
                            if (mouseButtonDown == MouseButton.Left)
3191
                            {
3192
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3193
                                {
3194
                                    if (currentControl is LineControl)
3195
                                    {
3196
                                        CreateControl();
3197

    
3198
                                        (currentControl as LineControl).ApplyOverViewData();
3199
                                        currentControl = null;
3200
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3201
                                    }
3202
                                    else
3203
                                    {
3204
                                        currentControl = new LineControl
3205
                                        {
3206
                                            Background = new SolidColorBrush(Colors.Black)
3207
                                        };
3208
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3209
                                        currentControl.CommentID = Save.shortGuid();
3210
                                        currentControl.IsNew = true;
3211
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3212
                                        this.MainAngle.Visibility = Visibility.Visible;
3213
                                    }
3214
                                }
3215
                            }
3216
                        }
3217
                        break;
3218
                    case ControlType.DimLine:
3219
                        {
3220
                            if (mouseButtonDown == MouseButton.Left)
3221
                            {
3222
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3223
                                {
3224
                                    if (currentControl is LineControl)
3225
                                    {
3226
                                        CreateControl();
3227

    
3228
                                        (currentControl as LineControl).ApplyOverViewData();
3229
                                        currentControl = null;
3230
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3231
                                    }
3232
                                    else
3233
                                    {
3234
                                        currentControl = new LineControl
3235
                                        {
3236
                                            Background = new SolidColorBrush(Colors.Black)
3237
                                        };
3238
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3239
                                        currentControl.CommentID = Save.shortGuid();
3240
                                        currentControl.IsNew = true;
3241
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3242
                                        this.MainAngle.Visibility = Visibility.Visible;
3243
                                    }
3244
                                }
3245
                            }
3246
                        }
3247
                        break;
3248
                    case ControlType.ChainLine:
3249
                        {
3250
                            if (currentControl is PolygonControl)
3251
                            {
3252
                                var control = currentControl as PolygonControl;
3253

    
3254
                                if (mouseButtonDown == MouseButton.Right)
3255
                                {
3256
                                    CreateControl();
3257

    
3258
                                    (currentControl as PolygonControl).ApplyOverViewData();
3259
                                    currentControl = null;
3260
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3261
                                    return;
3262
                                }
3263

    
3264
                                if (!control.IsCompleted)
3265
                                {
3266
                                    control.PointSet.Add(control.EndPoint);
3267
                                    this.MainAngle.Visibility = Visibility.Visible;
3268
                                }
3269
                            }
3270
                            else
3271
                            {
3272
                                if (mouseButtonDown == MouseButton.Left)
3273
                                {
3274
                                    MainAngle.Visibility = Visibility.Visible;
3275
                                    currentControl = new PolygonControl
3276
                                    {
3277
                                        PointSet = new List<Point>(),
3278
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3279
                                        ControlType = ControlType.ChainLine,
3280
                                        DashSize = ViewerDataModel.Instance.DashSize,
3281
                                        LineSize = ViewerDataModel.Instance.LineSize,
3282
                                        //PointC = new StylusPointSet()
3283
                                    };
3284

    
3285
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3286
                                    {
3287
                                        var polygonControl = (currentControl as PolygonControl);
3288
                                        currentControl.CommentID = Save.shortGuid();
3289
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3290
                                        currentControl.IsNew = true;
3291
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3292
                                        //currentControl.OnApplyTemplate();
3293
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3294
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3295
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3296
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3297
                                    }
3298
                                }
3299
                            }
3300
                        }
3301
                        break;
3302
                    case ControlType.ArcLine:
3303
                        {
3304
                            if (mouseButtonDown == MouseButton.Left)
3305
                            {
3306
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3307
                                {
3308
                                    if (currentControl is ArcControl)
3309
                                    {
3310
                                        CreateControl();
3311

    
3312
                                        (currentControl as ArcControl).ApplyOverViewData();
3313
                                        currentControl = null;
3314
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3315
                                    }
3316
                                    else
3317
                                    {
3318
                                        currentControl = new ArcControl
3319
                                        {
3320
                                            Background = new SolidColorBrush(Colors.Black)
3321
                                        };
3322
                                        currentControl.CommentID = Save.shortGuid();
3323
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3324
                                        currentControl.IsNew = true;
3325
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3326
                                        this.MainAngle.Visibility = Visibility.Visible;
3327
                                    }
3328
                                }
3329
                            }
3330
                            else if (mouseButtonDown == MouseButton.Right)
3331
                            {
3332
                                if (currentControl != null)
3333
                                {
3334
                                    (currentControl as ArcControl).setClock();
3335
                                }
3336

    
3337
                            }
3338

    
3339
                        }
3340
                        break;
3341
                    case ControlType.ArcArrow:
3342
                        {
3343
                            if (mouseButtonDown == MouseButton.Left)
3344
                            {
3345
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3346
                                {
3347
                                    if (currentControl is ArcControl)
3348
                                    {
3349
                                        CreateControl();
3350

    
3351
                                        (currentControl as ArcControl).ApplyOverViewData();
3352
                                        currentControl = null;
3353
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3354
                                    }
3355
                                    else
3356
                                    {
3357
                                        currentControl = new ArcControl
3358
                                        {
3359
                                            Background = new SolidColorBrush(Colors.Red),
3360
                                        };
3361
                                        currentControl.CommentID = Save.shortGuid();
3362
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3363
                                        currentControl.IsNew = true;
3364
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3365
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3366
                                        this.MainAngle.Visibility = Visibility.Visible;
3367
                                    }
3368
                                }
3369
                            }
3370
                            else if (mouseButtonDown == MouseButton.Right)
3371
                            {
3372
                                (currentControl as ArcControl).setClock();
3373
                            }
3374
                        }
3375
                        break;
3376
                    case ControlType.ArrowMultiLine:
3377
                        {
3378
                            if (mouseButtonDown == MouseButton.Left)
3379
                            {
3380
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3381
                                {
3382

    
3383
                                    if (currentControl is ArrowControl_Multi)
3384
                                    {
3385
                                        var content = currentControl as ArrowControl_Multi;
3386
                                        if (content.MiddlePoint == new Point(0, 0))
3387
                                        {
3388
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3389
                                            {
3390
                                                content.MiddlePoint = content.EndPoint;
3391
                                            }
3392
                                            else
3393
                                            {
3394
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3395
                                            }
3396
                                        }
3397
                                        else
3398
                                        {
3399
                                            CreateControl();
3400

    
3401
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3402
                                            currentControl = null;
3403
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3404
                                        }
3405
                                    }
3406
                                    else
3407
                                    {
3408
                                        currentControl = new ArrowControl_Multi
3409
                                        {
3410
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3411
                                            Background = new SolidColorBrush(Colors.Black)
3412
                                        };
3413
                                        currentControl.CommentID = Save.shortGuid();
3414
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3415
                                        currentControl.IsNew = true;
3416
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3417
                                        this.MainAngle.Visibility = Visibility.Visible;
3418
                                    }
3419
                                }
3420
                            }
3421
                        }
3422
                        break;
3423
                    case ControlType.PolygonCloud:
3424
                        {
3425
                            if (currentControl is CloudControl)
3426
                            {
3427
                                var control = currentControl as CloudControl;
3428
                                if (mouseButtonDown == MouseButton.Right)
3429
                                {
3430
                                    control.IsCompleted = true;
3431
                                }
3432

    
3433
                                if (!control.IsCompleted)
3434
                                {
3435
                                    control.PointSet.Add(control.EndPoint);
3436
                                }
3437
                                else
3438
                                {
3439
                                    CreateControl();
3440

    
3441
                                    control.isTransOn = true;
3442
                                    var firstPoint = control.PointSet.First();
3443

    
3444
                                    control.PointSet.Add(firstPoint);
3445
                                    control.DrawingCloud();
3446
                                    control.ApplyOverViewData();
3447

    
3448
                                    currentControl = null;
3449
                                }
3450
                            }
3451
                            else
3452
                            {
3453
                                if (mouseButtonDown == MouseButton.Left)
3454
                                {
3455
                                    currentControl = new CloudControl
3456
                                    {
3457
                                        PointSet = new List<Point>(),
3458
                                        PointC = new StylusPointSet()
3459
                                    };
3460

    
3461
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3462
                                    {
3463
                                        var polygonControl = (currentControl as CloudControl);
3464
                                        currentControl.CommentID = Save.shortGuid();
3465
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3466
                                        currentControl.IsNew = true;
3467
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3468

    
3469
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3470
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3471
                                    }
3472
                                }
3473
                            }
3474
                        }
3475
                        break;
3476
                    case ControlType.ImgControl:
3477
                        {
3478
                            if (mouseButtonDown == MouseButton.Left)
3479
                            {
3480
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3481
                                {
3482
                                    if (currentControl is ImgControl)
3483
                                    {
3484
                                        CreateControl();
3485
                                        (currentControl as ImgControl).ApplyOverViewData();
3486

    
3487
                                        currentControl = null;
3488
                                    }
3489
                                    else
3490
                                    {
3491
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3492
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3493
                                        {
3494
                                            Image img = new Image();
3495
                                            img.Source = new BitmapImage(new Uri(filename));
3496

    
3497
                                            currentControl = new ImgControl
3498
                                            {
3499
                                                Background = new SolidColorBrush(Colors.Black),
3500
                                                PointSet = new List<Point>(),
3501
                                                FilePath = filename,
3502
                                                ImageData = img.Source,
3503
                                                StartPoint = canvasDrawingMouseDownPoint,
3504
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3505
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3506
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3507
                                            };
3508

    
3509
                                            currentControl.CommentID = Save.shortGuid();
3510
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3511
                                            currentControl.IsNew = true;
3512
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3513
                                        }
3514
                                    }
3515
                                }
3516
                            }
3517
                        }
3518
                        break;
3519
                    case ControlType.Date:
3520
                        {
3521
                            if (mouseButtonDown == MouseButton.Left)
3522
                            {
3523
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3524
                                {
3525
                                    if (currentControl is DateControl)
3526
                                    {
3527
                                        CreateControl();
3528
                                        (currentControl as DateControl).ApplyOverViewData();
3529
                                        currentControl = null;
3530

    
3531
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3532
                                        {
3533
                                            controlType = ControlType.None;
3534
                                            IsSwingMode = false;
3535
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3536
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3537
                                            mouseHandlingMode = MouseHandlingMode.None;
3538
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3539
                                            txtBatch.Visibility = Visibility.Collapsed;
3540

    
3541
                                        }
3542
                                    }
3543
                                    else
3544
                                    {
3545
                                        currentControl = new DateControl
3546
                                        {
3547
                                            Background = new SolidColorBrush(Colors.Black)
3548
                                        };
3549
                                        currentControl.CommentID = Save.shortGuid();
3550
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3551
                                        currentControl.IsNew = true;
3552
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3553
                                    }
3554
                                }
3555
                            }
3556
                        }
3557
                        break;
3558
                    case ControlType.TextControl:
3559
                        {
3560
                            if (mouseButtonDown == MouseButton.Left)
3561
                            {
3562
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3563
                                {
3564

    
3565
                                    currentControl = new TextControl
3566
                                    {
3567
                                        ControlType = controlType
3568
                                    };
3569
                                        currentControl.CommentID = Save.shortGuid();
3570
                                        currentControl.IsNew = true;
3571
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3572
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3573
                                        currentControl.SetValue(Canvas.ZIndexProperty, 2);
3574
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3575
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3576
                                        currentControl.Focus();
3577
                                        (currentControl as TextControl).ApplyOverViewData();
3578
                                        (currentControl as TextControl).ControlType_No = 0;
3579
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3580
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3581

    
3582
                                        CreateControl();
3583

    
3584
                                        currentControl = null;
3585
                                }
3586
                            }
3587
                        }
3588
                        break;
3589
                    case ControlType.TextBorder:
3590
                        {
3591
                            if (mouseButtonDown == MouseButton.Left)
3592
                            {
3593
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3594
                                {
3595
                                    currentControl = new TextControl
3596
                                    {
3597
                                        ControlType = controlType
3598
                                    };
3599

    
3600

    
3601
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3602
                                    currentControl.CommentID = Save.shortGuid();
3603
                                    currentControl.IsNew = true;
3604
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3605
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3606
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3607
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3608
                                    currentControl.Focus();
3609
                                    (currentControl as TextControl).ControlType_No = 1;
3610
                                    (currentControl as TextControl).Angle = Ang;
3611
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3612
                                    CreateControl();
3613

    
3614
                                    currentControl = null;
3615
                                }
3616
                            }
3617
                        }
3618
                        break;
3619
                    case ControlType.TextCloud:
3620
                        {
3621
                            if (mouseButtonDown == MouseButton.Left)
3622
                            {
3623
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3624
                                {
3625
                                    currentControl = new TextControl
3626
                                    {
3627
                                        ControlType = controlType
3628
                                    };
3629
                                    currentControl.CommentID = Save.shortGuid();
3630
                                    currentControl.IsNew = true;
3631
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3632
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3633

    
3634
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3635
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3636
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3637
                                    currentControl.Focus();
3638

    
3639
                                    (currentControl as TextControl).Angle = Ang;
3640
                                    (currentControl as TextControl).ControlType_No = 2;
3641
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3642

    
3643
                                    CreateControl();
3644
                                    currentControl = null;
3645
                                }
3646
                            }
3647
                        }
3648
                        break;
3649
                    case ControlType.ArrowTextControl:
3650
                        {
3651
                            if (mouseButtonDown == MouseButton.Left)
3652
                            {
3653
                                if (currentControl is ArrowTextControl)
3654
                                {
3655
                                    CreateControl();
3656

    
3657
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3658
                                    (currentControl as ArrowTextControl).IsEditing = false;
3659
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3660
                                    currentControl = null;
3661
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3662

    
3663
                                }
3664
                                else
3665
                                {
3666
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3667
                                    {
3668
                                        currentControl = new ArrowTextControl();
3669
                                        currentControl.CommentID = Save.shortGuid();
3670
                                        currentControl.IsNew = true;
3671
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3672
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3673

    
3674
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3675

    
3676
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3677

    
3678
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3679

    
3680
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3681

    
3682
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3683

    
3684
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3685
                                        this.MainAngle.Visibility = Visibility.Visible;
3686
                                    }
3687
                                }
3688
                            }
3689
                        }
3690
                        break;
3691
                    case ControlType.ArrowTransTextControl:
3692
                        {
3693
                            if (mouseButtonDown == MouseButton.Left)
3694
                            {
3695
                                if (currentControl is ArrowTextControl)
3696
                                {
3697
                                    CreateControl();
3698
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3699
                                    currentControl = null;
3700
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3701
                                }
3702
                                else
3703
                                {
3704
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3705
                                    {
3706
                                        currentControl = new ArrowTextControl();
3707
                                        currentControl.CommentID = Save.shortGuid();
3708
                                        currentControl.IsNew = true;
3709
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3710
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3711

    
3712
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3713

    
3714
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3715

    
3716
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3717

    
3718
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3719

    
3720
                                        (currentControl as ArrowTextControl).isFixed = true;
3721
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3722

    
3723
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3724
                                        this.MainAngle.Visibility = Visibility.Visible;
3725
                                    }
3726
                                }
3727
                            }
3728
                        }
3729
                        break;
3730
                    case ControlType.ArrowTextBorderControl:
3731
                        {
3732
                            if (mouseButtonDown == MouseButton.Left)
3733
                            {
3734
                                if (currentControl is ArrowTextControl)
3735
                                {
3736
                                    CreateControl();
3737
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3738
                                    currentControl = null;
3739
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3740
                                }
3741
                                else
3742
                                {
3743
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3744
                                    {
3745
                                        currentControl = new ArrowTextControl()
3746
                                        {
3747
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3748
                                        };
3749
                                        currentControl.CommentID = Save.shortGuid();
3750
                                        currentControl.IsNew = true;
3751
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3752
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3753

    
3754
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3755

    
3756
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3757

    
3758
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3759
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3760

    
3761
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3762

    
3763
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3764
                                        this.MainAngle.Visibility = Visibility.Visible;
3765
                                    }
3766
                                }
3767
                            }
3768
                        }
3769
                        break;
3770
                    case ControlType.ArrowTransTextBorderControl:
3771
                        {
3772
                            if (mouseButtonDown == MouseButton.Left)
3773
                            {
3774
                                if (currentControl is ArrowTextControl)
3775
                                {
3776
                                    CreateControl();
3777
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3778
                                    currentControl = null;
3779
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3780
                                }
3781
                                else
3782
                                {
3783
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3784
                                    {
3785
                                        currentControl = new ArrowTextControl()
3786
                                        {
3787
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3788
                                        };
3789
                                        currentControl.CommentID = Save.shortGuid();
3790
                                        currentControl.IsNew = true;
3791
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3792
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3793

    
3794
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3795

    
3796
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3797

    
3798
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3799

    
3800
                                        (currentControl as ArrowTextControl).isFixed = true;
3801
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3802

    
3803
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3804

    
3805
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3806
                                        this.MainAngle.Visibility = Visibility.Visible;
3807
                                    }
3808
                                }
3809
                            }
3810
                        }
3811
                        break;
3812
                    case ControlType.ArrowTextCloudControl:
3813
                        {
3814
                            if (mouseButtonDown == MouseButton.Left)
3815
                            {
3816
                                if (currentControl is ArrowTextControl)
3817
                                {
3818
                                    CreateControl();
3819
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3820
                                    currentControl = null;
3821
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3822
                                }
3823
                                else
3824
                                {
3825
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3826
                                    {
3827
                                        currentControl = new ArrowTextControl()
3828
                                        {
3829
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3830
                                        };
3831
                                        currentControl.CommentID = Save.shortGuid();
3832
                                        currentControl.IsNew = true;
3833
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3834
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3835

    
3836
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3837

    
3838
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3839

    
3840
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3841
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3842
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3843

    
3844
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3845
                                        this.MainAngle.Visibility = Visibility.Visible;
3846
                                    }
3847
                                }
3848
                            }
3849
                        }
3850
                        break;
3851
                    case ControlType.ArrowTransTextCloudControl:
3852
                        {
3853
                            if (mouseButtonDown == MouseButton.Left)
3854
                            {
3855
                                if (currentControl is ArrowTextControl)
3856
                                {
3857
                                    CreateControl();
3858
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3859
                                    currentControl = null;
3860
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3861
                                }
3862
                                else
3863
                                {
3864
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3865
                                    {
3866
                                        currentControl = new ArrowTextControl()
3867
                                        {
3868
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3869
                                        };
3870
                                        currentControl.CommentID = Save.shortGuid();
3871
                                        currentControl.IsNew = true;
3872
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3873
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3874

    
3875
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3876

    
3877
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3878

    
3879
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3880

    
3881
                                        (currentControl as ArrowTextControl).isFixed = true;
3882
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3883

    
3884
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3885

    
3886
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3887
                                        this.MainAngle.Visibility = Visibility.Visible;
3888
                                    }
3889
                                }
3890
                            }
3891
                        }
3892
                        break;
3893
                    case ControlType.PolygonControl:
3894
                        {
3895
                            if (currentControl is PolygonControl)
3896
                            {
3897
                                var control = currentControl as PolygonControl;
3898

    
3899
                                if (mouseButtonDown == MouseButton.Right)
3900
                                {
3901
                                    control.IsCompleted = true;
3902
                                }
3903

    
3904
                                if (!control.IsCompleted)
3905
                                {
3906
                                    control.PointSet.Add(control.EndPoint);
3907
                                }
3908
                                else
3909
                                {
3910
                                    var firstPoint = control.PointSet.First();
3911
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3912
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3913
                                    control.PointSet.Add(firstPoint);
3914

    
3915
                                    control.SetPolyPath();
3916

    
3917
                                    control.ApplyOverViewData();
3918

    
3919
                                    CreateControl();
3920

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

    
3934
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3935
                                    {
3936
                                        var polygonControl = (currentControl as PolygonControl);
3937
                                        currentControl.CommentID = Save.shortGuid();
3938
                                        currentControl.IsNew = true;
3939
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3940
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3941
                                        //currentControl.OnApplyTemplate();
3942
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3943
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3944
                                    }
3945
                                }
3946
                            }
3947
                        }
3948
                        break;
3949
                    //강인구 추가
3950
                    case ControlType.Sign:
3951
                        {
3952
                            if (mouseButtonDown == MouseButton.Left)
3953
                            {
3954
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3955
                                {
3956
                                    if (currentControl is SignControl)
3957
                                    {
3958
                                        CreateControl();
3959
                                        currentControl = null;
3960
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3961
                                        {
3962
                                            txtBatch.Text = "Date Control을 그립니다.";
3963
                                            controlType = ControlType.Date;
3964
                                        }
3965
                                    }
3966
                                    else
3967
                                    {
3968
                                        currentControl = new SignControl
3969
                                        {
3970
                                            Background = new SolidColorBrush(Colors.Black),
3971
                                            UserNumber = App.ViewInfo.UserID,
3972
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3973
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3974
                                            ControlType = ControlType.Sign
3975
                                        };
3976

    
3977
                                        currentControl.CommentID = Save.shortGuid();
3978
                                        currentControl.IsNew = true;
3979
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3980
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3981
                                    }
3982
                                }
3983
                            }
3984
                        }
3985
                        break;
3986
                    case ControlType.Mark:
3987
                        {
3988
                            if (mouseButtonDown == MouseButton.Left)
3989
                            {
3990
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3991
                                {
3992
                                    if (currentControl is RectangleControl)
3993
                                    {
3994
                                        CreateControl();
3995
                                        (currentControl as RectangleControl).ApplyOverViewData();
3996
                                        currentControl = null;
3997
                                        this.cursor = Cursors.Arrow;
3998

    
3999
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4000
                                        {
4001
                                            txtBatch.Text = "Sign Control을 그립니다.";
4002
                                            controlType = ControlType.Sign;
4003
                                        }
4004
                                    }
4005
                                    else
4006
                                    {
4007
                                        currentControl = new RectangleControl
4008
                                        {
4009
                                            Background = new SolidColorBrush(Colors.Black),
4010
                                            Paint = PaintSet.Fill
4011
                                        };
4012

    
4013
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4014
                                        currentControl.CommentID = Save.shortGuid();
4015
                                        currentControl.IsNew = true;
4016
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4017
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4018
                                    }
4019
                                }
4020
                            }
4021
                        }
4022
                        break;
4023
                    case ControlType.Symbol:
4024
                        {
4025
                            if (mouseButtonDown == MouseButton.Left)
4026
                            {
4027
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4028
                                {
4029
                                    if (currentControl is SymControl)
4030
                                    {
4031
                                        CreateControl();
4032
                                        currentControl = null;
4033
                                        this.cursor = Cursors.Arrow;
4034
                                    }
4035
                                    else
4036
                                    {
4037
                                        currentControl = new SymControl
4038
                                        {
4039
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4040
                                            Background = new SolidColorBrush(Colors.Black),
4041
                                            ControlType = ControlType.Symbol
4042
                                        };
4043

    
4044
                                        currentControl.IsNew = true;
4045
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4046
                                        currentControl.CommentID = Save.shortGuid();
4047
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4048
                                    }
4049
                                }
4050
                            }
4051
                        }
4052
                        break;
4053
                    case ControlType.Stamp:
4054
                        {
4055
                            if (mouseButtonDown == MouseButton.Left)
4056
                            {
4057
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4058
                                {
4059
                                    if (currentControl is SymControlN)
4060
                                    {
4061
                                        CreateControl();
4062
                                        currentControl = null;
4063
                                        this.cursor = Cursors.Arrow;
4064
                                    }
4065
                                    else
4066
                                    {
4067
                                        currentControl = new SymControlN
4068
                                        {
4069
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4070
                                            Background = new SolidColorBrush(Colors.Black),
4071
                                            ControlType = ControlType.Stamp
4072
                                        };
4073

    
4074
                                        currentControl.IsNew = true;
4075
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4076
                                        currentControl.CommentID = Save.shortGuid();
4077
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4078
                                    }
4079
                                }
4080
                            }
4081
                        }
4082
                        break;
4083
                    case ControlType.PenControl:
4084
                        {
4085
                            if (inkBoard.Tag.ToString() == "Ink")
4086
                            {
4087
                                inkBoard.IsEnabled = true;
4088
                                StartNewStroke(canvasDrawingMouseDownPoint);
4089
                            }
4090
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4091
                            {
4092
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4093
                            }
4094
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4095
                            {
4096
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4097
                            }
4098
                            IsDrawing = true;
4099
                            return;
4100
                        }
4101
                    default:
4102
                        if (currentControl != null)
4103
                        {
4104
                            currentControl.CommentID = null;
4105
                            currentControl.IsNew = false;
4106
                        }
4107
                        break;
4108
                }
4109

    
4110
            }
4111

    
4112
            //else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4113
            //{
4114
            //    if (controlType == ControlType.None)
4115
            //    {
4116
            //        mouseHandlingMode = MouseHandlingMode.Selecting;
4117
            //        this.cursor = Cursors.Arrow;
4118
            //        inkDrawingCanvas.IsEnabled = false;
4119
            //        isLeftMouseButtonDownOnWindow = true;
4120
            //    }
4121
            //}
4122

    
4123
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4124
            {
4125
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4126
                {
4127
                    bool mouseOff = false;
4128
                    foreach (var item in SelectLayer.Children)
4129
                    {
4130
                        if (item is AdornerFinal)
4131
                        {
4132

    
4133
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4134
                            if (over != null)
4135
                            {
4136
                                mouseOff = true;
4137
                            }
4138
                        }
4139
                    }
4140

    
4141
                    if (!mouseOff)
4142
                    {
4143
                        ReleaseAdorner();
4144
                    }
4145
                }
4146
                zoomAndPanControl.CaptureMouse();
4147
                e.Handled = true;
4148
            }
4149
            
4150
        }
4151
        
4152
        private void RemoveLineStroke(Point P)
4153
        {
4154
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4155
            if (control != null)
4156
            {
4157
                UndoData = new Undo_data()
4158
                {
4159
                    IsUndo = false,
4160
                    Event = Event_Type.Delete,
4161
                    EventTime = DateTime.Now,
4162
                    Markup_List = new List<Multi_Undo_data>()
4163
                };
4164

    
4165

    
4166
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4167
                UndoData.Markup_List.Add(multi_Undo_Data);
4168
                multi_Undo_Data = new Multi_Undo_data();
4169

    
4170
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4171
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4172
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4173

    
4174

    
4175
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4176
                {
4177
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4178
                });
4179
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4180
                
4181
            }
4182
        }
4183

    
4184
        private void RemovePointStroke(Point P)
4185
        {
4186
            foreach (Stroke hits in inkBoard.Strokes)
4187
            {
4188
                foreach (StylusPoint sty in hits.StylusPoints)
4189
                {
4190

    
4191
                }
4192
                if (hits.HitTest(P))
4193
                {
4194
                    inkBoard.Strokes.Remove(hits);
4195
                    return;
4196
                }
4197
            }
4198
        }
4199

    
4200
        private void StartNewStroke(Point P)
4201
        {
4202
            strokePoints = new StylusPointCollection();
4203
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4204
            strokePoints.Add(segment1Start);
4205
            stroke = new Stroke(strokePoints);
4206

    
4207
            stroke.DrawingAttributes.Color = Colors.Red;
4208
            stroke.DrawingAttributes.Width = 4;
4209
            stroke.DrawingAttributes.Height = 4;
4210

    
4211
            inkBoard.Strokes.Add(stroke);
4212

    
4213
        }
4214

    
4215
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4216
        {
4217
            ConsolidationMethod();
4218
        }
4219

    
4220
        public void ConsolidationMethod()
4221
        {
4222
            ChangeCommentReact();
4223

    
4224
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4225
            {
4226
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4227
            }
4228
            else
4229
            {
4230

    
4231
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4232
                {
4233
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4234
                }
4235

    
4236
                ViewerDataModel.Instance.IsConsolidate = true;
4237
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4238
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4239
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4240
                {
4241
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4242
                    if (markupInfo.CONSOLIDATE == 1)
4243
                    {
4244
                        markupInfo.AVOID_CONSOLIDATE = 1;
4245
                    }
4246

    
4247
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4248
                    {
4249
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4250
                          {
4251
                              instanceDataSet.Add(d);
4252
                          });
4253
                    }
4254

    
4255
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4256
                    info.ID = Save.shortGuid();
4257
                    info.CONSOLIDATE = 1;
4258
                    info.CREATE_TIME = DateTime.Now;
4259
                    info.DOCINFO_ID = _DocInfo.ID;
4260
                    info.UPDATE_TIME = DateTime.Now;
4261
                    info.USER_ID = App.ViewInfo.UserID;
4262
                    info.AVOID_CONSOLIDATE = 0;
4263

    
4264
                    Entity.MARKUP_INFO.AddObject(info);
4265
                    Entity.SaveChanges();
4266

    
4267

    
4268
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4269
                    {
4270
                        ID = Save.shortGuid(),
4271
                        CREATE_DATE = DateTime.Now,
4272
                        MARKUP_INFO = info,
4273
                    };
4274
                    Entity.SaveChanges();
4275

    
4276
                    foreach (var item in instanceDataSet)
4277
                    {
4278
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4279
                        {
4280
                            ID = Save.shortGuid(),
4281
                            DATA = item.DATA,
4282
                            DATA_TYPE = item.DATA_TYPE,
4283
                            PAGENUMBER = item.PAGENUMBER,
4284
                            MARKUP_INFO_VERSION = info2
4285
                        });
4286
                    }
4287
                    Entity.SaveChanges();
4288
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4289
                }
4290
            }
4291
        }
4292

    
4293
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4294
        {
4295
            if (App.ViewInfo != null)
4296
            {
4297
                btnConsolidate = (sender as RadRibbonButton);
4298
                if (!App.ViewInfo.NewCommentPermission)
4299
                {
4300
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4301
                }
4302
            }
4303
        }
4304

    
4305
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4306
        {
4307

    
4308
        }
4309

    
4310
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4311
        {
4312
            btnTeamConsolidate = sender as RadRibbonButton;
4313
            if (App.ViewInfo != null)
4314
            {
4315
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4316
                {
4317
                    if (btnConsolidate != null)
4318
                    {
4319
                        btnConsolidate.Visibility = Visibility.Collapsed;
4320
                    }
4321

    
4322
                    if (!App.ViewInfo.NewCommentPermission)
4323
                    {
4324
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4325
                    }
4326
                }
4327
                else
4328
                {
4329
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4330
                }
4331
            }
4332
        }
4333

    
4334
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4335
        {
4336
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4337
            if (item != null)
4338
            {
4339
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4340
            }
4341
            else
4342
            {
4343
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4344
            }
4345
        }
4346

    
4347
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4348
        {
4349
            btnFinalPDF = sender as RadRibbonButton;
4350
            if (App.ViewInfo != null)
4351
            {
4352
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4353
                {
4354
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4355
                    if (btnConsolidate != null)
4356
                    {
4357
                        btnConsolidate.Visibility = Visibility.Collapsed;
4358
                    }
4359
                }
4360
            }
4361
        }
4362

    
4363
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4364
        {
4365
            if (CompareMode.IsChecked)
4366
            {
4367
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4368
                {
4369
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4370
                }
4371
                if (ViewerDataModel.Instance.PageNumber == 0)
4372
                {
4373
                    ViewerDataModel.Instance.PageNumber = 1;
4374
                }
4375

    
4376
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4377
            }
4378
            else
4379
            {
4380
                da.From = 1;
4381
                da.To = 1;
4382
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4383
                da.AutoReverse = false;
4384
                canvas_compareBorder.Children.Clear();
4385
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4386
            }
4387
        }
4388

    
4389
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4390
        {
4391
            if (UserList.IsChecked)
4392
            {
4393
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4394
            }
4395
            else
4396
            {
4397
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4398
            }
4399
        }
4400

    
4401
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4402
        {
4403

    
4404
            if (BalanceMode.IsChecked)
4405
            {
4406
                ViewerDataModel.Instance.PageBalanceMode = true;
4407
            }
4408
            else
4409
            {
4410
                ViewerDataModel.Instance.PageBalanceMode = false;
4411
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4412
            }
4413
        }
4414

    
4415
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4416
        {
4417
            //초기화
4418
            testPanel2.IsHidden = true;
4419
            ViewerDataModel.Instance.PageBalanceMode = false;
4420
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4421
            ViewerDataModel.Instance.PageNumber = 0;
4422
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4423
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4424
            UserList.IsChecked = false;
4425
            BalanceMode.IsChecked = false;
4426
        }
4427

    
4428
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4429
        {
4430
            if ((sender as System.Windows.Controls.Control).Tag != null)
4431
            {
4432
                //Compare 초기화
4433
                CompareMode.IsChecked = false;
4434
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4435

    
4436
                if (ViewerDataModel.Instance.PageNumber == 0)
4437
                {
4438
                    ViewerDataModel.Instance.PageNumber = 1;
4439
                }
4440

    
4441
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4442
                {
4443
                }
4444
                else
4445
                {
4446
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4447
                }
4448

    
4449
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4450
                {
4451

    
4452
                }
4453
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4454
                {
4455
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4456
                }
4457

    
4458
                if (!testPanel2.IsHidden)
4459
                {
4460
                    if (IsSyncPDFMode)
4461
                    {
4462
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4463
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4464

    
4465
                        if (pdfpath.IsDownloading)
4466
                        {
4467
                            pdfpath.DownloadCompleted += (ex, arg) =>
4468
                            {
4469
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4470
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4471
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4472
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4473
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4474
                            };
4475
                        }
4476
                        else
4477
                        {
4478
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4479
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4480
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4481

    
4482
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4483
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4484
                        }
4485

    
4486
                    }
4487
                    else
4488
                    {
4489
                        var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4490

    
4491
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4492

    
4493
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4494
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4495
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4496

    
4497
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4498
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4499

    
4500
                        if (defaultBitmapImage_Compare.IsDownloading)
4501
                        {
4502
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4503
                            {
4504
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4505
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4506
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4507

    
4508
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4509
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4510
                            };
4511
                        }
4512
                    }
4513

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

    
4518
                    foreach (var item in gridSelectionRevItem)
4519
                    {
4520
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4521
                        {
4522
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4523
                        });
4524
                    }
4525
                    
4526
                    //강인구 추가
4527
                    zoomAndPanControl2.ZoomTo(new Rect
4528
                    {
4529
                        X = 0,
4530
                        Y = 0,
4531
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4532
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4533
                    });
4534

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

    
4537
                }
4538
            }
4539
        }
4540

    
4541
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4542
        {
4543
            if (MarkupMode.IsChecked)
4544
            {
4545
                IsSyncPDFMode = true;
4546

    
4547
                var uri = CurrentRev.TO_VENDOR;
4548

    
4549
                if (ViewerDataModel.Instance.PageNumber == 0)
4550
                {
4551
                    ViewerDataModel.Instance.PageNumber = 1;
4552
                }
4553

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

    
4558
                if (pdfpath.IsDownloading)
4559
                {
4560
                    pdfpath.DownloadCompleted += (ex, arg) =>
4561
                    {
4562
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4563
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4564
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4565
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4566
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4567
                    };
4568
                }
4569
                else
4570
                {
4571
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4572
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4573
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4574

    
4575
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4576
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4577
                }
4578
            }
4579
            else
4580
            {
4581
                IsSyncPDFMode = false;
4582
                var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4583

    
4584
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4585

    
4586
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4587
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4588
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4589

    
4590
                if (defaultBitmapImage_Compare.IsDownloading)
4591
                {
4592
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4593
                    {
4594
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4595
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4596
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4597
                    };
4598
                }
4599
                zoomAndPanControl2.ApplyTemplate();
4600
                zoomAndPanControl2.UpdateLayout();
4601
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4602
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4603
            }
4604
        }
4605

    
4606
        private void RadButton_Click(object sender, RoutedEventArgs e)
4607
        {
4608
            gridViewHistory_Busy.IsBusy = true;
4609

    
4610
            RadButton instance = sender as RadButton;
4611
            if (instance.CommandParameter != null)
4612
            {
4613
                CurrentRev = instance.CommandParameter as VPRevision;
4614
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4615
                {
4616
                    if (ea.Error == null && ea.Result != null)
4617
                    {
4618
                        testPanel2.IsHidden = false;
4619

    
4620
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4621
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4622

    
4623
                        var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4624

    
4625
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4626

    
4627
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4628

    
4629
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4630
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4631
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4632

    
4633
                        if (defaultBitmapImage_Compare.IsDownloading)
4634
                        {
4635
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4636
                            {
4637
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4638
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4639
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4640
                            };
4641
                        }
4642

    
4643
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4644
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4645
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4646
                        zoomAndPanControl2.ApplyTemplate();
4647
                        zoomAndPanControl2.UpdateLayout();
4648

    
4649
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4650
                        {
4651
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4652
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4653
                        }
4654

    
4655
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4656
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4657
                        gridViewHistory_Busy.IsBusy = false;
4658
                    }
4659
                };
4660
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4661
            }
4662
        }
4663

    
4664
        public void Sync_Event(VPRevision Currnet_Rev)
4665
        {
4666
            CurrentRev = Currnet_Rev;
4667

    
4668
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4669
            {
4670
                if (ea.Error == null && ea.Result != null)
4671
                {
4672
                    testPanel2.IsHidden = false;
4673

    
4674
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4675
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4676

    
4677
                    var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4678

    
4679
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4680

    
4681
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4682

    
4683
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4684
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4685
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4686

    
4687
                    if (defaultBitmapImage_Compare.IsDownloading)
4688
                    {
4689
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4690
                        {
4691
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4692
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4693
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4694
                        };
4695
                    }
4696

    
4697
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4698
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4699
                    zoomAndPanControl2.ApplyTemplate();
4700
                    zoomAndPanControl2.UpdateLayout();
4701

    
4702
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4703
                    {
4704
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4705
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4706
                    }
4707
                    //}
4708

    
4709
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4710
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4711
                    gridViewHistory_Busy.IsBusy = false;
4712
                }
4713
            };
4714
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4715

    
4716

    
4717
        }
4718

    
4719
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4720
        {
4721
            if (sender is Image)
4722
            {
4723
                if ((sender as Image).Tag != null)
4724
                {
4725
                    var pdfUrl = (sender as Image).Tag.ToString();
4726
                    System.Diagnostics.Process.Start(pdfUrl);
4727
                }
4728
                else
4729
                {
4730
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4731
                }
4732
            }
4733
        }
4734

    
4735
        private void Create_Symbol(object sender, RoutedEventArgs e)
4736
        {
4737
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4738
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4739

    
4740
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4741
            {
4742
                DialogMessage_Alert("Please Select Controls", "Alert");
4743
            }
4744
            else //선택된 것이 있으면
4745
            {
4746
                string MarkupData = "";
4747
                adorner_ = new AdornerFinal();
4748

    
4749
                foreach (var item in SelectLayer.Children)
4750
                {
4751
                    if (item.GetType().Name == "AdornerFinal")
4752
                    {
4753
                        adorner_ = (item as Controls.AdornerFinal);
4754
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4755
                        {
4756
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4757
                            {
4758
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4759
                                MarkupData += markupReturn.ConvertData;
4760
                            }
4761
                        }
4762
                    }
4763
                }
4764
                DialogParameters parameters = new DialogParameters()
4765
                {
4766
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4767
                    DefaultPromptResultValue = "Custom State",
4768
                    Content = "Name :",
4769
                    Header = "Insert Custom Symbol Name",
4770
                    Theme = new VisualStudio2013Theme(),
4771
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4772
                };
4773
                RadWindow.Prompt(parameters);
4774
            }
4775

    
4776
        }
4777

    
4778
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4779
        {
4780
            Save save = new Save();
4781

    
4782
            if (args.DialogResult.Value)
4783
            {
4784
                PngBitmapEncoder _Encoder = symImage(data);
4785

    
4786
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4787
                _Encoder.Save(fs);
4788
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4789

    
4790
                byte[] Img_byte = fs.ToArray();
4791

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

    
4795
                save.SymbolSave(args.PromptResult, filename, data);
4796
            }
4797
        }
4798

    
4799
        public PngBitmapEncoder symImage(string data)
4800
        {
4801

    
4802
            Canvas _canvas = new Canvas();
4803
            _canvas.Background = Brushes.White;
4804
            _canvas.Width = adorner_.BorderSize.Width;
4805
            _canvas.Height = adorner_.BorderSize.Height;
4806
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4807

    
4808
            BitmapEncoder encoder = new PngBitmapEncoder();
4809

    
4810

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

    
4813
            DrawingVisual dv = new DrawingVisual();
4814

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

    
4818
            using (DrawingContext ctx = dv.RenderOpen())
4819
            {
4820
                VisualBrush vb = new VisualBrush(_canvas);
4821
                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)));
4822
            }
4823

    
4824
            try
4825
            {
4826
                renderBitmap.Render(dv);
4827

    
4828
                GC.Collect();
4829
                GC.WaitForPendingFinalizers();
4830
                GC.Collect();
4831
                // encode png data
4832
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4833
                // puch rendered bitmap into it
4834
                pngEncoder.Interlace = PngInterlaceOption.Off;
4835
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4836
                return pngEncoder;
4837

    
4838
            }
4839
            catch (Exception ex)
4840
            {
4841
                return null;
4842
            }
4843

    
4844
        }
4845

    
4846
        public void DialogMessage_Alert(string content, string header)
4847
        {
4848
            var box = new TextBlock();
4849
            box.MinWidth = 400;
4850
            box.FontSize = 11;
4851
            //box.FontSize = 12;
4852
            box.Text = content;
4853
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4854

    
4855
            DialogParameters parameters = new DialogParameters()
4856
            {
4857
                Content = box,
4858
                Header = header,
4859
                Theme = new VisualStudio2013Theme(),
4860
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4861
            };
4862
            RadWindow.Alert(parameters);
4863
        }
4864

    
4865
        #region 캡쳐 기능
4866

    
4867
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4868
        {
4869
            if (x < 0)
4870
            {
4871
                width += x;
4872
                x = 0;
4873
            }
4874
            if (y < 0)
4875
            {
4876
                height += y;
4877
                y = 0;
4878

    
4879
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4880
            }
4881
            if (x + width > zoomAndPanCanvas.ActualWidth)
4882
            {
4883
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4884
            }
4885
            if (y + height > zoomAndPanCanvas.ActualHeight)
4886
            {
4887
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4888
            }
4889

    
4890
            byte[] pixels = CopyPixels(x, y, width, height);
4891

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

    
4894
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4895
        }
4896

    
4897
        public byte[] CopyPixels(int x, int y, int width, int height)
4898
        {
4899
            byte[] pixels = new byte[width * height * 4];
4900
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4901

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

    
4905
            return pixels;
4906
        }
4907

    
4908
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4909
        {
4910
            DrawingVisual drawingVisual = new DrawingVisual();
4911
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4912

    
4913
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4914
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4915
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4916
            drawingContext.Close();
4917

    
4918
            // 비트맵으로 변환합니다.
4919
            RenderTargetBitmap target =
4920
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4921
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4922

    
4923
            target.Render(drawingVisual);
4924
            return target;
4925
        }
4926

    
4927
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4928
        {
4929
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4930
            KCOMDataModel.DataModel.CHECK_LIST check_;
4931
            string Result = streamToBase64.ImageToBase64(source);
4932
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4933

    
4934
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4935
            {
4936
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
4937

    
4938
                //새로운 데이터 추가
4939
                if (Item == null)
4940
                {
4941
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
4942
                    {
4943
                        ID = Save.shortGuid(),
4944
                        USER_ID = App.ViewInfo.UserID,
4945
                        IMAGE_URL = Result,
4946
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4947
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4948
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4949
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4950
                        PROJECT_NO = App.ViewInfo.ProjectNO,
4951
                        STATUS = "False",
4952
                        CREATE_TIME = DateTime.Now,
4953
                        UPDATE_TIME = DateTime.Now,
4954
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4955
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
4956
                    };
4957

    
4958
                    Entity.CHECK_LIST.AddObject(check_);
4959
                }
4960
                //기존에 있던 데이터 업데이트
4961
                else
4962
                {
4963
                    Item.IMAGE_URL = Result;
4964
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4965
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4966
                }
4967

    
4968
                //Item.REV_0 = "Test";
4969

    
4970
                try
4971
                {
4972
                    Entity.SaveChanges();
4973
                }
4974
                catch (Exception ex)
4975
                {
4976

    
4977
                }
4978
                //Entity.SaveChanges();
4979
            }
4980
        }
4981

    
4982
        public void Set_Capture()
4983
        {
4984
            //double x = Canvas.GetLeft(dragCaptureBorder);
4985
            //double y = Canvas.GetTop(dragCaptureBorder);
4986
            double x = canvasDrawingMouseDownPoint.X;
4987
            double y = canvasDrawingMouseDownPoint.Y;
4988
            double width = dragCaptureBorder.Width;
4989
            double height = dragCaptureBorder.Height;
4990

    
4991
            if (width > 5 || height > 5)
4992
            {
4993
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
4994
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
4995
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
4996
            }
4997
        }
4998
        #endregion
4999

    
5000
        public void CreateControl()
5001
        {
5002
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5003
            {
5004
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5005
            });
5006
            multi_Undo_Data.Markup = currentControl;
5007
            UndoData.Markup_List.Add(multi_Undo_Data);
5008
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5009
        }
5010

    
5011
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5012
        {
5013
            multi_Undo_Data = new Multi_Undo_data();
5014

    
5015
            multi_Undo_Data.Markup = control;
5016

    
5017
            if ((control as IShapeControl) != null)
5018
            {
5019
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5020
            }
5021
            if ((control as IDashControl) != null)
5022
            {
5023
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5024
            }
5025
            if ((control as IPath) != null)
5026
            {
5027
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5028
            }
5029
            if ((control as UIElement) != null)
5030
            {
5031
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5032
            }
5033

    
5034
            return multi_Undo_Data;
5035
        }
5036

    
5037
        public void Undo()
5038
        {
5039
            Undo_data undo = new Undo_data();
5040
            AdornerFinal final;
5041
            ReleaseAdorner();
5042

    
5043
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5044
            if (undo == null)
5045
                return;
5046

    
5047
            switch (undo.Event)
5048
            {
5049
                case (Event_Type.Create):
5050
                    {
5051
                        foreach (var item in undo.Markup_List)
5052
                        {
5053
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5054
                        }
5055
                    }
5056
                    break;
5057
                case (Event_Type.Delete):
5058
                    {
5059
                        foreach (var item in undo.Markup_List)
5060
                        {
5061
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5062
                        }
5063
                    }
5064
                    break;
5065
                case (Event_Type.Thumb):
5066
                    {
5067
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5068

    
5069
                        foreach (var item in undo.Markup_List)
5070
                        {
5071
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5072

    
5073
                            if ((item.Markup as IViewBox) != null)
5074
                            {
5075
                                (item.Markup as IViewBox).Angle = item.Angle;
5076
                            }
5077
                            if ((item.Markup as TextControl) != null)
5078
                            {
5079
                                (item.Markup as TextControl).Angle = item.Angle;
5080
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5081
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5082
                            }
5083
                            else
5084
                            {
5085
                                (item.Markup as IPath).PointSet = item.PointSet;
5086
                                (item.Markup as IPath).updateControl();
5087
                            }
5088

    
5089
                            comment.Add(item.Markup);
5090
                        }
5091
                        final = new AdornerFinal(comment);
5092
                        SelectLayer.Children.Add(final);
5093
                        ReleaseAdorner();
5094
                    }
5095
                    break;
5096
                case (Event_Type.Select):
5097
                    {
5098
                        ReleaseAdorner();
5099
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5100

    
5101
                        foreach (var item in undo.Markup_List)
5102
                        {
5103
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5104

    
5105
                            if ((item.Markup as IPath) != null)
5106
                            {
5107
                                (item.Markup as IPath).LineSize = item.LineSize;
5108
                            }
5109
                            if ((item.Markup as UIElement) != null)
5110
                            {
5111
                                (item.Markup as UIElement).Opacity = item.Opacity;
5112
                            }
5113
                            if ((item.Markup as IDashControl) != null)
5114
                            {
5115
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5116
                            }
5117
                            if ((item.Markup as IShapeControl) != null)
5118
                            {
5119
                                (item.Markup as IShapeControl).Paint = item.paint;
5120
                            }
5121

    
5122
                            comment.Add(item.Markup);
5123
                        }
5124

    
5125
                        final = new AdornerFinal(comment);
5126
                        SelectLayer.Children.Add(final);
5127
                    }
5128
                    break;
5129
                case (Event_Type.Option):
5130
                    {
5131
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5132

    
5133
                        foreach (var item in undo.Markup_List)
5134
                        {
5135
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5136

    
5137
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5138
                            {
5139
                                (item.Markup as IPath).LineSize = undo.LineSize;
5140
                            }
5141
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5142
                            {
5143
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5144
                            }
5145
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5146
                            {
5147
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5148
                            }
5149
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5150
                            {
5151
                                (item.Markup as LineControl).Interval = undo.Interval;
5152
                            }
5153
                            else if (item.Markup as IShapeControl != null)
5154
                            {
5155
                                (item.Markup as IShapeControl).Paint = undo.paint;
5156
                            }
5157
                            comment.Add(item.Markup);
5158
                        }
5159
                        final = new AdornerFinal(comment);
5160
                        SelectLayer.Children.Add(final);
5161
                    }
5162
                    break;
5163
            }
5164
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5165
           {
5166
               i.IsUndo = true;
5167
           });
5168
        }
5169

    
5170
        public void Redo()
5171
        {
5172
            AdornerFinal final;
5173
            Undo_data redo = new Undo_data();
5174
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5175
            ReleaseAdorner();
5176
            if (redo == null)
5177
                return;
5178

    
5179
            switch (redo.Event)
5180
            {
5181
                case (Event_Type.Create):
5182
                    {
5183
                        foreach (var item in redo.Markup_List)
5184
                        {
5185
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5186
                        }
5187
                    }
5188
                    break;
5189
                case (Event_Type.Delete):
5190
                    {
5191
                        foreach (var item in redo.Markup_List)
5192
                        {
5193
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5194
                        }
5195
                    }
5196
                    break;
5197
                case (Event_Type.Thumb):
5198
                    {
5199
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5200

    
5201
                        foreach (var item in redo.Markup_List)
5202
                        {
5203
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5204

    
5205
                            if ((item.Markup as IViewBox) != null)
5206
                            {
5207
                                (item.Markup as IViewBox).Angle = item.Angle;
5208
                            }
5209
                            if ((item.Markup as TextControl) != null)
5210
                            {
5211
                                (item.Markup as TextControl).Angle = item.Angle;
5212

    
5213
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5214
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5215
                            }
5216
                            else
5217
                            {
5218
                                (item.Markup as IPath).PointSet = item.PointSet;
5219
                                (item.Markup as IPath).updateControl();
5220
                            }
5221
                            comment.Add(item.Markup);
5222
                        }
5223
                        final = new AdornerFinal(comment);
5224
                        SelectLayer.Children.Add(final);
5225
                        ReleaseAdorner();
5226
                    }
5227
                    break;
5228
                case (Event_Type.Select):
5229
                    {
5230
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5231

    
5232
                        foreach (var item in redo.Markup_List)
5233
                        {
5234
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5235

    
5236
                            if ((item.Markup as IPath) != null)
5237
                            {
5238
                                (item.Markup as IPath).LineSize = item.LineSize;
5239
                            }
5240
                            if ((item.Markup as UIElement) != null)
5241
                            {
5242
                                (item.Markup as UIElement).Opacity = item.Opacity;
5243
                            }
5244
                            if ((item.Markup as IDashControl) != null)
5245
                            {
5246
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5247
                            }
5248
                            if ((item.Markup as IShapeControl) != null)
5249
                            {
5250
                                (item.Markup as IShapeControl).Paint = item.paint;
5251
                            }
5252

    
5253
                            comment.Add(item.Markup);
5254
                        }
5255
                        final = new AdornerFinal(comment);
5256
                        SelectLayer.Children.Add(final);
5257
                    }
5258
                    break;
5259
                case (Event_Type.Option):
5260
                    {
5261
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5262

    
5263
                        foreach (var item in redo.Markup_List)
5264
                        {
5265
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5266
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5267
                            {
5268
                                (item.Markup as IPath).LineSize = redo.LineSize;
5269
                            }
5270
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5271
                            {
5272
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5273
                            }
5274
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5275
                            {
5276
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5277
                            }
5278
                            else if(redo.Interval != 0 && item.Markup as LineControl != null)
5279
                            {
5280
                                (item.Markup as LineControl).Interval = redo.Interval;
5281
                            }
5282
                            else if (item.Markup as IShapeControl != null)
5283
                            {
5284
                                (item.Markup as IShapeControl).Paint = redo.paint;
5285
                            }
5286
                            comment.Add(item.Markup);
5287
                        }
5288
                        final = new AdornerFinal(comment);
5289
                        SelectLayer.Children.Add(final);
5290
                    }
5291
                    break;
5292
            }
5293

    
5294
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5295
            {
5296
                i.IsUndo = false;
5297
            });
5298
        }
5299

    
5300
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5301
        {
5302
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5303
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5304
            {
5305
                if (items.UserID == Select_ID)
5306
                {
5307
                    foreach (var item in items.MarkupList)
5308
                    {
5309
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5310
                        {
5311
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5312
                        }
5313
                    }
5314
                }
5315
            }
5316
        }
5317

    
5318
        public void InkControl_Convert()
5319
        {
5320
            if (inkBoard.Strokes.Count > 0)
5321
            {
5322
                inkBoard.Strokes.ToList().ForEach(stroke =>
5323
                {
5324
                    List<Stroke> removingStroke = new List<Stroke>();
5325
                    StrokeCollection stC = new StrokeCollection();
5326

    
5327
                    removingStroke.Add(stroke);
5328

    
5329
                    InkToPath ip = new InkToPath();
5330
                    List<Point> inkPointSet = new List<Point>();
5331
                    PolygonControl pc = null;
5332
                    pc = new PolygonControl()
5333
                    {
5334
                        Angle = 0,
5335
                        PointSet = new List<Point>(),
5336
                        ControlType = ControlType.Ink
5337
                    };
5338
                    foreach (var item in removingStroke)
5339
                    {
5340
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5341
                        inkBoard.Strokes.Remove(item);
5342
                    }
5343
                    if (inkPointSet.Count != 0)
5344
                    {
5345
                        //강인구 추가(PenControl Undo Redo 추가)
5346
                        UndoData = new Undo_data()
5347
                        {
5348
                            IsUndo = false,
5349
                            Event = Event_Type.Create,
5350
                            EventTime = DateTime.Now,
5351
                            Markup_List = new List<Multi_Undo_data>()
5352
                        };
5353

    
5354
                        pc.StartPoint = inkPointSet[0];
5355
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5356
                        pc.PointSet = inkPointSet;
5357
                        pc.LineSize = 3;
5358
                        pc.CommentID = Save.shortGuid();
5359
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5360
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5361
                        pc.SetPolyPath();
5362

    
5363
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5364
                        {
5365
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5366
                        });
5367
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5368
                        UndoData.Markup_List.Add(multi_Undo_Data);
5369
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5370
                    }
5371
                });
5372
            }
5373
        }
5374

    
5375
        /// <summary>
5376
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5377
        /// </summary>
5378
        /// <param name="StartP">StartPoint</param>
5379
        /// <param name="EndP">EndPoint</param>
5380
        /// <returns>Return_EndPoint</returns>
5381
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5382
        {
5383
            Point Return_Point = new Point();
5384

    
5385
            double dx = EndP.X - StartP.X;
5386
            double dy = EndP.Y - StartP.Y;
5387
            double length;
5388

    
5389
            switch (controlType)
5390
            {
5391
                case ControlType.Triangle:
5392
                    {
5393
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5394
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5395
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5396
                    }
5397
                    break;
5398
                default:
5399
                    {
5400
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5401
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5402
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5403
                    }
5404
                    break;
5405
            }
5406

    
5407
            return Return_Point;
5408
        }
5409

    
5410
        /// <summary>
5411
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5412
        /// </summary>
5413
        /// <author>humkyung</author>
5414
        /// <date>2018.04.26</date>
5415
        /// <param name="StartP"></param>
5416
        /// <param name="EndP"></param>
5417
        /// <returns></returns>
5418
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP)
5419
        {
5420
            List<Point> res = new List<Point>();
5421

    
5422
            double dx = EndP.X - StartP.X;
5423
            double dy = EndP.Y - StartP.Y;
5424
            double length = Math.Sqrt(dx * dx + dy * dy);
5425
            double baseLength = length * Math.Tan(30.0* Math.PI / 180.0);
5426
            dx /= length;
5427
            dy /= length;
5428
            double tmp = dx;
5429
            dx = -dy; dy = tmp; /// rotate by 90 degree
5430

    
5431
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5432
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5433

    
5434
            return res;
5435
        }
5436
    }
5437
}
클립보드 이미지 추가 (최대 크기: 500 MB)