프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 5a6a5dd1

이력 | 보기 | 이력해설 | 다운로드 (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) || (mouseButtonDown == MouseButton.Right))
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

    
1046
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1047
            {
1048
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1049
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1050
                SetCursor();
1051

    
1052
                if (IsDrawing)
1053
                {
1054
                    if (currentControl == null)
1055
                    {
1056
                        switch (controlType)
1057
                        {
1058
                            case ControlType.PenControl:
1059
                                {
1060
                                    if (inkBoard.Tag.ToString() == "Ink")
1061
                                    {
1062
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1063
                                    }
1064
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1065
                                    {
1066
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1067
                                    }
1068
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1069
                                    {
1070
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1071
                                    }
1072

    
1073
                                    //inkBoard.Strokes.Add(stroke);
1074
                                }
1075
                                break;
1076
                        }
1077
                        return;
1078
                    }
1079
                }
1080

    
1081
                if (currentControl != null)
1082
                {
1083
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1084
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1085
                    //강인구 추가
1086
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1087

    
1088
                    if ((currentControl as IPath) != null)
1089
                    {
1090
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1091
                    }
1092
                    if ((currentControl as LineControl) != null)
1093
                    {
1094
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1095
                    }
1096

    
1097
                    if ((currentControl as IShapeControl) != null)
1098
                    {
1099
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1100
                    }
1101
                    if ((currentControl as TextControl) != null)
1102
                    {
1103
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1104
                        {
1105
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1106
                        }
1107
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1108
                        {
1109
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1110
                        }
1111
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1112
                        {
1113
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1114
                        }
1115
                    }
1116
                    else if ((currentControl as ArrowTextControl) != null)
1117
                    {
1118
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1119
                        {
1120
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1121
                        }
1122
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1123
                        {
1124
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1125
                        }
1126
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1127
                        {
1128
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1129
                        }
1130
                    }
1131
                    else if ((currentControl as RectCloudControl) != null)
1132
                    {
1133
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1134
                    }
1135
                    else if ((currentControl as CloudControl) != null)
1136
                    {
1137
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1138
                    }
1139

    
1140
                    switch (controlType)
1141
                    {
1142
                        case ControlType.Rectangle:
1143
                            {
1144
                                var control = currentControl as RectangleControl;
1145

    
1146
                                if (control != null)
1147
                                {
1148
                                    if (move.mousemode == MouseMode.Drawing)
1149
                                    {
1150
                                        //move.control_Move(ControlList, true, moveX, moveY);
1151
                                    }
1152
                                    else
1153
                                    {
1154
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1155
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1156
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1157
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1158

    
1159

    
1160
                                        if (ViewerDataModel.Instance.IsPressShift)
1161
                                        {
1162
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1163
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1164
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1165
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1166
                                        }
1167
                                        
1168
                                        control.PointSet = new List<Point>
1169
                                        {
1170
                                            control.StartPoint,
1171
                                            control.LeftBottomPoint,
1172
                                            control.EndPoint,
1173
                                            control.TopRightPoint,
1174
                                        };
1175
                                        control.updateControl();
1176
                                    }
1177

    
1178
                                    //강인구 추가
1179
                                    control.ControlType = controlType;
1180
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1181
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1182
                                }
1183
                            }
1184
                            break;
1185

    
1186
                        case ControlType.RectCloud:
1187
                            {
1188
                                var control = currentControl as RectCloudControl;
1189

    
1190
                                if (control != null)
1191
                                {
1192
                                    if (move.mousemode == MouseMode.Drawing)
1193
                                    {
1194
                                        //move.control_Move(ControlList, true, moveX, moveY);
1195
                                    }
1196
                                    else
1197
                                    {
1198
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1199
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1200
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1201
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1202

    
1203
                                        if (ViewerDataModel.Instance.IsPressShift)
1204
                                        {
1205
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1206
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1207
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1208
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1209
                                        }
1210

    
1211
                                        control.PointSet = new List<Point>
1212
                                        {
1213
                                            control.StartPoint,
1214
                                            control.LeftBottomPoint,
1215
                                            control.EndPoint,
1216
                                            control.TopRightPoint,
1217
                                        };
1218
                                    }
1219
                                    //강인구 추가
1220
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1221
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1222
                                }
1223
                            }
1224
                            break;
1225

    
1226
                        case ControlType.SingleLine:
1227
                            {
1228
                                if (currentControl != null)
1229
                                {
1230
                                    var control = currentControl as LineControl;
1231
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1232
                                    control.ControlType = controlType;
1233
                                    if (control != null)
1234
                                    {
1235
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1236
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1237
                                        Point tempPoint = control.EndPoint;
1238

    
1239
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1240
                                        {
1241
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1242
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1243
                                            control.EndPoint = tempPoint;
1244
                                        }
1245
                                        else
1246
                                        {
1247
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1248
                                        }
1249

    
1250
                                       control.PointSet = new List<Point>
1251
                                        {
1252
                                            control.StartPoint,
1253
                                            control.EndPoint,
1254
                                        };
1255
                                        //강인구 추가
1256
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1257
                                    }
1258
                                }
1259

    
1260
                            }
1261
                            break;
1262

    
1263
                        case ControlType.CancelLine:
1264
                            {
1265
                                if (currentControl != null)
1266
                                {
1267
                                    var control = currentControl as LineControl;
1268
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1269
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1270
                                    control.ControlType = controlType;
1271
                                    if (control != null)
1272
                                    {
1273
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1274
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1275
                                        Point tempPoint = control.EndPoint;
1276

    
1277
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1278
                                        {
1279
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1280
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1281
                                            control.EndPoint = tempPoint;
1282
                                        }
1283
                                        else
1284
                                        {
1285
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1286
                                        }
1287

    
1288

    
1289
                                        control.PointSet = new List<Point>
1290
                                            {
1291
                                                control.StartPoint,
1292
                                                control.EndPoint,
1293
                                            };
1294
                                    }
1295
                                    //강인구 추가
1296
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1297
                                }
1298
                            }
1299
                            break;
1300

    
1301
                        case ControlType.ArrowLine:
1302
                            {
1303
                                if (currentControl != null)
1304
                                {
1305
                                    var control = currentControl as LineControl;
1306
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1307
                                    control.ControlType = controlType;
1308
                                    if (control != null)
1309
                                    {
1310
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1311
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1312
                                        Point tempPoint = control.EndPoint;
1313

    
1314
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1315
                                        {
1316
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1317
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1318
                                            control.EndPoint = tempPoint;
1319
                                        }
1320
                                        else
1321
                                        {
1322
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1323
                                        }
1324

    
1325

    
1326
                                        control.PointSet = new List<Point>
1327
                                            {
1328
                                                control.StartPoint,
1329
                                                control.EndPoint,
1330
                                            };
1331
                                    }
1332
                                    //강인구 추가
1333
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1334
                                }
1335

    
1336
                            }
1337
                            break;
1338

    
1339
                        case ControlType.TwinLine:
1340
                            {
1341
                                if (currentControl != null)
1342
                                {
1343
                                    var control = currentControl as LineControl;
1344
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1345
                                    control.ControlType = controlType;
1346
                                    if (control != null)
1347
                                    {
1348
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1349
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1350
                                        Point tempPoint = control.EndPoint;
1351

    
1352
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1353
                                        {
1354
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1355
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1356
                                            control.EndPoint = tempPoint;
1357
                                        }
1358
                                        else
1359
                                        {
1360
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1361
                                        }
1362

    
1363

    
1364
                                        control.PointSet = new List<Point>
1365
                                            {
1366
                                                control.StartPoint,
1367
                                                control.EndPoint,
1368
                                            };
1369
                                    }
1370
                                    //강인구 추가
1371
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1372
                                }
1373

    
1374
                            }
1375
                            break;
1376

    
1377
                        case ControlType.DimLine:
1378
                            {
1379
                                if (currentControl != null)
1380
                                {
1381
                                    var control = currentControl as LineControl;
1382
                                    control.LineStyleSet = LineStyleSet.DimLine;
1383
                                    control.ControlType = controlType;
1384
                                    if (control != null)
1385
                                    {
1386
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1387
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1388
                                        Point tempPoint = control.EndPoint;
1389

    
1390
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1391
                                        {
1392
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1393
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1394
                                            control.EndPoint = tempPoint;
1395
                                        }
1396
                                        else
1397
                                        {
1398
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1399
                                        }
1400

    
1401
                                        control.PointSet = new List<Point>
1402
                                            {
1403
                                                control.StartPoint,
1404
                                                control.EndPoint,
1405
                                            };
1406
                                    }
1407
                                    //강인구 추가
1408
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1409
                                }
1410

    
1411
                            }
1412
                            break;
1413

    
1414
                        case ControlType.ChainLine:
1415
                            {
1416
                                var control = currentControl as PolygonControl;
1417

    
1418
                                if (control != null)
1419
                                {
1420

    
1421
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1422
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1423

    
1424
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1425

    
1426
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1427
                                    {
1428
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1429
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count-2], ref tempPoint, true);
1430
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1431
                                        //control.EndPoint = tempPoint;
1432
                                    }
1433
                                    else
1434
                                    {
1435
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1436
                                    }
1437

    
1438
                                    control.SetPolyPath();
1439
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1440
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1441
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1442

    
1443
                                    //강인구 추가
1444
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1445
                                }
1446
                            }
1447
                            break;
1448

    
1449
                        case ControlType.ArcLine:
1450
                            {
1451
                                if (currentControl != null)
1452
                                {
1453
                                    var control = currentControl as ArcControl;
1454
                                    control.isTransOn = false;
1455
                                    control.ControlType = controlType;
1456

    
1457
                                    if (control != null)
1458
                                    {
1459
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1460
                                        control.MidPoint = new Point(0, 0);
1461
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1462
                                        Point tempPoint = control.EndPoint;
1463

    
1464
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1465
                                        {
1466
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1467
                                            control.EndPoint = tempPoint;
1468
                                        }
1469
                                        else
1470
                                        {
1471
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1472
                                        }
1473

    
1474

    
1475
                                        control.PointSet = new List<Point>
1476
                                            {
1477
                                                control.StartPoint,
1478
                                                control.MidPoint,
1479
                                                control.EndPoint,
1480
                                            };
1481
                                    }
1482
                                    //강인구 추가
1483
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1484
                                }
1485

    
1486
                            }
1487
                            break;
1488

    
1489
                        case ControlType.ArcArrow:
1490
                            {
1491
                                if (currentControl != null)
1492
                                {
1493
                                    var control = currentControl as ArcControl;
1494
                                    control.isTransOn = true;
1495
                                    control.ControlType = controlType;
1496

    
1497
                                    if (control != null)
1498
                                    {
1499
                                        if (move.mousemode == MouseMode.Drawing)
1500
                                        {
1501
                                            //move.control_Move(ControlList, true, moveX, moveY);
1502
                                        }
1503
                                        else
1504
                                        {
1505
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1506
                                            control.MidPoint = new Point(0, 0);
1507
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1508
                                        }
1509

    
1510
                                        control.PointSet = new List<Point>
1511
                                            {
1512
                                                control.StartPoint,
1513
                                                control.MidPoint,
1514
                                                control.EndPoint,
1515
                                            };
1516
                                    }
1517
                                    //강인구 추가
1518
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1519
                                }
1520
                            }
1521
                            break;
1522

    
1523
                        case ControlType.ArrowMultiLine:
1524
                            {
1525
                                if (currentControl != null)
1526
                                {
1527
                                    var control = currentControl as ArrowControl_Multi;
1528

    
1529
                                    if (control != null)
1530
                                    {
1531
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1532
                                        Point tempPoint = control.EndPoint;
1533
                                        if (control.MiddlePoint == new Point(0, 0))
1534
                                        {
1535
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1536
                                            {
1537
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1538
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1539
                                                control.EndPoint = tempPoint;
1540
                                            }
1541
                                            else
1542
                                            {
1543
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1544
                                            }
1545
                                        }
1546
                                        else
1547
                                        {
1548
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1549
                                            {
1550
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1551
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1552
                                                control.EndPoint = tempPoint;
1553
                                            }
1554
                                            else
1555
                                            {
1556
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1557
                                            }
1558

    
1559
                                        }
1560

    
1561
                                        control.PointSet = new List<Point>
1562
                                            {
1563
                                                control.StartPoint,
1564
                                                control.MiddlePoint,
1565
                                                control.EndPoint,
1566
                                            };
1567

    
1568
                                    }
1569
                                    //강인구 추가
1570
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1571
                                }
1572

    
1573
                            }
1574
                            break;
1575

    
1576
                        case ControlType.Circle:
1577
                            {
1578
                                var control = currentControl as CircleControl;
1579

    
1580
                                if (control != null)
1581
                                {
1582
                                    if (move.mousemode == MouseMode.Drawing)
1583
                                    {
1584
                                        //move.control_Move(ControlList, true, moveX, moveY);
1585
                                    }
1586
                                    else
1587
                                    {
1588
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1589
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1590
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1591
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1592

    
1593
                                        if (ViewerDataModel.Instance.IsPressShift)
1594
                                        {
1595
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1596
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1597
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1598
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1599
                                        }
1600

    
1601
                                        control.PointSet = new List<Point>
1602
                                        {
1603
                                            control.StartPoint,
1604
                                            control.LeftBottomPoint,
1605
                                            control.EndPoint,
1606
                                            control.TopRightPoint,
1607
                                        };
1608
                                    }
1609
                                    //강인구 추가
1610
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1611
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1612

    
1613
                                }
1614
                            }
1615
                            break;
1616

    
1617
                        case ControlType.PolygonCloud:
1618
                            {
1619
                                var control = currentControl as CloudControl;
1620

    
1621
                                if (control != null)
1622
                                {
1623
                                    control.isTransOn = true;
1624
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1625

    
1626
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1627

    
1628
                                    control.SetCloud();
1629
                                    //강인구 추가
1630
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1631
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1632
                                }
1633
                            }
1634
                            break;
1635

    
1636
                        case ControlType.Triangle:
1637
                            {
1638
                                var control = currentControl as TriControl;
1639

    
1640
                                if (control != null)
1641
                                {
1642
                                    if (move.mousemode == MouseMode.Drawing)
1643
                                    {
1644
                                        //move.control_Move(ControlList, true, moveX, moveY);
1645
                                    }
1646
                                    else
1647
                                    {
1648
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1649
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1650

    
1651
                                        if (ViewerDataModel.Instance.checkAxis)
1652
                                        {
1653
                                            Point tempPoint = control.EndPoint;
1654
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1655
                                            control.EndPoint = tempPoint;
1656
                                        }
1657

    
1658
                                        if (ViewerDataModel.Instance.IsPressShift)
1659
                                        {
1660
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1661
                                            if (2 == Points.Count())
1662
                                            {
1663
                                                control.MidPoint = Points[0];
1664
                                                control.EndPoint = Points[1];
1665
                                            }
1666
                                        }
1667

    
1668
                                        control.PointSet = new List<Point>
1669
                                            {
1670
                                                control.StartPoint,
1671
                                                control.MidPoint,
1672
                                                control.EndPoint,
1673
                                            };
1674
                                    }
1675
                                    //강인구 추가
1676
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1677
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1678
                                }
1679
                            }
1680
                            break;
1681

    
1682
                        case ControlType.ImgControl:
1683
                            {
1684
                                var control = currentControl as ImgControl;
1685

    
1686
                                if (control != null)
1687
                                {
1688
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1689
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1690
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1691
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1692

    
1693
                                    control.PointSet = new List<Point>
1694
                                        {
1695
                                            control.StartPoint,
1696
                                            control.LeftBottomPoint,
1697
                                            control.EndPoint,
1698
                                            control.TopRightPoint,
1699
                                        };
1700
                                }
1701
                            }
1702
                            break;
1703

    
1704
                        case ControlType.Date:
1705
                            {
1706
                                var control = currentControl as DateControl;
1707

    
1708
                                if (control != null)
1709
                                {
1710
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1711
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1712
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1713
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1714
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1715

    
1716
                                    control.PointSet = new List<Point>
1717
                                        {
1718
                                            control.StartPoint,
1719
                                            control.LeftBottomPoint,
1720
                                            control.EndPoint,
1721
                                            control.TopRightPoint,
1722
                                        };
1723
                                }
1724
                            }
1725
                            break;
1726

    
1727
                        case ControlType.ArrowTextControl:
1728
                            {
1729
                                var control = currentControl as ArrowTextControl;
1730

    
1731
                                if (control != null)
1732
                                {
1733
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1734
                                    Point tempPoint = control.EndPoint;
1735

    
1736
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1737

    
1738
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1739
                                    {
1740
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1741
                                        control.EndPoint = tempPoint;
1742
                                    }
1743
                                    else
1744
                                    {
1745
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1746
                                    }
1747
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1748

    
1749
                                    control.PointSet = new List<Point>
1750
                                            {
1751
                                                control.StartPoint,
1752
                                                control.MidPoint,
1753
                                                control.EndPoint,
1754
                                            };
1755
                                }
1756
                            }
1757
                            break;
1758

    
1759
                        case ControlType.ArrowTransTextControl:
1760
                            {
1761
                                var control = currentControl as ArrowTextControl;
1762

    
1763
                                if (control != null)
1764
                                {
1765
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1766
                                    Point tempPoint = control.EndPoint;
1767
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1768

    
1769
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1770
                                    {
1771
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1772
                                        control.EndPoint = tempPoint;
1773
                                    }
1774
                                    else
1775
                                    {
1776
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1777
                                    }
1778
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1779
                                    control.isFixed = true;
1780

    
1781
                                    control.PointSet = new List<Point>
1782
                                            {
1783
                                                control.StartPoint,
1784
                                                control.MidPoint,
1785
                                                control.EndPoint,
1786
                                            };
1787
                                }
1788
                            }
1789
                            break;
1790

    
1791
                        case ControlType.ArrowTextBorderControl:
1792
                            {
1793
                                var control = currentControl as ArrowTextControl;
1794

    
1795
                                if (control != null)
1796
                                {
1797
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1798
                                    Point tempPoint = control.EndPoint;
1799
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1800
                                    {
1801
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1802
                                        control.EndPoint = tempPoint;
1803
                                    }
1804
                                    else
1805
                                    {
1806
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1807
                                    }
1808
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1809
                                    control.PointSet = new List<Point>
1810
                                            {
1811
                                                control.StartPoint,
1812
                                                control.MidPoint,
1813
                                                control.EndPoint,
1814
                                            };
1815
                                }
1816

    
1817
                            }
1818
                            break;
1819
                        case ControlType.ArrowTransTextBorderControl:
1820
                            {
1821
                                var control = currentControl as ArrowTextControl;
1822

    
1823
                                if (control != null)
1824
                                {
1825
                                    control.isFixed = true;
1826
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1827
                                    Point tempPoint = control.EndPoint;
1828
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1829
                                    {
1830
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1831
                                        control.EndPoint = tempPoint;
1832
                                    }
1833
                                    else
1834
                                    {
1835
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1836
                                    }
1837

    
1838
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1839
                                    control.PointSet = new List<Point>
1840
                                            {
1841
                                                control.StartPoint,
1842
                                                control.MidPoint,
1843
                                                control.EndPoint,
1844
                                            };
1845
                                }
1846

    
1847
                            }
1848
                            break;
1849
                        case ControlType.ArrowTextCloudControl:
1850
                            {
1851
                                var control = currentControl as ArrowTextControl;
1852

    
1853
                                if (control != null)
1854
                                {
1855
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1856
                                    Point tempPoint = control.EndPoint;
1857
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1858
                                    {
1859
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1860
                                        control.EndPoint = tempPoint;
1861
                                    }
1862
                                    else
1863
                                    {
1864
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1865
                                    }
1866
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1867
                                    control.PointSet = new List<Point>
1868
                                            {
1869
                                                control.StartPoint,
1870
                                                control.MidPoint,
1871
                                                control.EndPoint,
1872
                                            };
1873
                                }
1874

    
1875
                            }
1876
                            break;
1877
                        case ControlType.ArrowTransTextCloudControl:
1878
                            {
1879
                                var control = currentControl as ArrowTextControl;
1880

    
1881
                                if (control != null)
1882
                                {
1883
                                    control.isFixed = true;
1884
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1885
                                    Point tempPoint = control.EndPoint;
1886
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1887
                                    {
1888
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1889
                                        control.EndPoint = tempPoint;
1890
                                    }
1891
                                    else
1892
                                    {
1893
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1894
                                    }
1895
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1896
                                    control.PointSet = new List<Point>
1897
                                            {
1898
                                                control.StartPoint,
1899
                                                control.MidPoint,
1900
                                                control.EndPoint,
1901
                                            };
1902
                                }
1903

    
1904
                            }
1905
                            break;
1906
                        case ControlType.PolygonControl:
1907
                            {
1908
                                
1909
                                var control = currentControl as PolygonControl;
1910

    
1911
                                if (control != null)
1912
                                {
1913
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1914
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1915
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1916
                                    control.SetPolyPath();
1917
                                    //강인구 추가
1918
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1919
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1920
                                }
1921
                            }
1922
                            break;
1923
                        //강인구 추가
1924
                        case ControlType.Sign:
1925
                            {
1926
                                var control = currentControl as SignControl;
1927

    
1928
                                if (control != null)
1929
                                {
1930
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1931
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1932
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1933
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1934

    
1935
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
1936
                                    {
1937
                                        GetUserSign getUser = new GetUserSign();
1938
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
1939
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
1940
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
1941
                                        stream.Write(imageBytes, 0, imageBytes.Length);
1942
                                        stream.Position = 0;
1943
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
1944
                                        BitmapImage returnImage = new BitmapImage();
1945
                                        returnImage.BeginInit();
1946
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
1947
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
1948
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
1949
                                        returnImage.StreamSource = ms;
1950
                                        returnImage.EndInit();
1951
                                        stream.Close();
1952

    
1953
                                        control.SignImage = returnImage;
1954
                                    }
1955
                                    control.PointSet = new List<Point>
1956
                                        {
1957
                                            control.StartPoint,
1958
                                            control.LeftBottomPoint,
1959
                                            control.EndPoint,
1960
                                            control.TopRightPoint,
1961
                                        };
1962
                                }
1963
                            }
1964
                            break;
1965
                        //강인구 추가
1966
                        case ControlType.Symbol:
1967
                            {
1968
                                var control = currentControl as SymControl;
1969

    
1970
                                if (control != null)
1971
                                {
1972
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1973
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1974
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1975
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1976
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1977
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
1978

    
1979
                                    if (control.StartPoint != control.EndPoint)
1980
                                    {
1981
                                        if (control.PathData == null)
1982
                                        {
1983
                                            using (StringToPathConverter Convert = new StringToPathConverter())
1984
                                            {
1985
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
1986
                                            }
1987
                                        }
1988
                                    }
1989

    
1990
                                    control.PointSet = new List<Point>
1991
                                        {
1992
                                            control.StartPoint,
1993
                                            control.LeftBottomPoint,
1994
                                            control.EndPoint,
1995
                                            control.TopRightPoint,
1996
                                        };
1997
                                }
1998
                            }
1999
                            break;
2000
                        case ControlType.Stamp:
2001
                            {
2002
                                var control = currentControl as SymControlN;
2003

    
2004
                                if (control != null)
2005
                                {
2006

    
2007
                                    if (control.StartPoint == control.EndPoint)
2008
                                    {
2009
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2010

    
2011
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2012
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2013

    
2014

    
2015
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2016

    
2017
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2018
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2019
                                        writer.Write(xamlData);
2020
                                        writer.Flush();
2021
                                        stream.Position = 0;
2022

    
2023
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2024
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2025
                                        UIElement ob = obj as UIElement;
2026

    
2027
                                        //control.ApplyTemplate();
2028

    
2029
                                        control.SetViewBox();
2030
                                        control.PathXathData = appovalData;
2031
                                        control.Base_ViewBox.Child = ob;
2032
                                    }
2033

    
2034
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2035
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2036
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2037
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2038
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2039

    
2040

    
2041
                                    control.PointSet = new List<Point>
2042
                                    {
2043
                                        control.StartPoint,
2044
                                        control.LeftBottomPoint,
2045
                                        control.EndPoint,
2046
                                        control.TopRightPoint,
2047
                                    };
2048
                                }
2049
                            }
2050
                            break;
2051
                        case ControlType.Mark:
2052
                            {
2053
                                var control = currentControl as RectangleControl;
2054

    
2055
                                if (control != null)
2056
                                {
2057
                                    if (move.mousemode == MouseMode.Drawing)
2058
                                    {
2059
                                        //move.control_Move(ControlList, true, moveX, moveY);
2060
                                    }
2061
                                    else
2062
                                    {
2063
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2064
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2065
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2066
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2067

    
2068

    
2069
                                        control.PointSet = new List<Point>
2070
                                    {
2071
                                        control.StartPoint,
2072
                                        control.LeftBottomPoint,
2073
                                        control.EndPoint,
2074
                                        control.TopRightPoint,
2075
                                    };
2076
                                    }
2077

    
2078
                                    //강인구 추가
2079
                                    control.Paint = PaintSet.Fill;
2080
                                }
2081
                            }
2082
                            break;
2083
                        case ControlType.PenControl:
2084
                            {
2085
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2086
                                //inkBoard.Strokes.Add(stroke);
2087
                            }
2088
                            break;
2089
                        default:
2090
                            break;
2091
                    }
2092
                }
2093
            }
2094
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2095
            {
2096
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2097

    
2098
                if (isDraggingSelectionRect)
2099
                {
2100
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2101

    
2102
                    e.Handled = true;
2103
                }
2104
                else if (isLeftMouseButtonDownOnWindow)
2105
                {
2106
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2107
                    double dragDistance = Math.Abs(dragDelta.Length);
2108

    
2109
                    if (dragDistance > DragThreshold)
2110
                    {
2111
                        isDraggingSelectionRect = true;
2112

    
2113
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2114
                    }
2115

    
2116
                    e.Handled = true;
2117
                }
2118

    
2119

    
2120
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2121
                {
2122
                    //SelectionPath = new Path();
2123
                    //PathFigure pathFigure = new PathFigure();
2124
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2125
                    //SelectionPath.Opacity = 0.5;
2126
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2127
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2128
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2129
                }
2130
                else
2131
                {
2132
                    //List<Stroke> removingStroke = new List<Stroke>();
2133
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2134
                    //StrokeCollection stC = new StrokeCollection();
2135
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2136
                    //{
2137
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2138
                    //    p1.Intersect(p2);
2139
                    //    if (p1.IsEmpty)
2140
                    //    {
2141

    
2142

    
2143
                    //        p1 = SelectionPath.Data.Bounds;
2144
                    //        bool intersectCheck = false;
2145
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2146
                    //        {
2147
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2148
                    //            p1.Intersect(p3);
2149
                    //            if (!p1.IsEmpty)
2150
                    //            {
2151
                    //                intersectCheck = true;
2152
                    //            }
2153
                    //        }
2154
                    //        if (intersectCheck)
2155
                    //        {
2156
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2157
                    //        }
2158

    
2159
                    //    }
2160
                    //    else
2161
                    //    {
2162
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2163
                    //    }
2164
                    //}
2165

    
2166
                    e.Handled = true;
2167
                }
2168
            }
2169
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2170
            {
2171
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2172
                if (control != null)
2173
                {
2174
                    this.cursor = Cursors.Hand;
2175
                    SetCursor();
2176
                }
2177
                else
2178
                {
2179
                    this.cursor = Cursors.Arrow;
2180
                    SetCursor();
2181
                }
2182
            }
2183
            else
2184
            {
2185
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2186

    
2187
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2188
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2189

    
2190
                //if (hitList.Count > 0)
2191
                //{
2192

    
2193
                //}
2194

    
2195
                #region 조건 설정 : firstCondition
2196
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2197
                //pnts = generalTransform.Transform(pnts);
2198
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2199
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2200
                //                               this.DeepLayer._BaseLayer).ToObservable()
2201
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2202
                //                      select kkk).FirstOrDefault();
2203

    
2204
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2205
                //if (canvas !=null)
2206
                //{
2207
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2208
                //    {
2209
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2210
                //        if (uiElement!=null)
2211
                //        {
2212
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2213
                //        }
2214
                //    }
2215
                //}
2216

    
2217
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2218
                //hitResultsList.Clear();
2219

    
2220
                #endregion
2221
            }
2222
        }
2223

    
2224
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2225

    
2226
        private EllipseGeometry hitArea = new EllipseGeometry();
2227

    
2228
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2229
        {
2230
            IsDrawing = false;
2231

    
2232
            if (mouseHandlingMode != MouseHandlingMode.None)
2233
            {
2234
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2235
                {
2236
                    this.cursor = Cursors.Arrow;
2237

    
2238
                    SetCursor();
2239

    
2240
                    switch (controlType)
2241
                    {
2242
                        case ControlType.None:
2243
                            break;
2244
                        case ControlType.Rectangle:
2245
                            {
2246

    
2247
                            }
2248
                            break;
2249
                        case ControlType.PenControl:
2250
                            {
2251

    
2252
                            }
2253
                            break;
2254
                        default:
2255
                            break;
2256
                    }
2257
                }
2258
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2259
                {
2260
                    if (isLeftMouseButtonDownOnWindow)
2261
                    {
2262
                        bool wasDragSelectionApplied = false;
2263

    
2264
                        if (isDraggingSelectionRect)
2265
                        {
2266
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2267
                            {
2268
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2269
                                mouseHandlingMode = MouseHandlingMode.None;
2270
                                Set_Capture();
2271

    
2272
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2273
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2274
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2275
                            }
2276
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2277
                            {
2278
                                ApplyDragSelectionRect();
2279
                            }
2280
                            else
2281
                            {
2282
                                double x = Canvas.GetLeft(dragZoomBorder);
2283
                                double y = Canvas.GetTop(dragZoomBorder);
2284
                                double width = dragZoomBorder.Width;
2285
                                double height = dragZoomBorder.Height;
2286
                                Rect dragRect = new Rect(x, y, width, height);
2287

    
2288
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2289

    
2290
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2291
                            }
2292

    
2293
                            isDraggingSelectionRect = false;
2294
                            e.Handled = true;
2295
                            wasDragSelectionApplied = true;
2296
                        }
2297

    
2298
                        if (isLeftMouseButtonDownOnWindow)
2299
                        {
2300
                            isLeftMouseButtonDownOnWindow = false;
2301
                            this.ReleaseMouseCapture();
2302
                            e.Handled = true;
2303
                        }
2304

    
2305
                        if (!wasDragSelectionApplied)
2306
                        {
2307
                            init();
2308
                        }
2309
                    }
2310
                }
2311
                else if (mouseButtonDown == MouseButton.Right)
2312
                {
2313
                    this.cursor = Cursors.Arrow;
2314
                    SetCursor();
2315
                }
2316

    
2317
                zoomAndPanControl.ReleaseMouseCapture();
2318

    
2319

    
2320
                e.Handled = true;
2321
            }
2322
            else
2323
            {
2324
                this.cursor = Cursors.Arrow;
2325
                SetCursor();
2326
            }
2327
            mouseButtonDown = MouseButton.Left;
2328

    
2329
            //controlType = ControlType.SingleLine;
2330
        }
2331

    
2332
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2333
        {
2334
            mouseButtonDown = MouseButton.Left;
2335
            this.Cursor = Cursors.Arrow;
2336
        }
2337

    
2338
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2339
        {
2340

    
2341
        }
2342

    
2343
        private void ApplyDragSelectionRect()
2344
        {
2345
            multi_Undo_Data = new Multi_Undo_data();
2346

    
2347
            UndoData = new Undo_data()
2348
            {
2349
                IsUndo = false,
2350
                Event = Event_Type.Select,
2351
                EventTime = DateTime.Now,
2352
                Markup_List = new List<Multi_Undo_data>()
2353
            };
2354

    
2355
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2356

    
2357
            double x = Canvas.GetLeft(dragSelectionBorder);
2358
            double y = Canvas.GetTop(dragSelectionBorder);
2359
            double width = dragSelectionBorder.Width;
2360
            double height = dragSelectionBorder.Height;
2361
            Rect dragRect = new Rect(x, y, width, height);
2362
            Boolean Flag = false;
2363
            dragRect.Inflate(width / 10, height / 10);
2364
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2365
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2366

    
2367
            dragRect = new Rect(x, y, width, height);
2368
            dragRect.Inflate(width / 10, height / 10);
2369

    
2370
            foreach (var item in Items)
2371
            {
2372
                Flag = move.control_Select(item, dragRect);
2373

    
2374
                if (Flag)
2375
                {
2376
                    adornerSet.Add(item);
2377
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2378

    
2379
                    Control_Style(item);
2380
                    UndoData.Markup_List.Add(multi_Undo_Data);
2381
                    multi_Undo_Data = new Multi_Undo_data();
2382
                }
2383
            }
2384
            if (adornerSet.Count > 0)
2385
            {
2386
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2387
                {
2388
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2389
                });
2390
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2391

    
2392
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2393
                SelectLayer.Children.Add(final);
2394
            }
2395
        }
2396

    
2397
        private void InitDragSelectionRect(Point pt1, Point pt2)
2398
        {
2399
            //캡쳐 중
2400
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2401
            {
2402
                dragCaptureBorder.Visibility = Visibility.Visible;
2403
            }
2404
            //선택 중
2405
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2406
            {
2407
                
2408
                dragSelectionBorder.Visibility = Visibility.Visible;
2409
            }
2410
            else
2411
            {
2412
                dragZoomBorder.Visibility = Visibility.Visible;
2413
            }
2414
            UpdateDragSelectionRect(pt1, pt2);
2415
        }
2416

    
2417
        /// <summary>
2418
        /// Update the position and size of the rectangle used for drag selection.
2419
        /// </summary>
2420
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2421
        {
2422
            double x, y, width, height;
2423

    
2424
            //
2425
            // Determine x,y,width and height of the rect inverting the points if necessary.
2426
            // 
2427

    
2428
            if (pt2.X < pt1.X)
2429
            {
2430
                x = pt2.X;
2431
                width = pt1.X - pt2.X;
2432
            }
2433
            else
2434
            {
2435
                x = pt1.X;
2436
                width = pt2.X - pt1.X;
2437
            }
2438

    
2439
            if (pt2.Y < pt1.Y)
2440
            {
2441
                y = pt2.Y;
2442
                height = pt1.Y - pt2.Y;
2443
            }
2444
            else
2445
            {
2446
                y = pt1.Y;
2447
                height = pt2.Y - pt1.Y;
2448
            }
2449

    
2450
            //
2451
            // Update the coordinates of the rectangle used for drag selection.
2452
            //
2453
            //캡쳐 중
2454
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2455
            {
2456
                Canvas.SetLeft(dragCaptureBorder, x);
2457
                Canvas.SetTop(dragCaptureBorder, y);
2458
                dragCaptureBorder.Width = width;
2459
                dragCaptureBorder.Height = height;
2460
            }
2461
            //선택 중
2462
            else if(mouseHandlingMode == MouseHandlingMode.Selecting)
2463
            {
2464
                Canvas.SetLeft(dragSelectionBorder, x);
2465
                Canvas.SetTop(dragSelectionBorder, y);
2466
                dragSelectionBorder.Width = width;
2467
                dragSelectionBorder.Height = height;
2468
            }
2469
            else
2470
            {
2471
                Canvas.SetLeft(dragZoomBorder, x);
2472
                Canvas.SetTop(dragZoomBorder, y);
2473
                dragZoomBorder.Width = width;
2474
                dragZoomBorder.Height = height;
2475
            }
2476

    
2477

    
2478
        }
2479

    
2480
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2481
        {
2482
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2483

    
2484
            bool result = false;
2485
            if (dragRect.Contains(controlRect))
2486
            {
2487
                result = true;
2488
                //잡은 객체들을 담은 리스트
2489
                try
2490
                {
2491
                    selected_item.Add(OverViewPathData, type.ToString());
2492
                }
2493
                catch (Exception)
2494
                {
2495

    
2496
                }
2497
            }
2498
            return result;
2499
        }
2500

    
2501
        private void drawingPannelRotate(double angle)
2502
        {
2503
            rotate.Angle = angle;
2504
            var rotationNum = Math.Abs((rotate.Angle / 90));
2505

    
2506
            if (angle == 90 || angle == 270)
2507
            {
2508
                double emptySize = zoomAndPanCanvas.Width;
2509
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2510
                zoomAndPanCanvas.Height = emptySize;
2511
            }
2512
            if (angle == 0)
2513
            {
2514
                translate.X = 0;
2515
                translate.Y = 0;
2516
            }
2517
            else if (angle == 90)
2518
            {
2519
                translate.X = zoomAndPanCanvas.Width;
2520
                translate.Y = 0;
2521
            }
2522
            else if (angle == 180)
2523
            {
2524
                translate.X = zoomAndPanCanvas.Width;
2525
                translate.Y = zoomAndPanCanvas.Height;
2526
            }
2527
            else
2528
            {
2529
                translate.X = 0;
2530
                translate.Y = zoomAndPanCanvas.Height;
2531
            }
2532

    
2533
            zoomAndPanControl.RotationAngle = rotate.Angle;
2534

    
2535

    
2536
            if (!testPanel2.IsHidden)
2537
            {
2538
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2539
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2540
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2541
            }
2542

    
2543
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2544
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2545
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2546
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2547
            ViewerDataModel.Instance.Angle = rotate.Angle;
2548

    
2549

    
2550
        }
2551

    
2552
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2553
        {
2554
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2555
            if (set_option != null)
2556
            {
2557
                set_option.Value = double.Parse(set_option.ContentText);
2558
            }
2559

    
2560
            InkControl_Convert();
2561

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

    
2565
            if(text_item != null && (currentControl as ArrowTextControl) == null)
2566
            {
2567
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2568
            }
2569

    
2570
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2571
            {
2572
                if (arrow_text as ArrowTextControl != null)
2573
                {
2574
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2575
                }
2576
            }
2577

    
2578
            if(currentControl == null)
2579
            {
2580
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2581
                if (text_item_ != null)
2582
                {
2583
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2584
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2585
                    (text_item_ as TextControl).IsEditing = false;
2586
                    (text_item_ as TextControl).EnableEditing = false;
2587
                }
2588

    
2589
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2590
                if (Arrowtext_item_ != null)
2591
                {
2592
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2593
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2594
                }
2595
            }
2596

    
2597
            double Ang = 0;
2598
            if (rotate.Angle != 0)
2599
            {
2600
                Ang = 360 - rotate.Angle;
2601
            }
2602
            move = new Move();
2603

    
2604
            if (e.OriginalSource is System.Windows.Controls.Image)
2605
            {
2606
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2607
            }
2608

    
2609
            mouseButtonDown = e.ChangedButton;
2610
            if (mouseButtonDown == MouseButton.Left)
2611
            {
2612
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2613
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2614

    
2615
                this.cursor = Cursors.Arrow;
2616
                SetCursor();
2617

    
2618
                if (!ViewerDataModel.Instance.IsPressCtrl)
2619
                {
2620
                    ReleaseAdorner();
2621
                }
2622
            }
2623
            if (mouseButtonDown == MouseButton.Middle)
2624
            {
2625
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2626
                cursor = Cursors.SizeAll;
2627
                SetCursor();
2628
            }
2629
            if (mouseButtonDown == MouseButton.Right)
2630
            {
2631
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2632
                cursor = Cursors.SizeAll;
2633
                SetCursor();
2634
            }
2635
            else if (mouseButtonDown == MouseButton.XButton1)
2636
            {
2637
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2638
                {
2639
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2640
                }
2641

    
2642
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2643

    
2644
            }
2645
            else if (mouseButtonDown == MouseButton.XButton2)
2646
            {
2647
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2648
                {
2649
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2650
                }
2651
            }
2652

    
2653
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2654
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2655
            {
2656

    
2657
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2658
                {
2659
                    if (SelectLayer.Children.Count == 0)
2660
                    {
2661
                        isLeftMouseButtonDownOnWindow = true;
2662
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2663
                    }
2664

    
2665
                    if (controlType == ControlType.None)
2666
                    {
2667
                        isLeftMouseButtonDownOnWindow = true;
2668
                    }
2669
                }
2670

    
2671
                //캡쳐 모드 설정
2672
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2673
                {
2674
                    dragCaptureBorder.Visibility = Visibility.Visible;
2675
                    isLeftMouseButtonDownOnWindow = true;
2676
                }
2677

    
2678
                //줌 모드 설정
2679
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2680
                {
2681
                    //dragSelectionBorder.Visibility = Visibility.Visible;
2682
                    isLeftMouseButtonDownOnWindow = true;
2683
                }
2684

    
2685

    
2686
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2687
                if (control != null)
2688
                {
2689
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2690
                    AdornerFinal final;
2691
                    List<Point> p_set = new List<Point>();
2692
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2693
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2694
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2695
                    multi_Undo_Data = new Multi_Undo_data();
2696

    
2697
                    //강인구 Undo/Redo 보류
2698
                    UndoData = new Undo_data()
2699
                    {
2700
                        IsUndo = false,
2701
                        Event = Event_Type.Select,
2702
                        EventTime = DateTime.Now,
2703
                        Markup_List = new List<Multi_Undo_data>()
2704
                    };
2705

    
2706
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2707
                    {
2708
                        ReleaseAdorner();
2709
                        final = new AdornerFinal(control);
2710
                        //단일 컨트롤 언두 저장
2711

    
2712
                        Control_Style(control);
2713
                        UndoData.Markup_List.Add(multi_Undo_Data);
2714

    
2715
                        if ((control as IPath) != null)
2716
                        {
2717
                            if ((control as IPath).LineSize != 0)
2718
                            {
2719
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2720
                            }
2721
                        }
2722
                        if ((control as IShapeControl) != null)
2723
                        {
2724
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2725
                            {
2726
                                ViewerDataModel.Instance.checkHatchShape = true;
2727
                            }
2728
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2729
                            {
2730
                                ViewerDataModel.Instance.checkFillShape = true;
2731
                            }
2732
                            else
2733
                            {
2734
                                ViewerDataModel.Instance.checkHatchShape = false;
2735
                                ViewerDataModel.Instance.checkFillShape = false;
2736
                            }
2737
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2738
                        }
2739

    
2740
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2741

    
2742
                        if ((control as TextControl) != null)
2743
                        {
2744
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2745
                            {
2746
                                ViewerDataModel.Instance.checkTextStyle = true;
2747
                            }
2748
                            else
2749
                            {
2750
                                ViewerDataModel.Instance.checkTextStyle = false;
2751
                            }
2752

    
2753
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2754
                            {
2755
                                ViewerDataModel.Instance.checkTextStyle = true;
2756
                            }
2757
                            else
2758
                            {
2759
                                ViewerDataModel.Instance.checkTextStyle = false;
2760
                            }
2761
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2762
                            {
2763
                                ViewerDataModel.Instance.checkTextWeight = true;
2764
                            }
2765
                            else
2766
                            {
2767
                                ViewerDataModel.Instance.checkTextWeight = false;
2768
                            }
2769
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2770
                            {
2771
                                ViewerDataModel.Instance.checkUnderLine = true;
2772
                            }
2773
                            else
2774
                            {
2775
                                ViewerDataModel.Instance.checkUnderLine = false;
2776
                            }
2777
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2778
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2779
                            
2780
                        }
2781
                        else if ((control as ArrowTextControl) != null)
2782
                        {
2783
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2784
                            {
2785
                                ViewerDataModel.Instance.checkTextStyle = true;
2786
                            }
2787
                            else
2788
                            {
2789
                                ViewerDataModel.Instance.checkTextStyle = false;
2790
                            }
2791

    
2792
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2793
                            {
2794
                                ViewerDataModel.Instance.checkTextStyle = true;
2795
                            }
2796
                            else
2797
                            {
2798
                                ViewerDataModel.Instance.checkTextStyle = false;
2799
                            }
2800
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2801
                            {
2802
                                ViewerDataModel.Instance.checkTextWeight = true;
2803
                            }
2804
                            else
2805
                            {
2806
                                ViewerDataModel.Instance.checkTextWeight = false;
2807
                            }
2808
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2809
                            {
2810
                                ViewerDataModel.Instance.checkUnderLine = true;
2811
                            }
2812
                            else
2813
                            {
2814
                                ViewerDataModel.Instance.checkUnderLine = false;
2815
                            }
2816
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2817
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2818
                        }
2819
                        else if ((control as RectCloudControl) != null)
2820
                        {
2821
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2822
                        }
2823
                        else if ((control as CloudControl) != null)
2824
                        {
2825
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2826
                        }
2827

    
2828
                    }
2829
                    else
2830
                    {
2831
                        comment = AddAdorner();
2832
                        comment.Add(control);
2833

    
2834
                        Control_Style(control);
2835
                        UndoData.Markup_List.Add(multi_Undo_Data);
2836

    
2837
                        final = new AdornerFinal(comment);
2838
                        //다중 컨트롤 언두 저장
2839
                    }
2840

    
2841
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2842
                    {
2843
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2844
                    });
2845

    
2846
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2847

    
2848
                    SelectLayer.Children.Add(final);
2849

    
2850
                    //Control_Init(control);
2851

    
2852

    
2853
                    
2854

    
2855

    
2856
                    //강인구 폰트 변경 보류
2857

    
2858
                    //if ((currentControl as TextControl) != null)
2859
                    //{
2860
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2861
                    //    {
2862
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2863
                    //    }
2864
                    //    else
2865
                    //    {
2866
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2867
                    //    }
2868

    
2869
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2870
                    //    {
2871

    
2872
                    //    }
2873
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
2874
                    //    {
2875

    
2876
                    //    }
2877
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2878
                    //    {
2879

    
2880
                    //    }
2881
                    //}
2882
                    //else if ((currentControl as ArrowTextControl) != null)
2883
                    //{
2884
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2885
                    //    {
2886
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
2887
                    //    }
2888
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2889
                    //    {
2890
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
2891
                    //    }
2892
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2893
                    //    {
2894
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
2895
                    //    }
2896
                    //}
2897

    
2898
                    //mouseHandlingMode = MouseHandlingMode.Adorner;
2899
                }
2900
            }
2901

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

    
2938
                multi_Undo_Data = new Multi_Undo_data();
2939
                //강인구 Undo/Redo 보류
2940
                UndoData = new Undo_data()
2941
                {
2942
                    IsUndo = false,
2943
                    Event = Event_Type.Create,
2944
                    EventTime = DateTime.Now,
2945
                    Markup_List = new List<Multi_Undo_data>()
2946
                };
2947

    
2948
                switch (controlType)
2949
                {
2950
                    case ControlType.Rectangle:
2951
                        {
2952
                            if (mouseButtonDown == MouseButton.Left)
2953
                            {
2954
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2955
                                {
2956
                                    if (currentControl is RectangleControl)
2957
                                    {
2958
                                        CreateControl();
2959

    
2960
                                        (currentControl as RectangleControl).ApplyOverViewData();
2961
                                        currentControl = null;
2962
                                        this.cursor = Cursors.Arrow;
2963
                                    }
2964
                                    else
2965
                                    {
2966
                                        currentControl = new RectangleControl
2967
                                        {
2968
                                            Background = new SolidColorBrush(Colors.Black),
2969
                                            ControlType = ControlType.Rectangle
2970
                                        };
2971

    
2972
                                        currentControl.CommentID = Save.shortGuid();
2973
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2974
                                        currentControl.IsNew = true;
2975
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2976

    
2977
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2978
                                    }
2979
                                }
2980
                            }
2981
                        }
2982
                        break;
2983
                    case ControlType.RectCloud:
2984
                        {
2985
                            if (mouseButtonDown == MouseButton.Left)
2986
                            {
2987
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2988
                                {
2989
                                    if (currentControl is RectCloudControl)
2990
                                    {
2991
                                        CreateControl();
2992

    
2993
                                        (currentControl as RectCloudControl).ApplyOverViewData();
2994
                                        currentControl = null;
2995
                                        this.cursor = Cursors.Arrow;
2996
                                    }
2997
                                    else
2998
                                    {
2999
                                        currentControl = new RectCloudControl
3000
                                        {
3001
                                            Background = new SolidColorBrush(Colors.Black)
3002
                                        };
3003

    
3004
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3005
                                        currentControl.CommentID = Save.shortGuid();
3006
                                        currentControl.IsNew = true;
3007
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3008
                                    }
3009
                                }
3010
                            }
3011
                        }
3012
                        break;
3013
                    case ControlType.Circle:
3014
                        {
3015
                            if (mouseButtonDown == MouseButton.Left)
3016
                            {
3017
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3018
                                {
3019
                                    if (currentControl is CircleControl)
3020
                                    {
3021
                                        CreateControl();
3022

    
3023
                                        (currentControl as CircleControl).ApplyOverViewData();
3024
                                        currentControl = null;
3025
                                    }
3026
                                    else
3027
                                    {
3028
                                        currentControl = new CircleControl
3029
                                        {
3030
                                            Background = new SolidColorBrush(Colors.Black)
3031
                                        };
3032

    
3033
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3034
                                        currentControl.CommentID = Save.shortGuid();
3035
                                        currentControl.IsNew = true;
3036
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3037
                                    }
3038
                                }
3039
                            }
3040
                        }
3041
                        break;
3042
                    case ControlType.Triangle:
3043
                        {
3044
                            if (mouseButtonDown == MouseButton.Left)
3045
                            {
3046
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3047
                                {
3048
                                    if (currentControl is TriControl)
3049
                                    {
3050
                                        var content = currentControl as TriControl;
3051
                                        if (content.MidPoint == new Point(0, 0))
3052
                                        {
3053
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3054
                                        }
3055
                                        else
3056
                                        {
3057
                                            CreateControl();
3058

    
3059
                                            (currentControl as TriControl).ApplyOverViewData();
3060
                                            currentControl = null;
3061
                                        }
3062
                                    }
3063
                                    else
3064
                                    {
3065
                                        currentControl = new TriControl
3066
                                        {
3067
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3068
                                            Background = new SolidColorBrush(Colors.Black),
3069
                                        };
3070

    
3071
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3072
                                        currentControl.CommentID = Save.shortGuid();
3073
                                        currentControl.IsNew = true;
3074
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3075
                                    }
3076
                                }
3077
                            }
3078
                        }
3079
                        break;
3080
                    case ControlType.SingleLine:
3081
                        {
3082
                            if (mouseButtonDown == MouseButton.Left)
3083
                            {
3084
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3085
                                {
3086
                                    if (currentControl is LineControl)
3087
                                    {
3088
                                        CreateControl();
3089

    
3090
                                        (currentControl as LineControl).ApplyOverViewData();
3091
                                        currentControl = null;
3092
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3093
                                    }
3094
                                    else
3095
                                    {
3096
                                        currentControl = new LineControl
3097
                                        {
3098
                                            Background = new SolidColorBrush(Colors.Black)
3099
                                        };
3100

    
3101
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3102
                                        currentControl.CommentID = Save.shortGuid();
3103
                                        currentControl.IsNew = true;
3104
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3105
                                        this.MainAngle.Visibility = Visibility.Visible;
3106
                                    }
3107
                                }
3108
                            }
3109
                        }
3110
                        break;
3111
                    case ControlType.CancelLine:
3112
                        {
3113
                            if (mouseButtonDown == MouseButton.Left)
3114
                            {
3115
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3116
                                {
3117
                                    if (currentControl is LineControl)
3118
                                    {
3119
                                        CreateControl();
3120

    
3121
                                        (currentControl as LineControl).ApplyOverViewData();
3122
                                        currentControl = null;
3123
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3124
                                    }
3125
                                    else
3126
                                    {
3127
                                        currentControl = new LineControl
3128
                                        {
3129
                                            Background = new SolidColorBrush(Colors.Black)
3130
                                        };
3131

    
3132
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3133
                                        currentControl.CommentID = Save.shortGuid();
3134
                                        currentControl.IsNew = true;
3135
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3136
                                        this.MainAngle.Visibility = Visibility.Visible;
3137
                                    }
3138
                                }
3139
                            }
3140
                        }
3141
                        break;
3142
                    case ControlType.ArrowLine:
3143
                        {
3144
                            if (mouseButtonDown == MouseButton.Left)
3145
                            {
3146
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3147
                                {
3148
                                    if (currentControl is LineControl)
3149
                                    {
3150
                                        CreateControl();
3151

    
3152
                                        (currentControl as LineControl).ApplyOverViewData();
3153
                                        currentControl = null;
3154
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3155
                                    }
3156
                                    else
3157
                                    {
3158
                                        currentControl = new LineControl
3159
                                        {
3160
                                            Background = new SolidColorBrush(Colors.Black)
3161
                                        };
3162

    
3163
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3164
                                        currentControl.CommentID = Save.shortGuid();
3165
                                        currentControl.IsNew = true;
3166
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3167
                                        this.MainAngle.Visibility = Visibility.Visible;
3168
                                    }
3169
                                }
3170
                            }
3171
                        }
3172
                        break;
3173
                    case ControlType.TwinLine:
3174
                        {
3175
                            if (mouseButtonDown == MouseButton.Left)
3176
                            {
3177
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3178
                                {
3179
                                    if (currentControl is LineControl)
3180
                                    {
3181
                                        CreateControl();
3182

    
3183
                                        (currentControl as LineControl).ApplyOverViewData();
3184
                                        currentControl = null;
3185
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3186
                                    }
3187
                                    else
3188
                                    {
3189
                                        currentControl = new LineControl
3190
                                        {
3191
                                            Background = new SolidColorBrush(Colors.Black)
3192
                                        };
3193
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3194
                                        currentControl.CommentID = Save.shortGuid();
3195
                                        currentControl.IsNew = true;
3196
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3197
                                        this.MainAngle.Visibility = Visibility.Visible;
3198
                                    }
3199
                                }
3200
                            }
3201
                        }
3202
                        break;
3203
                    case ControlType.DimLine:
3204
                        {
3205
                            if (mouseButtonDown == MouseButton.Left)
3206
                            {
3207
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3208
                                {
3209
                                    if (currentControl is LineControl)
3210
                                    {
3211
                                        CreateControl();
3212

    
3213
                                        (currentControl as LineControl).ApplyOverViewData();
3214
                                        currentControl = null;
3215
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3216
                                    }
3217
                                    else
3218
                                    {
3219
                                        currentControl = new LineControl
3220
                                        {
3221
                                            Background = new SolidColorBrush(Colors.Black)
3222
                                        };
3223
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3224
                                        currentControl.CommentID = Save.shortGuid();
3225
                                        currentControl.IsNew = true;
3226
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3227
                                        this.MainAngle.Visibility = Visibility.Visible;
3228
                                    }
3229
                                }
3230
                            }
3231
                        }
3232
                        break;
3233
                    case ControlType.ChainLine:
3234
                        {
3235
                            if (currentControl is PolygonControl)
3236
                            {
3237
                                var control = currentControl as PolygonControl;
3238

    
3239
                                if (mouseButtonDown == MouseButton.Right)
3240
                                {
3241
                                    CreateControl();
3242

    
3243
                                    (currentControl as PolygonControl).ApplyOverViewData();
3244
                                    currentControl = null;
3245
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3246
                                    return;
3247
                                }
3248

    
3249
                                if (!control.IsCompleted)
3250
                                {
3251
                                    control.PointSet.Add(control.EndPoint);
3252
                                    this.MainAngle.Visibility = Visibility.Visible;
3253
                                }
3254
                            }
3255
                            else
3256
                            {
3257
                                if (mouseButtonDown == MouseButton.Left)
3258
                                {
3259
                                    MainAngle.Visibility = Visibility.Visible;
3260
                                    currentControl = new PolygonControl
3261
                                    {
3262
                                        PointSet = new List<Point>(),
3263
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3264
                                        ControlType = ControlType.ChainLine,
3265
                                        DashSize = ViewerDataModel.Instance.DashSize,
3266
                                        LineSize = ViewerDataModel.Instance.LineSize,
3267
                                        //PointC = new StylusPointSet()
3268
                                    };
3269

    
3270
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3271
                                    {
3272
                                        var polygonControl = (currentControl as PolygonControl);
3273
                                        currentControl.CommentID = Save.shortGuid();
3274
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3275
                                        currentControl.IsNew = true;
3276
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3277
                                        //currentControl.OnApplyTemplate();
3278
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3279
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3280
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3281
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3282
                                    }
3283
                                }
3284
                            }
3285
                        }
3286
                        break;
3287
                    case ControlType.ArcLine:
3288
                        {
3289
                            if (mouseButtonDown == MouseButton.Left)
3290
                            {
3291
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3292
                                {
3293
                                    if (currentControl is ArcControl)
3294
                                    {
3295
                                        CreateControl();
3296

    
3297
                                        (currentControl as ArcControl).ApplyOverViewData();
3298
                                        currentControl = null;
3299
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3300
                                    }
3301
                                    else
3302
                                    {
3303
                                        currentControl = new ArcControl
3304
                                        {
3305
                                            Background = new SolidColorBrush(Colors.Black)
3306
                                        };
3307
                                        currentControl.CommentID = Save.shortGuid();
3308
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3309
                                        currentControl.IsNew = true;
3310
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3311
                                        this.MainAngle.Visibility = Visibility.Visible;
3312
                                    }
3313
                                }
3314
                            }
3315
                            else if (mouseButtonDown == MouseButton.Right)
3316
                            {
3317
                                if (currentControl != null)
3318
                                {
3319
                                    (currentControl as ArcControl).setClock();
3320
                                }
3321

    
3322
                            }
3323

    
3324
                        }
3325
                        break;
3326
                    case ControlType.ArcArrow:
3327
                        {
3328
                            if (mouseButtonDown == MouseButton.Left)
3329
                            {
3330
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3331
                                {
3332
                                    if (currentControl is ArcControl)
3333
                                    {
3334
                                        CreateControl();
3335

    
3336
                                        (currentControl as ArcControl).ApplyOverViewData();
3337
                                        currentControl = null;
3338
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3339
                                    }
3340
                                    else
3341
                                    {
3342
                                        currentControl = new ArcControl
3343
                                        {
3344
                                            Background = new SolidColorBrush(Colors.Red),
3345
                                        };
3346
                                        currentControl.CommentID = Save.shortGuid();
3347
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3348
                                        currentControl.IsNew = true;
3349
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3350
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3351
                                        this.MainAngle.Visibility = Visibility.Visible;
3352
                                    }
3353
                                }
3354
                            }
3355
                            else if (mouseButtonDown == MouseButton.Right)
3356
                            {
3357
                                (currentControl as ArcControl).setClock();
3358
                            }
3359
                        }
3360
                        break;
3361
                    case ControlType.ArrowMultiLine:
3362
                        {
3363
                            if (mouseButtonDown == MouseButton.Left)
3364
                            {
3365
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3366
                                {
3367

    
3368
                                    if (currentControl is ArrowControl_Multi)
3369
                                    {
3370
                                        var content = currentControl as ArrowControl_Multi;
3371
                                        if (content.MiddlePoint == new Point(0, 0))
3372
                                        {
3373
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3374
                                            {
3375
                                                content.MiddlePoint = content.EndPoint;
3376
                                            }
3377
                                            else
3378
                                            {
3379
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3380
                                            }
3381
                                        }
3382
                                        else
3383
                                        {
3384
                                            CreateControl();
3385

    
3386
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3387
                                            currentControl = null;
3388
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3389
                                        }
3390
                                    }
3391
                                    else
3392
                                    {
3393
                                        currentControl = new ArrowControl_Multi
3394
                                        {
3395
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3396
                                            Background = new SolidColorBrush(Colors.Black)
3397
                                        };
3398
                                        currentControl.CommentID = Save.shortGuid();
3399
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3400
                                        currentControl.IsNew = true;
3401
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3402
                                        this.MainAngle.Visibility = Visibility.Visible;
3403
                                    }
3404
                                }
3405
                            }
3406
                        }
3407
                        break;
3408
                    case ControlType.PolygonCloud:
3409
                        {
3410
                            if (currentControl is CloudControl)
3411
                            {
3412
                                var control = currentControl as CloudControl;
3413
                                if (mouseButtonDown == MouseButton.Right)
3414
                                {
3415
                                    control.IsCompleted = true;
3416
                                }
3417

    
3418
                                if (!control.IsCompleted)
3419
                                {
3420
                                    control.PointSet.Add(control.EndPoint);
3421
                                }
3422
                                else
3423
                                {
3424
                                    CreateControl();
3425

    
3426
                                    control.isTransOn = true;
3427
                                    var firstPoint = control.PointSet.First();
3428

    
3429
                                    control.PointSet.Add(firstPoint);
3430
                                    control.DrawingCloud();
3431
                                    control.ApplyOverViewData();
3432

    
3433
                                    currentControl = null;
3434
                                }
3435
                            }
3436
                            else
3437
                            {
3438
                                if (mouseButtonDown == MouseButton.Left)
3439
                                {
3440
                                    currentControl = new CloudControl
3441
                                    {
3442
                                        PointSet = new List<Point>(),
3443
                                        PointC = new StylusPointSet()
3444
                                    };
3445

    
3446
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3447
                                    {
3448
                                        var polygonControl = (currentControl as CloudControl);
3449
                                        currentControl.CommentID = Save.shortGuid();
3450
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3451
                                        currentControl.IsNew = true;
3452
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3453

    
3454
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3455
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3456
                                    }
3457
                                }
3458
                            }
3459
                        }
3460
                        break;
3461
                    case ControlType.ImgControl:
3462
                        {
3463
                            if (mouseButtonDown == MouseButton.Left)
3464
                            {
3465
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3466
                                {
3467
                                    if (currentControl is ImgControl)
3468
                                    {
3469
                                        CreateControl();
3470
                                        (currentControl as ImgControl).ApplyOverViewData();
3471

    
3472
                                        currentControl = null;
3473
                                    }
3474
                                    else
3475
                                    {
3476
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3477
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3478
                                        {
3479
                                            Image img = new Image();
3480
                                            img.Source = new BitmapImage(new Uri(filename));
3481

    
3482
                                            currentControl = new ImgControl
3483
                                            {
3484
                                                Background = new SolidColorBrush(Colors.Black),
3485
                                                PointSet = new List<Point>(),
3486
                                                FilePath = filename,
3487
                                                ImageData = img.Source,
3488
                                                StartPoint = canvasDrawingMouseDownPoint,
3489
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3490
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3491
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3492
                                            };
3493

    
3494
                                            currentControl.CommentID = Save.shortGuid();
3495
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3496
                                            currentControl.IsNew = true;
3497
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3498
                                        }
3499
                                    }
3500
                                }
3501
                            }
3502
                        }
3503
                        break;
3504
                    case ControlType.Date:
3505
                        {
3506
                            if (mouseButtonDown == MouseButton.Left)
3507
                            {
3508
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3509
                                {
3510
                                    if (currentControl is DateControl)
3511
                                    {
3512
                                        CreateControl();
3513
                                        (currentControl as DateControl).ApplyOverViewData();
3514
                                        currentControl = null;
3515

    
3516
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3517
                                        {
3518
                                            controlType = ControlType.None;
3519
                                            IsSwingMode = false;
3520
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3521
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3522
                                            mouseHandlingMode = MouseHandlingMode.None;
3523
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3524
                                            txtBatch.Visibility = Visibility.Collapsed;
3525

    
3526
                                        }
3527
                                    }
3528
                                    else
3529
                                    {
3530
                                        currentControl = new DateControl
3531
                                        {
3532
                                            Background = new SolidColorBrush(Colors.Black)
3533
                                        };
3534
                                        currentControl.CommentID = Save.shortGuid();
3535
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3536
                                        currentControl.IsNew = true;
3537
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3538
                                    }
3539
                                }
3540
                            }
3541
                        }
3542
                        break;
3543
                    case ControlType.TextControl:
3544
                        {
3545
                            if (mouseButtonDown == MouseButton.Left)
3546
                            {
3547
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3548
                                {
3549

    
3550
                                    currentControl = new TextControl
3551
                                    {
3552
                                        ControlType = controlType
3553
                                    };
3554
                                        currentControl.CommentID = Save.shortGuid();
3555
                                        currentControl.IsNew = true;
3556
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3557
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3558
                                        currentControl.SetValue(Canvas.ZIndexProperty, 2);
3559
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3560
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3561
                                        currentControl.Focus();
3562
                                        (currentControl as TextControl).ApplyOverViewData();
3563
                                        (currentControl as TextControl).ControlType_No = 0;
3564
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3565
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3566

    
3567
                                        CreateControl();
3568

    
3569
                                        currentControl = null;
3570
                                }
3571
                            }
3572
                        }
3573
                        break;
3574
                    case ControlType.TextBorder:
3575
                        {
3576
                            if (mouseButtonDown == MouseButton.Left)
3577
                            {
3578
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3579
                                {
3580
                                    currentControl = new TextControl
3581
                                    {
3582
                                        ControlType = controlType
3583
                                    };
3584

    
3585

    
3586
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3587
                                    currentControl.CommentID = Save.shortGuid();
3588
                                    currentControl.IsNew = true;
3589
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3590
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3591
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3592
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3593
                                    currentControl.Focus();
3594
                                    (currentControl as TextControl).ControlType_No = 1;
3595
                                    (currentControl as TextControl).Angle = Ang;
3596
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3597
                                    CreateControl();
3598

    
3599
                                    currentControl = null;
3600
                                }
3601
                            }
3602
                        }
3603
                        break;
3604
                    case ControlType.TextCloud:
3605
                        {
3606
                            if (mouseButtonDown == MouseButton.Left)
3607
                            {
3608
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3609
                                {
3610
                                    currentControl = new TextControl
3611
                                    {
3612
                                        ControlType = controlType
3613
                                    };
3614
                                    currentControl.CommentID = Save.shortGuid();
3615
                                    currentControl.IsNew = true;
3616
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3617
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3618

    
3619
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3620
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3621
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3622
                                    currentControl.Focus();
3623

    
3624
                                    (currentControl as TextControl).Angle = Ang;
3625
                                    (currentControl as TextControl).ControlType_No = 2;
3626
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3627

    
3628
                                    CreateControl();
3629
                                    currentControl = null;
3630
                                }
3631
                            }
3632
                        }
3633
                        break;
3634
                    case ControlType.ArrowTextControl:
3635
                        {
3636
                            if (mouseButtonDown == MouseButton.Left)
3637
                            {
3638
                                if (currentControl is ArrowTextControl)
3639
                                {
3640
                                    CreateControl();
3641

    
3642
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3643
                                    (currentControl as ArrowTextControl).IsEditing = false;
3644
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3645
                                    currentControl = null;
3646
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3647

    
3648
                                }
3649
                                else
3650
                                {
3651
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3652
                                    {
3653
                                        currentControl = new ArrowTextControl();
3654
                                        currentControl.CommentID = Save.shortGuid();
3655
                                        currentControl.IsNew = true;
3656
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3657
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3658

    
3659
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3660

    
3661
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3662

    
3663
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3664

    
3665
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3666

    
3667
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3668

    
3669
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3670
                                        this.MainAngle.Visibility = Visibility.Visible;
3671
                                    }
3672
                                }
3673
                            }
3674
                        }
3675
                        break;
3676
                    case ControlType.ArrowTransTextControl:
3677
                        {
3678
                            if (mouseButtonDown == MouseButton.Left)
3679
                            {
3680
                                if (currentControl is ArrowTextControl)
3681
                                {
3682
                                    CreateControl();
3683
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3684
                                    currentControl = null;
3685
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3686
                                }
3687
                                else
3688
                                {
3689
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3690
                                    {
3691
                                        currentControl = new ArrowTextControl();
3692
                                        currentControl.CommentID = Save.shortGuid();
3693
                                        currentControl.IsNew = true;
3694
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3695
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3696

    
3697
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3698

    
3699
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3700

    
3701
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3702

    
3703
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3704

    
3705
                                        (currentControl as ArrowTextControl).isFixed = true;
3706
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3707

    
3708
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3709
                                        this.MainAngle.Visibility = Visibility.Visible;
3710
                                    }
3711
                                }
3712
                            }
3713
                        }
3714
                        break;
3715
                    case ControlType.ArrowTextBorderControl:
3716
                        {
3717
                            if (mouseButtonDown == MouseButton.Left)
3718
                            {
3719
                                if (currentControl is ArrowTextControl)
3720
                                {
3721
                                    CreateControl();
3722
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3723
                                    currentControl = null;
3724
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3725
                                }
3726
                                else
3727
                                {
3728
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3729
                                    {
3730
                                        currentControl = new ArrowTextControl()
3731
                                        {
3732
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3733
                                        };
3734
                                        currentControl.CommentID = Save.shortGuid();
3735
                                        currentControl.IsNew = true;
3736
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3737
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3738

    
3739
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3740

    
3741
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3742

    
3743
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3744
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3745

    
3746
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3747

    
3748
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3749
                                        this.MainAngle.Visibility = Visibility.Visible;
3750
                                    }
3751
                                }
3752
                            }
3753
                        }
3754
                        break;
3755
                    case ControlType.ArrowTransTextBorderControl:
3756
                        {
3757
                            if (mouseButtonDown == MouseButton.Left)
3758
                            {
3759
                                if (currentControl is ArrowTextControl)
3760
                                {
3761
                                    CreateControl();
3762
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3763
                                    currentControl = null;
3764
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3765
                                }
3766
                                else
3767
                                {
3768
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3769
                                    {
3770
                                        currentControl = new ArrowTextControl()
3771
                                        {
3772
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3773
                                        };
3774
                                        currentControl.CommentID = Save.shortGuid();
3775
                                        currentControl.IsNew = true;
3776
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3777
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3778

    
3779
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3780

    
3781
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3782

    
3783
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3784

    
3785
                                        (currentControl as ArrowTextControl).isFixed = true;
3786
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3787

    
3788
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3789

    
3790
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3791
                                        this.MainAngle.Visibility = Visibility.Visible;
3792
                                    }
3793
                                }
3794
                            }
3795
                        }
3796
                        break;
3797
                    case ControlType.ArrowTextCloudControl:
3798
                        {
3799
                            if (mouseButtonDown == MouseButton.Left)
3800
                            {
3801
                                if (currentControl is ArrowTextControl)
3802
                                {
3803
                                    CreateControl();
3804
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3805
                                    currentControl = null;
3806
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3807
                                }
3808
                                else
3809
                                {
3810
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3811
                                    {
3812
                                        currentControl = new ArrowTextControl()
3813
                                        {
3814
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3815
                                        };
3816
                                        currentControl.CommentID = Save.shortGuid();
3817
                                        currentControl.IsNew = true;
3818
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3819
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3820

    
3821
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3822

    
3823
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3824

    
3825
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3826
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3827
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3828

    
3829
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3830
                                        this.MainAngle.Visibility = Visibility.Visible;
3831
                                    }
3832
                                }
3833
                            }
3834
                        }
3835
                        break;
3836
                    case ControlType.ArrowTransTextCloudControl:
3837
                        {
3838
                            if (mouseButtonDown == MouseButton.Left)
3839
                            {
3840
                                if (currentControl is ArrowTextControl)
3841
                                {
3842
                                    CreateControl();
3843
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3844
                                    currentControl = null;
3845
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3846
                                }
3847
                                else
3848
                                {
3849
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3850
                                    {
3851
                                        currentControl = new ArrowTextControl()
3852
                                        {
3853
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3854
                                        };
3855
                                        currentControl.CommentID = Save.shortGuid();
3856
                                        currentControl.IsNew = true;
3857
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3858
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3859

    
3860
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3861

    
3862
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3863

    
3864
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3865

    
3866
                                        (currentControl as ArrowTextControl).isFixed = true;
3867
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3868

    
3869
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3870

    
3871
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3872
                                        this.MainAngle.Visibility = Visibility.Visible;
3873
                                    }
3874
                                }
3875
                            }
3876
                        }
3877
                        break;
3878
                    case ControlType.PolygonControl:
3879
                        {
3880
                            if (currentControl is PolygonControl)
3881
                            {
3882
                                var control = currentControl as PolygonControl;
3883

    
3884
                                if (mouseButtonDown == MouseButton.Right)
3885
                                {
3886
                                    control.IsCompleted = true;
3887
                                }
3888

    
3889
                                if (!control.IsCompleted)
3890
                                {
3891
                                    control.PointSet.Add(control.EndPoint);
3892
                                }
3893
                                else
3894
                                {
3895
                                    var firstPoint = control.PointSet.First();
3896
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3897
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3898
                                    control.PointSet.Add(firstPoint);
3899

    
3900
                                    control.SetPolyPath();
3901

    
3902
                                    control.ApplyOverViewData();
3903

    
3904
                                    CreateControl();
3905

    
3906
                                    currentControl = null;
3907
                                }
3908
                            }
3909
                            else
3910
                            {
3911
                                if (mouseButtonDown == MouseButton.Left)
3912
                                {
3913
                                    currentControl = new PolygonControl
3914
                                    {
3915
                                        PointSet = new List<Point>(),
3916
                                        //PointC = new StylusPointSet()
3917
                                    };
3918

    
3919
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3920
                                    {
3921
                                        var polygonControl = (currentControl as PolygonControl);
3922
                                        currentControl.CommentID = Save.shortGuid();
3923
                                        currentControl.IsNew = true;
3924
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3925
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3926
                                        //currentControl.OnApplyTemplate();
3927
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3928
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3929
                                    }
3930
                                }
3931
                            }
3932
                        }
3933
                        break;
3934
                    //강인구 추가
3935
                    case ControlType.Sign:
3936
                        {
3937
                            if (mouseButtonDown == MouseButton.Left)
3938
                            {
3939
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3940
                                {
3941
                                    if (currentControl is SignControl)
3942
                                    {
3943
                                        CreateControl();
3944
                                        currentControl = null;
3945
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3946
                                        {
3947
                                            txtBatch.Text = "Date Control을 그립니다.";
3948
                                            controlType = ControlType.Date;
3949
                                        }
3950
                                    }
3951
                                    else
3952
                                    {
3953
                                        currentControl = new SignControl
3954
                                        {
3955
                                            Background = new SolidColorBrush(Colors.Black),
3956
                                            UserNumber = App.ViewInfo.UserID,
3957
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3958
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3959
                                            ControlType = ControlType.Sign
3960
                                        };
3961

    
3962
                                        currentControl.CommentID = Save.shortGuid();
3963
                                        currentControl.IsNew = true;
3964
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3965
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3966
                                    }
3967
                                }
3968
                            }
3969
                        }
3970
                        break;
3971
                    case ControlType.Mark:
3972
                        {
3973
                            if (mouseButtonDown == MouseButton.Left)
3974
                            {
3975
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3976
                                {
3977
                                    if (currentControl is RectangleControl)
3978
                                    {
3979
                                        CreateControl();
3980
                                        (currentControl as RectangleControl).ApplyOverViewData();
3981
                                        currentControl = null;
3982
                                        this.cursor = Cursors.Arrow;
3983

    
3984
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3985
                                        {
3986
                                            txtBatch.Text = "Sign Control을 그립니다.";
3987
                                            controlType = ControlType.Sign;
3988
                                        }
3989
                                    }
3990
                                    else
3991
                                    {
3992
                                        currentControl = new RectangleControl
3993
                                        {
3994
                                            Background = new SolidColorBrush(Colors.Black),
3995
                                            Paint = PaintSet.Fill
3996
                                        };
3997

    
3998
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3999
                                        currentControl.CommentID = Save.shortGuid();
4000
                                        currentControl.IsNew = true;
4001
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4002
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4003
                                    }
4004
                                }
4005
                            }
4006
                        }
4007
                        break;
4008
                    case ControlType.Symbol:
4009
                        {
4010
                            if (mouseButtonDown == MouseButton.Left)
4011
                            {
4012
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4013
                                {
4014
                                    if (currentControl is SymControl)
4015
                                    {
4016
                                        CreateControl();
4017
                                        currentControl = null;
4018
                                        this.cursor = Cursors.Arrow;
4019
                                    }
4020
                                    else
4021
                                    {
4022
                                        currentControl = new SymControl
4023
                                        {
4024
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4025
                                            Background = new SolidColorBrush(Colors.Black),
4026
                                            ControlType = ControlType.Symbol
4027
                                        };
4028

    
4029
                                        currentControl.IsNew = true;
4030
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4031
                                        currentControl.CommentID = Save.shortGuid();
4032
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4033
                                    }
4034
                                }
4035
                            }
4036
                        }
4037
                        break;
4038
                    case ControlType.Stamp:
4039
                        {
4040
                            if (mouseButtonDown == MouseButton.Left)
4041
                            {
4042
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4043
                                {
4044
                                    if (currentControl is SymControlN)
4045
                                    {
4046
                                        CreateControl();
4047
                                        currentControl = null;
4048
                                        this.cursor = Cursors.Arrow;
4049
                                    }
4050
                                    else
4051
                                    {
4052
                                        currentControl = new SymControlN
4053
                                        {
4054
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4055
                                            Background = new SolidColorBrush(Colors.Black),
4056
                                            ControlType = ControlType.Stamp
4057
                                        };
4058

    
4059
                                        currentControl.IsNew = true;
4060
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4061
                                        currentControl.CommentID = Save.shortGuid();
4062
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4063
                                    }
4064
                                }
4065
                            }
4066
                        }
4067
                        break;
4068
                    case ControlType.PenControl:
4069
                        {
4070
                            if (inkBoard.Tag.ToString() == "Ink")
4071
                            {
4072
                                inkBoard.IsEnabled = true;
4073
                                StartNewStroke(canvasDrawingMouseDownPoint);
4074
                            }
4075
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4076
                            {
4077
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4078
                            }
4079
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4080
                            {
4081
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4082
                            }
4083
                            IsDrawing = true;
4084
                            return;
4085
                        }
4086
                    default:
4087
                        if (currentControl != null)
4088
                        {
4089
                            currentControl.CommentID = null;
4090
                            currentControl.IsNew = false;
4091
                        }
4092
                        break;
4093
                }
4094

    
4095
            }
4096

    
4097
            //else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4098
            //{
4099
            //    if (controlType == ControlType.None)
4100
            //    {
4101
            //        mouseHandlingMode = MouseHandlingMode.Selecting;
4102
            //        this.cursor = Cursors.Arrow;
4103
            //        inkDrawingCanvas.IsEnabled = false;
4104
            //        isLeftMouseButtonDownOnWindow = true;
4105
            //    }
4106
            //}
4107

    
4108
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4109
            {
4110
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4111
                {
4112
                    bool mouseOff = false;
4113
                    foreach (var item in SelectLayer.Children)
4114
                    {
4115
                        if (item is AdornerFinal)
4116
                        {
4117

    
4118
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4119
                            if (over != null)
4120
                            {
4121
                                mouseOff = true;
4122
                            }
4123
                        }
4124
                    }
4125

    
4126
                    if (!mouseOff)
4127
                    {
4128
                        ReleaseAdorner();
4129
                    }
4130
                }
4131
                zoomAndPanControl.CaptureMouse();
4132
                e.Handled = true;
4133
            }
4134
        }
4135
        
4136
        private void RemoveLineStroke(Point P)
4137
        {
4138
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4139
            if (control != null)
4140
            {
4141
                UndoData = new Undo_data()
4142
                {
4143
                    IsUndo = false,
4144
                    Event = Event_Type.Delete,
4145
                    EventTime = DateTime.Now,
4146
                    Markup_List = new List<Multi_Undo_data>()
4147
                };
4148

    
4149

    
4150
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4151
                UndoData.Markup_List.Add(multi_Undo_Data);
4152
                multi_Undo_Data = new Multi_Undo_data();
4153

    
4154
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4155
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4156
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4157

    
4158

    
4159
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4160
                {
4161
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4162
                });
4163
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4164
                
4165
            }
4166
        }
4167

    
4168
        private void RemovePointStroke(Point P)
4169
        {
4170
            foreach (Stroke hits in inkBoard.Strokes)
4171
            {
4172
                foreach (StylusPoint sty in hits.StylusPoints)
4173
                {
4174

    
4175
                }
4176
                if (hits.HitTest(P))
4177
                {
4178
                    inkBoard.Strokes.Remove(hits);
4179
                    return;
4180
                }
4181
            }
4182
        }
4183

    
4184
        private void StartNewStroke(Point P)
4185
        {
4186
            strokePoints = new StylusPointCollection();
4187
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4188
            strokePoints.Add(segment1Start);
4189
            stroke = new Stroke(strokePoints);
4190

    
4191
            stroke.DrawingAttributes.Color = Colors.Red;
4192
            stroke.DrawingAttributes.Width = 4;
4193
            stroke.DrawingAttributes.Height = 4;
4194

    
4195
            inkBoard.Strokes.Add(stroke);
4196

    
4197
        }
4198

    
4199
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4200
        {
4201
            ConsolidationMethod();
4202
        }
4203

    
4204
        public void ConsolidationMethod()
4205
        {
4206
            ChangeCommentReact();
4207

    
4208
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4209
            {
4210
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4211
            }
4212
            else
4213
            {
4214

    
4215
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4216
                {
4217
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4218
                }
4219

    
4220
                ViewerDataModel.Instance.IsConsolidate = true;
4221
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4222
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4223
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4224
                {
4225
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4226
                    if (markupInfo.CONSOLIDATE == 1)
4227
                    {
4228
                        markupInfo.AVOID_CONSOLIDATE = 1;
4229
                    }
4230

    
4231
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4232
                    {
4233
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4234
                          {
4235
                              instanceDataSet.Add(d);
4236
                          });
4237
                    }
4238

    
4239
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4240
                    info.ID = Save.shortGuid();
4241
                    info.CONSOLIDATE = 1;
4242
                    info.CREATE_TIME = DateTime.Now;
4243
                    info.DOCINFO_ID = _DocInfo.ID;
4244
                    info.UPDATE_TIME = DateTime.Now;
4245
                    info.USER_ID = App.ViewInfo.UserID;
4246
                    info.AVOID_CONSOLIDATE = 0;
4247

    
4248
                    Entity.MARKUP_INFO.AddObject(info);
4249
                    Entity.SaveChanges();
4250

    
4251

    
4252
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4253
                    {
4254
                        ID = Save.shortGuid(),
4255
                        CREATE_DATE = DateTime.Now,
4256
                        MARKUP_INFO = info,
4257
                    };
4258
                    Entity.SaveChanges();
4259

    
4260
                    foreach (var item in instanceDataSet)
4261
                    {
4262
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4263
                        {
4264
                            ID = Save.shortGuid(),
4265
                            DATA = item.DATA,
4266
                            DATA_TYPE = item.DATA_TYPE,
4267
                            PAGENUMBER = item.PAGENUMBER,
4268
                            MARKUP_INFO_VERSION = info2
4269
                        });
4270
                    }
4271
                    Entity.SaveChanges();
4272
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4273
                }
4274
            }
4275
        }
4276

    
4277
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4278
        {
4279
            if (App.ViewInfo != null)
4280
            {
4281
                btnConsolidate = (sender as RadRibbonButton);
4282
                if (!App.ViewInfo.NewCommentPermission)
4283
                {
4284
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4285
                }
4286
            }
4287
        }
4288

    
4289
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4290
        {
4291

    
4292
        }
4293

    
4294
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4295
        {
4296
            btnTeamConsolidate = sender as RadRibbonButton;
4297
            if (App.ViewInfo != null)
4298
            {
4299
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4300
                {
4301
                    if (btnConsolidate != null)
4302
                    {
4303
                        btnConsolidate.Visibility = Visibility.Collapsed;
4304
                    }
4305

    
4306
                    if (!App.ViewInfo.NewCommentPermission)
4307
                    {
4308
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4309
                    }
4310
                }
4311
                else
4312
                {
4313
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4314
                }
4315
            }
4316
        }
4317

    
4318
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4319
        {
4320
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4321
            if (item != null)
4322
            {
4323
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4324
            }
4325
            else
4326
            {
4327
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4328
            }
4329
        }
4330

    
4331
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4332
        {
4333
            btnFinalPDF = sender as RadRibbonButton;
4334
            if (App.ViewInfo != null)
4335
            {
4336
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4337
                {
4338
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4339
                    if (btnConsolidate != null)
4340
                    {
4341
                        btnConsolidate.Visibility = Visibility.Collapsed;
4342
                    }
4343
                }
4344
            }
4345
        }
4346

    
4347
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4348
        {
4349
            if (CompareMode.IsChecked)
4350
            {
4351
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4352
                {
4353
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4354
                }
4355
                if (ViewerDataModel.Instance.PageNumber == 0)
4356
                {
4357
                    ViewerDataModel.Instance.PageNumber = 1;
4358
                }
4359

    
4360
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4361
            }
4362
            else
4363
            {
4364
                da.From = 1;
4365
                da.To = 1;
4366
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4367
                da.AutoReverse = false;
4368
                canvas_compareBorder.Children.Clear();
4369
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4370
            }
4371
        }
4372

    
4373
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4374
        {
4375
            if (UserList.IsChecked)
4376
            {
4377
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4378
            }
4379
            else
4380
            {
4381
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4382
            }
4383
        }
4384

    
4385
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4386
        {
4387

    
4388
            if (BalanceMode.IsChecked)
4389
            {
4390
                ViewerDataModel.Instance.PageBalanceMode = true;
4391
            }
4392
            else
4393
            {
4394
                ViewerDataModel.Instance.PageBalanceMode = false;
4395
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4396
            }
4397
        }
4398

    
4399
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4400
        {
4401
            //초기화
4402
            testPanel2.IsHidden = true;
4403
            ViewerDataModel.Instance.PageBalanceMode = false;
4404
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4405
            ViewerDataModel.Instance.PageNumber = 0;
4406
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4407
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4408
            UserList.IsChecked = false;
4409
            BalanceMode.IsChecked = false;
4410
        }
4411

    
4412
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4413
        {
4414
            if ((sender as System.Windows.Controls.Control).Tag != null)
4415
            {
4416
                //Compare 초기화
4417
                CompareMode.IsChecked = false;
4418
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4419

    
4420
                if (ViewerDataModel.Instance.PageNumber == 0)
4421
                {
4422
                    ViewerDataModel.Instance.PageNumber = 1;
4423
                }
4424

    
4425
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4426
                {
4427
                }
4428
                else
4429
                {
4430
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4431
                }
4432

    
4433
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4434
                {
4435

    
4436
                }
4437
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4438
                {
4439
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4440
                }
4441

    
4442
                if (!testPanel2.IsHidden)
4443
                {
4444
                    if (IsSyncPDFMode)
4445
                    {
4446
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4447
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4448

    
4449
                        if (pdfpath.IsDownloading)
4450
                        {
4451
                            pdfpath.DownloadCompleted += (ex, arg) =>
4452
                            {
4453
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4454
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4455
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4456
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4457
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4458
                            };
4459
                        }
4460
                        else
4461
                        {
4462
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4463
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4464
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4465

    
4466
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4467
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4468
                        }
4469

    
4470
                    }
4471
                    else
4472
                    {
4473
                        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);
4474

    
4475
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4476

    
4477
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4478
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4479
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4480

    
4481
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4482
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4483

    
4484
                        if (defaultBitmapImage_Compare.IsDownloading)
4485
                        {
4486
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4487
                            {
4488
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4489
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4490
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4491

    
4492
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4493
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4494
                            };
4495
                        }
4496
                    }
4497

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

    
4502
                    foreach (var item in gridSelectionRevItem)
4503
                    {
4504
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4505
                        {
4506
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4507
                        });
4508
                    }
4509
                    
4510
                    //강인구 추가
4511
                    zoomAndPanControl2.ZoomTo(new Rect
4512
                    {
4513
                        X = 0,
4514
                        Y = 0,
4515
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4516
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4517
                    });
4518

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

    
4521
                }
4522
            }
4523
        }
4524

    
4525
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4526
        {
4527
            if (MarkupMode.IsChecked)
4528
            {
4529
                IsSyncPDFMode = true;
4530

    
4531
                var uri = CurrentRev.TO_VENDOR;
4532

    
4533
                if (ViewerDataModel.Instance.PageNumber == 0)
4534
                {
4535
                    ViewerDataModel.Instance.PageNumber = 1;
4536
                }
4537

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

    
4542
                if (pdfpath.IsDownloading)
4543
                {
4544
                    pdfpath.DownloadCompleted += (ex, arg) =>
4545
                    {
4546
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4547
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4548
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4549
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4550
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4551
                    };
4552
                }
4553
                else
4554
                {
4555
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4556
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4557
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4558

    
4559
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4560
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4561
                }
4562
            }
4563
            else
4564
            {
4565
                IsSyncPDFMode = false;
4566
                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);
4567

    
4568
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4569

    
4570
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4571
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4572
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4573

    
4574
                if (defaultBitmapImage_Compare.IsDownloading)
4575
                {
4576
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4577
                    {
4578
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4579
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4580
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4581
                    };
4582
                }
4583
                zoomAndPanControl2.ApplyTemplate();
4584
                zoomAndPanControl2.UpdateLayout();
4585
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4586
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4587
            }
4588
        }
4589

    
4590
        private void RadButton_Click(object sender, RoutedEventArgs e)
4591
        {
4592
            gridViewHistory_Busy.IsBusy = true;
4593

    
4594
            RadButton instance = sender as RadButton;
4595
            if (instance.CommandParameter != null)
4596
            {
4597
                CurrentRev = instance.CommandParameter as VPRevision;
4598
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4599
                {
4600
                    if (ea.Error == null && ea.Result != null)
4601
                    {
4602
                        testPanel2.IsHidden = false;
4603

    
4604
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4605
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4606

    
4607
                        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);
4608

    
4609
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4610

    
4611
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4612

    
4613
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4614
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4615
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4616

    
4617
                        if (defaultBitmapImage_Compare.IsDownloading)
4618
                        {
4619
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4620
                            {
4621
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4622
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4623
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4624
                            };
4625
                        }
4626

    
4627
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4628
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4629
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4630
                        zoomAndPanControl2.ApplyTemplate();
4631
                        zoomAndPanControl2.UpdateLayout();
4632

    
4633
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4634
                        {
4635
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4636
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4637
                        }
4638

    
4639
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4640
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4641
                        gridViewHistory_Busy.IsBusy = false;
4642
                    }
4643
                };
4644
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4645
            }
4646
        }
4647

    
4648
        public void Sync_Event(VPRevision Currnet_Rev)
4649
        {
4650
            CurrentRev = Currnet_Rev;
4651

    
4652
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4653
            {
4654
                if (ea.Error == null && ea.Result != null)
4655
                {
4656
                    testPanel2.IsHidden = false;
4657

    
4658
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4659
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4660

    
4661
                    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);
4662

    
4663
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4664

    
4665
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4666

    
4667
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4668
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4669
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4670

    
4671
                    if (defaultBitmapImage_Compare.IsDownloading)
4672
                    {
4673
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4674
                        {
4675
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4676
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4677
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4678
                        };
4679
                    }
4680

    
4681
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4682
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4683
                    zoomAndPanControl2.ApplyTemplate();
4684
                    zoomAndPanControl2.UpdateLayout();
4685

    
4686
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4687
                    {
4688
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4689
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4690
                    }
4691
                    //}
4692

    
4693
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4694
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4695
                    gridViewHistory_Busy.IsBusy = false;
4696
                }
4697
            };
4698
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4699

    
4700

    
4701
        }
4702

    
4703
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4704
        {
4705
            if (sender is Image)
4706
            {
4707
                if ((sender as Image).Tag != null)
4708
                {
4709
                    var pdfUrl = (sender as Image).Tag.ToString();
4710
                    System.Diagnostics.Process.Start(pdfUrl);
4711
                }
4712
                else
4713
                {
4714
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4715
                }
4716
            }
4717
        }
4718

    
4719
        private void Create_Symbol(object sender, RoutedEventArgs e)
4720
        {
4721
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4722
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4723

    
4724
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4725
            {
4726
                DialogMessage_Alert("Please Select Controls", "Alert");
4727
            }
4728
            else //선택된 것이 있으면
4729
            {
4730
                string MarkupData = "";
4731
                adorner_ = new AdornerFinal();
4732

    
4733
                foreach (var item in SelectLayer.Children)
4734
                {
4735
                    if (item.GetType().Name == "AdornerFinal")
4736
                    {
4737
                        adorner_ = (item as Controls.AdornerFinal);
4738
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4739
                        {
4740
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4741
                            {
4742
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4743
                                MarkupData += markupReturn.ConvertData;
4744
                            }
4745
                        }
4746
                    }
4747
                }
4748
                DialogParameters parameters = new DialogParameters()
4749
                {
4750
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4751
                    DefaultPromptResultValue = "Custom State",
4752
                    Content = "Name :",
4753
                    Header = "Insert Custom Symbol Name",
4754
                    Theme = new VisualStudio2013Theme(),
4755
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4756
                };
4757
                RadWindow.Prompt(parameters);
4758
            }
4759

    
4760
        }
4761

    
4762
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4763
        {
4764
            Save save = new Save();
4765

    
4766
            if (args.DialogResult.Value)
4767
            {
4768
                PngBitmapEncoder _Encoder = symImage(data);
4769

    
4770
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4771
                _Encoder.Save(fs);
4772
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4773

    
4774
                byte[] Img_byte = fs.ToArray();
4775

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

    
4779
                save.SymbolSave(args.PromptResult, filename, data);
4780
            }
4781
        }
4782

    
4783
        public PngBitmapEncoder symImage(string data)
4784
        {
4785

    
4786
            Canvas _canvas = new Canvas();
4787
            _canvas.Background = Brushes.White;
4788
            _canvas.Width = adorner_.BorderSize.Width;
4789
            _canvas.Height = adorner_.BorderSize.Height;
4790
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4791

    
4792
            BitmapEncoder encoder = new PngBitmapEncoder();
4793

    
4794

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

    
4797
            DrawingVisual dv = new DrawingVisual();
4798

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

    
4802
            using (DrawingContext ctx = dv.RenderOpen())
4803
            {
4804
                VisualBrush vb = new VisualBrush(_canvas);
4805
                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)));
4806
            }
4807

    
4808
            try
4809
            {
4810
                renderBitmap.Render(dv);
4811

    
4812
                GC.Collect();
4813
                GC.WaitForPendingFinalizers();
4814
                GC.Collect();
4815
                // encode png data
4816
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4817
                // puch rendered bitmap into it
4818
                pngEncoder.Interlace = PngInterlaceOption.Off;
4819
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4820
                return pngEncoder;
4821

    
4822
            }
4823
            catch (Exception ex)
4824
            {
4825
                return null;
4826
            }
4827

    
4828
        }
4829

    
4830
        public void DialogMessage_Alert(string content, string header)
4831
        {
4832
            var box = new TextBlock();
4833
            box.MinWidth = 400;
4834
            box.FontSize = 11;
4835
            //box.FontSize = 12;
4836
            box.Text = content;
4837
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4838

    
4839
            DialogParameters parameters = new DialogParameters()
4840
            {
4841
                Content = box,
4842
                Header = header,
4843
                Theme = new VisualStudio2013Theme(),
4844
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4845
            };
4846
            RadWindow.Alert(parameters);
4847
        }
4848

    
4849
        #region 캡쳐 기능
4850

    
4851
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4852
        {
4853
            if (x < 0)
4854
            {
4855
                width += x;
4856
                x = 0;
4857
            }
4858
            if (y < 0)
4859
            {
4860
                height += y;
4861
                y = 0;
4862

    
4863
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4864
            }
4865
            if (x + width > zoomAndPanCanvas.ActualWidth)
4866
            {
4867
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4868
            }
4869
            if (y + height > zoomAndPanCanvas.ActualHeight)
4870
            {
4871
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4872
            }
4873

    
4874
            byte[] pixels = CopyPixels(x, y, width, height);
4875

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

    
4878
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4879
        }
4880

    
4881
        public byte[] CopyPixels(int x, int y, int width, int height)
4882
        {
4883
            byte[] pixels = new byte[width * height * 4];
4884
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4885

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

    
4889
            return pixels;
4890
        }
4891

    
4892
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4893
        {
4894
            DrawingVisual drawingVisual = new DrawingVisual();
4895
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4896

    
4897
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4898
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4899
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4900
            drawingContext.Close();
4901

    
4902
            // 비트맵으로 변환합니다.
4903
            RenderTargetBitmap target =
4904
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4905
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4906

    
4907
            target.Render(drawingVisual);
4908
            return target;
4909
        }
4910

    
4911
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4912
        {
4913
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4914
            KCOMDataModel.DataModel.CHECK_LIST check_;
4915
            string Result = streamToBase64.ImageToBase64(source);
4916
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4917

    
4918
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4919
            {
4920
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
4921

    
4922
                //새로운 데이터 추가
4923
                if (Item == null)
4924
                {
4925
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
4926
                    {
4927
                        ID = Save.shortGuid(),
4928
                        USER_ID = App.ViewInfo.UserID,
4929
                        IMAGE_URL = Result,
4930
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4931
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4932
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4933
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4934
                        PROJECT_NO = App.ViewInfo.ProjectNO,
4935
                        STATUS = "False",
4936
                        CREATE_TIME = DateTime.Now,
4937
                        UPDATE_TIME = DateTime.Now,
4938
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4939
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
4940
                    };
4941

    
4942
                    Entity.CHECK_LIST.AddObject(check_);
4943
                }
4944
                //기존에 있던 데이터 업데이트
4945
                else
4946
                {
4947
                    Item.IMAGE_URL = Result;
4948
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4949
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4950
                }
4951

    
4952
                //Item.REV_0 = "Test";
4953

    
4954
                try
4955
                {
4956
                    Entity.SaveChanges();
4957
                }
4958
                catch (Exception ex)
4959
                {
4960

    
4961
                }
4962
                //Entity.SaveChanges();
4963
            }
4964
        }
4965

    
4966
        public void Set_Capture()
4967
        {
4968
            //double x = Canvas.GetLeft(dragCaptureBorder);
4969
            //double y = Canvas.GetTop(dragCaptureBorder);
4970
            double x = canvasDrawingMouseDownPoint.X;
4971
            double y = canvasDrawingMouseDownPoint.Y;
4972
            double width = dragCaptureBorder.Width;
4973
            double height = dragCaptureBorder.Height;
4974

    
4975
            if (width > 5 || height > 5)
4976
            {
4977
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
4978
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
4979
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
4980
            }
4981
        }
4982
        #endregion
4983

    
4984
        public void CreateControl()
4985
        {
4986
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4987
            {
4988
                ViewerDataModel.Instance.UndoDataList.Remove(i);
4989
            });
4990
            multi_Undo_Data.Markup = currentControl;
4991
            UndoData.Markup_List.Add(multi_Undo_Data);
4992
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4993
        }
4994

    
4995
        public Multi_Undo_data Control_Style(CommentUserInfo control)
4996
        {
4997
            multi_Undo_Data = new Multi_Undo_data();
4998

    
4999
            multi_Undo_Data.Markup = control;
5000

    
5001
            if ((control as IShapeControl) != null)
5002
            {
5003
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5004
            }
5005
            if ((control as IDashControl) != null)
5006
            {
5007
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5008
            }
5009
            if ((control as IPath) != null)
5010
            {
5011
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5012
            }
5013
            if ((control as UIElement) != null)
5014
            {
5015
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5016
            }
5017

    
5018
            return multi_Undo_Data;
5019
        }
5020

    
5021
        public void Undo()
5022
        {
5023
            Undo_data undo = new Undo_data();
5024
            AdornerFinal final;
5025
            ReleaseAdorner();
5026

    
5027
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5028
            if (undo == null)
5029
                return;
5030

    
5031
            switch (undo.Event)
5032
            {
5033
                case (Event_Type.Create):
5034
                    {
5035
                        foreach (var item in undo.Markup_List)
5036
                        {
5037
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5038
                        }
5039
                    }
5040
                    break;
5041
                case (Event_Type.Delete):
5042
                    {
5043
                        foreach (var item in undo.Markup_List)
5044
                        {
5045
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5046
                        }
5047
                    }
5048
                    break;
5049
                case (Event_Type.Thumb):
5050
                    {
5051
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5052

    
5053
                        foreach (var item in undo.Markup_List)
5054
                        {
5055
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5056

    
5057
                            if ((item.Markup as IViewBox) != null)
5058
                            {
5059
                                (item.Markup as IViewBox).Angle = item.Angle;
5060
                            }
5061
                            if ((item.Markup as TextControl) != null)
5062
                            {
5063
                                (item.Markup as TextControl).Angle = item.Angle;
5064
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5065
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5066
                            }
5067
                            else
5068
                            {
5069
                                (item.Markup as IPath).PointSet = item.PointSet;
5070
                                (item.Markup as IPath).updateControl();
5071
                            }
5072

    
5073
                            comment.Add(item.Markup);
5074
                        }
5075
                        final = new AdornerFinal(comment);
5076
                        SelectLayer.Children.Add(final);
5077
                        ReleaseAdorner();
5078
                    }
5079
                    break;
5080
                case (Event_Type.Select):
5081
                    {
5082
                        ReleaseAdorner();
5083
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5084

    
5085
                        foreach (var item in undo.Markup_List)
5086
                        {
5087
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5088

    
5089
                            if ((item.Markup as IPath) != null)
5090
                            {
5091
                                (item.Markup as IPath).LineSize = item.LineSize;
5092
                            }
5093
                            if ((item.Markup as UIElement) != null)
5094
                            {
5095
                                (item.Markup as UIElement).Opacity = item.Opacity;
5096
                            }
5097
                            if ((item.Markup as IDashControl) != null)
5098
                            {
5099
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5100
                            }
5101
                            if ((item.Markup as IShapeControl) != null)
5102
                            {
5103
                                (item.Markup as IShapeControl).Paint = item.paint;
5104
                            }
5105

    
5106
                            comment.Add(item.Markup);
5107
                        }
5108

    
5109
                        final = new AdornerFinal(comment);
5110
                        SelectLayer.Children.Add(final);
5111
                    }
5112
                    break;
5113
                case (Event_Type.Option):
5114
                    {
5115
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5116

    
5117
                        foreach (var item in undo.Markup_List)
5118
                        {
5119
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5120

    
5121
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5122
                            {
5123
                                (item.Markup as IPath).LineSize = undo.LineSize;
5124
                            }
5125
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5126
                            {
5127
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5128
                            }
5129
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5130
                            {
5131
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5132
                            }
5133
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5134
                            {
5135
                                (item.Markup as LineControl).Interval = undo.Interval;
5136
                            }
5137
                            else if (item.Markup as IShapeControl != null)
5138
                            {
5139
                                (item.Markup as IShapeControl).Paint = undo.paint;
5140
                            }
5141
                            comment.Add(item.Markup);
5142
                        }
5143
                        final = new AdornerFinal(comment);
5144
                        SelectLayer.Children.Add(final);
5145
                    }
5146
                    break;
5147
            }
5148
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5149
           {
5150
               i.IsUndo = true;
5151
           });
5152
        }
5153

    
5154
        public void Redo()
5155
        {
5156
            AdornerFinal final;
5157
            Undo_data redo = new Undo_data();
5158
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5159
            ReleaseAdorner();
5160
            if (redo == null)
5161
                return;
5162

    
5163
            switch (redo.Event)
5164
            {
5165
                case (Event_Type.Create):
5166
                    {
5167
                        foreach (var item in redo.Markup_List)
5168
                        {
5169
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5170
                        }
5171
                    }
5172
                    break;
5173
                case (Event_Type.Delete):
5174
                    {
5175
                        foreach (var item in redo.Markup_List)
5176
                        {
5177
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5178
                        }
5179
                    }
5180
                    break;
5181
                case (Event_Type.Thumb):
5182
                    {
5183
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5184

    
5185
                        foreach (var item in redo.Markup_List)
5186
                        {
5187
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5188

    
5189
                            if ((item.Markup as IViewBox) != null)
5190
                            {
5191
                                (item.Markup as IViewBox).Angle = item.Angle;
5192
                            }
5193
                            if ((item.Markup as TextControl) != null)
5194
                            {
5195
                                (item.Markup as TextControl).Angle = item.Angle;
5196

    
5197
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5198
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5199
                            }
5200
                            else
5201
                            {
5202
                                (item.Markup as IPath).PointSet = item.PointSet;
5203
                                (item.Markup as IPath).updateControl();
5204
                            }
5205
                            comment.Add(item.Markup);
5206
                        }
5207
                        final = new AdornerFinal(comment);
5208
                        SelectLayer.Children.Add(final);
5209
                        ReleaseAdorner();
5210
                    }
5211
                    break;
5212
                case (Event_Type.Select):
5213
                    {
5214
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5215

    
5216
                        foreach (var item in redo.Markup_List)
5217
                        {
5218
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5219

    
5220
                            if ((item.Markup as IPath) != null)
5221
                            {
5222
                                (item.Markup as IPath).LineSize = item.LineSize;
5223
                            }
5224
                            if ((item.Markup as UIElement) != null)
5225
                            {
5226
                                (item.Markup as UIElement).Opacity = item.Opacity;
5227
                            }
5228
                            if ((item.Markup as IDashControl) != null)
5229
                            {
5230
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5231
                            }
5232
                            if ((item.Markup as IShapeControl) != null)
5233
                            {
5234
                                (item.Markup as IShapeControl).Paint = item.paint;
5235
                            }
5236

    
5237
                            comment.Add(item.Markup);
5238
                        }
5239
                        final = new AdornerFinal(comment);
5240
                        SelectLayer.Children.Add(final);
5241
                    }
5242
                    break;
5243
                case (Event_Type.Option):
5244
                    {
5245
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5246

    
5247
                        foreach (var item in redo.Markup_List)
5248
                        {
5249
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5250
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5251
                            {
5252
                                (item.Markup as IPath).LineSize = redo.LineSize;
5253
                            }
5254
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5255
                            {
5256
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5257
                            }
5258
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5259
                            {
5260
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5261
                            }
5262
                            else if(redo.Interval != 0 && item.Markup as LineControl != null)
5263
                            {
5264
                                (item.Markup as LineControl).Interval = redo.Interval;
5265
                            }
5266
                            else if (item.Markup as IShapeControl != null)
5267
                            {
5268
                                (item.Markup as IShapeControl).Paint = redo.paint;
5269
                            }
5270
                            comment.Add(item.Markup);
5271
                        }
5272
                        final = new AdornerFinal(comment);
5273
                        SelectLayer.Children.Add(final);
5274
                    }
5275
                    break;
5276
            }
5277

    
5278
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5279
            {
5280
                i.IsUndo = false;
5281
            });
5282
        }
5283

    
5284
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5285
        {
5286
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5287
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5288
            {
5289
                if (items.UserID == Select_ID)
5290
                {
5291
                    foreach (var item in items.MarkupList)
5292
                    {
5293
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5294
                        {
5295
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5296
                        }
5297
                    }
5298
                }
5299
            }
5300
        }
5301

    
5302
        public void InkControl_Convert()
5303
        {
5304
            if (inkBoard.Strokes.Count > 0)
5305
            {
5306
                inkBoard.Strokes.ToList().ForEach(stroke =>
5307
                {
5308
                    List<Stroke> removingStroke = new List<Stroke>();
5309
                    StrokeCollection stC = new StrokeCollection();
5310

    
5311
                    removingStroke.Add(stroke);
5312

    
5313
                    InkToPath ip = new InkToPath();
5314
                    List<Point> inkPointSet = new List<Point>();
5315
                    PolygonControl pc = null;
5316
                    pc = new PolygonControl()
5317
                    {
5318
                        Angle = 0,
5319
                        PointSet = new List<Point>(),
5320
                        ControlType = ControlType.Ink
5321
                    };
5322
                    foreach (var item in removingStroke)
5323
                    {
5324
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5325
                        inkBoard.Strokes.Remove(item);
5326
                    }
5327
                    if (inkPointSet.Count != 0)
5328
                    {
5329
                        //강인구 추가(PenControl Undo Redo 추가)
5330
                        UndoData = new Undo_data()
5331
                        {
5332
                            IsUndo = false,
5333
                            Event = Event_Type.Create,
5334
                            EventTime = DateTime.Now,
5335
                            Markup_List = new List<Multi_Undo_data>()
5336
                        };
5337

    
5338
                        pc.StartPoint = inkPointSet[0];
5339
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5340
                        pc.PointSet = inkPointSet;
5341
                        pc.LineSize = 3;
5342
                        pc.CommentID = Save.shortGuid();
5343
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5344
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5345
                        pc.SetPolyPath();
5346

    
5347
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5348
                        {
5349
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5350
                        });
5351
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5352
                        UndoData.Markup_List.Add(multi_Undo_Data);
5353
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5354
                    }
5355
                });
5356
            }
5357
        }
5358

    
5359
        /// <summary>
5360
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5361
        /// </summary>
5362
        /// <param name="StartP">StartPoint</param>
5363
        /// <param name="EndP">EndPoint</param>
5364
        /// <returns>Return_EndPoint</returns>
5365
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5366
        {
5367
            Point Return_Point = new Point();
5368

    
5369
            double dx = EndP.X - StartP.X;
5370
            double dy = EndP.Y - StartP.Y;
5371
            double length;
5372

    
5373
            switch (controlType)
5374
            {
5375
                case ControlType.Triangle:
5376
                    {
5377
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5378
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5379
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5380
                    }
5381
                    break;
5382
                default:
5383
                    {
5384
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5385
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5386
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5387
                    }
5388
                    break;
5389
            }
5390

    
5391
            return Return_Point;
5392
        }
5393

    
5394
        /// <summary>
5395
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5396
        /// </summary>
5397
        /// <author>humkyung</author>
5398
        /// <date>2018.04.26</date>
5399
        /// <param name="StartP"></param>
5400
        /// <param name="EndP"></param>
5401
        /// <returns></returns>
5402
        /// <history>humkyung 2018.05.11 apply axis lock</history>
5403
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis=false)
5404
        {
5405
            List<Point> res = new List<Point>();
5406

    
5407
            double dx = EndP.X - StartP.X;
5408
            double dy = EndP.Y - StartP.Y;
5409
            double length = Math.Sqrt(dx * dx + dy * dy);
5410
            double baseLength = length * Math.Tan(30.0* Math.PI / 180.0);
5411
            dx /= length;
5412
            dy /= length;
5413
            double tmp = dx;
5414
            dx = -dy; dy = tmp; /// rotate by 90 degree
5415

    
5416
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5417
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5418

    
5419
            return res;
5420
        }
5421
    }
5422
}
클립보드 이미지 추가 (최대 크기: 500 MB)