프로젝트

일반

사용자정보

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

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

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

    
1043
                zoomAndPanControl.ContentOffsetX += 1;
1044
                zoomAndPanControl.ContentOffsetY += 1;
1045

    
1046
                //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1047
                //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1048
            }
1049

    
1050
            if (mouseButtonDown == MouseButton.Right)
1051
            {
1052
                SetCursor();
1053
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1054
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1055

    
1056
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1057
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1058
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1059
            }
1060
            //else if (currentControl != null && mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1061
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1062
            {
1063
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1064
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1065
                SetCursor();
1066

    
1067
                if (IsDrawing)
1068
                {
1069
                    if (currentControl == null)
1070
                    {
1071
                        switch (controlType)
1072
                        {
1073
                            case ControlType.PenControl:
1074
                                {
1075
                                    if (inkBoard.Tag.ToString() == "Ink")
1076
                                    {
1077
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1078
                                    }
1079
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1080
                                    {
1081
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1082
                                    }
1083
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1084
                                    {
1085
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1086
                                    }
1087

    
1088
                                    //inkBoard.Strokes.Add(stroke);
1089
                                }
1090
                                break;
1091
                        }
1092
                        return;
1093
                    }
1094
                }
1095

    
1096
                if (currentControl != null)
1097
                {
1098
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1099
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1100
                    //강인구 추가
1101
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1102

    
1103
                    if ((currentControl as IPath) != null)
1104
                    {
1105
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1106
                    }
1107
                    if ((currentControl as LineControl) != null)
1108
                    {
1109
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1110
                    }
1111

    
1112
                    if ((currentControl as IShapeControl) != null)
1113
                    {
1114
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1115
                    }
1116
                    if ((currentControl as TextControl) != null)
1117
                    {
1118
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1119
                        {
1120
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1121
                        }
1122
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1123
                        {
1124
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1125
                        }
1126
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1127
                        {
1128
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1129
                        }
1130
                    }
1131
                    else if ((currentControl as ArrowTextControl) != null)
1132
                    {
1133
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1134
                        {
1135
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1136
                        }
1137
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1138
                        {
1139
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1140
                        }
1141
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1142
                        {
1143
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1144
                        }
1145
                    }
1146

    
1147
                    switch (controlType)
1148
                    {
1149
                        case ControlType.Rectangle:
1150
                            {
1151
                                var control = currentControl as RectangleControl;
1152

    
1153
                                if (control != null)
1154
                                {
1155
                                    if (move.mousemode == MouseMode.Drawing)
1156
                                    {
1157
                                        //move.control_Move(ControlList, true, moveX, moveY);
1158
                                    }
1159
                                    else
1160
                                    {
1161
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1162
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1163
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1164
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1165

    
1166

    
1167
                                        if (ViewerDataModel.Instance.IsPressShift)
1168
                                        {
1169
                                            //getNearPoint
1170
                                            Point setpoint = GetSpherePoint(control.StartPoint, control.EndPoint);
1171
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1172
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1173
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1174
                                        }
1175

    
1176
                                        //control.PointSet = new List<Point>
1177
                                        //{
1178
                                        //    control.StartPoint,
1179
                                        //    control.LeftBottomPoint,
1180
                                        //    control.EndPoint,
1181
                                        //    control.TopRightPoint,
1182
                                        //};
1183

    
1184
                                        control.PointSet = new List<Point>
1185
                                        {
1186
                                            control.StartPoint,
1187
                                            control.LeftBottomPoint,
1188
                                            control.EndPoint,
1189
                                            control.TopRightPoint,
1190
                                        };
1191
                                        control.updateControl();
1192
                                    }
1193

    
1194
                                    //강인구 추가
1195
                                    control.ControlType = controlType;
1196
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1197
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1198
                                }
1199
                            }
1200
                            break;
1201

    
1202
                        case ControlType.RectCloud:
1203
                            {
1204
                                var control = currentControl as RectCloudControl;
1205

    
1206
                                if (control != null)
1207
                                {
1208
                                    if (move.mousemode == MouseMode.Drawing)
1209
                                    {
1210
                                        //move.control_Move(ControlList, true, moveX, moveY);
1211
                                    }
1212
                                    else
1213
                                    {
1214
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1215
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1216
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1217
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1218

    
1219
                                        if (ViewerDataModel.Instance.IsPressShift)
1220
                                        {
1221
                                            Point setpoint = GetSpherePoint(control.StartPoint, control.EndPoint);
1222
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1223
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1224
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1225
                                        }
1226

    
1227
                                        control.PointSet = new List<Point>
1228
                                        {
1229
                                            control.StartPoint,
1230
                                            control.LeftBottomPoint,
1231
                                            control.EndPoint,
1232
                                            control.TopRightPoint,
1233
                                        };
1234
                                    }
1235
                                    //강인구 추가
1236
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1237
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1238
                                }
1239
                            }
1240
                            break;
1241

    
1242
                        case ControlType.SingleLine:
1243
                            {
1244
                                if (currentControl != null)
1245
                                {
1246
                                    var control = currentControl as LineControl;
1247
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1248
                                    control.ControlType = controlType;
1249
                                    if (control != null)
1250
                                    {
1251
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1252
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1253
                                        Point tempPoint = control.EndPoint;
1254

    
1255
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1256
                                        {
1257
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1258
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1259
                                            control.EndPoint = tempPoint;
1260
                                        }
1261
                                        else
1262
                                        {
1263
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1264
                                        }
1265

    
1266
                                       control.PointSet = new List<Point>
1267
                                        {
1268
                                            control.StartPoint,
1269
                                            control.EndPoint,
1270
                                        };
1271
                                        //강인구 추가
1272
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1273
                                    }
1274
                                }
1275

    
1276
                            }
1277
                            break;
1278

    
1279
                        case ControlType.CancelLine:
1280
                            {
1281
                                if (currentControl != null)
1282
                                {
1283
                                    var control = currentControl as LineControl;
1284
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1285
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1286
                                    control.ControlType = controlType;
1287
                                    if (control != null)
1288
                                    {
1289
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1290
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1291
                                        Point tempPoint = control.EndPoint;
1292

    
1293
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1294
                                        {
1295
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1296
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1297
                                            control.EndPoint = tempPoint;
1298
                                        }
1299
                                        else
1300
                                        {
1301
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1302
                                        }
1303

    
1304

    
1305
                                        control.PointSet = new List<Point>
1306
                                            {
1307
                                                control.StartPoint,
1308
                                                control.EndPoint,
1309
                                            };
1310
                                    }
1311
                                    //강인구 추가
1312
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1313
                                }
1314
                            }
1315
                            break;
1316

    
1317
                        case ControlType.ArrowLine:
1318
                            {
1319
                                if (currentControl != null)
1320
                                {
1321
                                    var control = currentControl as LineControl;
1322
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1323
                                    control.ControlType = controlType;
1324
                                    if (control != null)
1325
                                    {
1326
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1327
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1328
                                        Point tempPoint = control.EndPoint;
1329

    
1330
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1331
                                        {
1332
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1333
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1334
                                            control.EndPoint = tempPoint;
1335
                                        }
1336
                                        else
1337
                                        {
1338
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1339
                                        }
1340

    
1341

    
1342
                                        control.PointSet = new List<Point>
1343
                                            {
1344
                                                control.StartPoint,
1345
                                                control.EndPoint,
1346
                                            };
1347
                                    }
1348
                                    //강인구 추가
1349
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1350
                                }
1351

    
1352
                            }
1353
                            break;
1354

    
1355
                        case ControlType.TwinLine:
1356
                            {
1357
                                if (currentControl != null)
1358
                                {
1359
                                    var control = currentControl as LineControl;
1360
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1361
                                    control.ControlType = controlType;
1362
                                    if (control != null)
1363
                                    {
1364
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1365
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1366
                                        Point tempPoint = control.EndPoint;
1367

    
1368
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1369
                                        {
1370
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1371
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1372
                                            control.EndPoint = tempPoint;
1373
                                        }
1374
                                        else
1375
                                        {
1376
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1377
                                        }
1378

    
1379

    
1380
                                        control.PointSet = new List<Point>
1381
                                            {
1382
                                                control.StartPoint,
1383
                                                control.EndPoint,
1384
                                            };
1385
                                    }
1386
                                    //강인구 추가
1387
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1388
                                }
1389

    
1390
                            }
1391
                            break;
1392

    
1393
                        case ControlType.DimLine:
1394
                            {
1395
                                if (currentControl != null)
1396
                                {
1397
                                    var control = currentControl as LineControl;
1398
                                    control.LineStyleSet = LineStyleSet.DimLine;
1399
                                    control.ControlType = controlType;
1400
                                    if (control != null)
1401
                                    {
1402
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1403
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1404
                                        Point tempPoint = control.EndPoint;
1405

    
1406
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1407
                                        {
1408
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1409
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1410
                                            control.EndPoint = tempPoint;
1411
                                        }
1412
                                        else
1413
                                        {
1414
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1415
                                        }
1416

    
1417
                                        control.PointSet = new List<Point>
1418
                                            {
1419
                                                control.StartPoint,
1420
                                                control.EndPoint,
1421
                                            };
1422
                                    }
1423
                                    //강인구 추가
1424
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1425
                                }
1426

    
1427
                            }
1428
                            break;
1429

    
1430
                        case ControlType.ChainLine:
1431
                            {
1432
                                var control = currentControl as PolygonControl;
1433

    
1434
                                if (control != null)
1435
                                {
1436

    
1437
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1438
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1439

    
1440
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1441

    
1442
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1443
                                    {
1444
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1445
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count-2], ref tempPoint, true);
1446
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1447
                                        //control.EndPoint = tempPoint;
1448
                                    }
1449
                                    else
1450
                                    {
1451
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1452
                                    }
1453

    
1454
                                    control.SetPolyPath();
1455
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1456
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1457
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1458

    
1459
                                    //강인구 추가
1460
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1461
                                }
1462
                            }
1463
                            break;
1464

    
1465
                        case ControlType.ArcLine:
1466
                            {
1467
                                if (currentControl != null)
1468
                                {
1469
                                    var control = currentControl as ArcControl;
1470
                                    control.isTransOn = false;
1471
                                    control.ControlType = controlType;
1472

    
1473
                                    if (control != null)
1474
                                    {
1475
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1476
                                        control.MidPoint = new Point(0, 0);
1477
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1478
                                        Point tempPoint = control.EndPoint;
1479

    
1480
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1481
                                        {
1482
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1483
                                            control.EndPoint = tempPoint;
1484
                                        }
1485
                                        else
1486
                                        {
1487
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1488
                                        }
1489

    
1490

    
1491
                                        control.PointSet = new List<Point>
1492
                                            {
1493
                                                control.StartPoint,
1494
                                                control.MidPoint,
1495
                                                control.EndPoint,
1496
                                            };
1497
                                    }
1498
                                    //강인구 추가
1499
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1500
                                }
1501

    
1502
                            }
1503
                            break;
1504

    
1505
                        case ControlType.ArcArrow:
1506
                            {
1507
                                if (currentControl != null)
1508
                                {
1509
                                    var control = currentControl as ArcControl;
1510
                                    control.isTransOn = true;
1511
                                    control.ControlType = controlType;
1512

    
1513
                                    if (control != null)
1514
                                    {
1515
                                        if (move.mousemode == MouseMode.Drawing)
1516
                                        {
1517
                                            //move.control_Move(ControlList, true, moveX, moveY);
1518
                                        }
1519
                                        else
1520
                                        {
1521
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1522
                                            control.MidPoint = new Point(0, 0);
1523
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1524
                                        }
1525

    
1526
                                        control.PointSet = new List<Point>
1527
                                            {
1528
                                                control.StartPoint,
1529
                                                control.MidPoint,
1530
                                                control.EndPoint,
1531
                                            };
1532
                                    }
1533
                                    //강인구 추가
1534
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1535
                                }
1536
                            }
1537
                            break;
1538

    
1539
                        case ControlType.ArrowMultiLine:
1540
                            {
1541
                                if (currentControl != null)
1542
                                {
1543
                                    var control = currentControl as ArrowControl_Multi;
1544

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

    
1575
                                        }
1576

    
1577
                                        control.PointSet = new List<Point>
1578
                                            {
1579
                                                control.StartPoint,
1580
                                                control.MiddlePoint,
1581
                                                control.EndPoint,
1582
                                            };
1583

    
1584
                                    }
1585
                                    //강인구 추가
1586
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1587
                                }
1588

    
1589
                            }
1590
                            break;
1591

    
1592
                        case ControlType.Circle:
1593
                            {
1594
                                var control = currentControl as CircleControl;
1595

    
1596
                                if (control != null)
1597
                                {
1598
                                    if (move.mousemode == MouseMode.Drawing)
1599
                                    {
1600
                                        //move.control_Move(ControlList, true, moveX, moveY);
1601
                                    }
1602
                                    else
1603
                                    {
1604
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1605
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1606
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1607
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1608

    
1609
                                        if (ViewerDataModel.Instance.IsPressShift)
1610
                                        {
1611
                                            Point setpoint = GetSpherePoint(control.StartPoint, control.EndPoint);
1612
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1613
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1614
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1615
                                        }
1616

    
1617
                                        control.PointSet = new List<Point>
1618
                                        {
1619
                                            control.StartPoint,
1620
                                            control.LeftBottomPoint,
1621
                                            control.EndPoint,
1622
                                            control.TopRightPoint,
1623
                                        };
1624
                                    }
1625
                                    //강인구 추가
1626
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1627
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1628

    
1629
                                }
1630
                            }
1631
                            break;
1632

    
1633
                        case ControlType.PolygonCloud:
1634
                            {
1635
                                var control = currentControl as CloudControl;
1636

    
1637
                                if (control != null)
1638
                                {
1639
                                    control.isTransOn = true;
1640
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1641

    
1642
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1643

    
1644
                                    control.SetCloud();
1645
                                    //강인구 추가
1646
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1647
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1648
                                }
1649
                            }
1650
                            break;
1651

    
1652
                        case ControlType.Triangle:
1653
                            {
1654
                                var control = currentControl as TriControl;
1655

    
1656
                                if (control != null)
1657
                                {
1658
                                    if (move.mousemode == MouseMode.Drawing)
1659
                                    {
1660
                                        //move.control_Move(ControlList, true, moveX, moveY);
1661
                                    }
1662
                                    else
1663
                                    {
1664
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1665
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1666

    
1667
                                        control.PointSet = new List<Point>
1668
                                            {
1669
                                                control.StartPoint,
1670
                                                control.MidPoint,
1671
                                                control.EndPoint,
1672
                                            };
1673

    
1674
                                        //if (ViewerDataModel.Instance.IsPressShift)
1675
                                        //{
1676
                                        //    Point setpoint = ShiftDrawing(control.StartPoint, control.EndPoint);
1677
                                        //    control.MidPoint = new Point(setpoint.X, setpoint.Y);
1678
                                        //    control.EndPoint = new Point(setpoint.X, setpoint.Y);
1679
                                        //}
1680

    
1681

    
1682
                                    }
1683
                                    //강인구 추가
1684
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1685
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1686
                                }
1687
                            }
1688
                            break;
1689

    
1690
                        case ControlType.ImgControl:
1691
                            {
1692
                                var control = currentControl as ImgControl;
1693

    
1694
                                if (control != null)
1695
                                {
1696
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1697
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1698
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1699
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1700

    
1701
                                    control.PointSet = new List<Point>
1702
                                        {
1703
                                            control.StartPoint,
1704
                                            control.LeftBottomPoint,
1705
                                            control.EndPoint,
1706
                                            control.TopRightPoint,
1707
                                        };
1708
                                }
1709
                            }
1710
                            break;
1711

    
1712
                        case ControlType.Date:
1713
                            {
1714
                                var control = currentControl as DateControl;
1715

    
1716
                                if (control != null)
1717
                                {
1718
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1719
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1720
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1721
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1722
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1723

    
1724
                                    control.PointSet = new List<Point>
1725
                                        {
1726
                                            control.StartPoint,
1727
                                            control.LeftBottomPoint,
1728
                                            control.EndPoint,
1729
                                            control.TopRightPoint,
1730
                                        };
1731
                                }
1732
                            }
1733
                            break;
1734

    
1735
                        case ControlType.ArrowTextControl:
1736
                            {
1737
                                var control = currentControl as ArrowTextControl;
1738

    
1739
                                if (control != null)
1740
                                {
1741
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1742
                                    Point tempPoint = control.EndPoint;
1743
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1744
                                    {
1745
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1746
                                        control.EndPoint = tempPoint;
1747
                                    }
1748
                                    else
1749
                                    {
1750
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1751
                                    }
1752

    
1753
                                    control.PointSet = new List<Point>
1754
                                            {
1755
                                                control.StartPoint,
1756
                                                control.MidPoint,
1757
                                                control.EndPoint,
1758
                                            };
1759
                                }
1760
                            }
1761
                            break;
1762

    
1763
                        case ControlType.ArrowTransTextControl:
1764
                            {
1765
                                var control = currentControl as ArrowTextControl;
1766

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

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

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

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

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

    
1823
                                if (control != null)
1824
                                {
1825
                                    control.isFixed = true;
1826
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1827
                                    Point tempPoint = control.EndPoint;
1828
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1829
                                    {
1830
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1831
                                        control.EndPoint = tempPoint;
1832
                                    }
1833
                                    else
1834
                                    {
1835
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1836
                                    }
1837
                                    control.PointSet = new List<Point>
1838
                                            {
1839
                                                control.StartPoint,
1840
                                                control.MidPoint,
1841
                                                control.EndPoint,
1842
                                            };
1843
                                }
1844

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

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

    
1872
                            }
1873
                            break;
1874
                        case ControlType.ArrowTransTextCloudControl:
1875
                            {
1876
                                var control = currentControl as ArrowTextControl;
1877

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

    
1900
                            }
1901
                            break;
1902
                        case ControlType.PolygonControl:
1903
                            {
1904
                                var control = currentControl as PolygonControl;
1905

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

    
1923
                                if (control != null)
1924
                                {
1925
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1926
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1927
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1928
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1929

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

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

    
1965
                                if (control != null)
1966
                                {
1967
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1968
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1969
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1970
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1971
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1972
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
1973

    
1974
                                    if (control.StartPoint != control.EndPoint)
1975
                                    {
1976
                                        if (control.PathData == null)
1977
                                        {
1978
                                            using (StringToPathConverter Convert = new StringToPathConverter())
1979
                                            {
1980
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
1981
                                            }
1982
                                        }
1983
                                    }
1984

    
1985
                                    control.PointSet = new List<Point>
1986
                                        {
1987
                                            control.StartPoint,
1988
                                            control.LeftBottomPoint,
1989
                                            control.EndPoint,
1990
                                            control.TopRightPoint,
1991
                                        };
1992
                                }
1993
                            }
1994
                            break;
1995
                        case ControlType.Stamp:
1996
                            {
1997
                                var control = currentControl as SymControlN;
1998

    
1999
                                if (control != null)
2000
                                {
2001

    
2002
                                    if (control.StartPoint == control.EndPoint)
2003
                                    {
2004
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2005

    
2006
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2007
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2008

    
2009

    
2010
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2011

    
2012
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2013
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2014
                                        writer.Write(xamlData);
2015
                                        writer.Flush();
2016
                                        stream.Position = 0;
2017

    
2018
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2019
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2020
                                        UIElement ob = obj as UIElement;
2021

    
2022
                                        //control.ApplyTemplate();
2023

    
2024
                                        control.SetViewBox();
2025
                                        control.PathXathData = appovalData;
2026
                                        control.Base_ViewBox.Child = ob;
2027
                                    }
2028

    
2029
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2030
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2031
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2032
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2033
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2034

    
2035

    
2036
                                    control.PointSet = new List<Point>
2037
                                    {
2038
                                        control.StartPoint,
2039
                                        control.LeftBottomPoint,
2040
                                        control.EndPoint,
2041
                                        control.TopRightPoint,
2042
                                    };
2043
                                }
2044
                            }
2045
                            break;
2046
                        case ControlType.Mark:
2047
                            {
2048
                                var control = currentControl as RectangleControl;
2049

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

    
2063

    
2064
                                        control.PointSet = new List<Point>
2065
                                    {
2066
                                        control.StartPoint,
2067
                                        control.LeftBottomPoint,
2068
                                        control.EndPoint,
2069
                                        control.TopRightPoint,
2070
                                    };
2071
                                    }
2072

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

    
2093
                if (isDraggingSelectionRect)
2094
                {
2095
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2096

    
2097
                    e.Handled = true;
2098
                }
2099
                else if (isLeftMouseButtonDownOnWindow)
2100
                {
2101
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2102
                    double dragDistance = Math.Abs(dragDelta.Length);
2103

    
2104
                    if (dragDistance > DragThreshold)
2105
                    {
2106
                        isDraggingSelectionRect = true;
2107

    
2108
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2109
                    }
2110

    
2111
                    e.Handled = true;
2112
                }
2113

    
2114

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

    
2137

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

    
2154
                    //    }
2155
                    //    else
2156
                    //    {
2157
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2158
                    //    }
2159
                    //}
2160

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

    
2182
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2183
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2184

    
2185
                //if (hitList.Count > 0)
2186
                //{
2187

    
2188
                //}
2189

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

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

    
2212
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2213
                //hitResultsList.Clear();
2214

    
2215
                #endregion
2216
            }
2217
        }
2218

    
2219
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2220

    
2221
        private EllipseGeometry hitArea = new EllipseGeometry();
2222

    
2223
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2224
        {
2225
            IsDrawing = false;
2226

    
2227
            if (mouseHandlingMode != MouseHandlingMode.None)
2228
            {
2229
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2230
                {
2231
                    this.cursor = Cursors.Arrow;
2232

    
2233
                    SetCursor();
2234

    
2235
                    switch (controlType)
2236
                    {
2237
                        case ControlType.None:
2238
                            break;
2239
                        case ControlType.Rectangle:
2240
                            {
2241

    
2242
                            }
2243
                            break;
2244
                        case ControlType.PenControl:
2245
                            {
2246

    
2247
                            }
2248
                            break;
2249
                        default:
2250
                            break;
2251
                    }
2252
                }
2253
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left)
2254
                {
2255
                    if (isLeftMouseButtonDownOnWindow)
2256
                    {
2257
                        bool wasDragSelectionApplied = false;
2258

    
2259
                        if (isDraggingSelectionRect)
2260
                        {
2261
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2262
                            {
2263
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2264
                                mouseHandlingMode = MouseHandlingMode.None;
2265
                                Set_Capture();
2266

    
2267
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2268
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2269
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2270
                            }
2271

    
2272
                            isDraggingSelectionRect = false;
2273
                            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2274
                            {
2275
                                ApplyDragSelectionRect();
2276
                            }
2277

    
2278
                            e.Handled = true;
2279
                            wasDragSelectionApplied = true;
2280
                        }
2281

    
2282
                        if (isLeftMouseButtonDownOnWindow)
2283
                        {
2284
                            isLeftMouseButtonDownOnWindow = false;
2285
                            this.ReleaseMouseCapture();
2286
                            e.Handled = true;
2287
                        }
2288

    
2289
                        if (!wasDragSelectionApplied)
2290
                        {
2291
                            init();
2292
                        }
2293
                    }
2294
                }
2295
                else if (mouseButtonDown == MouseButton.Right)
2296
                {
2297
                    this.cursor = Cursors.Arrow;
2298
                    SetCursor();
2299
                }
2300

    
2301
                zoomAndPanControl.ReleaseMouseCapture();
2302

    
2303

    
2304
                e.Handled = true;
2305
            }
2306
            else
2307
            {
2308
                this.cursor = Cursors.Arrow;
2309
                SetCursor();
2310
            }
2311
            mouseButtonDown = MouseButton.Left;
2312

    
2313
            //controlType = ControlType.SingleLine;
2314
        }
2315

    
2316
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2317
        {
2318
            mouseButtonDown = MouseButton.Left;
2319
            this.Cursor = Cursors.Arrow;
2320
        }
2321

    
2322
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2323
        {
2324

    
2325
        }
2326

    
2327
        private void ApplyDragSelectionRect()
2328
        {
2329
            multi_Undo_Data = new Multi_Undo_data();
2330

    
2331
            UndoData = new Undo_data()
2332
            {
2333
                IsUndo = false,
2334
                Event = Event_Type.Select,
2335
                EventTime = DateTime.Now,
2336
                Markup_List = new List<Multi_Undo_data>()
2337
            };
2338

    
2339
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2340

    
2341
            double x = Canvas.GetLeft(dragSelectionBorder);
2342
            double y = Canvas.GetTop(dragSelectionBorder);
2343
            double width = dragSelectionBorder.Width;
2344
            double height = dragSelectionBorder.Height;
2345
            Rect dragRect = new Rect(x, y, width, height);
2346
            Boolean Flag = false;
2347
            dragRect.Inflate(width / 10, height / 10);
2348
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2349
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2350

    
2351
            dragRect = new Rect(x, y, width, height);
2352
            dragRect.Inflate(width / 10, height / 10);
2353

    
2354
            foreach (var item in Items)
2355
            {
2356
                Flag = move.control_Select(item, dragRect);
2357

    
2358
                if (Flag)
2359
                {
2360
                    adornerSet.Add(item);
2361
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2362

    
2363
                    Control_Style(item);
2364
                    UndoData.Markup_List.Add(multi_Undo_Data);
2365
                    multi_Undo_Data = new Multi_Undo_data();
2366
                }
2367
            }
2368
            if (adornerSet.Count > 0)
2369
            {
2370
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2371
                {
2372
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2373
                });
2374
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2375

    
2376
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2377
                SelectLayer.Children.Add(final);
2378
            }
2379
        }
2380

    
2381
        private void InitDragSelectionRect(Point pt1, Point pt2)
2382
        {
2383
            //선택 중
2384
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2385
            {
2386
                dragSelectionBorder.Visibility = Visibility.Visible;
2387
            }
2388
            //캡쳐 중
2389
            else
2390
            {
2391
                dragCaptureBorder.Visibility = Visibility.Visible;
2392
            }
2393
            UpdateDragSelectionRect(pt1, pt2);
2394
        }
2395

    
2396
        /// <summary>
2397
        /// Update the position and size of the rectangle used for drag selection.
2398
        /// </summary>
2399
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2400
        {
2401
            double x, y, width, height;
2402

    
2403
            //
2404
            // Determine x,y,width and height of the rect inverting the points if necessary.
2405
            // 
2406

    
2407
            if (pt2.X < pt1.X)
2408
            {
2409
                x = pt2.X;
2410
                width = pt1.X - pt2.X;
2411
            }
2412
            else
2413
            {
2414
                x = pt1.X;
2415
                width = pt2.X - pt1.X;
2416
            }
2417

    
2418
            if (pt2.Y < pt1.Y)
2419
            {
2420
                y = pt2.Y;
2421
                height = pt1.Y - pt2.Y;
2422
            }
2423
            else
2424
            {
2425
                y = pt1.Y;
2426
                height = pt2.Y - pt1.Y;
2427
            }
2428

    
2429
            //
2430
            // Update the coordinates of the rectangle used for drag selection.
2431
            //
2432
            //선택 중
2433
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2434
            {
2435
                Canvas.SetLeft(dragSelectionBorder, x);
2436
                Canvas.SetTop(dragSelectionBorder, y);
2437
                dragSelectionBorder.Width = width;
2438
                dragSelectionBorder.Height = height;
2439
            }
2440
            //캡쳐 중
2441
            else
2442
            {
2443
                Canvas.SetLeft(dragCaptureBorder, x);
2444
                Canvas.SetTop(dragCaptureBorder, y);
2445
                dragCaptureBorder.Width = width;
2446
                dragCaptureBorder.Height = height;
2447
            }
2448
        }
2449

    
2450
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2451
        {
2452
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2453

    
2454
            bool result = false;
2455
            if (dragRect.Contains(controlRect))
2456
            {
2457
                result = true;
2458
                //잡은 객체들을 담은 리스트
2459
                try
2460
                {
2461
                    selected_item.Add(OverViewPathData, type.ToString());
2462
                }
2463
                catch (Exception)
2464
                {
2465

    
2466
                }
2467
            }
2468
            return result;
2469
        }
2470

    
2471
        private void drawingPannelRotate(double angle)
2472
        {
2473
            rotate.Angle = angle;
2474
            var rotationNum = Math.Abs((rotate.Angle / 90));
2475

    
2476
            if (angle == 90 || angle == 270)
2477
            {
2478
                double emptySize = zoomAndPanCanvas.Width;
2479
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2480
                zoomAndPanCanvas.Height = emptySize;
2481
            }
2482
            if (angle == 0)
2483
            {
2484
                translate.X = 0;
2485
                translate.Y = 0;
2486
            }
2487
            else if (angle == 90)
2488
            {
2489
                translate.X = zoomAndPanCanvas.Width;
2490
                translate.Y = 0;
2491
            }
2492
            else if (angle == 180)
2493
            {
2494
                translate.X = zoomAndPanCanvas.Width;
2495
                translate.Y = zoomAndPanCanvas.Height;
2496
            }
2497
            else
2498
            {
2499
                translate.X = 0;
2500
                translate.Y = zoomAndPanCanvas.Height;
2501
            }
2502

    
2503
            zoomAndPanControl.RotationAngle = rotate.Angle;
2504

    
2505

    
2506
            if (!testPanel2.IsHidden)
2507
            {
2508
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2509
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2510
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2511
            }
2512

    
2513
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2514
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2515
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2516
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2517
            ViewerDataModel.Instance.Angle = rotate.Angle;
2518

    
2519

    
2520
        }
2521

    
2522
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2523
        {
2524
            InkControl_Convert();
2525

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

    
2529
            if(text_item != null && (currentControl as ArrowTextControl) == null)
2530
            {
2531
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2532
            }
2533

    
2534
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2535
            {
2536
                if (arrow_text as ArrowTextControl != null)
2537
                {
2538
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2539
                }
2540
            }
2541

    
2542
            if(currentControl == null)
2543
            {
2544
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2545
                if (text_item_ != null)
2546
                {
2547
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2548
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2549
                    (text_item_ as TextControl).IsEditing = false;
2550
                    (text_item_ as TextControl).EnableEditing = false;
2551
                }
2552

    
2553
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2554
                if (Arrowtext_item_ != null)
2555
                {
2556
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2557
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2558
                }
2559
            }
2560

    
2561
            double Ang = 0;
2562
            if (rotate.Angle != 0)
2563
            {
2564
                Ang = 360 - rotate.Angle;
2565
            }
2566
            move = new Move();
2567

    
2568
            if (e.OriginalSource is System.Windows.Controls.Image)
2569
            {
2570
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2571
            }
2572

    
2573
            mouseButtonDown = e.ChangedButton;
2574
            if (mouseButtonDown == MouseButton.Left)
2575
            {
2576
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2577
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2578

    
2579
                this.cursor = Cursors.Arrow;
2580
                SetCursor();
2581

    
2582
                if (!ViewerDataModel.Instance.IsPressCtrl)
2583
                {
2584
                    ReleaseAdorner();
2585
                }
2586
            }
2587
            if (mouseButtonDown == MouseButton.Middle)
2588
            {
2589
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2590
                cursor = Cursors.SizeAll;
2591
                SetCursor();
2592
            }
2593
            if (mouseButtonDown == MouseButton.Right)
2594
            {
2595
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2596
                cursor = Cursors.SizeAll;
2597
                SetCursor();
2598
            }
2599
            else if (mouseButtonDown == MouseButton.XButton1)
2600
            {
2601
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2602
                {
2603
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2604
                }
2605

    
2606
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2607

    
2608
            }
2609
            else if (mouseButtonDown == MouseButton.XButton2)
2610
            {
2611
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2612
                {
2613
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2614
                }
2615
            }
2616

    
2617
            //캡쳐 모드 설정
2618
            if (mouseHandlingMode == MouseHandlingMode.Capture && mouseButtonDown == MouseButton.Left)
2619
            {
2620
                dragCaptureBorder.Visibility = Visibility.Visible;
2621
                isLeftMouseButtonDownOnWindow = true;
2622
            }
2623

    
2624
            if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2625
            {
2626

    
2627
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2628
                {
2629
                    if (SelectLayer.Children.Count == 0)
2630
                    {
2631
                        isLeftMouseButtonDownOnWindow = true;
2632
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2633
                    }
2634

    
2635
                    if (controlType == ControlType.None)
2636
                    {
2637
                        isLeftMouseButtonDownOnWindow = true;
2638
                    }
2639
                }
2640

    
2641

    
2642
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2643
                if (control != null)
2644
                {
2645
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2646
                    AdornerFinal final;
2647
                    List<Point> p_set = new List<Point>();
2648
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2649
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2650
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2651
                    multi_Undo_Data = new Multi_Undo_data();
2652

    
2653
                    //강인구 Undo/Redo 보류
2654
                    UndoData = new Undo_data()
2655
                    {
2656
                        IsUndo = false,
2657
                        Event = Event_Type.Select,
2658
                        EventTime = DateTime.Now,
2659
                        Markup_List = new List<Multi_Undo_data>()
2660
                    };
2661

    
2662
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2663
                    {
2664
                        ReleaseAdorner();
2665
                        final = new AdornerFinal(control);
2666
                        //단일 컨트롤 언두 저장
2667

    
2668
                        Control_Style(control);
2669
                        UndoData.Markup_List.Add(multi_Undo_Data);
2670

    
2671
                        if ((control as IPath) != null)
2672
                        {
2673
                            if ((control as IPath).LineSize != 0)
2674
                            {
2675
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2676
                            }
2677
                        }
2678
                        if ((control as IShapeControl) != null)
2679
                        {
2680
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2681
                            {
2682
                                ViewerDataModel.Instance.checkHatchShape = true;
2683
                            }
2684
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2685
                            {
2686
                                ViewerDataModel.Instance.checkFillShape = true;
2687
                            }
2688
                            else
2689
                            {
2690
                                ViewerDataModel.Instance.checkHatchShape = false;
2691
                                ViewerDataModel.Instance.checkFillShape = false;
2692
                            }
2693
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2694
                        }
2695
                        //SelectLayer.Children.Add(final);
2696
                        if ((control as IPath) != null)
2697
                        {
2698
                            if ((control as IPath).LineSize != 0)
2699
                            {
2700
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2701
                            }
2702
                        }
2703
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2704

    
2705
                        if ((control as TextControl) != null)
2706
                        {
2707
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2708
                            {
2709
                                ViewerDataModel.Instance.checkTextStyle = true;
2710
                            }
2711
                            else
2712
                            {
2713
                                ViewerDataModel.Instance.checkTextStyle = false;
2714
                            }
2715

    
2716
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2717
                            {
2718
                                ViewerDataModel.Instance.checkTextStyle = true;
2719
                            }
2720
                            else
2721
                            {
2722
                                ViewerDataModel.Instance.checkTextStyle = false;
2723
                            }
2724
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2725
                            {
2726
                                ViewerDataModel.Instance.checkTextWeight = true;
2727
                            }
2728
                            else
2729
                            {
2730
                                ViewerDataModel.Instance.checkTextWeight = false;
2731
                            }
2732
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2733
                            {
2734
                                ViewerDataModel.Instance.checkUnderLine = true;
2735
                            }
2736
                            else
2737
                            {
2738
                                ViewerDataModel.Instance.checkUnderLine = false;
2739
                            }
2740

    
2741
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2742
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2743
                            
2744
                        }
2745
                        else if ((control as ArrowTextControl) != null)
2746
                        {
2747
                            //if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2748
                            //{
2749
                            //    (control as ArrowTextControl).TextStyle = FontStyles.Italic;
2750
                            //}
2751
                            //if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2752
                            //{
2753
                            //    (control as ArrowTextControl).TextWeight = FontWeights.Bold;
2754
                            //}
2755
                            //if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2756
                            //{
2757
                            //    (control as ArrowTextControl).UnderLine = TextDecorations.Underline;
2758
                            //}
2759
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2760
                            {
2761
                                ViewerDataModel.Instance.checkTextStyle = true;
2762
                            }
2763
                            else
2764
                            {
2765
                                ViewerDataModel.Instance.checkTextStyle = false;
2766
                            }
2767

    
2768
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2769
                            {
2770
                                ViewerDataModel.Instance.checkTextStyle = true;
2771
                            }
2772
                            else
2773
                            {
2774
                                ViewerDataModel.Instance.checkTextStyle = false;
2775
                            }
2776
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2777
                            {
2778
                                ViewerDataModel.Instance.checkTextWeight = true;
2779
                            }
2780
                            else
2781
                            {
2782
                                ViewerDataModel.Instance.checkTextWeight = false;
2783
                            }
2784
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2785
                            {
2786
                                ViewerDataModel.Instance.checkUnderLine = true;
2787
                            }
2788
                            else
2789
                            {
2790
                                ViewerDataModel.Instance.checkUnderLine = false;
2791
                            }
2792
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2793
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2794
                        }
2795

    
2796
                    }
2797
                    else
2798
                    {
2799
                        comment = AddAdorner();
2800
                        comment.Add(control);
2801

    
2802
                        Control_Style(control);
2803
                        UndoData.Markup_List.Add(multi_Undo_Data);
2804

    
2805
                        final = new AdornerFinal(comment);
2806
                        //다중 컨트롤 언두 저장
2807
                    }
2808

    
2809
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2810
                    {
2811
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2812
                    });
2813

    
2814
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2815

    
2816
                    SelectLayer.Children.Add(final);
2817

    
2818
                    //Control_Init(control);
2819

    
2820

    
2821
                    
2822

    
2823

    
2824
                    //강인구 폰트 변경 보류
2825

    
2826
                    //if ((currentControl as TextControl) != null)
2827
                    //{
2828
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2829
                    //    {
2830
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2831
                    //    }
2832
                    //    else
2833
                    //    {
2834
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2835
                    //    }
2836

    
2837
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2838
                    //    {
2839

    
2840
                    //    }
2841
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
2842
                    //    {
2843

    
2844
                    //    }
2845
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2846
                    //    {
2847

    
2848
                    //    }
2849
                    //}
2850
                    //else if ((currentControl as ArrowTextControl) != null)
2851
                    //{
2852
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2853
                    //    {
2854
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
2855
                    //    }
2856
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2857
                    //    {
2858
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
2859
                    //    }
2860
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2861
                    //    {
2862
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
2863
                    //    }
2864
                    //}
2865

    
2866
                    mouseHandlingMode = MouseHandlingMode.Adorner;
2867
                }
2868
            }
2869

    
2870
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2871
            {
2872
                init();
2873
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2874
                if (cursor != Cursors.SizeAll)
2875
                {
2876
                    cursor = Cursors.Cross;
2877
                    SetCursor();
2878
                }
2879
                bool init_user = false;
2880
                foreach (var user in gridViewMarkup.Items)
2881
                {
2882
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2883
                    {
2884
                        init_user = true;
2885
                    }
2886
                }
2887
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2888
                {
2889
                    RadWindow.Alert(new DialogParameters
2890
                    {
2891
                        Theme = new VisualStudio2013Theme(),
2892
                        Header = "안내",
2893
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2894
                    });
2895
                    return;
2896
                }
2897
                else
2898
                {
2899
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2900
                    if (item != null)
2901
                    {
2902
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2903
                    }
2904
                }
2905

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

    
2916
                switch (controlType)
2917
                {
2918
                    case ControlType.Rectangle:
2919
                        {
2920
                            if (mouseButtonDown == MouseButton.Left)
2921
                            {
2922
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2923
                                {
2924
                                    if (currentControl is RectangleControl)
2925
                                    {
2926
                                        CreateControl();
2927

    
2928
                                        (currentControl as RectangleControl).ApplyOverViewData();
2929
                                        currentControl = null;
2930
                                        this.cursor = Cursors.Arrow;
2931
                                    }
2932
                                    else
2933
                                    {
2934
                                        currentControl = new RectangleControl
2935
                                        {
2936
                                            Background = new SolidColorBrush(Colors.Black),
2937
                                            ControlType = ControlType.Rectangle
2938
                                        };
2939

    
2940
                                        currentControl.CommentID = Save.shortGuid();
2941
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2942
                                        currentControl.IsNew = true;
2943
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2944

    
2945
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2946
                                    }
2947
                                }
2948
                            }
2949
                        }
2950
                        break;
2951
                    case ControlType.RectCloud:
2952
                        {
2953
                            if (mouseButtonDown == MouseButton.Left)
2954
                            {
2955
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2956
                                {
2957
                                    if (currentControl is RectCloudControl)
2958
                                    {
2959
                                        CreateControl();
2960

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

    
2972
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2973
                                        currentControl.CommentID = Save.shortGuid();
2974
                                        currentControl.IsNew = true;
2975
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2976
                                    }
2977
                                }
2978
                            }
2979
                        }
2980
                        break;
2981
                    case ControlType.Circle:
2982
                        {
2983
                            if (mouseButtonDown == MouseButton.Left)
2984
                            {
2985
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2986
                                {
2987
                                    if (currentControl is CircleControl)
2988
                                    {
2989
                                        CreateControl();
2990

    
2991
                                        (currentControl as CircleControl).ApplyOverViewData();
2992
                                        currentControl = null;
2993
                                    }
2994
                                    else
2995
                                    {
2996
                                        currentControl = new CircleControl
2997
                                        {
2998
                                            Background = new SolidColorBrush(Colors.Black)
2999
                                        };
3000

    
3001
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3002
                                        currentControl.CommentID = Save.shortGuid();
3003
                                        currentControl.IsNew = true;
3004
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3005
                                    }
3006
                                }
3007
                            }
3008
                        }
3009
                        break;
3010
                    case ControlType.Triangle:
3011
                        {
3012
                            if (mouseButtonDown == MouseButton.Left)
3013
                            {
3014
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3015
                                {
3016
                                    if (currentControl is TriControl)
3017
                                    {
3018
                                        var content = currentControl as TriControl;
3019
                                        if (content.MidPoint == new Point(0, 0))
3020
                                        {
3021
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3022
                                        }
3023
                                        else
3024
                                        {
3025
                                            CreateControl();
3026

    
3027
                                            (currentControl as TriControl).ApplyOverViewData();
3028
                                            currentControl = null;
3029
                                        }
3030
                                    }
3031
                                    else
3032
                                    {
3033
                                        currentControl = new TriControl
3034
                                        {
3035
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3036
                                            Background = new SolidColorBrush(Colors.Black),
3037
                                        };
3038

    
3039
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3040
                                        currentControl.CommentID = Save.shortGuid();
3041
                                        currentControl.IsNew = true;
3042
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3043
                                    }
3044
                                }
3045
                            }
3046
                        }
3047
                        break;
3048
                    case ControlType.SingleLine:
3049
                        {
3050
                            if (mouseButtonDown == MouseButton.Left)
3051
                            {
3052
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3053
                                {
3054
                                    if (currentControl is LineControl)
3055
                                    {
3056
                                        CreateControl();
3057

    
3058
                                        (currentControl as LineControl).ApplyOverViewData();
3059
                                        currentControl = null;
3060
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3061
                                    }
3062
                                    else
3063
                                    {
3064
                                        currentControl = new LineControl
3065
                                        {
3066
                                            Background = new SolidColorBrush(Colors.Black)
3067
                                        };
3068

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

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

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

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

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

    
3151
                                        (currentControl as LineControl).ApplyOverViewData();
3152
                                        currentControl = null;
3153
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3154
                                    }
3155
                                    else
3156
                                    {
3157
                                        currentControl = new LineControl
3158
                                        {
3159
                                            Background = new SolidColorBrush(Colors.Black)
3160
                                        };
3161
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3162
                                        currentControl.CommentID = Save.shortGuid();
3163
                                        currentControl.IsNew = true;
3164
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3165
                                        this.MainAngle.Visibility = Visibility.Visible;
3166
                                    }
3167
                                }
3168
                            }
3169
                        }
3170
                        break;
3171
                    case ControlType.DimLine:
3172
                        {
3173
                            if (mouseButtonDown == MouseButton.Left)
3174
                            {
3175
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3176
                                {
3177
                                    if (currentControl is LineControl)
3178
                                    {
3179
                                        CreateControl();
3180

    
3181
                                        (currentControl as LineControl).ApplyOverViewData();
3182
                                        currentControl = null;
3183
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3184
                                    }
3185
                                    else
3186
                                    {
3187
                                        currentControl = new LineControl
3188
                                        {
3189
                                            Background = new SolidColorBrush(Colors.Black)
3190
                                        };
3191
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3192
                                        currentControl.CommentID = Save.shortGuid();
3193
                                        currentControl.IsNew = true;
3194
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3195
                                        this.MainAngle.Visibility = Visibility.Visible;
3196
                                    }
3197
                                }
3198
                            }
3199
                        }
3200
                        break;
3201
                    case ControlType.ChainLine:
3202
                        {
3203
                            if (currentControl is PolygonControl)
3204
                            {
3205
                                var control = currentControl as PolygonControl;
3206

    
3207
                                if (mouseButtonDown == MouseButton.Right)
3208
                                {
3209
                                    CreateControl();
3210

    
3211
                                    (currentControl as PolygonControl).ApplyOverViewData();
3212
                                    currentControl = null;
3213
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3214
                                    return;
3215
                                }
3216

    
3217
                                if (!control.IsCompleted)
3218
                                {
3219
                                    control.PointSet.Add(control.EndPoint);
3220
                                    this.MainAngle.Visibility = Visibility.Visible;
3221
                                }
3222
                            }
3223
                            else
3224
                            {
3225
                                if (mouseButtonDown == MouseButton.Left)
3226
                                {
3227
                                    MainAngle.Visibility = Visibility.Visible;
3228
                                    currentControl = new PolygonControl
3229
                                    {
3230
                                        PointSet = new List<Point>(),
3231
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3232
                                        ControlType = ControlType.ChainLine,
3233
                                        DashSize = ViewerDataModel.Instance.DashSize,
3234
                                        LineSize = ViewerDataModel.Instance.LineSize,
3235
                                        //PointC = new StylusPointSet()
3236
                                    };
3237

    
3238
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3239
                                    {
3240
                                        var polygonControl = (currentControl as PolygonControl);
3241
                                        currentControl.CommentID = Save.shortGuid();
3242
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3243
                                        currentControl.IsNew = true;
3244
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3245
                                        //currentControl.OnApplyTemplate();
3246
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3247
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3248
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3249
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3250
                                    }
3251
                                }
3252
                            }
3253
                        }
3254
                        break;
3255
                    case ControlType.ArcLine:
3256
                        {
3257
                            if (mouseButtonDown == MouseButton.Left)
3258
                            {
3259
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3260
                                {
3261
                                    if (currentControl is ArcControl)
3262
                                    {
3263
                                        CreateControl();
3264

    
3265
                                        (currentControl as ArcControl).ApplyOverViewData();
3266
                                        currentControl = null;
3267
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3268
                                    }
3269
                                    else
3270
                                    {
3271
                                        currentControl = new ArcControl
3272
                                        {
3273
                                            Background = new SolidColorBrush(Colors.Black)
3274
                                        };
3275
                                        currentControl.CommentID = Save.shortGuid();
3276
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3277
                                        currentControl.IsNew = true;
3278
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3279
                                        this.MainAngle.Visibility = Visibility.Visible;
3280
                                    }
3281
                                }
3282
                            }
3283
                            else if (mouseButtonDown == MouseButton.Right)
3284
                            {
3285
                                if (currentControl != null)
3286
                                {
3287
                                    (currentControl as ArcControl).setClock();
3288
                                }
3289

    
3290
                            }
3291

    
3292
                        }
3293
                        break;
3294
                    case ControlType.ArcArrow:
3295
                        {
3296
                            if (mouseButtonDown == MouseButton.Left)
3297
                            {
3298
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3299
                                {
3300
                                    if (currentControl is ArcControl)
3301
                                    {
3302
                                        CreateControl();
3303

    
3304
                                        (currentControl as ArcControl).ApplyOverViewData();
3305
                                        currentControl = null;
3306
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3307
                                    }
3308
                                    else
3309
                                    {
3310
                                        currentControl = new ArcControl
3311
                                        {
3312
                                            Background = new SolidColorBrush(Colors.Red),
3313
                                        };
3314
                                        currentControl.CommentID = Save.shortGuid();
3315
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3316
                                        currentControl.IsNew = true;
3317
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3318
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3319
                                        this.MainAngle.Visibility = Visibility.Visible;
3320
                                    }
3321
                                }
3322
                            }
3323
                            else if (mouseButtonDown == MouseButton.Right)
3324
                            {
3325
                                (currentControl as ArcControl).setClock();
3326
                            }
3327
                        }
3328
                        break;
3329
                    case ControlType.ArrowMultiLine:
3330
                        {
3331
                            if (mouseButtonDown == MouseButton.Left)
3332
                            {
3333
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3334
                                {
3335

    
3336
                                    if (currentControl is ArrowControl_Multi)
3337
                                    {
3338
                                        var content = currentControl as ArrowControl_Multi;
3339
                                        if (content.MiddlePoint == new Point(0, 0))
3340
                                        {
3341
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3342
                                            {
3343
                                                content.MiddlePoint = content.EndPoint;
3344
                                            }
3345
                                            else
3346
                                            {
3347
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3348
                                            }
3349
                                        }
3350
                                        else
3351
                                        {
3352
                                            CreateControl();
3353

    
3354
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3355
                                            currentControl = null;
3356
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3357
                                        }
3358
                                    }
3359
                                    else
3360
                                    {
3361
                                        currentControl = new ArrowControl_Multi
3362
                                        {
3363
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3364
                                            Background = new SolidColorBrush(Colors.Black)
3365
                                        };
3366
                                        currentControl.CommentID = Save.shortGuid();
3367
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3368
                                        currentControl.IsNew = true;
3369
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3370
                                        this.MainAngle.Visibility = Visibility.Visible;
3371
                                    }
3372
                                }
3373
                            }
3374
                        }
3375
                        break;
3376
                    case ControlType.PolygonCloud:
3377
                        {
3378
                            if (currentControl is CloudControl)
3379
                            {
3380
                                var control = currentControl as CloudControl;
3381
                                if (mouseButtonDown == MouseButton.Right)
3382
                                {
3383
                                    control.IsCompleted = true;
3384
                                }
3385

    
3386
                                if (!control.IsCompleted)
3387
                                {
3388
                                    control.PointSet.Add(control.EndPoint);
3389
                                }
3390
                                else
3391
                                {
3392
                                    CreateControl();
3393

    
3394
                                    control.isTransOn = true;
3395
                                    var firstPoint = control.PointSet.First();
3396

    
3397
                                    control.PointSet.Add(firstPoint);
3398
                                    control.DrawingCloud();
3399
                                    control.ApplyOverViewData();
3400

    
3401
                                    currentControl = null;
3402
                                }
3403
                            }
3404
                            else
3405
                            {
3406
                                if (mouseButtonDown == MouseButton.Left)
3407
                                {
3408
                                    currentControl = new CloudControl
3409
                                    {
3410
                                        PointSet = new List<Point>(),
3411
                                        PointC = new StylusPointSet()
3412
                                    };
3413

    
3414
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3415
                                    {
3416
                                        var polygonControl = (currentControl as CloudControl);
3417
                                        currentControl.CommentID = Save.shortGuid();
3418
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3419
                                        currentControl.IsNew = true;
3420
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3421

    
3422
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3423
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3424
                                    }
3425
                                }
3426
                            }
3427
                        }
3428
                        break;
3429
                    case ControlType.ImgControl:
3430
                        {
3431
                            if (mouseButtonDown == MouseButton.Left)
3432
                            {
3433
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3434
                                {
3435
                                    if (currentControl is ImgControl)
3436
                                    {
3437
                                        CreateControl();
3438
                                        (currentControl as ImgControl).ApplyOverViewData();
3439

    
3440
                                        currentControl = null;
3441
                                    }
3442
                                    else
3443
                                    {
3444
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3445
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3446
                                        {
3447
                                            Image img = new Image();
3448
                                            img.Source = new BitmapImage(new Uri(filename));
3449

    
3450
                                            currentControl = new ImgControl
3451
                                            {
3452
                                                Background = new SolidColorBrush(Colors.Black),
3453
                                                PointSet = new List<Point>(),
3454
                                                FilePath = filename,
3455
                                                ImageData = img.Source,
3456
                                                StartPoint = canvasDrawingMouseDownPoint,
3457
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3458
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3459
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3460
                                            };
3461

    
3462
                                            currentControl.CommentID = Save.shortGuid();
3463
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3464
                                            currentControl.IsNew = true;
3465
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3466
                                        }
3467
                                    }
3468
                                }
3469
                            }
3470
                        }
3471
                        break;
3472
                    case ControlType.Date:
3473
                        {
3474
                            if (mouseButtonDown == MouseButton.Left)
3475
                            {
3476
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3477
                                {
3478
                                    if (currentControl is DateControl)
3479
                                    {
3480
                                        CreateControl();
3481
                                        (currentControl as DateControl).ApplyOverViewData();
3482
                                        currentControl = null;
3483

    
3484
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3485
                                        {
3486
                                            controlType = ControlType.None;
3487
                                            IsSwingMode = false;
3488
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3489
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3490
                                            mouseHandlingMode = MouseHandlingMode.None;
3491
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3492
                                            txtBatch.Visibility = Visibility.Collapsed;
3493

    
3494
                                        }
3495
                                    }
3496
                                    else
3497
                                    {
3498
                                        currentControl = new DateControl
3499
                                        {
3500
                                            Background = new SolidColorBrush(Colors.Black)
3501
                                        };
3502
                                        currentControl.CommentID = Save.shortGuid();
3503
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3504
                                        currentControl.IsNew = true;
3505
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3506
                                    }
3507
                                }
3508
                            }
3509
                        }
3510
                        break;
3511
                    case ControlType.TextControl:
3512
                        {
3513
                            if (mouseButtonDown == MouseButton.Left)
3514
                            {
3515
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3516
                                {
3517

    
3518
                                    currentControl = new TextControl
3519
                                    {
3520
                                        ControlType = controlType
3521
                                    };
3522
                                        currentControl.CommentID = Save.shortGuid();
3523
                                        currentControl.IsNew = true;
3524
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3525
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3526
                                        currentControl.SetValue(Canvas.ZIndexProperty, 2);
3527
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3528
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3529
                                        currentControl.Focus();
3530
                                        (currentControl as TextControl).ApplyOverViewData();
3531
                                        (currentControl as TextControl).ControlType_No = 0;
3532
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3533
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3534

    
3535
                                        CreateControl();
3536

    
3537
                                        currentControl = null;
3538
                                }
3539
                            }
3540
                        }
3541
                        break;
3542
                    case ControlType.TextBorder:
3543
                        {
3544
                            if (mouseButtonDown == MouseButton.Left)
3545
                            {
3546
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3547
                                {
3548
                                    currentControl = new TextControl
3549
                                    {
3550
                                        ControlType = controlType
3551
                                    };
3552

    
3553

    
3554
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3555
                                    currentControl.CommentID = Save.shortGuid();
3556
                                    currentControl.IsNew = true;
3557
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3558
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3559
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3560
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3561
                                    currentControl.Focus();
3562
                                    (currentControl as TextControl).ControlType_No = 1;
3563
                                    (currentControl as TextControl).Angle = Ang;
3564
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3565
                                    CreateControl();
3566

    
3567
                                    currentControl = null;
3568
                                }
3569
                            }
3570
                        }
3571
                        break;
3572
                    case ControlType.TextCloud:
3573
                        {
3574
                            if (mouseButtonDown == MouseButton.Left)
3575
                            {
3576
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3577
                                {
3578
                                    currentControl = new TextControl
3579
                                    {
3580
                                        ControlType = controlType
3581
                                    };
3582
                                    currentControl.CommentID = Save.shortGuid();
3583
                                    currentControl.IsNew = true;
3584
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3585
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3586

    
3587
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3588
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3589
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3590
                                    currentControl.Focus();
3591

    
3592
                                    (currentControl as TextControl).Angle = Ang;
3593
                                    (currentControl as TextControl).ControlType_No = 2;
3594
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3595

    
3596
                                    CreateControl();
3597
                                    currentControl = null;
3598
                                }
3599
                            }
3600
                        }
3601
                        break;
3602
                    case ControlType.ArrowTextControl:
3603
                        {
3604
                            if (mouseButtonDown == MouseButton.Left)
3605
                            {
3606
                                if (currentControl is ArrowTextControl)
3607
                                {
3608
                                    CreateControl();
3609

    
3610
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3611
                                    (currentControl as ArrowTextControl).IsEditing = false;
3612
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3613
                                    currentControl = null;
3614
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3615

    
3616
                                }
3617
                                else
3618
                                {
3619
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3620
                                    {
3621
                                        currentControl = new ArrowTextControl();
3622
                                        currentControl.CommentID = Save.shortGuid();
3623
                                        currentControl.IsNew = true;
3624
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3625
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3626

    
3627
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3628

    
3629
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3630

    
3631
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3632

    
3633
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3634

    
3635
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3636

    
3637
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3638
                                        this.MainAngle.Visibility = Visibility.Visible;
3639
                                    }
3640
                                }
3641
                            }
3642
                        }
3643
                        break;
3644
                    case ControlType.ArrowTransTextControl:
3645
                        {
3646
                            if (mouseButtonDown == MouseButton.Left)
3647
                            {
3648
                                if (currentControl is ArrowTextControl)
3649
                                {
3650
                                    CreateControl();
3651
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3652
                                    currentControl = null;
3653
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3654
                                }
3655
                                else
3656
                                {
3657
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3658
                                    {
3659
                                        currentControl = new ArrowTextControl();
3660
                                        currentControl.CommentID = Save.shortGuid();
3661
                                        currentControl.IsNew = true;
3662
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3663
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3664

    
3665
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3666

    
3667
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3668

    
3669
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3670

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

    
3673
                                        (currentControl as ArrowTextControl).isFixed = true;
3674
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3675

    
3676
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3677
                                        this.MainAngle.Visibility = Visibility.Visible;
3678
                                    }
3679
                                }
3680
                            }
3681
                        }
3682
                        break;
3683
                    case ControlType.ArrowTextBorderControl:
3684
                        {
3685
                            if (mouseButtonDown == MouseButton.Left)
3686
                            {
3687
                                if (currentControl is ArrowTextControl)
3688
                                {
3689
                                    CreateControl();
3690
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3691
                                    currentControl = null;
3692
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3693
                                }
3694
                                else
3695
                                {
3696
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3697
                                    {
3698
                                        currentControl = new ArrowTextControl()
3699
                                        {
3700
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3701
                                        };
3702
                                        currentControl.CommentID = Save.shortGuid();
3703
                                        currentControl.IsNew = true;
3704
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3705
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3706

    
3707
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3708

    
3709
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3710

    
3711
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3712
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3713

    
3714
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3715

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

    
3747
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3748

    
3749
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3750

    
3751
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3752

    
3753
                                        (currentControl as ArrowTextControl).isFixed = true;
3754
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3755

    
3756
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3757

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

    
3789
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3790

    
3791
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3792

    
3793
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3794
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3795
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3796

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

    
3828
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3829

    
3830
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3831

    
3832
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3833

    
3834
                                        (currentControl as ArrowTextControl).isFixed = true;
3835
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3836

    
3837
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3838

    
3839
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3840
                                        this.MainAngle.Visibility = Visibility.Visible;
3841
                                    }
3842
                                }
3843
                            }
3844
                        }
3845
                        break;
3846
                    case ControlType.PolygonControl:
3847
                        {
3848
                            if (currentControl is PolygonControl)
3849
                            {
3850
                                var control = currentControl as PolygonControl;
3851

    
3852
                                if (mouseButtonDown == MouseButton.Right)
3853
                                {
3854
                                    control.IsCompleted = true;
3855
                                }
3856

    
3857
                                if (!control.IsCompleted)
3858
                                {
3859
                                    control.PointSet.Add(control.EndPoint);
3860
                                }
3861
                                else
3862
                                {
3863
                                    var firstPoint = control.PointSet.First();
3864
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3865
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3866
                                    control.PointSet.Add(firstPoint);
3867

    
3868
                                    control.SetPolyPath();
3869

    
3870
                                    control.ApplyOverViewData();
3871

    
3872
                                    CreateControl();
3873

    
3874
                                    currentControl = null;
3875
                                }
3876
                            }
3877
                            else
3878
                            {
3879
                                if (mouseButtonDown == MouseButton.Left)
3880
                                {
3881
                                    currentControl = new PolygonControl
3882
                                    {
3883
                                        PointSet = new List<Point>(),
3884
                                        //PointC = new StylusPointSet()
3885
                                    };
3886

    
3887
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3888
                                    {
3889
                                        var polygonControl = (currentControl as PolygonControl);
3890
                                        currentControl.CommentID = Save.shortGuid();
3891
                                        currentControl.IsNew = true;
3892
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3893
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3894
                                        //currentControl.OnApplyTemplate();
3895
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3896
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3897
                                    }
3898
                                }
3899
                            }
3900
                        }
3901
                        break;
3902
                    //강인구 추가
3903
                    case ControlType.Sign:
3904
                        {
3905
                            if (mouseButtonDown == MouseButton.Left)
3906
                            {
3907
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3908
                                {
3909
                                    if (currentControl is SignControl)
3910
                                    {
3911
                                        CreateControl();
3912
                                        currentControl = null;
3913
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3914
                                        {
3915
                                            txtBatch.Text = "Date Control을 그립니다.";
3916
                                            controlType = ControlType.Date;
3917
                                        }
3918
                                    }
3919
                                    else
3920
                                    {
3921
                                        currentControl = new SignControl
3922
                                        {
3923
                                            Background = new SolidColorBrush(Colors.Black),
3924
                                            UserNumber = App.ViewInfo.UserID,
3925
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3926
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3927
                                            ControlType = ControlType.Sign
3928
                                        };
3929

    
3930
                                        currentControl.CommentID = Save.shortGuid();
3931
                                        currentControl.IsNew = true;
3932
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3933
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3934
                                    }
3935
                                }
3936
                            }
3937
                        }
3938
                        break;
3939
                    case ControlType.Mark:
3940
                        {
3941
                            if (mouseButtonDown == MouseButton.Left)
3942
                            {
3943
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3944
                                {
3945
                                    if (currentControl is RectangleControl)
3946
                                    {
3947
                                        CreateControl();
3948
                                        (currentControl as RectangleControl).ApplyOverViewData();
3949
                                        currentControl = null;
3950
                                        this.cursor = Cursors.Arrow;
3951

    
3952
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3953
                                        {
3954
                                            txtBatch.Text = "Sign Control을 그립니다.";
3955
                                            controlType = ControlType.Sign;
3956
                                        }
3957
                                    }
3958
                                    else
3959
                                    {
3960
                                        currentControl = new RectangleControl
3961
                                        {
3962
                                            Background = new SolidColorBrush(Colors.Black),
3963
                                            Paint = PaintSet.Fill
3964
                                        };
3965

    
3966
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3967
                                        currentControl.CommentID = Save.shortGuid();
3968
                                        currentControl.IsNew = true;
3969
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3970
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3971
                                    }
3972
                                }
3973
                            }
3974
                        }
3975
                        break;
3976
                    case ControlType.Symbol:
3977
                        {
3978
                            if (mouseButtonDown == MouseButton.Left)
3979
                            {
3980
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3981
                                {
3982
                                    if (currentControl is SymControl)
3983
                                    {
3984
                                        CreateControl();
3985
                                        currentControl = null;
3986
                                        this.cursor = Cursors.Arrow;
3987
                                    }
3988
                                    else
3989
                                    {
3990
                                        currentControl = new SymControl
3991
                                        {
3992
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3993
                                            Background = new SolidColorBrush(Colors.Black),
3994
                                            ControlType = ControlType.Symbol
3995
                                        };
3996

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

    
4027
                                        currentControl.IsNew = true;
4028
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4029
                                        currentControl.CommentID = Save.shortGuid();
4030
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4031
                                    }
4032
                                }
4033
                            }
4034
                        }
4035
                        break;
4036
                    case ControlType.PenControl:
4037
                        {
4038
                            if (inkBoard.Tag.ToString() == "Ink")
4039
                            {
4040
                                inkBoard.IsEnabled = true;
4041
                                StartNewStroke(canvasDrawingMouseDownPoint);
4042
                            }
4043
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4044
                            {
4045
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4046
                            }
4047
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4048
                            {
4049
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4050
                            }
4051
                            IsDrawing = true;
4052
                            return;
4053
                        }
4054
                    default:
4055
                        if (currentControl != null)
4056
                        {
4057
                            currentControl.CommentID = null;
4058
                            currentControl.IsNew = false;
4059
                        }
4060
                        break;
4061
                }
4062

    
4063
            }
4064

    
4065
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4066
            {
4067
                if (controlType == ControlType.None)
4068
                {
4069
                    mouseHandlingMode = MouseHandlingMode.Selecting;
4070
                    this.cursor = Cursors.Arrow;
4071
                    inkDrawingCanvas.IsEnabled = false;
4072
                    isLeftMouseButtonDownOnWindow = true;
4073
                }
4074
            }
4075

    
4076
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4077
            {
4078
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4079
                {
4080
                    bool mouseOff = false;
4081
                    foreach (var item in SelectLayer.Children)
4082
                    {
4083
                        if (item is AdornerFinal)
4084
                        {
4085

    
4086
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4087
                            if (over != null)
4088
                            {
4089
                                mouseOff = true;
4090
                            }
4091
                        }
4092
                    }
4093

    
4094
                    if (!mouseOff)
4095
                    {
4096
                        ReleaseAdorner();
4097
                    }
4098
                }
4099
                zoomAndPanControl.CaptureMouse();
4100
                e.Handled = true;
4101
            }
4102
            
4103
        }
4104
        
4105
        private void RemoveLineStroke(Point P)
4106
        {
4107
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4108
            if (control != null)
4109
            {
4110
                UndoData = new Undo_data()
4111
                {
4112
                    IsUndo = false,
4113
                    Event = Event_Type.Delete,
4114
                    EventTime = DateTime.Now,
4115
                    Markup_List = new List<Multi_Undo_data>()
4116
                };
4117

    
4118

    
4119
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4120
                UndoData.Markup_List.Add(multi_Undo_Data);
4121
                multi_Undo_Data = new Multi_Undo_data();
4122

    
4123
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4124
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4125
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4126

    
4127

    
4128
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4129
                {
4130
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4131
                });
4132
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4133
                
4134
            }
4135
        }
4136

    
4137
        private void RemovePointStroke(Point P)
4138
        {
4139
            foreach (Stroke hits in inkBoard.Strokes)
4140
            {
4141
                foreach (StylusPoint sty in hits.StylusPoints)
4142
                {
4143

    
4144
                }
4145
                if (hits.HitTest(P))
4146
                {
4147
                    inkBoard.Strokes.Remove(hits);
4148
                    return;
4149
                }
4150
            }
4151
        }
4152

    
4153
        private void StartNewStroke(Point P)
4154
        {
4155
            strokePoints = new StylusPointCollection();
4156
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4157
            strokePoints.Add(segment1Start);
4158
            stroke = new Stroke(strokePoints);
4159

    
4160
            stroke.DrawingAttributes.Color = Colors.Red;
4161
            stroke.DrawingAttributes.Width = 4;
4162
            stroke.DrawingAttributes.Height = 4;
4163

    
4164
            inkBoard.Strokes.Add(stroke);
4165

    
4166
        }
4167

    
4168
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4169
        {
4170
            ConsolidationMethod();
4171
        }
4172

    
4173
        public void ConsolidationMethod()
4174
        {
4175
            ChangeCommentReact();
4176

    
4177
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4178
            {
4179
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4180
            }
4181
            else
4182
            {
4183

    
4184
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4185
                {
4186
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4187
                }
4188

    
4189
                ViewerDataModel.Instance.IsConsolidate = true;
4190
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4191
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4192
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4193
                {
4194
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4195
                    if (markupInfo.CONSOLIDATE == 1)
4196
                    {
4197
                        markupInfo.AVOID_CONSOLIDATE = 1;
4198
                    }
4199

    
4200
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4201
                    {
4202
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4203
                          {
4204
                              instanceDataSet.Add(d);
4205
                          });
4206
                    }
4207

    
4208
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4209
                    info.ID = Save.shortGuid();
4210
                    info.CONSOLIDATE = 1;
4211
                    info.CREATE_TIME = DateTime.Now;
4212
                    info.DOCINFO_ID = _DocInfo.ID;
4213
                    info.UPDATE_TIME = DateTime.Now;
4214
                    info.USER_ID = App.ViewInfo.UserID;
4215
                    info.AVOID_CONSOLIDATE = 0;
4216

    
4217
                    Entity.MARKUP_INFO.AddObject(info);
4218
                    Entity.SaveChanges();
4219

    
4220

    
4221
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4222
                    {
4223
                        ID = Save.shortGuid(),
4224
                        CREATE_DATE = DateTime.Now,
4225
                        MARKUP_INFO = info,
4226
                    };
4227
                    Entity.SaveChanges();
4228

    
4229
                    foreach (var item in instanceDataSet)
4230
                    {
4231
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4232
                        {
4233
                            ID = Save.shortGuid(),
4234
                            DATA = item.DATA,
4235
                            DATA_TYPE = item.DATA_TYPE,
4236
                            PAGENUMBER = item.PAGENUMBER,
4237
                            MARKUP_INFO_VERSION = info2
4238
                        });
4239
                    }
4240
                    Entity.SaveChanges();
4241
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4242
                }
4243
            }
4244
        }
4245

    
4246
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4247
        {
4248
            if (App.ViewInfo != null)
4249
            {
4250
                btnConsolidate = (sender as RadRibbonButton);
4251
                if (!App.ViewInfo.NewCommentPermission)
4252
                {
4253
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4254
                }
4255
            }
4256
        }
4257

    
4258
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4259
        {
4260

    
4261
        }
4262

    
4263
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4264
        {
4265
            btnTeamConsolidate = sender as RadRibbonButton;
4266
            if (App.ViewInfo != null)
4267
            {
4268
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4269
                {
4270
                    if (btnConsolidate != null)
4271
                    {
4272
                        btnConsolidate.Visibility = Visibility.Collapsed;
4273
                    }
4274

    
4275
                    if (!App.ViewInfo.NewCommentPermission)
4276
                    {
4277
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4278
                    }
4279
                }
4280
                else
4281
                {
4282
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4283
                }
4284
            }
4285
        }
4286

    
4287
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4288
        {
4289
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4290
            if (item != null)
4291
            {
4292
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4293
            }
4294
            else
4295
            {
4296
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4297
            }
4298
        }
4299

    
4300
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4301
        {
4302
            btnFinalPDF = sender as RadRibbonButton;
4303
            if (App.ViewInfo != null)
4304
            {
4305
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4306
                {
4307
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4308
                    if (btnConsolidate != null)
4309
                    {
4310
                        btnConsolidate.Visibility = Visibility.Collapsed;
4311
                    }
4312
                }
4313
            }
4314
        }
4315

    
4316
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4317
        {
4318
            if (CompareMode.IsChecked)
4319
            {
4320
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4321
                {
4322
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4323
                }
4324
                if (ViewerDataModel.Instance.PageNumber == 0)
4325
                {
4326
                    ViewerDataModel.Instance.PageNumber = 1;
4327
                }
4328

    
4329
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4330
            }
4331
            else
4332
            {
4333
                da.From = 1;
4334
                da.To = 1;
4335
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4336
                da.AutoReverse = false;
4337
                canvas_compareBorder.Children.Clear();
4338
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4339
            }
4340
        }
4341

    
4342
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4343
        {
4344
            if (UserList.IsChecked)
4345
            {
4346
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4347
            }
4348
            else
4349
            {
4350
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4351
            }
4352
        }
4353

    
4354
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4355
        {
4356

    
4357
            if (BalanceMode.IsChecked)
4358
            {
4359
                ViewerDataModel.Instance.PageBalanceMode = true;
4360
            }
4361
            else
4362
            {
4363
                ViewerDataModel.Instance.PageBalanceMode = false;
4364
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4365
            }
4366
        }
4367

    
4368
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4369
        {
4370
            //초기화
4371
            testPanel2.IsHidden = true;
4372
            ViewerDataModel.Instance.PageBalanceMode = false;
4373
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4374
            ViewerDataModel.Instance.PageNumber = 0;
4375
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4376
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4377
            UserList.IsChecked = false;
4378
            BalanceMode.IsChecked = false;
4379
        }
4380

    
4381
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4382
        {
4383
            if ((sender as System.Windows.Controls.Control).Tag != null)
4384
            {
4385
                //Compare 초기화
4386
                CompareMode.IsChecked = false;
4387
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4388

    
4389
                if (ViewerDataModel.Instance.PageNumber == 0)
4390
                {
4391
                    ViewerDataModel.Instance.PageNumber = 1;
4392
                }
4393

    
4394
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4395
                {
4396
                }
4397
                else
4398
                {
4399
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4400
                }
4401

    
4402
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4403
                {
4404

    
4405
                }
4406
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4407
                {
4408
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4409
                }
4410

    
4411
                if (!testPanel2.IsHidden)
4412
                {
4413
                    if (IsSyncPDFMode)
4414
                    {
4415
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4416
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4417

    
4418
                        if (pdfpath.IsDownloading)
4419
                        {
4420
                            pdfpath.DownloadCompleted += (ex, arg) =>
4421
                            {
4422
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4423
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4424
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4425
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4426
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4427
                            };
4428
                        }
4429
                        else
4430
                        {
4431
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4432
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4433
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4434

    
4435
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4436
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4437
                        }
4438

    
4439
                    }
4440
                    else
4441
                    {
4442
                        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);
4443

    
4444
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4445

    
4446
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4447
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4448
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4449

    
4450
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4451
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4452

    
4453
                        if (defaultBitmapImage_Compare.IsDownloading)
4454
                        {
4455
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4456
                            {
4457
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4458
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4459
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4460

    
4461
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4462
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4463
                            };
4464
                        }
4465
                    }
4466

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

    
4471
                    foreach (var item in gridSelectionRevItem)
4472
                    {
4473
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4474
                        {
4475
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4476
                        });
4477
                    }
4478
                    
4479
                    //강인구 추가
4480
                    zoomAndPanControl2.ZoomTo(new Rect
4481
                    {
4482
                        X = 0,
4483
                        Y = 0,
4484
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4485
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4486
                    });
4487

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

    
4490
                }
4491
            }
4492
        }
4493

    
4494
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4495
        {
4496
            if (MarkupMode.IsChecked)
4497
            {
4498
                IsSyncPDFMode = true;
4499

    
4500
                var uri = CurrentRev.TO_VENDOR;
4501

    
4502
                if (ViewerDataModel.Instance.PageNumber == 0)
4503
                {
4504
                    ViewerDataModel.Instance.PageNumber = 1;
4505
                }
4506

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

    
4511
                if (pdfpath.IsDownloading)
4512
                {
4513
                    pdfpath.DownloadCompleted += (ex, arg) =>
4514
                    {
4515
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4516
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4517
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4518
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4519
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4520
                    };
4521
                }
4522
                else
4523
                {
4524
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4525
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4526
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4527

    
4528
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4529
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4530
                }
4531
            }
4532
            else
4533
            {
4534
                IsSyncPDFMode = false;
4535
                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);
4536

    
4537
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4538

    
4539
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4540
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4541
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4542

    
4543
                if (defaultBitmapImage_Compare.IsDownloading)
4544
                {
4545
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4546
                    {
4547
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4548
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4549
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4550
                    };
4551
                }
4552
                zoomAndPanControl2.ApplyTemplate();
4553
                zoomAndPanControl2.UpdateLayout();
4554
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4555
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4556
            }
4557
        }
4558

    
4559
        private void RadButton_Click(object sender, RoutedEventArgs e)
4560
        {
4561
            gridViewHistory_Busy.IsBusy = true;
4562

    
4563
            RadButton instance = sender as RadButton;
4564
            if (instance.CommandParameter != null)
4565
            {
4566
                CurrentRev = instance.CommandParameter as VPRevision;
4567
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4568
                {
4569
                    if (ea.Error == null && ea.Result != null)
4570
                    {
4571
                        testPanel2.IsHidden = false;
4572

    
4573
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4574
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4575

    
4576
                        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);
4577

    
4578
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4579

    
4580
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
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
                        if (defaultBitmapImage_Compare.IsDownloading)
4587
                        {
4588
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4589
                            {
4590
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4591
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4592
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4593
                            };
4594
                        }
4595

    
4596
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4597
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4598
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4599
                        zoomAndPanControl2.ApplyTemplate();
4600
                        zoomAndPanControl2.UpdateLayout();
4601

    
4602
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4603
                        {
4604
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4605
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4606
                        }
4607

    
4608
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4609
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4610
                        gridViewHistory_Busy.IsBusy = false;
4611
                    }
4612
                };
4613
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4614
            }
4615
        }
4616

    
4617
        public void Sync_Event(VPRevision Currnet_Rev)
4618
        {
4619
            CurrentRev = Currnet_Rev;
4620

    
4621
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4622
            {
4623
                if (ea.Error == null && ea.Result != null)
4624
                {
4625
                    testPanel2.IsHidden = false;
4626

    
4627
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4628
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4629

    
4630
                    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);
4631

    
4632
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4633

    
4634
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4635

    
4636
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4637
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4638
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4639

    
4640
                    if (defaultBitmapImage_Compare.IsDownloading)
4641
                    {
4642
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4643
                        {
4644
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4645
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4646
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4647
                        };
4648
                    }
4649

    
4650
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4651
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4652
                    zoomAndPanControl2.ApplyTemplate();
4653
                    zoomAndPanControl2.UpdateLayout();
4654

    
4655
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4656
                    {
4657
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4658
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4659
                    }
4660
                    //}
4661

    
4662
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4663
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4664
                    gridViewHistory_Busy.IsBusy = false;
4665
                }
4666
            };
4667
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4668

    
4669

    
4670
        }
4671

    
4672
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4673
        {
4674
            if (sender is Image)
4675
            {
4676
                if ((sender as Image).Tag != null)
4677
                {
4678
                    var pdfUrl = (sender as Image).Tag.ToString();
4679
                    System.Diagnostics.Process.Start(pdfUrl);
4680
                }
4681
                else
4682
                {
4683
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4684
                }
4685
            }
4686
        }
4687

    
4688
        private void Create_Symbol(object sender, RoutedEventArgs e)
4689
        {
4690
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4691
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4692

    
4693
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4694
            {
4695
                DialogMessage_Alert("Please Select Controls", "Alert");
4696
            }
4697
            else //선택된 것이 있으면
4698
            {
4699
                string MarkupData = "";
4700
                adorner_ = new AdornerFinal();
4701

    
4702
                foreach (var item in SelectLayer.Children)
4703
                {
4704
                    if (item.GetType().Name == "AdornerFinal")
4705
                    {
4706
                        adorner_ = (item as Controls.AdornerFinal);
4707
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4708
                        {
4709
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4710
                            {
4711
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4712
                                MarkupData += markupReturn.ConvertData;
4713
                            }
4714
                        }
4715
                    }
4716
                }
4717
                DialogParameters parameters = new DialogParameters()
4718
                {
4719
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4720
                    DefaultPromptResultValue = "Custom State",
4721
                    Content = "Name :",
4722
                    Header = "Insert Custom Symbol Name",
4723
                    Theme = new VisualStudio2013Theme(),
4724
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4725
                };
4726
                RadWindow.Prompt(parameters);
4727
            }
4728

    
4729
        }
4730

    
4731
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4732
        {
4733
            Save save = new Save();
4734

    
4735
            if (args.DialogResult.Value)
4736
            {
4737
                PngBitmapEncoder _Encoder = symImage(data);
4738

    
4739
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4740
                _Encoder.Save(fs);
4741
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4742

    
4743
                byte[] Img_byte = fs.ToArray();
4744

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

    
4748
                save.SymbolSave(args.PromptResult, filename, data);
4749
            }
4750
        }
4751

    
4752
        public PngBitmapEncoder symImage(string data)
4753
        {
4754

    
4755
            Canvas _canvas = new Canvas();
4756
            _canvas.Background = Brushes.White;
4757
            _canvas.Width = adorner_.BorderSize.Width;
4758
            _canvas.Height = adorner_.BorderSize.Height;
4759
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4760

    
4761
            BitmapEncoder encoder = new PngBitmapEncoder();
4762

    
4763

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

    
4766
            DrawingVisual dv = new DrawingVisual();
4767

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

    
4771
            using (DrawingContext ctx = dv.RenderOpen())
4772
            {
4773
                VisualBrush vb = new VisualBrush(_canvas);
4774
                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)));
4775
            }
4776

    
4777
            try
4778
            {
4779
                renderBitmap.Render(dv);
4780

    
4781
                GC.Collect();
4782
                GC.WaitForPendingFinalizers();
4783
                GC.Collect();
4784
                // encode png data
4785
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4786
                // puch rendered bitmap into it
4787
                pngEncoder.Interlace = PngInterlaceOption.Off;
4788
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4789
                return pngEncoder;
4790

    
4791
            }
4792
            catch (Exception ex)
4793
            {
4794
                return null;
4795
            }
4796

    
4797
        }
4798

    
4799
        public void DialogMessage_Alert(string content, string header)
4800
        {
4801
            var box = new TextBlock();
4802
            box.MinWidth = 400;
4803
            box.FontSize = 11;
4804
            //box.FontSize = 12;
4805
            box.Text = content;
4806
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4807

    
4808
            DialogParameters parameters = new DialogParameters()
4809
            {
4810
                Content = box,
4811
                Header = header,
4812
                Theme = new VisualStudio2013Theme(),
4813
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4814
            };
4815
            RadWindow.Alert(parameters);
4816
        }
4817

    
4818
        #region 캡쳐 기능
4819

    
4820
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4821
        {
4822
            if (x < 0)
4823
            {
4824
                width += x;
4825
                x = 0;
4826
            }
4827
            if (y < 0)
4828
            {
4829
                height += y;
4830
                y = 0;
4831

    
4832
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4833
            }
4834
            if (x + width > zoomAndPanCanvas.ActualWidth)
4835
            {
4836
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4837
            }
4838
            if (y + height > zoomAndPanCanvas.ActualHeight)
4839
            {
4840
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4841
            }
4842

    
4843
            byte[] pixels = CopyPixels(x, y, width, height);
4844

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

    
4847
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4848
        }
4849

    
4850
        public byte[] CopyPixels(int x, int y, int width, int height)
4851
        {
4852
            byte[] pixels = new byte[width * height * 4];
4853
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4854

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

    
4858
            return pixels;
4859
        }
4860

    
4861
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4862
        {
4863
            DrawingVisual drawingVisual = new DrawingVisual();
4864
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4865

    
4866
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4867
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4868
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4869
            drawingContext.Close();
4870

    
4871
            // 비트맵으로 변환합니다.
4872
            RenderTargetBitmap target =
4873
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4874
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4875

    
4876
            target.Render(drawingVisual);
4877
            return target;
4878
        }
4879

    
4880
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4881
        {
4882
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4883
            KCOMDataModel.DataModel.CHECK_LIST check_;
4884
            string Result = streamToBase64.ImageToBase64(source);
4885
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4886

    
4887
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4888
            {
4889
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
4890

    
4891
                //새로운 데이터 추가
4892
                if (Item == null)
4893
                {
4894
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
4895
                    {
4896
                        ID = Save.shortGuid(),
4897
                        USER_ID = App.ViewInfo.UserID,
4898
                        IMAGE_URL = Result,
4899
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4900
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4901
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4902
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4903
                        PROJECT_NO = App.ViewInfo.ProjectNO,
4904
                        STATUS = "False",
4905
                        CREATE_TIME = DateTime.Now,
4906
                        UPDATE_TIME = DateTime.Now,
4907
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4908
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
4909
                    };
4910

    
4911
                    Entity.CHECK_LIST.AddObject(check_);
4912
                }
4913
                //기존에 있던 데이터 업데이트
4914
                else
4915
                {
4916
                    Item.IMAGE_URL = Result;
4917
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4918
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4919
                }
4920

    
4921
                //Item.REV_0 = "Test";
4922

    
4923
                try
4924
                {
4925
                    Entity.SaveChanges();
4926
                }
4927
                catch (Exception ex)
4928
                {
4929

    
4930
                }
4931
                //Entity.SaveChanges();
4932
            }
4933
        }
4934

    
4935
        public void Set_Capture()
4936
        {
4937
            //double x = Canvas.GetLeft(dragCaptureBorder);
4938
            //double y = Canvas.GetTop(dragCaptureBorder);
4939
            double x = canvasDrawingMouseDownPoint.X;
4940
            double y = canvasDrawingMouseDownPoint.Y;
4941
            double width = dragCaptureBorder.Width;
4942
            double height = dragCaptureBorder.Height;
4943

    
4944
            if (width > 5 || height > 5)
4945
            {
4946
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
4947
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
4948
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
4949
            }
4950
        }
4951
        #endregion
4952

    
4953
        public void CreateControl()
4954
        {
4955
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4956
            {
4957
                ViewerDataModel.Instance.UndoDataList.Remove(i);
4958
            });
4959
            multi_Undo_Data.Markup = currentControl;
4960
            UndoData.Markup_List.Add(multi_Undo_Data);
4961
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4962
        }
4963

    
4964
        public Multi_Undo_data Control_Style(CommentUserInfo control)
4965
        {
4966
            multi_Undo_Data = new Multi_Undo_data();
4967

    
4968
            multi_Undo_Data.Markup = control;
4969

    
4970
            if ((control as IShapeControl) != null)
4971
            {
4972
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
4973
            }
4974
            if ((control as IDashControl) != null)
4975
            {
4976
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
4977
            }
4978
            if ((control as IPath) != null)
4979
            {
4980
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
4981
            }
4982
            if ((control as UIElement) != null)
4983
            {
4984
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
4985
            }
4986

    
4987
            return multi_Undo_Data;
4988
        }
4989

    
4990
        public void Undo()
4991
        {
4992
            Undo_data undo = new Undo_data();
4993
            AdornerFinal final;
4994
            ReleaseAdorner();
4995

    
4996
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
4997
            if (undo == null)
4998
                return;
4999

    
5000
            switch (undo.Event)
5001
            {
5002
                case (Event_Type.Create):
5003
                    {
5004
                        foreach (var item in undo.Markup_List)
5005
                        {
5006
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5007
                        }
5008
                    }
5009
                    break;
5010
                case (Event_Type.Delete):
5011
                    {
5012
                        foreach (var item in undo.Markup_List)
5013
                        {
5014
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5015
                        }
5016
                    }
5017
                    break;
5018
                case (Event_Type.Thumb):
5019
                    {
5020
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5021

    
5022
                        foreach (var item in undo.Markup_List)
5023
                        {
5024
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5025

    
5026
                            if ((item.Markup as IViewBox) != null)
5027
                            {
5028
                                (item.Markup as IViewBox).Angle = item.Angle;
5029
                            }
5030
                            if ((item.Markup as TextControl) != null)
5031
                            {
5032
                                (item.Markup as TextControl).Angle = item.Angle;
5033
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5034
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5035
                            }
5036
                            else
5037
                            {
5038
                                (item.Markup as IPath).PointSet = item.PointSet;
5039
                                (item.Markup as IPath).updateControl();
5040
                            }
5041

    
5042
                            comment.Add(item.Markup);
5043
                        }
5044
                        final = new AdornerFinal(comment);
5045
                        SelectLayer.Children.Add(final);
5046
                        ReleaseAdorner();
5047
                    }
5048
                    break;
5049
                case (Event_Type.Select):
5050
                    {
5051
                        ReleaseAdorner();
5052
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5053

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

    
5058
                            if ((item.Markup as IPath) != null)
5059
                            {
5060
                                (item.Markup as IPath).LineSize = item.LineSize;
5061
                            }
5062
                            if ((item.Markup as UIElement) != null)
5063
                            {
5064
                                (item.Markup as UIElement).Opacity = item.Opacity;
5065
                            }
5066
                            if ((item.Markup as IDashControl) != null)
5067
                            {
5068
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5069
                            }
5070
                            if ((item.Markup as IShapeControl) != null)
5071
                            {
5072
                                (item.Markup as IShapeControl).Paint = item.paint;
5073
                            }
5074

    
5075
                            comment.Add(item.Markup);
5076
                        }
5077

    
5078
                        final = new AdornerFinal(comment);
5079
                        SelectLayer.Children.Add(final);
5080
                    }
5081
                    break;
5082
                case (Event_Type.Option):
5083
                    {
5084
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5085

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

    
5090
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5091
                            {
5092
                                (item.Markup as IPath).LineSize = undo.LineSize;
5093
                            }
5094
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5095
                            {
5096
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5097
                            }
5098
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5099
                            {
5100
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5101
                            }
5102
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5103
                            {
5104
                                (item.Markup as LineControl).Interval = undo.Interval;
5105
                            }
5106
                            else if (item.Markup as IShapeControl != null)
5107
                            {
5108
                                (item.Markup as IShapeControl).Paint = undo.paint;
5109
                            }
5110
                            comment.Add(item.Markup);
5111
                        }
5112
                        final = new AdornerFinal(comment);
5113
                        SelectLayer.Children.Add(final);
5114
                    }
5115
                    break;
5116
            }
5117
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5118
           {
5119
               i.IsUndo = true;
5120
           });
5121
        }
5122

    
5123
        public void Redo()
5124
        {
5125
            AdornerFinal final;
5126
            Undo_data redo = new Undo_data();
5127
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5128
            ReleaseAdorner();
5129
            if (redo == null)
5130
                return;
5131

    
5132
            switch (redo.Event)
5133
            {
5134
                case (Event_Type.Create):
5135
                    {
5136
                        foreach (var item in redo.Markup_List)
5137
                        {
5138
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5139
                        }
5140
                    }
5141
                    break;
5142
                case (Event_Type.Delete):
5143
                    {
5144
                        foreach (var item in redo.Markup_List)
5145
                        {
5146
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5147
                        }
5148
                    }
5149
                    break;
5150
                case (Event_Type.Thumb):
5151
                    {
5152
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5153

    
5154
                        foreach (var item in redo.Markup_List)
5155
                        {
5156
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5157

    
5158
                            if ((item.Markup as IViewBox) != null)
5159
                            {
5160
                                (item.Markup as IViewBox).Angle = item.Angle;
5161
                            }
5162
                            if ((item.Markup as TextControl) != null)
5163
                            {
5164
                                (item.Markup as TextControl).Angle = item.Angle;
5165

    
5166
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5167
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5168
                            }
5169
                            else
5170
                            {
5171
                                (item.Markup as IPath).PointSet = item.PointSet;
5172
                                (item.Markup as IPath).updateControl();
5173
                            }
5174
                            comment.Add(item.Markup);
5175
                        }
5176
                        final = new AdornerFinal(comment);
5177
                        SelectLayer.Children.Add(final);
5178
                        ReleaseAdorner();
5179
                    }
5180
                    break;
5181
                case (Event_Type.Select):
5182
                    {
5183
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5184

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

    
5189
                            if ((item.Markup as IPath) != null)
5190
                            {
5191
                                (item.Markup as IPath).LineSize = item.LineSize;
5192
                            }
5193
                            if ((item.Markup as UIElement) != null)
5194
                            {
5195
                                (item.Markup as UIElement).Opacity = item.Opacity;
5196
                            }
5197
                            if ((item.Markup as IDashControl) != null)
5198
                            {
5199
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5200
                            }
5201
                            if ((item.Markup as IShapeControl) != null)
5202
                            {
5203
                                (item.Markup as IShapeControl).Paint = item.paint;
5204
                            }
5205

    
5206
                            comment.Add(item.Markup);
5207
                        }
5208
                        final = new AdornerFinal(comment);
5209
                        SelectLayer.Children.Add(final);
5210
                    }
5211
                    break;
5212
                case (Event_Type.Option):
5213
                    {
5214
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5215

    
5216
                        foreach (var item in redo.Markup_List)
5217
                        {
5218
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5219
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5220
                            {
5221
                                (item.Markup as IPath).LineSize = redo.LineSize;
5222
                            }
5223
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5224
                            {
5225
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5226
                            }
5227
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5228
                            {
5229
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5230
                            }
5231
                            else if(redo.Interval != 0 && item.Markup as LineControl != null)
5232
                            {
5233
                                (item.Markup as LineControl).Interval = redo.Interval;
5234
                            }
5235
                            else if (item.Markup as IShapeControl != null)
5236
                            {
5237
                                (item.Markup as IShapeControl).Paint = redo.paint;
5238
                            }
5239
                            comment.Add(item.Markup);
5240
                        }
5241
                        final = new AdornerFinal(comment);
5242
                        SelectLayer.Children.Add(final);
5243
                    }
5244
                    break;
5245
            }
5246

    
5247
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5248
            {
5249
                i.IsUndo = false;
5250
            });
5251
        }
5252

    
5253
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5254
        {
5255
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5256
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5257
            {
5258
                if (items.UserID == Select_ID)
5259
                {
5260
                    foreach (var item in items.MarkupList)
5261
                    {
5262
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5263
                        {
5264
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5265
                        }
5266
                    }
5267
                }
5268
            }
5269
        }
5270

    
5271
        public void InkControl_Convert()
5272
        {
5273
            if (inkBoard.Strokes.Count > 0)
5274
            {
5275
                inkBoard.Strokes.ToList().ForEach(stroke =>
5276
                {
5277
                    List<Stroke> removingStroke = new List<Stroke>();
5278
                    StrokeCollection stC = new StrokeCollection();
5279

    
5280
                    removingStroke.Add(stroke);
5281

    
5282
                    InkToPath ip = new InkToPath();
5283
                    List<Point> inkPointSet = new List<Point>();
5284
                    PolygonControl pc = null;
5285
                    pc = new PolygonControl()
5286
                    {
5287
                        Angle = 0,
5288
                        PointSet = new List<Point>(),
5289
                        ControlType = ControlType.Ink
5290
                    };
5291
                    foreach (var item in removingStroke)
5292
                    {
5293
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5294
                        inkBoard.Strokes.Remove(item);
5295
                    }
5296
                    if (inkPointSet.Count != 0)
5297
                    {
5298
                        //강인구 추가(PenControl Undo Redo 추가)
5299
                        UndoData = new Undo_data()
5300
                        {
5301
                            IsUndo = false,
5302
                            Event = Event_Type.Create,
5303
                            EventTime = DateTime.Now,
5304
                            Markup_List = new List<Multi_Undo_data>()
5305
                        };
5306

    
5307
                        pc.StartPoint = inkPointSet[0];
5308
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5309
                        pc.PointSet = inkPointSet;
5310
                        pc.LineSize = 3;
5311
                        pc.CommentID = Save.shortGuid();
5312
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5313
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5314
                        pc.SetPolyPath();
5315

    
5316
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5317
                        {
5318
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5319
                        });
5320
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5321
                        UndoData.Markup_List.Add(multi_Undo_Data);
5322
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5323
                    }
5324
                });
5325

    
5326
            }
5327
        }
5328

    
5329
        //강인구 추가
5330
        //가로 세로 동일한 컨트롤 그리기(계산 다시 필요)
5331
        private Point GetSpherePoint(Point StartP, Point EndP)
5332
        {
5333
            Point Return_Point = new Point();
5334

    
5335
            double dx = EndP.X - StartP.X;
5336
            double dy = EndP.Y - StartP.Y;
5337
            double length = Math.Max(Math.Abs(dx),Math.Abs(dy));
5338

    
5339
            Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5340
            Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5341

    
5342
            /*
5343
            double pt_X = Math.Max(StartP.X, EndP.X) - Math.Min(StartP.X, EndP.X);
5344
            double pt_Y = Math.Max(StartP.Y, EndP.Y) - Math.Min(StartP.Y, EndP.Y);
5345
            double result = Math.Max(pt_X, pt_Y) - Math.Min(pt_X, pt_Y);
5346

    
5347
            if (EndP.X >= StartP.X)
5348
                Return_Point.X = pt_X > pt_Y ? EndP.X : EndP.X + result;
5349
            else
5350
                Return_Point.X = pt_X > pt_Y ? EndP.X : EndP.X - result;
5351

    
5352
            if (EndP.Y >= StartP.Y)
5353
                Return_Point.Y = pt_Y > pt_X ? EndP.Y : EndP.Y + result;
5354
            else
5355
                Return_Point.Y = pt_Y > pt_X ? EndP.Y : EndP.Y - result;
5356
            */
5357

    
5358
            return Return_Point;
5359
        }
5360
    }
5361
}
클립보드 이미지 추가 (최대 크기: 500 MB)