프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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
                        //TODO: 강인구 추가
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
                        ///TODO: 
2001
                        case ControlType.Stamp:
2002
                            {
2003
                                var control = currentControl as SymControlN;
2004

    
2005
                                if (control != null)
2006
                                {
2007

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

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

    
2015

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

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

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

    
2028
                                        //control.ApplyTemplate();
2029

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

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

    
2041

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

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

    
2069

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

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

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

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

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

    
2114
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2115
                    }
2116

    
2117
                    e.Handled = true;
2118
                }
2119

    
2120

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

    
2143

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

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

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

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

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

    
2194
                //}
2195

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

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

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

    
2221
                #endregion
2222
            }
2223
        }
2224

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

    
2227
        private EllipseGeometry hitArea = new EllipseGeometry();
2228

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

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

    
2239
                    SetCursor();
2240

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

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

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

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

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

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

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

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

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

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

    
2318
                zoomAndPanControl.ReleaseMouseCapture();
2319

    
2320

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

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

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

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

    
2342
        }
2343

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

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

    
2356
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2357

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

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

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

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

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

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

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

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

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

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

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

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

    
2478

    
2479
        }
2480

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

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

    
2497
                }
2498
            }
2499
            return result;
2500
        }
2501

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

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

    
2534
            zoomAndPanControl.RotationAngle = rotate.Angle;
2535

    
2536

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

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

    
2550

    
2551
        }
2552

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

    
2561
            InkControl_Convert();
2562

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2686

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2849
                    SelectLayer.Children.Add(final);
2850

    
2851
                    //Control_Init(control);
2852

    
2853

    
2854
                    
2855

    
2856

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3323
                            }
3324

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3568
                                        CreateControl();
3569

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

    
3586

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3901
                                    control.SetPolyPath();
3902

    
3903
                                    control.ApplyOverViewData();
3904

    
3905
                                    CreateControl();
3906

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

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

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

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

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

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

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

    
4096
            }
4097

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

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

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

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

    
4150

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

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

    
4159

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

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

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

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

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

    
4196
            inkBoard.Strokes.Add(stroke);
4197

    
4198
        }
4199

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

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

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

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

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

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

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

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

    
4252

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

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

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

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

    
4293
        }
4294

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4522
                }
4523
            }
4524
        }
4525

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

    
4532
                var uri = CurrentRev.TO_VENDOR;
4533

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4701

    
4702
        }
4703

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

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

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

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

    
4761
        }
4762

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

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

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

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

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

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

    
4784
        public PngBitmapEncoder symImage(string data)
4785
        {
4786

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

    
4793
            BitmapEncoder encoder = new PngBitmapEncoder();
4794

    
4795

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

    
4798
            DrawingVisual dv = new DrawingVisual();
4799

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

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

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

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

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

    
4829
        }
4830

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

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

    
4850
        #region 캡쳐 기능
4851

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

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

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

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

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

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

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

    
4890
            return pixels;
4891
        }
4892

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5000
            multi_Undo_Data.Markup = control;
5001

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

    
5019
            return multi_Undo_Data;
5020
        }
5021

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5312
                    removingStroke.Add(stroke);
5313

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

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

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

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

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

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

    
5392
            return Return_Point;
5393
        }
5394

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

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

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

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