프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 8bb375a7

이력 | 보기 | 이력해설 | 다운로드 (256 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 Cursor cursor { get; set; }
120
        private Point canvasDrawingMouseDownPoint;
121
        public string filename { get; set; }
122
        private Point canvasZoomPanningMouseDownPoint;
123
        public Point getCurrentPoint;
124
        private Point canvasZoommovingMouseDownPoint;
125
        private int rotateOffSet = 0;
126
        List<object> ControlList = new List<object>();
127
        private ListBox listBox = new ListBox();
128
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
129
        private bool isDraggingSelectionRect = false;
130
        DrawingAttributes inkDA = new DrawingAttributes();
131
        private VPRevision CurrentRev { get; set; }
132
        public RadRibbonButton btnConsolidate { get; set; }
133
        public RadRibbonButton btnFinalPDF { get; set; }
134
        public RadRibbonButton btnTeamConsolidate { get; set; }
135
        public string Filename_ { get; set; }
136
        public double L_Size = 0;
137
        public AdornerFinal adorner_;
138
        public Multi_Undo_data multi_Undo_Data;
139
        public string Symbol_ID = "";
140
        /// <summary>
141
        /// Set to 'true' when the left mouse-button is down.
142
        /// </summary>
143
        public bool isLeftMouseButtonDownOnWindow = false;
144

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

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

    
168
                }
169
            }
170
        }
171

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

    
196
        public bool IsSyncPDFMode { get; set; }
197

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

    
222
        #endregion
223

    
224

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

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

    
245
            return false;
246
        }
247

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

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

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

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

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

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

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

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

    
311
            DeleteItem(item);
312
        }
313

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

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

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

    
333

    
334
        }
335

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

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

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

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

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

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

    
386
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
387

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

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

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

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

    
455
        }
456

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

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

    
464
            InkControl_Convert();
465

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

    
471

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

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

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

    
486
            #endregion
487

    
488
            ViewerDataModel.Instance.PageNumber = BalancePoint;
489

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

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

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

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

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

    
511

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

    
517

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

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

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

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

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

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

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

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

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

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

    
592
            this.pageNavigator.SetNextPage();
593

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

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

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

    
621

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

    
627

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

    
636
            }
637

    
638

    
639

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

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

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

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

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

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

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

    
697
        #region ZoomIn & ZoomOut
698

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

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

    
711

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

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

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

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

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

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

    
780
        #endregion
781

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

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

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

    
794
        }
795

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

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

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

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

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

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

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

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

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

    
943

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

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

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

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

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

    
1023
                //        default:
1024
                //            {
1025

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

    
1033
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1034

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

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

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

    
1049
                //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1050

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

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

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

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

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

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

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

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

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

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

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

    
1182

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

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

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

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

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

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

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

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

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

    
1283
                            }
1284
                            break;
1285

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

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

    
1311

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

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

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

    
1348

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

    
1359
                            }
1360
                            break;
1361

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

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

    
1386

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

    
1397
                            }
1398
                            break;
1399

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

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

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

    
1434
                            }
1435
                            break;
1436

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

    
1441
                                if (control != null)
1442
                                {
1443

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

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

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

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

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

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

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

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

    
1497

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

    
1509
                            }
1510
                            break;
1511

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

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

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

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

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

    
1582
                                        }
1583

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

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

    
1596
                            }
1597
                            break;
1598

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

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

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

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

    
1636
                                }
1637
                            }
1638
                            break;
1639

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

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

    
1649
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1650

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

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

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

    
1674

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1779
                                if (control != null)
1780
                                {
1781
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1782
                                    Point tempPoint = control.EndPoint;
1783

    
1784

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

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

    
1806
                        case ControlType.ArrowTextBorderControl:
1807
                            {
1808
                                var control = currentControl as ArrowTextControl;
1809

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

    
1831
                            }
1832
                            break;
1833
                        case ControlType.ArrowTransTextBorderControl:
1834
                            {
1835
                                var control = currentControl as ArrowTextControl;
1836

    
1837
                                if (control != null)
1838
                                {
1839
                                    control.isFixed = true;
1840
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1841
                                    Point tempPoint = control.EndPoint;
1842
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1843
                                    {
1844
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1845
                                        control.EndPoint = tempPoint;
1846
                                    }
1847
                                    else
1848
                                    {
1849
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1850
                                    }
1851
                                    control.PointSet = new List<Point>
1852
                                            {
1853
                                                control.StartPoint,
1854
                                                control.MidPoint,
1855
                                                control.EndPoint,
1856
                                            };
1857
                                }
1858

    
1859
                            }
1860
                            break;
1861
                        case ControlType.ArrowTextCloudControl:
1862
                            {
1863
                                var control = currentControl as ArrowTextControl;
1864

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

    
1886
                            }
1887
                            break;
1888
                        case ControlType.ArrowTransTextCloudControl:
1889
                            {
1890
                                var control = currentControl as ArrowTextControl;
1891

    
1892
                                if (control != null)
1893
                                {
1894
                                    control.isFixed = true;
1895
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1896
                                    Point tempPoint = control.EndPoint;
1897
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1898
                                    {
1899
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1900
                                        control.EndPoint = tempPoint;
1901
                                    }
1902
                                    else
1903
                                    {
1904
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1905
                                    }
1906
                                    control.PointSet = new List<Point>
1907
                                            {
1908
                                                control.StartPoint,
1909
                                                control.MidPoint,
1910
                                                control.EndPoint,
1911
                                            };
1912
                                }
1913

    
1914
                            }
1915
                            break;
1916
                        case ControlType.PolygonControl:
1917
                            {
1918
                                var control = currentControl as PolygonControl;
1919

    
1920
                                if (control != null)
1921
                                {
1922
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1923
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1924
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1925
                                    control.SetPolyPath();
1926
                                    //강인구 추가
1927
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1928
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1929
                                }
1930
                            }
1931
                            break;
1932
                        //강인구 추가
1933
                        case ControlType.Sign:
1934
                            {
1935
                                var control = currentControl as SignControl;
1936

    
1937
                                if (control != null)
1938
                                {
1939
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1940
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1941
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1942
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1943

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

    
1962
                                        control.SignImage = returnImage;
1963
                                    }
1964
                                    control.PointSet = new List<Point>
1965
                                        {
1966
                                            control.StartPoint,
1967
                                            control.LeftBottomPoint,
1968
                                            control.EndPoint,
1969
                                            control.TopRightPoint,
1970
                                        };
1971
                                }
1972
                            }
1973
                            break;
1974
                        //강인구 추가
1975
                        case ControlType.Symbol:
1976
                            {
1977
                                var control = currentControl as SymControl;
1978

    
1979
                                if (control != null)
1980
                                {
1981
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1982
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1983
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1984
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1985
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1986
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
1987

    
1988
                                    if (control.StartPoint != control.EndPoint)
1989
                                    {
1990
                                        if (control.PathData == null)
1991
                                        {
1992
                                            using (StringToPathConverter Convert = new StringToPathConverter())
1993
                                            {
1994
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
1995
                                            }
1996
                                        }
1997
                                    }
1998

    
1999
                                    control.PointSet = new List<Point>
2000
                                        {
2001
                                            control.StartPoint,
2002
                                            control.LeftBottomPoint,
2003
                                            control.EndPoint,
2004
                                            control.TopRightPoint,
2005
                                        };
2006
                                }
2007
                            }
2008
                            break;
2009
                        case ControlType.Stamp:
2010
                            {
2011
                                var control = currentControl as SymControlN;
2012

    
2013
                                if (control != null)
2014
                                {
2015

    
2016
                                    if (control.StartPoint == control.EndPoint)
2017
                                    {
2018
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2019

    
2020
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2021
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2022

    
2023

    
2024
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2025

    
2026
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2027
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2028
                                        writer.Write(xamlData);
2029
                                        writer.Flush();
2030
                                        stream.Position = 0;
2031

    
2032
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2033
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2034
                                        UIElement ob = obj as UIElement;
2035

    
2036
                                        //control.ApplyTemplate();
2037

    
2038
                                        control.SetViewBox();
2039
                                        control.PathXathData = appovalData;
2040
                                        control.Base_ViewBox.Child = ob;
2041
                                    }
2042

    
2043
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2044
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2045
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2046
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2047
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2048

    
2049

    
2050
                                    control.PointSet = new List<Point>
2051
                                    {
2052
                                        control.StartPoint,
2053
                                        control.LeftBottomPoint,
2054
                                        control.EndPoint,
2055
                                        control.TopRightPoint,
2056
                                    };
2057
                                }
2058
                            }
2059
                            break;
2060
                        case ControlType.Mark:
2061
                            {
2062
                                var control = currentControl as RectangleControl;
2063

    
2064
                                if (control != null)
2065
                                {
2066
                                    if (move.mousemode == MouseMode.Drawing)
2067
                                    {
2068
                                        //move.control_Move(ControlList, true, moveX, moveY);
2069
                                    }
2070
                                    else
2071
                                    {
2072
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2073
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2074
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2075
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2076

    
2077

    
2078
                                        control.PointSet = new List<Point>
2079
                                    {
2080
                                        control.StartPoint,
2081
                                        control.LeftBottomPoint,
2082
                                        control.EndPoint,
2083
                                        control.TopRightPoint,
2084
                                    };
2085
                                    }
2086

    
2087
                                    //강인구 추가
2088
                                    control.Paint = PaintSet.Fill;
2089
                                }
2090
                            }
2091
                            break;
2092
                        case ControlType.PenControl:
2093
                            {
2094
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2095
                                //inkBoard.Strokes.Add(stroke);
2096
                            }
2097
                            break;
2098
                        default:
2099
                            break;
2100
                    }
2101
                }
2102
            }
2103
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2104
            {
2105
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2106

    
2107
                if (isDraggingSelectionRect)
2108
                {
2109
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2110

    
2111
                    e.Handled = true;
2112
                }
2113
                else if (isLeftMouseButtonDownOnWindow)
2114
                {
2115
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2116
                    double dragDistance = Math.Abs(dragDelta.Length);
2117

    
2118
                    if (dragDistance > DragThreshold)
2119
                    {
2120
                        isDraggingSelectionRect = true;
2121

    
2122
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2123
                    }
2124

    
2125
                    e.Handled = true;
2126
                }
2127

    
2128

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

    
2151

    
2152
                    //        p1 = SelectionPath.Data.Bounds;
2153
                    //        bool intersectCheck = false;
2154
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2155
                    //        {
2156
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2157
                    //            p1.Intersect(p3);
2158
                    //            if (!p1.IsEmpty)
2159
                    //            {
2160
                    //                intersectCheck = true;
2161
                    //            }
2162
                    //        }
2163
                    //        if (intersectCheck)
2164
                    //        {
2165
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2166
                    //        }
2167

    
2168
                    //    }
2169
                    //    else
2170
                    //    {
2171
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2172
                    //    }
2173
                    //}
2174

    
2175
                    e.Handled = true;
2176
                }
2177
            }
2178
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2179
            {
2180
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2181
                if (control != null)
2182
                {
2183
                    this.cursor = Cursors.Hand;
2184
                    SetCursor();
2185
                }
2186
                else
2187
                {
2188
                    this.cursor = Cursors.Arrow;
2189
                    SetCursor();
2190
                }
2191
            }
2192
            else
2193
            {
2194
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2195

    
2196
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2197
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2198

    
2199
                //if (hitList.Count > 0)
2200
                //{
2201

    
2202
                //}
2203

    
2204
                #region 조건 설정 : firstCondition
2205
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2206
                //pnts = generalTransform.Transform(pnts);
2207
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2208
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2209
                //                               this.DeepLayer._BaseLayer).ToObservable()
2210
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2211
                //                      select kkk).FirstOrDefault();
2212

    
2213
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2214
                //if (canvas !=null)
2215
                //{
2216
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2217
                //    {
2218
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2219
                //        if (uiElement!=null)
2220
                //        {
2221
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2222
                //        }
2223
                //    }
2224
                //}
2225

    
2226
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2227
                //hitResultsList.Clear();
2228

    
2229
                #endregion
2230
            }
2231
        }
2232

    
2233
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2234

    
2235
        private EllipseGeometry hitArea = new EllipseGeometry();
2236

    
2237
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2238
        {
2239
            IsDrawing = false;
2240

    
2241
            if (mouseHandlingMode != MouseHandlingMode.None)
2242
            {
2243
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2244
                {
2245
                    this.cursor = Cursors.Arrow;
2246

    
2247
                    SetCursor();
2248

    
2249
                    switch (controlType)
2250
                    {
2251
                        case ControlType.None:
2252
                            break;
2253
                        case ControlType.Rectangle:
2254
                            {
2255

    
2256
                            }
2257
                            break;
2258
                        case ControlType.PenControl:
2259
                            {
2260

    
2261
                            }
2262
                            break;
2263
                        default:
2264
                            break;
2265
                    }
2266
                }
2267
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2268
                {
2269
                    if (isLeftMouseButtonDownOnWindow)
2270
                    {
2271
                        bool wasDragSelectionApplied = false;
2272

    
2273
                        if (isDraggingSelectionRect)
2274
                        {
2275
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2276
                            {
2277
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2278
                                mouseHandlingMode = MouseHandlingMode.None;
2279
                                Set_Capture();
2280

    
2281
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2282
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2283
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2284
                            }
2285
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2286
                            {
2287
                                ApplyDragSelectionRect();
2288
                            }
2289
                            else
2290
                            {
2291
                                double x = Canvas.GetLeft(dragZoomBorder);
2292
                                double y = Canvas.GetTop(dragZoomBorder);
2293
                                double width = dragZoomBorder.Width;
2294
                                double height = dragZoomBorder.Height;
2295
                                Rect dragRect = new Rect(x, y, width, height);
2296

    
2297
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2298

    
2299
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2300
                            }
2301

    
2302
                            isDraggingSelectionRect = false;
2303
                            e.Handled = true;
2304
                            wasDragSelectionApplied = true;
2305
                        }
2306

    
2307
                        if (isLeftMouseButtonDownOnWindow)
2308
                        {
2309
                            isLeftMouseButtonDownOnWindow = false;
2310
                            this.ReleaseMouseCapture();
2311
                            e.Handled = true;
2312
                        }
2313

    
2314
                        if (!wasDragSelectionApplied)
2315
                        {
2316
                            init();
2317
                        }
2318
                    }
2319
                }
2320
                else if (mouseButtonDown == MouseButton.Right)
2321
                {
2322
                    this.cursor = Cursors.Arrow;
2323
                    SetCursor();
2324
                }
2325

    
2326
                zoomAndPanControl.ReleaseMouseCapture();
2327

    
2328

    
2329
                e.Handled = true;
2330
            }
2331
            else
2332
            {
2333
                this.cursor = Cursors.Arrow;
2334
                SetCursor();
2335
            }
2336
            mouseButtonDown = MouseButton.Left;
2337

    
2338
            //controlType = ControlType.SingleLine;
2339
        }
2340

    
2341
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2342
        {
2343
            mouseButtonDown = MouseButton.Left;
2344
            this.Cursor = Cursors.Arrow;
2345
        }
2346

    
2347
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2348
        {
2349

    
2350
        }
2351

    
2352
        private void ApplyDragSelectionRect()
2353
        {
2354
            multi_Undo_Data = new Multi_Undo_data();
2355

    
2356
            UndoData = new Undo_data()
2357
            {
2358
                IsUndo = false,
2359
                Event = Event_Type.Select,
2360
                EventTime = DateTime.Now,
2361
                Markup_List = new List<Multi_Undo_data>()
2362
            };
2363

    
2364
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2365

    
2366
            double x = Canvas.GetLeft(dragSelectionBorder);
2367
            double y = Canvas.GetTop(dragSelectionBorder);
2368
            double width = dragSelectionBorder.Width;
2369
            double height = dragSelectionBorder.Height;
2370
            Rect dragRect = new Rect(x, y, width, height);
2371
            Boolean Flag = false;
2372
            dragRect.Inflate(width / 10, height / 10);
2373
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2374
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2375

    
2376
            dragRect = new Rect(x, y, width, height);
2377
            dragRect.Inflate(width / 10, height / 10);
2378

    
2379
            foreach (var item in Items)
2380
            {
2381
                Flag = move.control_Select(item, dragRect);
2382

    
2383
                if (Flag)
2384
                {
2385
                    adornerSet.Add(item);
2386
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2387

    
2388
                    Control_Style(item);
2389
                    UndoData.Markup_List.Add(multi_Undo_Data);
2390
                    multi_Undo_Data = new Multi_Undo_data();
2391
                }
2392
            }
2393
            if (adornerSet.Count > 0)
2394
            {
2395
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2396
                {
2397
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2398
                });
2399
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2400

    
2401
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2402
                SelectLayer.Children.Add(final);
2403
            }
2404
        }
2405

    
2406
        private void InitDragSelectionRect(Point pt1, Point pt2)
2407
        {
2408
            //캡쳐 중
2409
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2410
            {
2411
                dragCaptureBorder.Visibility = Visibility.Visible;
2412
            }
2413
            //선택 중
2414
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2415
            {
2416
                
2417
                dragSelectionBorder.Visibility = Visibility.Visible;
2418
            }
2419
            else
2420
            {
2421
                dragZoomBorder.Visibility = Visibility.Visible;
2422
            }
2423
            UpdateDragSelectionRect(pt1, pt2);
2424
        }
2425

    
2426
        /// <summary>
2427
        /// Update the position and size of the rectangle used for drag selection.
2428
        /// </summary>
2429
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2430
        {
2431
            double x, y, width, height;
2432

    
2433
            //
2434
            // Determine x,y,width and height of the rect inverting the points if necessary.
2435
            // 
2436

    
2437
            if (pt2.X < pt1.X)
2438
            {
2439
                x = pt2.X;
2440
                width = pt1.X - pt2.X;
2441
            }
2442
            else
2443
            {
2444
                x = pt1.X;
2445
                width = pt2.X - pt1.X;
2446
            }
2447

    
2448
            if (pt2.Y < pt1.Y)
2449
            {
2450
                y = pt2.Y;
2451
                height = pt1.Y - pt2.Y;
2452
            }
2453
            else
2454
            {
2455
                y = pt1.Y;
2456
                height = pt2.Y - pt1.Y;
2457
            }
2458

    
2459
            //
2460
            // Update the coordinates of the rectangle used for drag selection.
2461
            //
2462
            //캡쳐 중
2463
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2464
            {
2465
                Canvas.SetLeft(dragCaptureBorder, x);
2466
                Canvas.SetTop(dragCaptureBorder, y);
2467
                dragCaptureBorder.Width = width;
2468
                dragCaptureBorder.Height = height;
2469
            }
2470
            //선택 중
2471
            else if(mouseHandlingMode == MouseHandlingMode.Selecting)
2472
            {
2473
                Canvas.SetLeft(dragSelectionBorder, x);
2474
                Canvas.SetTop(dragSelectionBorder, y);
2475
                dragSelectionBorder.Width = width;
2476
                dragSelectionBorder.Height = height;
2477
            }
2478
            else
2479
            {
2480
                Canvas.SetLeft(dragZoomBorder, x);
2481
                Canvas.SetTop(dragZoomBorder, y);
2482
                dragZoomBorder.Width = width;
2483
                dragZoomBorder.Height = height;
2484
            }
2485

    
2486

    
2487
        }
2488

    
2489
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2490
        {
2491
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2492

    
2493
            bool result = false;
2494
            if (dragRect.Contains(controlRect))
2495
            {
2496
                result = true;
2497
                //잡은 객체들을 담은 리스트
2498
                try
2499
                {
2500
                    selected_item.Add(OverViewPathData, type.ToString());
2501
                }
2502
                catch (Exception)
2503
                {
2504

    
2505
                }
2506
            }
2507
            return result;
2508
        }
2509

    
2510
        private void drawingPannelRotate(double angle)
2511
        {
2512
            rotate.Angle = angle;
2513
            var rotationNum = Math.Abs((rotate.Angle / 90));
2514

    
2515
            if (angle == 90 || angle == 270)
2516
            {
2517
                double emptySize = zoomAndPanCanvas.Width;
2518
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2519
                zoomAndPanCanvas.Height = emptySize;
2520
            }
2521
            if (angle == 0)
2522
            {
2523
                translate.X = 0;
2524
                translate.Y = 0;
2525
            }
2526
            else if (angle == 90)
2527
            {
2528
                translate.X = zoomAndPanCanvas.Width;
2529
                translate.Y = 0;
2530
            }
2531
            else if (angle == 180)
2532
            {
2533
                translate.X = zoomAndPanCanvas.Width;
2534
                translate.Y = zoomAndPanCanvas.Height;
2535
            }
2536
            else
2537
            {
2538
                translate.X = 0;
2539
                translate.Y = zoomAndPanCanvas.Height;
2540
            }
2541

    
2542
            zoomAndPanControl.RotationAngle = rotate.Angle;
2543

    
2544

    
2545
            if (!testPanel2.IsHidden)
2546
            {
2547
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2548
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2549
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2550
            }
2551

    
2552
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2553
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2554
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2555
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2556
            ViewerDataModel.Instance.Angle = rotate.Angle;
2557

    
2558

    
2559
        }
2560

    
2561
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2562
        {
2563
            InkControl_Convert();
2564

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

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

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

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

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

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

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

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

    
2618
                this.cursor = Cursors.Arrow;
2619
                SetCursor();
2620

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

    
2645
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2646

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

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

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

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

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

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

    
2688

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

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

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

    
2715
                        Control_Style(control);
2716
                        UndoData.Markup_List.Add(multi_Undo_Data);
2717

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

    
2743
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2744

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

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

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

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

    
2837
                        Control_Style(control);
2838
                        UndoData.Markup_List.Add(multi_Undo_Data);
2839

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

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

    
2849
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2850

    
2851
                    SelectLayer.Children.Add(final);
2852

    
2853
                    //Control_Init(control);
2854

    
2855

    
2856
                    
2857

    
2858

    
2859
                    //강인구 폰트 변경 보류
2860

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

    
2872
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2873
                    //    {
2874

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

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

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

    
2901
                    //mouseHandlingMode = MouseHandlingMode.Adorner;
2902
                }
2903
            }
2904

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3242
                                if (mouseButtonDown == MouseButton.Right)
3243
                                {
3244
                                    CreateControl();
3245

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

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

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

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

    
3325
                            }
3326

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

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

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

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

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

    
3429
                                    control.isTransOn = true;
3430
                                    var firstPoint = control.PointSet.First();
3431

    
3432
                                    control.PointSet.Add(firstPoint);
3433
                                    control.DrawingCloud();
3434
                                    control.ApplyOverViewData();
3435

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

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

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

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

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

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

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

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

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

    
3570
                                        CreateControl();
3571

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

    
3588

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

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

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

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

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

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

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

    
3662
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3663

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

    
3666
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3667

    
3668
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3669

    
3670
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3671

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

    
3700
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3701

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

    
3704
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3705

    
3706
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3707

    
3708
                                        (currentControl as ArrowTextControl).isFixed = true;
3709
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3710

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

    
3742
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3743

    
3744
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3745

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

    
3749
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3750

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

    
3782
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3783

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

    
3786
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3787

    
3788
                                        (currentControl as ArrowTextControl).isFixed = true;
3789
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3790

    
3791
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3792

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

    
3824
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3825

    
3826
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3827

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

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

    
3863
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3864

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

    
3867
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3868

    
3869
                                        (currentControl as ArrowTextControl).isFixed = true;
3870
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3871

    
3872
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3873

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

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

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

    
3903
                                    control.SetPolyPath();
3904

    
3905
                                    control.ApplyOverViewData();
3906

    
3907
                                    CreateControl();
3908

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

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

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

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

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

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

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

    
4098
            }
4099

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

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

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

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

    
4153

    
4154
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4155
                UndoData.Markup_List.Add(multi_Undo_Data);
4156
                multi_Undo_Data = new Multi_Undo_data();
4157

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

    
4162

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

    
4172
        private void RemovePointStroke(Point P)
4173
        {
4174
            foreach (Stroke hits in inkBoard.Strokes)
4175
            {
4176
                foreach (StylusPoint sty in hits.StylusPoints)
4177
                {
4178

    
4179
                }
4180
                if (hits.HitTest(P))
4181
                {
4182
                    inkBoard.Strokes.Remove(hits);
4183
                    return;
4184
                }
4185
            }
4186
        }
4187

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

    
4195
            stroke.DrawingAttributes.Color = Colors.Red;
4196
            stroke.DrawingAttributes.Width = 4;
4197
            stroke.DrawingAttributes.Height = 4;
4198

    
4199
            inkBoard.Strokes.Add(stroke);
4200

    
4201
        }
4202

    
4203
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4204
        {
4205
            ConsolidationMethod();
4206
        }
4207

    
4208
        public void ConsolidationMethod()
4209
        {
4210
            ChangeCommentReact();
4211

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

    
4219
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4220
                {
4221
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4222
                }
4223

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

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

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

    
4252
                    Entity.MARKUP_INFO.AddObject(info);
4253
                    Entity.SaveChanges();
4254

    
4255

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

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

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

    
4293
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4294
        {
4295

    
4296
        }
4297

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

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

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

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

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

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

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

    
4389
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4390
        {
4391

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

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

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

    
4424
                if (ViewerDataModel.Instance.PageNumber == 0)
4425
                {
4426
                    ViewerDataModel.Instance.PageNumber = 1;
4427
                }
4428

    
4429
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4430
                {
4431
                }
4432
                else
4433
                {
4434
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4435
                }
4436

    
4437
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4438
                {
4439

    
4440
                }
4441
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4442
                {
4443
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4444
                }
4445

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

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

    
4470
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4471
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4472
                        }
4473

    
4474
                    }
4475
                    else
4476
                    {
4477
                        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);
4478

    
4479
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4480

    
4481
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4482
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4483
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4484

    
4485
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4486
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4487

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

    
4496
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4497
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4498
                            };
4499
                        }
4500
                    }
4501

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

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

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

    
4525
                }
4526
            }
4527
        }
4528

    
4529
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4530
        {
4531
            if (MarkupMode.IsChecked)
4532
            {
4533
                IsSyncPDFMode = true;
4534

    
4535
                var uri = CurrentRev.TO_VENDOR;
4536

    
4537
                if (ViewerDataModel.Instance.PageNumber == 0)
4538
                {
4539
                    ViewerDataModel.Instance.PageNumber = 1;
4540
                }
4541

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

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

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

    
4572
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4573

    
4574
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4575
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4576
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4577

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

    
4594
        private void RadButton_Click(object sender, RoutedEventArgs e)
4595
        {
4596
            gridViewHistory_Busy.IsBusy = true;
4597

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

    
4608
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4609
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4610

    
4611
                        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);
4612

    
4613
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4614

    
4615
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4616

    
4617
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4618
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4619
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4620

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

    
4631
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4632
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4633
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4634
                        zoomAndPanControl2.ApplyTemplate();
4635
                        zoomAndPanControl2.UpdateLayout();
4636

    
4637
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4638
                        {
4639
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4640
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4641
                        }
4642

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

    
4652
        public void Sync_Event(VPRevision Currnet_Rev)
4653
        {
4654
            CurrentRev = Currnet_Rev;
4655

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

    
4662
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4663
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4664

    
4665
                    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);
4666

    
4667
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4668

    
4669
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4670

    
4671
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4672
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4673
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4674

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

    
4685
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4686
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4687
                    zoomAndPanControl2.ApplyTemplate();
4688
                    zoomAndPanControl2.UpdateLayout();
4689

    
4690
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4691
                    {
4692
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4693
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4694
                    }
4695
                    //}
4696

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

    
4704

    
4705
        }
4706

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

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

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

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

    
4764
        }
4765

    
4766
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4767
        {
4768
            Save save = new Save();
4769

    
4770
            if (args.DialogResult.Value)
4771
            {
4772
                PngBitmapEncoder _Encoder = symImage(data);
4773

    
4774
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4775
                _Encoder.Save(fs);
4776
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4777

    
4778
                byte[] Img_byte = fs.ToArray();
4779

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

    
4783
                save.SymbolSave(args.PromptResult, filename, data);
4784
            }
4785
        }
4786

    
4787
        public PngBitmapEncoder symImage(string data)
4788
        {
4789

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

    
4796
            BitmapEncoder encoder = new PngBitmapEncoder();
4797

    
4798

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

    
4801
            DrawingVisual dv = new DrawingVisual();
4802

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

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

    
4812
            try
4813
            {
4814
                renderBitmap.Render(dv);
4815

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

    
4826
            }
4827
            catch (Exception ex)
4828
            {
4829
                return null;
4830
            }
4831

    
4832
        }
4833

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

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

    
4853
        #region 캡쳐 기능
4854

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

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

    
4878
            byte[] pixels = CopyPixels(x, y, width, height);
4879

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

    
4882
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4883
        }
4884

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

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

    
4893
            return pixels;
4894
        }
4895

    
4896
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4897
        {
4898
            DrawingVisual drawingVisual = new DrawingVisual();
4899
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4900

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

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

    
4911
            target.Render(drawingVisual);
4912
            return target;
4913
        }
4914

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

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

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

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

    
4956
                //Item.REV_0 = "Test";
4957

    
4958
                try
4959
                {
4960
                    Entity.SaveChanges();
4961
                }
4962
                catch (Exception ex)
4963
                {
4964

    
4965
                }
4966
                //Entity.SaveChanges();
4967
            }
4968
        }
4969

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

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

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

    
4999
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5000
        {
5001
            multi_Undo_Data = new Multi_Undo_data();
5002

    
5003
            multi_Undo_Data.Markup = control;
5004

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

    
5022
            return multi_Undo_Data;
5023
        }
5024

    
5025
        public void Undo()
5026
        {
5027
            Undo_data undo = new Undo_data();
5028
            AdornerFinal final;
5029
            ReleaseAdorner();
5030

    
5031
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5032
            if (undo == null)
5033
                return;
5034

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

    
5057
                        foreach (var item in undo.Markup_List)
5058
                        {
5059
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5060

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

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

    
5089
                        foreach (var item in undo.Markup_List)
5090
                        {
5091
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5092

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

    
5110
                            comment.Add(item.Markup);
5111
                        }
5112

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

    
5121
                        foreach (var item in undo.Markup_List)
5122
                        {
5123
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5124

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

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

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

    
5189
                        foreach (var item in redo.Markup_List)
5190
                        {
5191
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5192

    
5193
                            if ((item.Markup as IViewBox) != null)
5194
                            {
5195
                                (item.Markup as IViewBox).Angle = item.Angle;
5196
                            }
5197
                            if ((item.Markup as TextControl) != null)
5198
                            {
5199
                                (item.Markup as TextControl).Angle = item.Angle;
5200

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

    
5220
                        foreach (var item in redo.Markup_List)
5221
                        {
5222
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5223

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

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

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

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

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

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

    
5315
                    removingStroke.Add(stroke);
5316

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

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

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

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

    
5373
            double dx = EndP.X - StartP.X;
5374
            double dy = EndP.Y - StartP.Y;
5375
            double length;
5376

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

    
5395
            return Return_Point;
5396
        }
5397

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

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

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

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