프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 999c9e40

이력 | 보기 | 이력해설 | 다운로드 (259 KB)

1

2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Line;
4
using MarkupToPDF.Controls.Polygon;
5
using MarkupToPDF.Controls.Shape;
6
using MarkupToPDF.Controls.Text;
7
using MarkupToPDF.Controls.Etc;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Data;
15
using System.Windows.Documents;
16
using System.Windows.Input;
17
using System.Windows.Media;
18
using System.Windows.Media.Imaging;
19
using System.Windows.Navigation;
20
using System.Windows.Shapes;
21
using KCOM.Common;
22
using IKCOM;
23
using System.Windows.Ink;
24
using System.Collections.ObjectModel;
25
using Telerik.Windows.Controls;
26
using KCOM.Events;
27
using System.Reflection;
28
using MarkupToPDF.Common;
29
using KCOM.Controls;
30

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

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

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

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

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

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

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

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

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

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

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

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

    
168
                }
169
            }
170
        }
171

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

    
196
        public bool IsSyncPDFMode { get; set; }
197

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

    
222
        #endregion
223

    
224

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

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

    
245
            return false;
246
        }
247

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

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

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

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

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

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

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

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

    
312
            DeleteItem(item);
313
        }
314

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

    
317
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
318
        {
319
            if (App.ParameterMode)
320
            {
321
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
322
                imageViewer_Compare = new Image();
323

    
324
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
325
                ViewerDataModel.Instance.Capture_Opacity = 0;
326

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

    
334

    
335
        }
336

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

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

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

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

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

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

    
387
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
388

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

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

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

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

    
456
        }
457

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

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

    
465
            InkControl_Convert();
466

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

    
472

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

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

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

    
487
            #endregion
488

    
489
            ViewerDataModel.Instance.PageNumber = BalancePoint;
490

    
491

    
492
            var uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
493

    
494
            var defaultBitmapImage = new BitmapImage(new Uri(uri));
495

    
496
            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
497
            ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
498
            ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
499

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

    
510
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
511
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
512

    
513

    
514
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
515
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
516
            inkBoard.Width = zoomAndPanCanvas.Width;
517
            inkBoard.Height = zoomAndPanCanvas.Height;
518

    
519

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

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

    
545
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
546
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
547
                    }
548
                }
549
                else
550
                {
551
                    var uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
552

    
553
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
554

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

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

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

    
574
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
575
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
576
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
577

    
578
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
579
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
580

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

    
594
            this.pageNavigator.SetNextPage();
595

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

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

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

    
623

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

    
629

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

    
638
            }
639

    
640

    
641

    
642
            var instanceMain = this.ParentOfType<MainWindow>();
643
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
644
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
645

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

    
651
            //}
652
            SetCommentPages(true);
653
        }
654

    
655
        private void SetCommentPages(bool onlyMe = false)
656
        {
657

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

    
681
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
682
        {
683
            if (e.MiddleButton == MouseButtonState.Pressed)
684
            {
685

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

    
700
        #region ZoomIn & ZoomOut
701

    
702
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
703
        {
704
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
705
                zoomAndPanControl.ContentZoomFocusY));
706
        }
707

    
708
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
709
        {
710
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
711
                zoomAndPanControl.ContentZoomFocusY));
712
        }
713

    
714

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

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

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

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

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

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

    
783
        #endregion
784

    
785
        private void init()
786
        {
787
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
788
            {
789

    
790
                ControlList.Clear();
791
                listBox.Items.Clear();
792
                selected_item.Clear();
793

    
794
                (item as IMarkupCommonData).IsSelected = false;
795
            }
796

    
797
        }
798

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

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

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

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

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

    
930
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
931
        {
932
            //Control_Init(e.Source);
933
        }
934

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

    
941
                Point currentPos = e.GetPosition(rect);
942

    
943
                floatingTip.HorizontalOffset = currentPos.X + 20;
944
                floatingTip.VerticalOffset = currentPos.Y;
945

    
946

    
947
                //ToolTip tool = new System.Windows.Controls.ToolTip();
948
                //tool.Content = "ToolTip";
949
                //panel.ToolTip = tool;
950
            }
951

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

    
958
                //if (firstCondition != null)
959
                //{
960
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
961

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

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

    
1026
                //        default:
1027
                //            {
1028

    
1029
                //            }
1030
                //            break;
1031
                //    }
1032
                //} 
1033
                #endregion
1034
            }
1035

    
1036
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1037

    
1038
            //if (mouseButtonDown == MouseButton.Middle)
1039
            //{
1040
            //    SetCursor();
1041
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1042
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1043

    
1044
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1045
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1046
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1047

    
1048
            //    //SetCursor();
1049
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1050
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1051

    
1052
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1053

    
1054
            //    //zoomAndPanControl.ContentOffsetX += 1;
1055
            //    //zoomAndPanControl.ContentOffsetY += 1;
1056

    
1057
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1058
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1059
            //}
1060
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1061
            {
1062
                SetCursor();
1063
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1064
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1065

    
1066
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1067
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1068
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1069
            }
1070

    
1071

    
1072
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1073
            {
1074
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1075
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1076
                SetCursor();
1077

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

    
1099
                                    //inkBoard.Strokes.Add(stroke);
1100
                                }
1101
                                break;
1102
                        }
1103
                        return;
1104
                    }
1105
                }
1106

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

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

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

    
1166
                    switch (controlType)
1167
                    {
1168
                        case ControlType.Rectangle:
1169
                            {
1170
                                var control = currentControl as RectangleControl;
1171

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

    
1185

    
1186
                                        if (ViewerDataModel.Instance.IsPressShift)
1187
                                        {
1188
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1189
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1190
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1191
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1192
                                        }
1193

    
1194
                                        control.PointSet = new List<Point>
1195
                                        {
1196
                                            control.StartPoint,
1197
                                            control.LeftBottomPoint,
1198
                                            control.EndPoint,
1199
                                            control.TopRightPoint,
1200
                                        };
1201
                                        control.updateControl();
1202
                                    }
1203

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

    
1212
                        case ControlType.RectCloud:
1213
                            {
1214
                                var control = currentControl as RectCloudControl;
1215

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

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

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

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

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

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

    
1286
                            }
1287
                            break;
1288

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

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

    
1314

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

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

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

    
1351

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

    
1362
                            }
1363
                            break;
1364

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

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

    
1389

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

    
1400
                            }
1401
                            break;
1402

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

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

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

    
1437
                            }
1438
                            break;
1439

    
1440
                        case ControlType.ChainLine:
1441
                            {
1442
                                var control = currentControl as PolygonControl;
1443

    
1444
                                if (control != null)
1445
                                {
1446

    
1447
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1448
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1449

    
1450
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1451

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

    
1464
                                    control.SetPolyPath();
1465
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1466
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1467
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1468

    
1469
                                    //강인구 추가
1470
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1471
                                }
1472
                            }
1473
                            break;
1474

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

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

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

    
1500

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

    
1512
                            }
1513
                            break;
1514

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

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

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

    
1549
                        case ControlType.ArrowMultiLine:
1550
                            {
1551
                                if (currentControl != null)
1552
                                {
1553
                                    var control = currentControl as ArrowControl_Multi;
1554

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

    
1585
                                        }
1586

    
1587
                                        control.PointSet = new List<Point>
1588
                                            {
1589
                                                control.StartPoint,
1590
                                                control.MiddlePoint,
1591
                                                control.EndPoint,
1592
                                            };
1593

    
1594
                                    }
1595
                                    //강인구 추가
1596
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1597
                                }
1598

    
1599
                            }
1600
                            break;
1601

    
1602
                        case ControlType.Circle:
1603
                            {
1604
                                var control = currentControl as CircleControl;
1605

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

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

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

    
1639
                                }
1640
                            }
1641
                            break;
1642

    
1643
                        case ControlType.PolygonCloud:
1644
                            {
1645
                                var control = currentControl as CloudControl;
1646

    
1647
                                if (control != null)
1648
                                {
1649
                                    control.isTransOn = true;
1650
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1651

    
1652
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1653

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

    
1662
                        case ControlType.Triangle:
1663
                            {
1664
                                var control = currentControl as TriControl;
1665

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

    
1677
                                        if (ViewerDataModel.Instance.checkAxis)
1678
                                        {
1679
                                            Point tempPoint = control.EndPoint;
1680
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1681
                                            control.EndPoint = tempPoint;
1682
                                        }
1683

    
1684

    
1685
                                        if (ViewerDataModel.Instance.IsPressShift)
1686
                                        {
1687
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1688
                                            if (2 == Points.Count())
1689
                                            {
1690
                                                control.MidPoint = Points[0];
1691
                                                control.EndPoint = Points[1];
1692
                                            }
1693
                                        }
1694

    
1695
                                        control.PointSet = new List<Point>
1696
                                            {
1697
                                                control.StartPoint,
1698
                                                control.MidPoint,
1699
                                                control.EndPoint,
1700
                                            };
1701
                                    }
1702
                                    //강인구 추가
1703
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1704
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1705
                                }
1706
                            }
1707
                            break;
1708

    
1709
                        case ControlType.ImgControl:
1710
                            {
1711
                                var control = currentControl as ImgControl;
1712

    
1713
                                if (control != null)
1714
                                {
1715
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1716
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1717
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1718
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1719

    
1720
                                    control.PointSet = new List<Point>
1721
                                        {
1722
                                            control.StartPoint,
1723
                                            control.LeftBottomPoint,
1724
                                            control.EndPoint,
1725
                                            control.TopRightPoint,
1726
                                        };
1727
                                }
1728
                            }
1729
                            break;
1730

    
1731
                        case ControlType.Date:
1732
                            {
1733
                                var control = currentControl as DateControl;
1734

    
1735
                                if (control != null)
1736
                                {
1737
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1738
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1739
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1740
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1741
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1742

    
1743
                                    control.PointSet = new List<Point>
1744
                                        {
1745
                                            control.StartPoint,
1746
                                            control.LeftBottomPoint,
1747
                                            control.EndPoint,
1748
                                            control.TopRightPoint,
1749
                                        };
1750
                                }
1751
                            }
1752
                            break;
1753

    
1754
                        case ControlType.ArrowTextControl:
1755
                            {
1756
                                var control = currentControl as ArrowTextControl;
1757

    
1758
                                if (control != null)
1759
                                {
1760
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1761
                                    Point tempPoint = control.EndPoint;
1762

    
1763
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1764

    
1765
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1766
                                    {
1767
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1768
                                        control.EndPoint = tempPoint;
1769
                                    }
1770
                                    else
1771
                                    {
1772
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1773
                                    }
1774
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1775

    
1776
                                    control.PointSet = new List<Point>
1777
                                            {
1778
                                                control.StartPoint,
1779
                                                control.MidPoint,
1780
                                                control.EndPoint,
1781
                                            };
1782
                                }
1783
                            }
1784
                            break;
1785

    
1786
                        case ControlType.ArrowTransTextControl:
1787
                            {
1788
                                var control = currentControl as ArrowTextControl;
1789

    
1790
                                if (control != null)
1791
                                {
1792
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1793
                                    Point tempPoint = control.EndPoint;
1794
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1795

    
1796
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1797
                                    {
1798
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1799
                                        control.EndPoint = tempPoint;
1800
                                    }
1801
                                    else
1802
                                    {
1803
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1804
                                    }
1805
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1806
                                    control.isFixed = true;
1807

    
1808
                                    control.PointSet = new List<Point>
1809
                                            {
1810
                                                control.StartPoint,
1811
                                                control.MidPoint,
1812
                                                control.EndPoint,
1813
                                            };
1814
                                }
1815
                            }
1816
                            break;
1817

    
1818
                        case ControlType.ArrowTextBorderControl:
1819
                            {
1820
                                var control = currentControl as ArrowTextControl;
1821

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

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

    
1850
                                if (control != null)
1851
                                {
1852
                                    control.isFixed = true;
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

    
1865
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1866
                                    control.PointSet = new List<Point>
1867
                                            {
1868
                                                control.StartPoint,
1869
                                                control.MidPoint,
1870
                                                control.EndPoint,
1871
                                            };
1872
                                }
1873

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

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

    
1902
                            }
1903
                            break;
1904
                        case ControlType.ArrowTransTextCloudControl:
1905
                            {
1906
                                var control = currentControl as ArrowTextControl;
1907

    
1908
                                if (control != null)
1909
                                {
1910
                                    control.isFixed = true;
1911
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1912
                                    Point tempPoint = control.EndPoint;
1913
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1914
                                    {
1915
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1916
                                        control.EndPoint = tempPoint;
1917
                                    }
1918
                                    else
1919
                                    {
1920
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1921
                                    }
1922
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1923
                                    control.PointSet = new List<Point>
1924
                                            {
1925
                                                control.StartPoint,
1926
                                                control.MidPoint,
1927
                                                control.EndPoint,
1928
                                            };
1929
                                }
1930

    
1931
                            }
1932
                            break;
1933
                        case ControlType.PolygonControl:
1934
                            {
1935

    
1936
                                var control = currentControl as PolygonControl;
1937

    
1938
                                if (control != null)
1939
                                {
1940
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1941
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1942
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1943
                                    control.SetPolyPath();
1944
                                    //강인구 추가
1945
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1946
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1947
                                }
1948
                            }
1949
                            break;
1950
                        //강인구 추가
1951
                        case ControlType.Sign:
1952
                            {
1953
                                var control = currentControl as SignControl;
1954

    
1955
                                if (control != null)
1956
                                {
1957
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1958
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1959
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1960
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1961

    
1962
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
1963
                                    {
1964
                                        GetUserSign getUser = new GetUserSign();
1965
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
1966
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
1967
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
1968
                                        stream.Write(imageBytes, 0, imageBytes.Length);
1969
                                        stream.Position = 0;
1970
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
1971
                                        BitmapImage returnImage = new BitmapImage();
1972
                                        returnImage.BeginInit();
1973
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
1974
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
1975
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
1976
                                        returnImage.StreamSource = ms;
1977
                                        returnImage.EndInit();
1978
                                        stream.Close();
1979

    
1980
                                        control.SignImage = returnImage;
1981
                                    }
1982
                                    control.PointSet = new List<Point>
1983
                                        {
1984
                                            control.StartPoint,
1985
                                            control.LeftBottomPoint,
1986
                                            control.EndPoint,
1987
                                            control.TopRightPoint,
1988
                                        };
1989
                                }
1990
                            }
1991
                            break;
1992
                        //TODO: 강인구 추가
1993
                        case ControlType.Symbol:
1994
                            {
1995
                                var control = currentControl as SymControl;
1996

    
1997
                                if (control != null)
1998
                                {
1999
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2000
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2001
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2002
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2003
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2004
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2005

    
2006
                                    if (control.StartPoint != control.EndPoint)
2007
                                    {
2008
                                        if (control.PathData == null)
2009
                                        {
2010
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2011
                                            {
2012
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2013
                                            }
2014
                                        }
2015
                                    }
2016

    
2017
                                    control.PointSet = new List<Point>
2018
                                        {
2019
                                            control.StartPoint,
2020
                                            control.LeftBottomPoint,
2021
                                            control.EndPoint,
2022
                                            control.TopRightPoint,
2023
                                        };
2024
                                }
2025
                            }
2026
                            break;
2027
                        ///TODO: 
2028
                        case ControlType.Stamp:
2029
                            {
2030
                                var control = currentControl as SymControlN;
2031

    
2032
                                if (control != null)
2033
                                {
2034

    
2035
                                    if (control.StartPoint == control.EndPoint)
2036
                                    {
2037
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2038

    
2039
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2040
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2041

    
2042

    
2043
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2044

    
2045
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2046
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2047
                                        writer.Write(xamlData);
2048
                                        writer.Flush();
2049
                                        stream.Position = 0;
2050

    
2051
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2052
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2053
                                        UIElement ob = obj as UIElement;
2054

    
2055
                                        //control.ApplyTemplate();
2056

    
2057
                                        control.SetViewBox();
2058
                                        control.PathXathData = appovalData;
2059
                                        control.Base_ViewBox.Child = ob;
2060
                                    }
2061

    
2062
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2063
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2064
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2065
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2066
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2067

    
2068

    
2069
                                    control.PointSet = new List<Point>
2070
                                    {
2071
                                        control.StartPoint,
2072
                                        control.LeftBottomPoint,
2073
                                        control.EndPoint,
2074
                                        control.TopRightPoint,
2075
                                    };
2076
                                }
2077
                            }
2078
                            break;
2079
                        case ControlType.Mark:
2080
                            {
2081
                                var control = currentControl as RectangleControl;
2082

    
2083
                                if (control != null)
2084
                                {
2085
                                    if (move.mousemode == MouseMode.Drawing)
2086
                                    {
2087
                                        //move.control_Move(ControlList, true, moveX, moveY);
2088
                                    }
2089
                                    else
2090
                                    {
2091
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2092
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2093
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2094
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2095

    
2096

    
2097
                                        control.PointSet = new List<Point>
2098
                                    {
2099
                                        control.StartPoint,
2100
                                        control.LeftBottomPoint,
2101
                                        control.EndPoint,
2102
                                        control.TopRightPoint,
2103
                                    };
2104
                                    }
2105

    
2106
                                    //강인구 추가
2107
                                    control.Paint = PaintSet.Fill;
2108
                                }
2109
                            }
2110
                            break;
2111
                        case ControlType.PenControl:
2112
                            {
2113
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2114
                                //inkBoard.Strokes.Add(stroke);
2115
                            }
2116
                            break;
2117
                        default:
2118
                            break;
2119
                    }
2120
                }
2121
            }
2122
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2123
            {
2124
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2125

    
2126
                if (isDraggingSelectionRect)
2127
                {
2128
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2129

    
2130
                    e.Handled = true;
2131
                }
2132
                else if (isLeftMouseButtonDownOnWindow)
2133
                {
2134
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2135
                    double dragDistance = Math.Abs(dragDelta.Length);
2136

    
2137
                    if (dragDistance > DragThreshold)
2138
                    {
2139
                        isDraggingSelectionRect = true;
2140

    
2141
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2142
                    }
2143

    
2144
                    e.Handled = true;
2145
                }
2146

    
2147

    
2148
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2149
                {
2150
                    //SelectionPath = new Path();
2151
                    //PathFigure pathFigure = new PathFigure();
2152
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2153
                    //SelectionPath.Opacity = 0.5;
2154
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2155
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2156
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2157
                }
2158
                else
2159
                {
2160
                    //List<Stroke> removingStroke = new List<Stroke>();
2161
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2162
                    //StrokeCollection stC = new StrokeCollection();
2163
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2164
                    //{
2165
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2166
                    //    p1.Intersect(p2);
2167
                    //    if (p1.IsEmpty)
2168
                    //    {
2169

    
2170

    
2171
                    //        p1 = SelectionPath.Data.Bounds;
2172
                    //        bool intersectCheck = false;
2173
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2174
                    //        {
2175
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2176
                    //            p1.Intersect(p3);
2177
                    //            if (!p1.IsEmpty)
2178
                    //            {
2179
                    //                intersectCheck = true;
2180
                    //            }
2181
                    //        }
2182
                    //        if (intersectCheck)
2183
                    //        {
2184
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2185
                    //        }
2186

    
2187
                    //    }
2188
                    //    else
2189
                    //    {
2190
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2191
                    //    }
2192
                    //}
2193

    
2194
                    e.Handled = true;
2195
                }
2196
            }
2197
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2198
            {
2199
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2200
                if (control != null)
2201
                {
2202
                    this.cursor = Cursors.Hand;
2203
                    SetCursor();
2204
                }
2205
                else
2206
                {
2207
                    this.cursor = Cursors.Arrow;
2208
                    SetCursor();
2209
                }
2210
            }
2211
            else
2212
            {
2213
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2214

    
2215
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2216
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2217

    
2218
                //if (hitList.Count > 0)
2219
                //{
2220

    
2221
                //}
2222

    
2223
                #region 조건 설정 : firstCondition
2224
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2225
                //pnts = generalTransform.Transform(pnts);
2226
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2227
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2228
                //                               this.DeepLayer._BaseLayer).ToObservable()
2229
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2230
                //                      select kkk).FirstOrDefault();
2231

    
2232
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2233
                //if (canvas !=null)
2234
                //{
2235
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2236
                //    {
2237
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2238
                //        if (uiElement!=null)
2239
                //        {
2240
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2241
                //        }
2242
                //    }
2243
                //}
2244

    
2245
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2246
                //hitResultsList.Clear();
2247

    
2248
                #endregion
2249
            }
2250
        }
2251

    
2252
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2253

    
2254
        private EllipseGeometry hitArea = new EllipseGeometry();
2255

    
2256
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2257
        {
2258
            IsDrawing = false;
2259

    
2260
            if (mouseHandlingMode != MouseHandlingMode.None)
2261
            {
2262
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2263
                {
2264
                    this.cursor = Cursors.Arrow;
2265

    
2266
                    SetCursor();
2267

    
2268
                    switch (controlType)
2269
                    {
2270
                        case ControlType.None:
2271
                            break;
2272
                        case ControlType.Rectangle:
2273
                            {
2274

    
2275
                            }
2276
                            break;
2277
                        case ControlType.PenControl:
2278
                            {
2279

    
2280
                            }
2281
                            break;
2282
                        default:
2283
                            break;
2284
                    }
2285
                }
2286
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2287
                {
2288
                    if (isLeftMouseButtonDownOnWindow)
2289
                    {
2290
                        bool wasDragSelectionApplied = false;
2291

    
2292
                        if (isDraggingSelectionRect)
2293
                        {
2294
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2295
                            {
2296
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2297
                                mouseHandlingMode = MouseHandlingMode.None;
2298
                                Set_Capture();
2299

    
2300
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2301
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2302
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2303
                            }
2304
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2305
                            {
2306
                                ApplyDragSelectionRect();
2307
                            }
2308
                            else
2309
                            {
2310
                                double x = Canvas.GetLeft(dragZoomBorder);
2311
                                double y = Canvas.GetTop(dragZoomBorder);
2312
                                double width = dragZoomBorder.Width;
2313
                                double height = dragZoomBorder.Height;
2314
                                Rect dragRect = new Rect(x, y, width, height);
2315

    
2316
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2317

    
2318
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2319
                            }
2320

    
2321
                            isDraggingSelectionRect = false;
2322
                            e.Handled = true;
2323
                            wasDragSelectionApplied = true;
2324
                        }
2325

    
2326
                        if (isLeftMouseButtonDownOnWindow)
2327
                        {
2328
                            isLeftMouseButtonDownOnWindow = false;
2329
                            this.ReleaseMouseCapture();
2330
                            e.Handled = true;
2331
                        }
2332

    
2333
                        if (!wasDragSelectionApplied)
2334
                        {
2335
                            init();
2336
                        }
2337
                    }
2338
                }
2339
                else if (mouseButtonDown == MouseButton.Right)
2340
                {
2341
                    this.cursor = Cursors.Arrow;
2342
                    SetCursor();
2343
                }
2344

    
2345
                zoomAndPanControl.ReleaseMouseCapture();
2346

    
2347

    
2348
                e.Handled = true;
2349
            }
2350
            else
2351
            {
2352
                this.cursor = Cursors.Arrow;
2353
                SetCursor();
2354
            }
2355
            mouseButtonDown = MouseButton.Left;
2356

    
2357
            //controlType = ControlType.SingleLine;
2358
        }
2359

    
2360
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2361
        {
2362
            mouseButtonDown = MouseButton.Left;
2363
            this.Cursor = Cursors.Arrow;
2364
        }
2365

    
2366
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2367
        {
2368

    
2369
        }
2370

    
2371
        private void ApplyDragSelectionRect()
2372
        {
2373
            multi_Undo_Data = new Multi_Undo_data();
2374

    
2375
            UndoData = new Undo_data()
2376
            {
2377
                IsUndo = false,
2378
                Event = Event_Type.Select,
2379
                EventTime = DateTime.Now,
2380
                Markup_List = new List<Multi_Undo_data>()
2381
            };
2382

    
2383
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2384

    
2385
            double x = Canvas.GetLeft(dragSelectionBorder);
2386
            double y = Canvas.GetTop(dragSelectionBorder);
2387
            double width = dragSelectionBorder.Width;
2388
            double height = dragSelectionBorder.Height;
2389
            Rect dragRect = new Rect(x, y, width, height);
2390
            Boolean Flag = false;
2391
            dragRect.Inflate(width / 10, height / 10);
2392
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2393
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2394

    
2395
            dragRect = new Rect(x, y, width, height);
2396
            dragRect.Inflate(width / 10, height / 10);
2397

    
2398
            foreach (var item in Items)
2399
            {
2400
                Flag = move.control_Select(item, dragRect);
2401

    
2402
                if (Flag)
2403
                {
2404
                    adornerSet.Add(item);
2405
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2406

    
2407
                    Control_Style(item);
2408
                    UndoData.Markup_List.Add(multi_Undo_Data);
2409
                    multi_Undo_Data = new Multi_Undo_data();
2410
                }
2411
            }
2412
            if (adornerSet.Count > 0)
2413
            {
2414
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2415
                {
2416
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2417
                });
2418
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2419

    
2420
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2421
                SelectLayer.Children.Add(final);
2422
            }
2423
        }
2424

    
2425
        private void InitDragSelectionRect(Point pt1, Point pt2)
2426
        {
2427
            //캡쳐 중
2428
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2429
            {
2430
                dragCaptureBorder.Visibility = Visibility.Visible;
2431
            }
2432
            //선택 중
2433
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2434
            {
2435

    
2436
                dragSelectionBorder.Visibility = Visibility.Visible;
2437
            }
2438
            else
2439
            {
2440
                dragZoomBorder.Visibility = Visibility.Visible;
2441
            }
2442
            UpdateDragSelectionRect(pt1, pt2);
2443
        }
2444

    
2445
        /// <summary>
2446
        /// Update the position and size of the rectangle used for drag selection.
2447
        /// </summary>
2448
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2449
        {
2450
            double x, y, width, height;
2451

    
2452
            //
2453
            // Determine x,y,width and height of the rect inverting the points if necessary.
2454
            // 
2455

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

    
2467
            if (pt2.Y < pt1.Y)
2468
            {
2469
                y = pt2.Y;
2470
                height = pt1.Y - pt2.Y;
2471
            }
2472
            else
2473
            {
2474
                y = pt1.Y;
2475
                height = pt2.Y - pt1.Y;
2476
            }
2477

    
2478
            //
2479
            // Update the coordinates of the rectangle used for drag selection.
2480
            //
2481
            //캡쳐 중
2482
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2483
            {
2484
                Canvas.SetLeft(dragCaptureBorder, x);
2485
                Canvas.SetTop(dragCaptureBorder, y);
2486
                dragCaptureBorder.Width = width;
2487
                dragCaptureBorder.Height = height;
2488
            }
2489
            //선택 중
2490
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2491
            {
2492
                Canvas.SetLeft(dragSelectionBorder, x);
2493
                Canvas.SetTop(dragSelectionBorder, y);
2494
                dragSelectionBorder.Width = width;
2495
                dragSelectionBorder.Height = height;
2496
            }
2497
            else
2498
            {
2499
                Canvas.SetLeft(dragZoomBorder, x);
2500
                Canvas.SetTop(dragZoomBorder, y);
2501
                dragZoomBorder.Width = width;
2502
                dragZoomBorder.Height = height;
2503
            }
2504

    
2505

    
2506
        }
2507

    
2508
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2509
        {
2510
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2511

    
2512
            bool result = false;
2513
            if (dragRect.Contains(controlRect))
2514
            {
2515
                result = true;
2516
                //잡은 객체들을 담은 리스트
2517
                try
2518
                {
2519
                    selected_item.Add(OverViewPathData, type.ToString());
2520
                }
2521
                catch (Exception)
2522
                {
2523

    
2524
                }
2525
            }
2526
            return result;
2527
        }
2528

    
2529
        private void drawingPannelRotate(double angle)
2530
        {
2531
            rotate.Angle = angle;
2532
            var rotationNum = Math.Abs((rotate.Angle / 90));
2533

    
2534
            if (angle == 90 || angle == 270)
2535
            {
2536
                double emptySize = zoomAndPanCanvas.Width;
2537
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2538
                zoomAndPanCanvas.Height = emptySize;
2539
            }
2540
            if (angle == 0)
2541
            {
2542
                translate.X = 0;
2543
                translate.Y = 0;
2544
            }
2545
            else if (angle == 90)
2546
            {
2547
                translate.X = zoomAndPanCanvas.Width;
2548
                translate.Y = 0;
2549
            }
2550
            else if (angle == 180)
2551
            {
2552
                translate.X = zoomAndPanCanvas.Width;
2553
                translate.Y = zoomAndPanCanvas.Height;
2554
            }
2555
            else
2556
            {
2557
                translate.X = 0;
2558
                translate.Y = zoomAndPanCanvas.Height;
2559
            }
2560

    
2561
            zoomAndPanControl.RotationAngle = rotate.Angle;
2562

    
2563

    
2564
            if (!testPanel2.IsHidden)
2565
            {
2566
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2567
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2568
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2569
            }
2570

    
2571
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2572
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2573
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2574
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2575
            ViewerDataModel.Instance.Angle = rotate.Angle;
2576

    
2577

    
2578
        }
2579

    
2580
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2581
        {
2582
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2583
            if (set_option != null)
2584
            {
2585
                set_option.Value = double.Parse(set_option.ContentText);
2586
            }
2587

    
2588
            InkControl_Convert();
2589

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

    
2593
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2594
            {
2595
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2596
            }
2597

    
2598
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2599
            {
2600
                if (arrow_text as ArrowTextControl != null)
2601
                {
2602
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2603
                }
2604
            }
2605

    
2606
            mouseButtonDown = e.ChangedButton;
2607
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
2608

    
2609
            //if (currentControl != null)
2610
            {
2611
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2612
                if (text_item_ != null)
2613
                {
2614
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2615
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2616
                    (text_item_ as TextControl).IsEditing = false;
2617
                    (text_item_ as TextControl).EnableEditing = false;
2618
                    currentControl = null;
2619
                }
2620

    
2621
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2622
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2623
                {
2624
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2625
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2626
                    currentControl = null;
2627
                }
2628
            }
2629

    
2630
            double Ang = 0;
2631
            if (rotate.Angle != 0)
2632
            {
2633
                Ang = 360 - rotate.Angle;
2634
            }
2635
            move = new Move();
2636

    
2637
            if (e.OriginalSource is System.Windows.Controls.Image)
2638
            {
2639
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2640
            }
2641

    
2642
            if (mouseButtonDown == MouseButton.Left)
2643
            {
2644
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2645
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2646

    
2647
                this.cursor = Cursors.Arrow;
2648
                SetCursor();
2649

    
2650
                if (!ViewerDataModel.Instance.IsPressCtrl)
2651
                {
2652
                    ReleaseAdorner();
2653
                }
2654
            }
2655
            if (mouseButtonDown == MouseButton.Middle)
2656
            {
2657
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2658
                cursor = Cursors.SizeAll;
2659
                SetCursor();
2660
            }
2661
            if (mouseButtonDown == MouseButton.Right)
2662
            {
2663
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2664
                cursor = Cursors.SizeAll;
2665
                SetCursor();
2666
            }
2667
            else if (mouseButtonDown == MouseButton.XButton1)
2668
            {
2669
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2670
                {
2671
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2672
                }
2673

    
2674
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2675

    
2676
            }
2677
            else if (mouseButtonDown == MouseButton.XButton2)
2678
            {
2679
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2680
                {
2681
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2682
                }
2683
            }
2684

    
2685
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2686
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2687
            {
2688
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2689
                {
2690
                    if (SelectLayer.Children.Count == 0)
2691
                    {
2692
                        isLeftMouseButtonDownOnWindow = true;
2693
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2694
                    }
2695

    
2696
                    if (controlType == ControlType.None)
2697
                    {
2698
                        isLeftMouseButtonDownOnWindow = true;
2699
                    }
2700
                }
2701

    
2702
                //캡쳐 모드 설정
2703
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2704
                {
2705
                    dragCaptureBorder.Visibility = Visibility.Visible;
2706
                    isLeftMouseButtonDownOnWindow = true;
2707
                }
2708

    
2709
                //줌 모드 설정
2710
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2711
                {
2712
                    //dragSelectionBorder.Visibility = Visibility.Visible;
2713
                    isLeftMouseButtonDownOnWindow = true;
2714
                }
2715

    
2716

    
2717
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2718
                if (control != null)
2719
                {
2720
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2721
                    AdornerFinal final;
2722
                    List<Point> p_set = new List<Point>();
2723
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2724
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2725
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2726
                    multi_Undo_Data = new Multi_Undo_data();
2727

    
2728
                    //강인구 Undo/Redo 보류
2729
                    UndoData = new Undo_data()
2730
                    {
2731
                        IsUndo = false,
2732
                        Event = Event_Type.Select,
2733
                        EventTime = DateTime.Now,
2734
                        Markup_List = new List<Multi_Undo_data>()
2735
                    };
2736

    
2737
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2738
                    {
2739
                        ReleaseAdorner();
2740
                        final = new AdornerFinal(control);
2741
                        //단일 컨트롤 언두 저장
2742

    
2743
                        Control_Style(control);
2744
                        UndoData.Markup_List.Add(multi_Undo_Data);
2745

    
2746
                        if ((control as IPath) != null)
2747
                        {
2748
                            if ((control as IPath).LineSize != 0)
2749
                            {
2750
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2751
                            }
2752
                        }
2753
                        if ((control as IShapeControl) != null)
2754
                        {
2755
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2756
                            {
2757
                                ViewerDataModel.Instance.checkHatchShape = true;
2758
                            }
2759
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2760
                            {
2761
                                ViewerDataModel.Instance.checkFillShape = true;
2762
                            }
2763
                            else
2764
                            {
2765
                                ViewerDataModel.Instance.checkHatchShape = false;
2766
                                ViewerDataModel.Instance.checkFillShape = false;
2767
                            }
2768
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2769
                        }
2770

    
2771
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2772

    
2773
                        if ((control as TextControl) != null)
2774
                        {
2775
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2776
                            {
2777
                                ViewerDataModel.Instance.checkTextStyle = true;
2778
                            }
2779
                            else
2780
                            {
2781
                                ViewerDataModel.Instance.checkTextStyle = false;
2782
                            }
2783

    
2784
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2785
                            {
2786
                                ViewerDataModel.Instance.checkTextStyle = true;
2787
                            }
2788
                            else
2789
                            {
2790
                                ViewerDataModel.Instance.checkTextStyle = false;
2791
                            }
2792
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2793
                            {
2794
                                ViewerDataModel.Instance.checkTextWeight = true;
2795
                            }
2796
                            else
2797
                            {
2798
                                ViewerDataModel.Instance.checkTextWeight = false;
2799
                            }
2800
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2801
                            {
2802
                                ViewerDataModel.Instance.checkUnderLine = true;
2803
                            }
2804
                            else
2805
                            {
2806
                                ViewerDataModel.Instance.checkUnderLine = false;
2807
                            }
2808
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2809
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2810

    
2811
                        }
2812
                        else if ((control as ArrowTextControl) != null)
2813
                        {
2814
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2815
                            {
2816
                                ViewerDataModel.Instance.checkTextStyle = true;
2817
                            }
2818
                            else
2819
                            {
2820
                                ViewerDataModel.Instance.checkTextStyle = false;
2821
                            }
2822

    
2823
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2824
                            {
2825
                                ViewerDataModel.Instance.checkTextStyle = true;
2826
                            }
2827
                            else
2828
                            {
2829
                                ViewerDataModel.Instance.checkTextStyle = false;
2830
                            }
2831
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2832
                            {
2833
                                ViewerDataModel.Instance.checkTextWeight = true;
2834
                            }
2835
                            else
2836
                            {
2837
                                ViewerDataModel.Instance.checkTextWeight = false;
2838
                            }
2839
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2840
                            {
2841
                                ViewerDataModel.Instance.checkUnderLine = true;
2842
                            }
2843
                            else
2844
                            {
2845
                                ViewerDataModel.Instance.checkUnderLine = false;
2846
                            }
2847
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2848
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2849
                        }
2850
                        else if ((control as RectCloudControl) != null)
2851
                        {
2852
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2853
                        }
2854
                        else if ((control as CloudControl) != null)
2855
                        {
2856
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2857
                        }
2858

    
2859
                    }
2860
                    else
2861
                    {
2862
                        comment = AddAdorner();
2863
                        comment.Add(control);
2864

    
2865
                        Control_Style(control);
2866
                        UndoData.Markup_List.Add(multi_Undo_Data);
2867

    
2868
                        final = new AdornerFinal(comment);
2869
                        //다중 컨트롤 언두 저장
2870
                    }
2871

    
2872
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2873
                    {
2874
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2875
                    });
2876

    
2877
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2878

    
2879
                    SelectLayer.Children.Add(final);
2880

    
2881
                    //Control_Init(control);
2882

    
2883

    
2884

    
2885

    
2886

    
2887
                    //강인구 폰트 변경 보류
2888

    
2889
                    //if ((currentControl as TextControl) != null)
2890
                    //{
2891
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2892
                    //    {
2893
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2894
                    //    }
2895
                    //    else
2896
                    //    {
2897
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2898
                    //    }
2899

    
2900
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2901
                    //    {
2902

    
2903
                    //    }
2904
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
2905
                    //    {
2906

    
2907
                    //    }
2908
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2909
                    //    {
2910

    
2911
                    //    }
2912
                    //}
2913
                    //else if ((currentControl as ArrowTextControl) != null)
2914
                    //{
2915
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2916
                    //    {
2917
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
2918
                    //    }
2919
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2920
                    //    {
2921
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
2922
                    //    }
2923
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2924
                    //    {
2925
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
2926
                    //    }
2927
                    //}
2928

    
2929
                    //mouseHandlingMode = MouseHandlingMode.Adorner;
2930
                }
2931
            }
2932

    
2933
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2934
            {
2935
                init();
2936
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2937
                if (cursor != Cursors.SizeAll)
2938
                {
2939
                    cursor = Cursors.Cross;
2940
                    SetCursor();
2941
                }
2942
                bool init_user = false;
2943
                foreach (var user in gridViewMarkup.Items)
2944
                {
2945
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2946
                    {
2947
                        init_user = true;
2948
                    }
2949
                }
2950
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2951
                {
2952
                    RadWindow.Alert(new DialogParameters
2953
                    {
2954
                        Theme = new VisualStudio2013Theme(),
2955
                        Header = "안내",
2956
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2957
                    });
2958
                    return;
2959
                }
2960
                else
2961
                {
2962
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2963
                    if (item != null)
2964
                    {
2965
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2966
                    }
2967
                }
2968

    
2969
                multi_Undo_Data = new Multi_Undo_data();
2970
                //강인구 Undo/Redo 보류
2971
                UndoData = new Undo_data()
2972
                {
2973
                    IsUndo = false,
2974
                    Event = Event_Type.Create,
2975
                    EventTime = DateTime.Now,
2976
                    Markup_List = new List<Multi_Undo_data>()
2977
                };
2978

    
2979
                switch (controlType)
2980
                {
2981
                    case ControlType.Rectangle:
2982
                        {
2983
                            if (mouseButtonDown == MouseButton.Left)
2984
                            {
2985
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2986
                                {
2987
                                    if (currentControl is RectangleControl)
2988
                                    {
2989
                                        CreateControl();
2990

    
2991
                                        (currentControl as RectangleControl).ApplyOverViewData();
2992
                                        currentControl = null;
2993
                                        this.cursor = Cursors.Arrow;
2994
                                    }
2995
                                    else
2996
                                    {
2997
                                        currentControl = new RectangleControl
2998
                                        {
2999
                                            Background = new SolidColorBrush(Colors.Black),
3000
                                            ControlType = ControlType.Rectangle
3001
                                        };
3002

    
3003
                                        currentControl.CommentID = Save.shortGuid();
3004
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3005
                                        currentControl.IsNew = true;
3006
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3007

    
3008
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3009
                                    }
3010
                                }
3011
                            }
3012
                        }
3013
                        break;
3014
                    case ControlType.RectCloud:
3015
                        {
3016
                            if (mouseButtonDown == MouseButton.Left)
3017
                            {
3018
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3019
                                {
3020
                                    if (currentControl is RectCloudControl)
3021
                                    {
3022
                                        CreateControl();
3023

    
3024
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3025
                                        currentControl = null;
3026
                                        this.cursor = Cursors.Arrow;
3027
                                    }
3028
                                    else
3029
                                    {
3030
                                        currentControl = new RectCloudControl
3031
                                        {
3032
                                            Background = new SolidColorBrush(Colors.Black)
3033
                                        };
3034

    
3035
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3036
                                        currentControl.CommentID = Save.shortGuid();
3037
                                        currentControl.IsNew = true;
3038
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3039
                                    }
3040
                                }
3041
                            }
3042
                        }
3043
                        break;
3044
                    case ControlType.Circle:
3045
                        {
3046
                            if (mouseButtonDown == MouseButton.Left)
3047
                            {
3048
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3049
                                {
3050
                                    if (currentControl is CircleControl)
3051
                                    {
3052
                                        CreateControl();
3053

    
3054
                                        (currentControl as CircleControl).ApplyOverViewData();
3055
                                        currentControl = null;
3056
                                    }
3057
                                    else
3058
                                    {
3059
                                        currentControl = new CircleControl
3060
                                        {
3061
                                            Background = new SolidColorBrush(Colors.Black)
3062
                                        };
3063

    
3064
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3065
                                        currentControl.CommentID = Save.shortGuid();
3066
                                        currentControl.IsNew = true;
3067
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3068
                                    }
3069
                                }
3070
                            }
3071
                        }
3072
                        break;
3073
                    case ControlType.Triangle:
3074
                        {
3075
                            if (mouseButtonDown == MouseButton.Left)
3076
                            {
3077
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3078
                                {
3079
                                    if (currentControl is TriControl)
3080
                                    {
3081
                                        var content = currentControl as TriControl;
3082
                                        if (content.MidPoint == new Point(0, 0))
3083
                                        {
3084
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3085
                                        }
3086
                                        else
3087
                                        {
3088
                                            CreateControl();
3089

    
3090
                                            (currentControl as TriControl).ApplyOverViewData();
3091
                                            currentControl = null;
3092
                                        }
3093
                                    }
3094
                                    else
3095
                                    {
3096
                                        currentControl = new TriControl
3097
                                        {
3098
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3099
                                            Background = new SolidColorBrush(Colors.Black),
3100
                                        };
3101

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

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

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

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

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

    
3183
                                        (currentControl as LineControl).ApplyOverViewData();
3184
                                        currentControl = null;
3185
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3186
                                    }
3187
                                    else
3188
                                    {
3189
                                        currentControl = new LineControl
3190
                                        {
3191
                                            Background = new SolidColorBrush(Colors.Black)
3192
                                        };
3193

    
3194
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3195
                                        currentControl.CommentID = Save.shortGuid();
3196
                                        currentControl.IsNew = true;
3197
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3198
                                        this.MainAngle.Visibility = Visibility.Visible;
3199
                                    }
3200
                                }
3201
                            }
3202
                        }
3203
                        break;
3204
                    case ControlType.TwinLine:
3205
                        {
3206
                            if (mouseButtonDown == MouseButton.Left)
3207
                            {
3208
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3209
                                {
3210
                                    if (currentControl is LineControl)
3211
                                    {
3212
                                        CreateControl();
3213

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

    
3244
                                        (currentControl as LineControl).ApplyOverViewData();
3245
                                        currentControl = null;
3246
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3247
                                    }
3248
                                    else
3249
                                    {
3250
                                        currentControl = new LineControl
3251
                                        {
3252
                                            Background = new SolidColorBrush(Colors.Black)
3253
                                        };
3254
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3255
                                        currentControl.CommentID = Save.shortGuid();
3256
                                        currentControl.IsNew = true;
3257
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3258
                                        this.MainAngle.Visibility = Visibility.Visible;
3259
                                    }
3260
                                }
3261
                            }
3262
                        }
3263
                        break;
3264
                    case ControlType.ChainLine:
3265
                        {
3266
                            if (currentControl is PolygonControl)
3267
                            {
3268
                                var control = currentControl as PolygonControl;
3269

    
3270
                                if (mouseButtonDown == MouseButton.Right)
3271
                                {
3272
                                    CreateControl();
3273

    
3274
                                    (currentControl as PolygonControl).ApplyOverViewData();
3275
                                    currentControl = null;
3276
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3277
                                    return;
3278
                                }
3279

    
3280
                                if (!control.IsCompleted)
3281
                                {
3282
                                    control.PointSet.Add(control.EndPoint);
3283
                                    this.MainAngle.Visibility = Visibility.Visible;
3284
                                }
3285
                            }
3286
                            else
3287
                            {
3288
                                if (mouseButtonDown == MouseButton.Left)
3289
                                {
3290
                                    MainAngle.Visibility = Visibility.Visible;
3291
                                    currentControl = new PolygonControl
3292
                                    {
3293
                                        PointSet = new List<Point>(),
3294
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3295
                                        ControlType = ControlType.ChainLine,
3296
                                        DashSize = ViewerDataModel.Instance.DashSize,
3297
                                        LineSize = ViewerDataModel.Instance.LineSize,
3298
                                        //PointC = new StylusPointSet()
3299
                                    };
3300

    
3301
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3302
                                    {
3303
                                        var polygonControl = (currentControl as PolygonControl);
3304
                                        currentControl.CommentID = Save.shortGuid();
3305
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3306
                                        currentControl.IsNew = true;
3307
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3308
                                        //currentControl.OnApplyTemplate();
3309
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3310
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3311
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3312
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3313
                                    }
3314
                                }
3315
                            }
3316
                        }
3317
                        break;
3318
                    case ControlType.ArcLine:
3319
                        {
3320
                            if (mouseButtonDown == MouseButton.Left)
3321
                            {
3322
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3323
                                {
3324
                                    if (currentControl is ArcControl)
3325
                                    {
3326
                                        CreateControl();
3327

    
3328
                                        (currentControl as ArcControl).ApplyOverViewData();
3329
                                        currentControl = null;
3330
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3331
                                    }
3332
                                    else
3333
                                    {
3334
                                        currentControl = new ArcControl
3335
                                        {
3336
                                            Background = new SolidColorBrush(Colors.Black)
3337
                                        };
3338
                                        currentControl.CommentID = Save.shortGuid();
3339
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3340
                                        currentControl.IsNew = true;
3341
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3342
                                        this.MainAngle.Visibility = Visibility.Visible;
3343
                                    }
3344
                                }
3345
                            }
3346
                            else if (mouseButtonDown == MouseButton.Right)
3347
                            {
3348
                                if (currentControl != null)
3349
                                {
3350
                                    (currentControl as ArcControl).setClock();
3351
                                }
3352

    
3353
                            }
3354

    
3355
                        }
3356
                        break;
3357
                    case ControlType.ArcArrow:
3358
                        {
3359
                            if (mouseButtonDown == MouseButton.Left)
3360
                            {
3361
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3362
                                {
3363
                                    if (currentControl is ArcControl)
3364
                                    {
3365
                                        CreateControl();
3366

    
3367
                                        (currentControl as ArcControl).ApplyOverViewData();
3368
                                        currentControl = null;
3369
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3370
                                    }
3371
                                    else
3372
                                    {
3373
                                        currentControl = new ArcControl
3374
                                        {
3375
                                            Background = new SolidColorBrush(Colors.Red),
3376
                                        };
3377
                                        currentControl.CommentID = Save.shortGuid();
3378
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3379
                                        currentControl.IsNew = true;
3380
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3381
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3382
                                        this.MainAngle.Visibility = Visibility.Visible;
3383
                                    }
3384
                                }
3385
                            }
3386
                            else if (mouseButtonDown == MouseButton.Right)
3387
                            {
3388
                                (currentControl as ArcControl).setClock();
3389
                            }
3390
                        }
3391
                        break;
3392
                    case ControlType.ArrowMultiLine:
3393
                        {
3394
                            if (mouseButtonDown == MouseButton.Left)
3395
                            {
3396
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3397
                                {
3398

    
3399
                                    if (currentControl is ArrowControl_Multi)
3400
                                    {
3401
                                        var content = currentControl as ArrowControl_Multi;
3402
                                        if (content.MiddlePoint == new Point(0, 0))
3403
                                        {
3404
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3405
                                            {
3406
                                                content.MiddlePoint = content.EndPoint;
3407
                                            }
3408
                                            else
3409
                                            {
3410
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3411
                                            }
3412
                                        }
3413
                                        else
3414
                                        {
3415
                                            CreateControl();
3416

    
3417
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3418
                                            currentControl = null;
3419
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3420
                                        }
3421
                                    }
3422
                                    else
3423
                                    {
3424
                                        currentControl = new ArrowControl_Multi
3425
                                        {
3426
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3427
                                            Background = new SolidColorBrush(Colors.Black)
3428
                                        };
3429
                                        currentControl.CommentID = Save.shortGuid();
3430
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3431
                                        currentControl.IsNew = true;
3432
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3433
                                        this.MainAngle.Visibility = Visibility.Visible;
3434
                                    }
3435
                                }
3436
                            }
3437
                        }
3438
                        break;
3439
                    case ControlType.PolygonCloud:
3440
                        {
3441
                            if (currentControl is CloudControl)
3442
                            {
3443
                                var control = currentControl as CloudControl;
3444
                                if (mouseButtonDown == MouseButton.Right)
3445
                                {
3446
                                    control.IsCompleted = true;
3447
                                }
3448

    
3449
                                if (!control.IsCompleted)
3450
                                {
3451
                                    control.PointSet.Add(control.EndPoint);
3452
                                }
3453
                                else
3454
                                {
3455
                                    CreateControl();
3456

    
3457
                                    control.isTransOn = true;
3458
                                    var firstPoint = control.PointSet.First();
3459

    
3460
                                    control.PointSet.Add(firstPoint);
3461
                                    control.DrawingCloud();
3462
                                    control.ApplyOverViewData();
3463

    
3464
                                    currentControl = null;
3465
                                }
3466
                            }
3467
                            else
3468
                            {
3469
                                if (mouseButtonDown == MouseButton.Left)
3470
                                {
3471
                                    currentControl = new CloudControl
3472
                                    {
3473
                                        PointSet = new List<Point>(),
3474
                                        PointC = new StylusPointSet()
3475
                                    };
3476

    
3477
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3478
                                    {
3479
                                        var polygonControl = (currentControl as CloudControl);
3480
                                        currentControl.CommentID = Save.shortGuid();
3481
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3482
                                        currentControl.IsNew = true;
3483
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3484

    
3485
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3486
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3487
                                    }
3488
                                }
3489
                            }
3490
                        }
3491
                        break;
3492
                    case ControlType.ImgControl:
3493
                        {
3494
                            if (mouseButtonDown == MouseButton.Left)
3495
                            {
3496
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3497
                                {
3498
                                    if (currentControl is ImgControl)
3499
                                    {
3500
                                        CreateControl();
3501
                                        (currentControl as ImgControl).ApplyOverViewData();
3502

    
3503
                                        currentControl = null;
3504
                                    }
3505
                                    else
3506
                                    {
3507
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3508
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3509
                                        {
3510
                                            Image img = new Image();
3511
                                            img.Source = new BitmapImage(new Uri(filename));
3512

    
3513
                                            currentControl = new ImgControl
3514
                                            {
3515
                                                Background = new SolidColorBrush(Colors.Black),
3516
                                                PointSet = new List<Point>(),
3517
                                                FilePath = filename,
3518
                                                ImageData = img.Source,
3519
                                                StartPoint = canvasDrawingMouseDownPoint,
3520
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3521
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3522
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3523
                                            };
3524

    
3525
                                            currentControl.CommentID = Save.shortGuid();
3526
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3527
                                            currentControl.IsNew = true;
3528
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529
                                        }
3530
                                    }
3531
                                }
3532
                            }
3533
                        }
3534
                        break;
3535
                    case ControlType.Date:
3536
                        {
3537
                            if (mouseButtonDown == MouseButton.Left)
3538
                            {
3539
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3540
                                {
3541
                                    if (currentControl is DateControl)
3542
                                    {
3543
                                        CreateControl();
3544
                                        (currentControl as DateControl).ApplyOverViewData();
3545
                                        currentControl = null;
3546

    
3547
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3548
                                        {
3549
                                            controlType = ControlType.None;
3550
                                            IsSwingMode = false;
3551
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3552
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3553
                                            mouseHandlingMode = MouseHandlingMode.None;
3554
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3555
                                            txtBatch.Visibility = Visibility.Collapsed;
3556

    
3557
                                        }
3558
                                    }
3559
                                    else
3560
                                    {
3561
                                        currentControl = new DateControl
3562
                                        {
3563
                                            Background = new SolidColorBrush(Colors.Black)
3564
                                        };
3565
                                        currentControl.CommentID = Save.shortGuid();
3566
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3567
                                        currentControl.IsNew = true;
3568
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3569
                                    }
3570
                                }
3571
                            }
3572
                        }
3573
                        break;
3574
                    case ControlType.TextControl:
3575
                        {
3576
                            if (mouseButtonDown == MouseButton.Left)
3577
                            {
3578
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3579
                                {
3580
                                    currentControl = new TextControl
3581
                                    {
3582
                                        ControlType = controlType
3583
                                    };
3584
                                    currentControl.CommentID = Save.shortGuid();
3585
                                    currentControl.IsNew = true;
3586
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3587
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3588
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
3589
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3590
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3591
                                    currentControl.Focus();
3592
                                    (currentControl as TextControl).ApplyOverViewData();
3593
                                    (currentControl as TextControl).ControlType_No = 0;
3594
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3595
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3596

    
3597
                                    CreateControl();
3598

    
3599
                                    //currentControl = null;
3600
                                }
3601
                            }
3602
                        }
3603
                        break;
3604
                    case ControlType.TextBorder:
3605
                        {
3606
                            if (mouseButtonDown == MouseButton.Left)
3607
                            {
3608
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3609
                                {
3610
                                    currentControl = new TextControl
3611
                                    {
3612
                                        ControlType = controlType
3613
                                    };
3614

    
3615

    
3616
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3617
                                    currentControl.CommentID = Save.shortGuid();
3618
                                    currentControl.IsNew = true;
3619
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3620
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3621
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3622
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3623
                                    currentControl.Focus();
3624
                                    (currentControl as TextControl).ControlType_No = 1;
3625
                                    (currentControl as TextControl).Angle = Ang;
3626
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3627
                                    CreateControl();
3628

    
3629
                                    //currentControl = null;
3630
                                }
3631
                            }
3632
                        }
3633
                        break;
3634
                    case ControlType.TextCloud:
3635
                        {
3636
                            if (mouseButtonDown == MouseButton.Left)
3637
                            {
3638
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3639
                                {
3640
                                    currentControl = new TextControl
3641
                                    {
3642
                                        ControlType = controlType
3643
                                    };
3644
                                    currentControl.CommentID = Save.shortGuid();
3645
                                    currentControl.IsNew = true;
3646
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3647
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3648

    
3649
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3650
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3651
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3652
                                    currentControl.Focus();
3653

    
3654
                                    (currentControl as TextControl).Angle = Ang;
3655
                                    (currentControl as TextControl).ControlType_No = 2;
3656
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3657

    
3658
                                    CreateControl();
3659
                                    //currentControl = null;
3660
                                }
3661
                            }
3662
                        }
3663
                        break;
3664
                    case ControlType.ArrowTextControl:
3665
                        {
3666
                            if (mouseButtonDown == MouseButton.Left)
3667
                            {
3668
                                if (currentControl is ArrowTextControl)
3669
                                {
3670
                                    CreateControl();
3671

    
3672
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3673
                                    (currentControl as ArrowTextControl).IsEditing = false;
3674
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3675
                                    (currentControl as ArrowTextControl).IsNew = false;
3676
                                    currentControl = null;
3677
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3678
                                }
3679
                                else
3680
                                {
3681
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3682
                                    {
3683
                                        currentControl = new ArrowTextControl();
3684
                                        currentControl.CommentID = Save.shortGuid();
3685
                                        currentControl.IsNew = true;
3686
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3687
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3688

    
3689
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3690

    
3691
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3692

    
3693
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3694

    
3695
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3696

    
3697
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3698

    
3699
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3700
                                        this.MainAngle.Visibility = Visibility.Visible;
3701
                                    }
3702
                                }
3703
                            }
3704
                        }
3705
                        break;
3706
                    case ControlType.ArrowTransTextControl:
3707
                        {
3708
                            if (mouseButtonDown == MouseButton.Left)
3709
                            {
3710
                                if (currentControl is ArrowTextControl)
3711
                                {
3712
                                    CreateControl();
3713
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3714
                                    currentControl.IsNew = false;
3715
                                    currentControl = null;
3716
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3717
                                }
3718
                                else
3719
                                {
3720
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3721
                                    {
3722
                                        currentControl = new ArrowTextControl();
3723
                                        currentControl.CommentID = Save.shortGuid();
3724
                                        currentControl.IsNew = true;
3725
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3726
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3727

    
3728
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3729

    
3730
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3731

    
3732
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3733

    
3734
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3735

    
3736
                                        (currentControl as ArrowTextControl).isFixed = true;
3737
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3738

    
3739
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3740
                                        this.MainAngle.Visibility = Visibility.Visible;
3741
                                    }
3742
                                }
3743
                            }
3744
                        }
3745
                        break;
3746
                    case ControlType.ArrowTextBorderControl:
3747
                        {
3748
                            if (mouseButtonDown == MouseButton.Left)
3749
                            {
3750
                                if (currentControl is ArrowTextControl)
3751
                                {
3752
                                    CreateControl();
3753
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3754
                                    currentControl.IsNew = false;
3755
                                    currentControl = null;
3756
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3757
                                }
3758
                                else
3759
                                {
3760
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3761
                                    {
3762
                                        currentControl = new ArrowTextControl()
3763
                                        {
3764
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3765
                                        };
3766
                                        currentControl.CommentID = Save.shortGuid();
3767
                                        currentControl.IsNew = true;
3768
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3769
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3770

    
3771
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3772

    
3773
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3774

    
3775
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3776
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3777

    
3778
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3779

    
3780
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3781
                                        this.MainAngle.Visibility = Visibility.Visible;
3782
                                    }
3783
                                }
3784
                            }
3785
                        }
3786
                        break;
3787
                    case ControlType.ArrowTransTextBorderControl:
3788
                        {
3789
                            if (mouseButtonDown == MouseButton.Left)
3790
                            {
3791
                                if (currentControl is ArrowTextControl)
3792
                                {
3793
                                    CreateControl();
3794
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3795
                                    currentControl.IsNew = false;
3796
                                    currentControl = null;
3797
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3798
                                }
3799
                                else
3800
                                {
3801
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3802
                                    {
3803
                                        currentControl = new ArrowTextControl()
3804
                                        {
3805
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3806
                                        };
3807
                                        currentControl.CommentID = Save.shortGuid();
3808
                                        currentControl.IsNew = true;
3809
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3810
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3811

    
3812
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3813

    
3814
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3815

    
3816
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3817

    
3818
                                        (currentControl as ArrowTextControl).isFixed = true;
3819
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3820

    
3821
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3822

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

    
3855
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3856

    
3857
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3858

    
3859
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3860
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3861
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3862

    
3863
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3864
                                        this.MainAngle.Visibility = Visibility.Visible;
3865
                                    }
3866
                                }
3867
                            }
3868
                        }
3869
                        break;
3870
                    case ControlType.ArrowTransTextCloudControl:
3871
                        {
3872
                            if (mouseButtonDown == MouseButton.Left)
3873
                            {
3874
                                if (currentControl is ArrowTextControl)
3875
                                {
3876
                                    CreateControl();
3877
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3878
                                    currentControl.IsNew = false;
3879
                                    currentControl = null;
3880
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3881
                                }
3882
                                else
3883
                                {
3884
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3885
                                    {
3886
                                        currentControl = new ArrowTextControl()
3887
                                        {
3888
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3889
                                        };
3890
                                        currentControl.CommentID = Save.shortGuid();
3891
                                        currentControl.IsNew = true;
3892
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3893
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3894

    
3895
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3896

    
3897
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3898

    
3899
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3900

    
3901
                                        (currentControl as ArrowTextControl).isFixed = true;
3902
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3903

    
3904
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3905

    
3906
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3907
                                        this.MainAngle.Visibility = Visibility.Visible;
3908
                                    }
3909
                                }
3910
                            }
3911
                        }
3912
                        break;
3913
                    case ControlType.PolygonControl:
3914
                        {
3915
                            if (currentControl is PolygonControl)
3916
                            {
3917
                                var control = currentControl as PolygonControl;
3918

    
3919
                                if (mouseButtonDown == MouseButton.Right)
3920
                                {
3921
                                    control.IsCompleted = true;
3922
                                }
3923

    
3924
                                if (!control.IsCompleted)
3925
                                {
3926
                                    control.PointSet.Add(control.EndPoint);
3927
                                }
3928
                                else
3929
                                {
3930
                                    var firstPoint = control.PointSet.First();
3931
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3932
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3933
                                    control.PointSet.Add(firstPoint);
3934

    
3935
                                    control.SetPolyPath();
3936

    
3937
                                    control.ApplyOverViewData();
3938

    
3939
                                    CreateControl();
3940

    
3941
                                    currentControl = null;
3942
                                }
3943
                            }
3944
                            else
3945
                            {
3946
                                if (mouseButtonDown == MouseButton.Left)
3947
                                {
3948
                                    currentControl = new PolygonControl
3949
                                    {
3950
                                        PointSet = new List<Point>(),
3951
                                        //PointC = new StylusPointSet()
3952
                                    };
3953

    
3954
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3955
                                    {
3956
                                        var polygonControl = (currentControl as PolygonControl);
3957
                                        currentControl.CommentID = Save.shortGuid();
3958
                                        currentControl.IsNew = true;
3959
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3960
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3961
                                        //currentControl.OnApplyTemplate();
3962
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3963
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3964
                                    }
3965
                                }
3966
                            }
3967
                        }
3968
                        break;
3969
                    //강인구 추가
3970
                    case ControlType.Sign:
3971
                        {
3972
                            if (mouseButtonDown == MouseButton.Left)
3973
                            {
3974
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3975
                                {
3976
                                    GetUserSign getUser = new GetUserSign();
3977
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3978

    
3979
                                    if (_sign == null)
3980
                                    {
3981
                                        txtBatch.Visibility = Visibility.Collapsed;
3982
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3983
                                        controlType = ControlType.None;
3984

    
3985
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3986
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3987
                                        return;
3988
                                    }
3989

    
3990
                                    if (currentControl is SignControl)
3991
                                    {
3992
                                        CreateControl();
3993
                                        currentControl = null;
3994
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3995
                                        {
3996
                                            txtBatch.Text = "Place Date";
3997
                                            controlType = ControlType.Date;
3998
                                        }
3999
                                    }
4000
                                    else
4001
                                    {
4002
                                        currentControl = new SignControl
4003
                                        {
4004
                                            Background = new SolidColorBrush(Colors.Black),
4005
                                            UserNumber = App.ViewInfo.UserID,
4006
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4007
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4008
                                            ControlType = ControlType.Sign
4009
                                        };
4010

    
4011
                                        currentControl.CommentID = Save.shortGuid();
4012
                                        currentControl.IsNew = true;
4013
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4014
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4015
                                    }
4016
                                }
4017
                            }
4018
                        }
4019
                        break;
4020
                    case ControlType.Mark:
4021
                        {
4022
                            if (mouseButtonDown == MouseButton.Left)
4023
                            {
4024
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4025
                                {
4026
                                    if (currentControl is RectangleControl)
4027
                                    {
4028
                                        CreateControl();
4029
                                        (currentControl as RectangleControl).ApplyOverViewData();
4030
                                        currentControl = null;
4031
                                        this.cursor = Cursors.Arrow;
4032

    
4033
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4034
                                        {
4035
                                            txtBatch.Text = "Place Signature";
4036
                                            controlType = ControlType.Sign;
4037
                                        }
4038
                                    }
4039
                                    else
4040
                                    {
4041
                                        currentControl = new RectangleControl
4042
                                        {
4043
                                            Background = new SolidColorBrush(Colors.Black),
4044
                                            Paint = PaintSet.Fill
4045
                                        };
4046

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

    
4078
                                        currentControl.IsNew = true;
4079
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4080
                                        currentControl.CommentID = Save.shortGuid();
4081
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4082
                                    }
4083
                                }
4084
                            }
4085
                        }
4086
                        break;
4087
                    case ControlType.Stamp:
4088
                        {
4089
                            if (mouseButtonDown == MouseButton.Left)
4090
                            {
4091
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4092
                                {
4093
                                    if (currentControl is SymControlN)
4094
                                    {
4095
                                        CreateControl();
4096
                                        currentControl = null;
4097
                                        this.cursor = Cursors.Arrow;
4098
                                    }
4099
                                    else
4100
                                    {
4101
                                        currentControl = new SymControlN
4102
                                        {
4103
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4104
                                            Background = new SolidColorBrush(Colors.Black),
4105
                                            ControlType = ControlType.Stamp
4106
                                        };
4107

    
4108
                                        currentControl.IsNew = true;
4109
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4110
                                        currentControl.CommentID = Save.shortGuid();
4111
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4112
                                    }
4113
                                }
4114
                            }
4115
                        }
4116
                        break;
4117
                    case ControlType.PenControl:
4118
                        {
4119
                            if (inkBoard.Tag.ToString() == "Ink")
4120
                            {
4121
                                inkBoard.IsEnabled = true;
4122
                                StartNewStroke(canvasDrawingMouseDownPoint);
4123
                            }
4124
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4125
                            {
4126
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4127
                            }
4128
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4129
                            {
4130
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4131
                            }
4132
                            IsDrawing = true;
4133
                            return;
4134
                        }
4135
                    default:
4136
                        if (currentControl != null)
4137
                        {
4138
                            currentControl.CommentID = null;
4139
                            currentControl.IsNew = false;
4140
                        }
4141
                        break;
4142
                }
4143

    
4144
            }
4145

    
4146
            //else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4147
            //{
4148
            //    if (controlType == ControlType.None)
4149
            //    {
4150
            //        mouseHandlingMode = MouseHandlingMode.Selecting;
4151
            //        this.cursor = Cursors.Arrow;
4152
            //        inkDrawingCanvas.IsEnabled = false;
4153
            //        isLeftMouseButtonDownOnWindow = true;
4154
            //    }
4155
            //}
4156

    
4157
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4158
            {
4159
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4160
                {
4161
                    bool mouseOff = false;
4162
                    foreach (var item in SelectLayer.Children)
4163
                    {
4164
                        if (item is AdornerFinal)
4165
                        {
4166

    
4167
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4168
                            if (over != null)
4169
                            {
4170
                                mouseOff = true;
4171
                            }
4172
                        }
4173
                    }
4174

    
4175
                    if (!mouseOff)
4176
                    {
4177
                        ReleaseAdorner();
4178
                    }
4179
                }
4180
                zoomAndPanControl.CaptureMouse();
4181
                e.Handled = true;
4182
            }
4183
        }
4184

    
4185
        private void RemoveLineStroke(Point P)
4186
        {
4187
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4188
            if (control != null)
4189
            {
4190
                UndoData = new Undo_data()
4191
                {
4192
                    IsUndo = false,
4193
                    Event = Event_Type.Delete,
4194
                    EventTime = DateTime.Now,
4195
                    Markup_List = new List<Multi_Undo_data>()
4196
                };
4197

    
4198

    
4199
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4200
                UndoData.Markup_List.Add(multi_Undo_Data);
4201
                multi_Undo_Data = new Multi_Undo_data();
4202

    
4203
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4204
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4205
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4206

    
4207

    
4208
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4209
                {
4210
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4211
                });
4212
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4213

    
4214
            }
4215
        }
4216

    
4217
        private void RemovePointStroke(Point P)
4218
        {
4219
            foreach (Stroke hits in inkBoard.Strokes)
4220
            {
4221
                foreach (StylusPoint sty in hits.StylusPoints)
4222
                {
4223

    
4224
                }
4225
                if (hits.HitTest(P))
4226
                {
4227
                    inkBoard.Strokes.Remove(hits);
4228
                    return;
4229
                }
4230
            }
4231
        }
4232

    
4233
        private void StartNewStroke(Point P)
4234
        {
4235
            strokePoints = new StylusPointCollection();
4236
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4237
            strokePoints.Add(segment1Start);
4238
            stroke = new Stroke(strokePoints);
4239

    
4240
            stroke.DrawingAttributes.Color = Colors.Red;
4241
            stroke.DrawingAttributes.Width = 4;
4242
            stroke.DrawingAttributes.Height = 4;
4243

    
4244
            inkBoard.Strokes.Add(stroke);
4245

    
4246
        }
4247

    
4248
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4249
        {
4250
            ConsolidationMethod();
4251
        }
4252

    
4253
        public void ConsolidationMethod()
4254
        {
4255
            ChangeCommentReact();
4256

    
4257
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4258
            {
4259
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4260
            }
4261
            else
4262
            {
4263

    
4264
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4265
                {
4266
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4267
                }
4268

    
4269
                ViewerDataModel.Instance.IsConsolidate = true;
4270
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4271
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4272
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4273
                {
4274
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4275
                    if (markupInfo.CONSOLIDATE == 1)
4276
                    {
4277
                        markupInfo.AVOID_CONSOLIDATE = 1;
4278
                    }
4279

    
4280
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4281
                    {
4282
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4283
                          {
4284
                              instanceDataSet.Add(d);
4285
                          });
4286
                    }
4287

    
4288
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4289
                    info.ID = Save.shortGuid();
4290
                    info.CONSOLIDATE = 1;
4291
                    info.CREATE_TIME = DateTime.Now;
4292
                    info.DOCINFO_ID = _DocInfo.ID;
4293
                    info.UPDATE_TIME = DateTime.Now;
4294
                    info.USER_ID = App.ViewInfo.UserID;
4295
                    info.AVOID_CONSOLIDATE = 0;
4296

    
4297
                    Entity.MARKUP_INFO.AddObject(info);
4298
                    Entity.SaveChanges();
4299

    
4300

    
4301
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4302
                    {
4303
                        ID = Save.shortGuid(),
4304
                        CREATE_DATE = DateTime.Now,
4305
                        MARKUP_INFO = info,
4306
                    };
4307
                    Entity.SaveChanges();
4308

    
4309
                    foreach (var item in instanceDataSet)
4310
                    {
4311
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4312
                        {
4313
                            ID = Save.shortGuid(),
4314
                            DATA = item.DATA,
4315
                            DATA_TYPE = item.DATA_TYPE,
4316
                            PAGENUMBER = item.PAGENUMBER,
4317
                            MARKUP_INFO_VERSION = info2
4318
                        });
4319
                    }
4320
                    Entity.SaveChanges();
4321
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4322
                }
4323
            }
4324
        }
4325

    
4326
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4327
        {
4328
            if (App.ViewInfo != null)
4329
            {
4330
                btnConsolidate = (sender as RadRibbonButton);
4331
                if (!App.ViewInfo.NewCommentPermission)
4332
                {
4333
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4334
                }
4335
            }
4336
        }
4337

    
4338
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4339
        {
4340

    
4341
        }
4342

    
4343
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4344
        {
4345
            btnTeamConsolidate = sender as RadRibbonButton;
4346
            if (App.ViewInfo != null)
4347
            {
4348
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4349
                {
4350
                    if (btnConsolidate != null)
4351
                    {
4352
                        btnConsolidate.Visibility = Visibility.Collapsed;
4353
                    }
4354

    
4355
                    if (!App.ViewInfo.NewCommentPermission)
4356
                    {
4357
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4358
                    }
4359
                }
4360
                else
4361
                {
4362
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4363
                }
4364
            }
4365
        }
4366

    
4367
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4368
        {
4369
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4370
            if (item != null)
4371
            {
4372
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4373
            }
4374
            else
4375
            {
4376
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4377
            }
4378
        }
4379

    
4380
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4381
        {
4382
            btnFinalPDF = sender as RadRibbonButton;
4383
            if (App.ViewInfo != null)
4384
            {
4385
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4386
                {
4387
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4388
                    if (btnConsolidate != null)
4389
                    {
4390
                        btnConsolidate.Visibility = Visibility.Collapsed;
4391
                    }
4392
                }
4393
            }
4394
        }
4395

    
4396
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4397
        {
4398
            if (CompareMode.IsChecked)
4399
            {
4400
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4401
                {
4402
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4403
                }
4404
                if (ViewerDataModel.Instance.PageNumber == 0)
4405
                {
4406
                    ViewerDataModel.Instance.PageNumber = 1;
4407
                }
4408

    
4409
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4410
            }
4411
            else
4412
            {
4413
                da.From = 1;
4414
                da.To = 1;
4415
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4416
                da.AutoReverse = false;
4417
                canvas_compareBorder.Children.Clear();
4418
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4419
            }
4420
        }
4421

    
4422
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4423
        {
4424
            if (UserList.IsChecked)
4425
            {
4426
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4427
            }
4428
            else
4429
            {
4430
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4431
            }
4432
        }
4433

    
4434
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4435
        {
4436

    
4437
            if (BalanceMode.IsChecked)
4438
            {
4439
                ViewerDataModel.Instance.PageBalanceMode = true;
4440
            }
4441
            else
4442
            {
4443
                ViewerDataModel.Instance.PageBalanceMode = false;
4444
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4445
            }
4446
        }
4447

    
4448
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4449
        {
4450
            //초기화
4451
            testPanel2.IsHidden = true;
4452
            ViewerDataModel.Instance.PageBalanceMode = false;
4453
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4454
            ViewerDataModel.Instance.PageNumber = 0;
4455
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4456
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4457
            UserList.IsChecked = false;
4458
            BalanceMode.IsChecked = false;
4459
        }
4460

    
4461
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4462
        {
4463
            if ((sender as System.Windows.Controls.Control).Tag != null)
4464
            {
4465
                //Compare 초기화
4466
                CompareMode.IsChecked = false;
4467
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4468

    
4469
                if (ViewerDataModel.Instance.PageNumber == 0)
4470
                {
4471
                    ViewerDataModel.Instance.PageNumber = 1;
4472
                }
4473

    
4474
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4475
                {
4476
                }
4477
                else
4478
                {
4479
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4480
                }
4481

    
4482
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4483
                {
4484

    
4485
                }
4486
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4487
                {
4488
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4489
                }
4490

    
4491
                if (!testPanel2.IsHidden)
4492
                {
4493
                    if (IsSyncPDFMode)
4494
                    {
4495
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4496
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4497

    
4498
                        if (pdfpath.IsDownloading)
4499
                        {
4500
                            pdfpath.DownloadCompleted += (ex, arg) =>
4501
                            {
4502
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4503
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4504
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4505
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4506
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4507
                            };
4508
                        }
4509
                        else
4510
                        {
4511
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4512
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4513
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4514

    
4515
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4516
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4517
                        }
4518

    
4519
                    }
4520
                    else
4521
                    {
4522
                        var uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4523

    
4524
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4525

    
4526
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4527
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4528
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4529

    
4530
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4531
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4532

    
4533
                        if (defaultBitmapImage_Compare.IsDownloading)
4534
                        {
4535
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4536
                            {
4537
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4538
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4539
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4540

    
4541
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4542
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4543
                            };
4544
                        }
4545
                    }
4546

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

    
4551
                    foreach (var item in gridSelectionRevItem)
4552
                    {
4553
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4554
                        {
4555
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4556
                        });
4557
                    }
4558

    
4559
                    //강인구 추가
4560
                    zoomAndPanControl2.ZoomTo(new Rect
4561
                    {
4562
                        X = 0,
4563
                        Y = 0,
4564
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4565
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4566
                    });
4567

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

    
4570
                }
4571
            }
4572
        }
4573

    
4574
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4575
        {
4576
            if (MarkupMode.IsChecked)
4577
            {
4578
                IsSyncPDFMode = true;
4579

    
4580
                var uri = CurrentRev.TO_VENDOR;
4581

    
4582
                if (ViewerDataModel.Instance.PageNumber == 0)
4583
                {
4584
                    ViewerDataModel.Instance.PageNumber = 1;
4585
                }
4586

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

    
4591
                if (pdfpath.IsDownloading)
4592
                {
4593
                    pdfpath.DownloadCompleted += (ex, arg) =>
4594
                    {
4595
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4596
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4597
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4598
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4599
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4600
                    };
4601
                }
4602
                else
4603
                {
4604
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4605
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4606
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4607

    
4608
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4609
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4610
                }
4611
            }
4612
            else
4613
            {
4614
                IsSyncPDFMode = false;
4615
                var uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4616

    
4617
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4618

    
4619
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4620
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4621
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4622

    
4623
                if (defaultBitmapImage_Compare.IsDownloading)
4624
                {
4625
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4626
                    {
4627
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4628
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4629
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4630
                    };
4631
                }
4632
                zoomAndPanControl2.ApplyTemplate();
4633
                zoomAndPanControl2.UpdateLayout();
4634
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4635
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4636
            }
4637
        }
4638

    
4639
        private void RadButton_Click(object sender, RoutedEventArgs e)
4640
        {
4641
            gridViewHistory_Busy.IsBusy = true;
4642

    
4643
            RadButton instance = sender as RadButton;
4644
            if (instance.CommandParameter != null)
4645
            {
4646
                CurrentRev = instance.CommandParameter as VPRevision;
4647
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4648
                {
4649
                    if (ea.Error == null && ea.Result != null)
4650
                    {
4651
                        testPanel2.IsHidden = false;
4652

    
4653
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4654
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4655

    
4656
                        var uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4657

    
4658
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4659

    
4660
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4661

    
4662
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4663
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4664
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4665

    
4666
                        if (defaultBitmapImage_Compare.IsDownloading)
4667
                        {
4668
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4669
                            {
4670
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4671
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4672
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4673
                            };
4674
                        }
4675

    
4676
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4677
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4678
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4679
                        zoomAndPanControl2.ApplyTemplate();
4680
                        zoomAndPanControl2.UpdateLayout();
4681

    
4682
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4683
                        {
4684
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4685
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4686
                        }
4687

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

    
4697
        public void Sync_Event(VPRevision Currnet_Rev)
4698
        {
4699
            CurrentRev = Currnet_Rev;
4700

    
4701
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4702
            {
4703
                if (ea.Error == null && ea.Result != null)
4704
                {
4705
                    testPanel2.IsHidden = false;
4706

    
4707
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4708
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4709

    
4710
                    var uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4711

    
4712
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4713

    
4714
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4715

    
4716
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4717
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4718
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4719

    
4720
                    if (defaultBitmapImage_Compare.IsDownloading)
4721
                    {
4722
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4723
                        {
4724
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4725
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4726
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4727
                        };
4728
                    }
4729

    
4730
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4731
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4732
                    zoomAndPanControl2.ApplyTemplate();
4733
                    zoomAndPanControl2.UpdateLayout();
4734

    
4735
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4736
                    {
4737
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4738
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4739
                    }
4740
                    //}
4741

    
4742
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4743
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4744
                    gridViewHistory_Busy.IsBusy = false;
4745
                }
4746
            };
4747
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4748

    
4749

    
4750
        }
4751

    
4752
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4753
        {
4754
            if (sender is Image)
4755
            {
4756
                if ((sender as Image).Tag != null)
4757
                {
4758
                    var pdfUrl = (sender as Image).Tag.ToString();
4759
                    System.Diagnostics.Process.Start(pdfUrl);
4760
                }
4761
                else
4762
                {
4763
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4764
                }
4765
            }
4766
        }
4767

    
4768
        private void Create_Symbol(object sender, RoutedEventArgs e)
4769
        {
4770
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4771
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4772

    
4773
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4774
            {
4775
                DialogMessage_Alert("Please Select Controls", "Alert");
4776
            }
4777
            else //선택된 것이 있으면
4778
            {
4779
                string MarkupData = "";
4780
                adorner_ = new AdornerFinal();
4781

    
4782
                foreach (var item in SelectLayer.Children)
4783
                {
4784
                    if (item.GetType().Name == "AdornerFinal")
4785
                    {
4786
                        adorner_ = (item as Controls.AdornerFinal);
4787
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4788
                        {
4789
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4790
                            {
4791
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4792
                                MarkupData += markupReturn.ConvertData;
4793
                            }
4794
                        }
4795
                    }
4796
                }
4797
                DialogParameters parameters = new DialogParameters()
4798
                {
4799
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4800
                    DefaultPromptResultValue = "Custom State",
4801
                    Content = "Name :",
4802
                    Header = "Insert Custom Symbol Name",
4803
                    Theme = new VisualStudio2013Theme(),
4804
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4805
                };
4806
                RadWindow.Prompt(parameters);
4807
            }
4808

    
4809
        }
4810

    
4811
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4812
        {
4813
            Save save = new Save();
4814

    
4815
            if (args.DialogResult.Value)
4816
            {
4817
                PngBitmapEncoder _Encoder = symImage(data);
4818

    
4819
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4820
                _Encoder.Save(fs);
4821
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4822

    
4823
                byte[] Img_byte = fs.ToArray();
4824

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

    
4828
                save.SymbolSave(args.PromptResult, filename, data);
4829
            }
4830
        }
4831

    
4832
        public PngBitmapEncoder symImage(string data)
4833
        {
4834

    
4835
            Canvas _canvas = new Canvas();
4836
            _canvas.Background = Brushes.White;
4837
            _canvas.Width = adorner_.BorderSize.Width;
4838
            _canvas.Height = adorner_.BorderSize.Height;
4839
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4840

    
4841
            BitmapEncoder encoder = new PngBitmapEncoder();
4842

    
4843

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

    
4846
            DrawingVisual dv = new DrawingVisual();
4847

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

    
4851
            using (DrawingContext ctx = dv.RenderOpen())
4852
            {
4853
                VisualBrush vb = new VisualBrush(_canvas);
4854
                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)));
4855
            }
4856

    
4857
            try
4858
            {
4859
                renderBitmap.Render(dv);
4860

    
4861
                GC.Collect();
4862
                GC.WaitForPendingFinalizers();
4863
                GC.Collect();
4864
                // encode png data
4865
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4866
                // puch rendered bitmap into it
4867
                pngEncoder.Interlace = PngInterlaceOption.Off;
4868
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4869
                return pngEncoder;
4870

    
4871
            }
4872
            catch (Exception ex)
4873
            {
4874
                return null;
4875
            }
4876

    
4877
        }
4878

    
4879
        public void DialogMessage_Alert(string content, string header)
4880
        {
4881
            var box = new TextBlock();
4882
            box.MinWidth = 400;
4883
            box.FontSize = 11;
4884
            //box.FontSize = 12;
4885
            box.Text = content;
4886
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4887

    
4888
            DialogParameters parameters = new DialogParameters()
4889
            {
4890
                Content = box,
4891
                Header = header,
4892
                Theme = new VisualStudio2013Theme(),
4893
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4894
            };
4895
            RadWindow.Alert(parameters);
4896
        }
4897

    
4898
        #region 캡쳐 기능
4899

    
4900
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4901
        {
4902
            if (x < 0)
4903
            {
4904
                width += x;
4905
                x = 0;
4906
            }
4907
            if (y < 0)
4908
            {
4909
                height += y;
4910
                y = 0;
4911

    
4912
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4913
            }
4914
            if (x + width > zoomAndPanCanvas.ActualWidth)
4915
            {
4916
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4917
            }
4918
            if (y + height > zoomAndPanCanvas.ActualHeight)
4919
            {
4920
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4921
            }
4922

    
4923
            byte[] pixels = CopyPixels(x, y, width, height);
4924

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

    
4927
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4928
        }
4929

    
4930
        public byte[] CopyPixels(int x, int y, int width, int height)
4931
        {
4932
            byte[] pixels = new byte[width * height * 4];
4933
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4934

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

    
4938
            return pixels;
4939
        }
4940

    
4941
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4942
        {
4943
            DrawingVisual drawingVisual = new DrawingVisual();
4944
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4945

    
4946
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4947
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4948
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4949
            drawingContext.Close();
4950

    
4951
            // 비트맵으로 변환합니다.
4952
            RenderTargetBitmap target =
4953
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4954
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4955

    
4956
            target.Render(drawingVisual);
4957
            return target;
4958
        }
4959

    
4960
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
4961
        {
4962
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
4963
            KCOMDataModel.DataModel.CHECK_LIST check_;
4964
            string Result = streamToBase64.ImageToBase64(source);
4965
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
4966

    
4967
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4968
            {
4969
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
4970

    
4971
                //새로운 데이터 추가
4972
                if (Item == null)
4973
                {
4974
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
4975
                    {
4976
                        ID = Save.shortGuid(),
4977
                        USER_ID = App.ViewInfo.UserID,
4978
                        IMAGE_URL = Result,
4979
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
4980
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
4981
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
4982
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
4983
                        PROJECT_NO = App.ViewInfo.ProjectNO,
4984
                        STATUS = "False",
4985
                        CREATE_TIME = DateTime.Now,
4986
                        UPDATE_TIME = DateTime.Now,
4987
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
4988
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
4989
                    };
4990

    
4991
                    Entity.CHECK_LIST.AddObject(check_);
4992
                }
4993
                //기존에 있던 데이터 업데이트
4994
                else
4995
                {
4996
                    Item.IMAGE_URL = Result;
4997
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
4998
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
4999
                }
5000

    
5001
                //Item.REV_0 = "Test";
5002

    
5003
                try
5004
                {
5005
                    Entity.SaveChanges();
5006
                }
5007
                catch (Exception ex)
5008
                {
5009

    
5010
                }
5011
                //Entity.SaveChanges();
5012
            }
5013
        }
5014

    
5015
        public void Set_Capture()
5016
        {
5017
            //double x = Canvas.GetLeft(dragCaptureBorder);
5018
            //double y = Canvas.GetTop(dragCaptureBorder);
5019
            double x = canvasDrawingMouseDownPoint.X;
5020
            double y = canvasDrawingMouseDownPoint.Y;
5021
            double width = dragCaptureBorder.Width;
5022
            double height = dragCaptureBorder.Height;
5023

    
5024
            if (width > 5 || height > 5)
5025
            {
5026
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5027
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5028
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5029
            }
5030
        }
5031
        #endregion
5032

    
5033
        public void CreateControl()
5034
        {
5035
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5036
            {
5037
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5038
            });
5039
            multi_Undo_Data.Markup = currentControl;
5040
            UndoData.Markup_List.Add(multi_Undo_Data);
5041
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5042
        }
5043

    
5044
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5045
        {
5046
            multi_Undo_Data = new Multi_Undo_data();
5047

    
5048
            multi_Undo_Data.Markup = control;
5049

    
5050
            if ((control as IShapeControl) != null)
5051
            {
5052
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5053
            }
5054
            if ((control as IDashControl) != null)
5055
            {
5056
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5057
            }
5058
            if ((control as IPath) != null)
5059
            {
5060
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5061
            }
5062
            if ((control as UIElement) != null)
5063
            {
5064
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5065
            }
5066

    
5067
            return multi_Undo_Data;
5068
        }
5069

    
5070
        public void Undo()
5071
        {
5072
            Undo_data undo = new Undo_data();
5073
            AdornerFinal final;
5074
            ReleaseAdorner();
5075

    
5076
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5077
            if (undo == null)
5078
                return;
5079

    
5080
            switch (undo.Event)
5081
            {
5082
                case (Event_Type.Create):
5083
                    {
5084
                        foreach (var item in undo.Markup_List)
5085
                        {
5086
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5087
                        }
5088
                    }
5089
                    break;
5090
                case (Event_Type.Delete):
5091
                    {
5092
                        foreach (var item in undo.Markup_List)
5093
                        {
5094
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5095
                        }
5096
                    }
5097
                    break;
5098
                case (Event_Type.Thumb):
5099
                    {
5100
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5101

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

    
5106
                            if ((item.Markup as IViewBox) != null)
5107
                            {
5108
                                (item.Markup as IViewBox).Angle = item.Angle;
5109
                            }
5110
                            if ((item.Markup as TextControl) != null)
5111
                            {
5112
                                (item.Markup as TextControl).Angle = item.Angle;
5113
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5114
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5115
                            }
5116
                            else
5117
                            {
5118
                                (item.Markup as IPath).PointSet = item.PointSet;
5119
                                (item.Markup as IPath).updateControl();
5120
                            }
5121

    
5122
                            comment.Add(item.Markup);
5123
                        }
5124
                        final = new AdornerFinal(comment);
5125
                        SelectLayer.Children.Add(final);
5126
                        ReleaseAdorner();
5127
                    }
5128
                    break;
5129
                case (Event_Type.Select):
5130
                    {
5131
                        ReleaseAdorner();
5132
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5133

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

    
5138
                            if ((item.Markup as IPath) != null)
5139
                            {
5140
                                (item.Markup as IPath).LineSize = item.LineSize;
5141
                            }
5142
                            if ((item.Markup as UIElement) != null)
5143
                            {
5144
                                (item.Markup as UIElement).Opacity = item.Opacity;
5145
                            }
5146
                            if ((item.Markup as IDashControl) != null)
5147
                            {
5148
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5149
                            }
5150
                            if ((item.Markup as IShapeControl) != null)
5151
                            {
5152
                                (item.Markup as IShapeControl).Paint = item.paint;
5153
                            }
5154

    
5155
                            comment.Add(item.Markup);
5156
                        }
5157

    
5158
                        final = new AdornerFinal(comment);
5159
                        SelectLayer.Children.Add(final);
5160
                    }
5161
                    break;
5162
                case (Event_Type.Option):
5163
                    {
5164
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5165

    
5166
                        foreach (var item in undo.Markup_List)
5167
                        {
5168
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5169

    
5170
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5171
                            {
5172
                                (item.Markup as IPath).LineSize = undo.LineSize;
5173
                            }
5174
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5175
                            {
5176
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5177
                            }
5178
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5179
                            {
5180
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5181
                            }
5182
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5183
                            {
5184
                                (item.Markup as LineControl).Interval = undo.Interval;
5185
                            }
5186
                            else if (item.Markup as IShapeControl != null)
5187
                            {
5188
                                (item.Markup as IShapeControl).Paint = undo.paint;
5189
                            }
5190
                            comment.Add(item.Markup);
5191
                        }
5192
                        final = new AdornerFinal(comment);
5193
                        SelectLayer.Children.Add(final);
5194
                    }
5195
                    break;
5196
            }
5197
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5198
           {
5199
               i.IsUndo = true;
5200
           });
5201
        }
5202

    
5203
        public void Redo()
5204
        {
5205
            AdornerFinal final;
5206
            Undo_data redo = new Undo_data();
5207
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5208
            ReleaseAdorner();
5209
            if (redo == null)
5210
                return;
5211

    
5212
            switch (redo.Event)
5213
            {
5214
                case (Event_Type.Create):
5215
                    {
5216
                        foreach (var item in redo.Markup_List)
5217
                        {
5218
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5219
                        }
5220
                    }
5221
                    break;
5222
                case (Event_Type.Delete):
5223
                    {
5224
                        foreach (var item in redo.Markup_List)
5225
                        {
5226
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5227
                        }
5228
                    }
5229
                    break;
5230
                case (Event_Type.Thumb):
5231
                    {
5232
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5233

    
5234
                        foreach (var item in redo.Markup_List)
5235
                        {
5236
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5237

    
5238
                            if ((item.Markup as IViewBox) != null)
5239
                            {
5240
                                (item.Markup as IViewBox).Angle = item.Angle;
5241
                            }
5242
                            if ((item.Markup as TextControl) != null)
5243
                            {
5244
                                (item.Markup as TextControl).Angle = item.Angle;
5245

    
5246
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5247
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5248
                            }
5249
                            else
5250
                            {
5251
                                (item.Markup as IPath).PointSet = item.PointSet;
5252
                                (item.Markup as IPath).updateControl();
5253
                            }
5254
                            comment.Add(item.Markup);
5255
                        }
5256
                        final = new AdornerFinal(comment);
5257
                        SelectLayer.Children.Add(final);
5258
                        ReleaseAdorner();
5259
                    }
5260
                    break;
5261
                case (Event_Type.Select):
5262
                    {
5263
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5264

    
5265
                        foreach (var item in redo.Markup_List)
5266
                        {
5267
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5268

    
5269
                            if ((item.Markup as IPath) != null)
5270
                            {
5271
                                (item.Markup as IPath).LineSize = item.LineSize;
5272
                            }
5273
                            if ((item.Markup as UIElement) != null)
5274
                            {
5275
                                (item.Markup as UIElement).Opacity = item.Opacity;
5276
                            }
5277
                            if ((item.Markup as IDashControl) != null)
5278
                            {
5279
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5280
                            }
5281
                            if ((item.Markup as IShapeControl) != null)
5282
                            {
5283
                                (item.Markup as IShapeControl).Paint = item.paint;
5284
                            }
5285

    
5286
                            comment.Add(item.Markup);
5287
                        }
5288
                        final = new AdornerFinal(comment);
5289
                        SelectLayer.Children.Add(final);
5290
                    }
5291
                    break;
5292
                case (Event_Type.Option):
5293
                    {
5294
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5295

    
5296
                        foreach (var item in redo.Markup_List)
5297
                        {
5298
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5299
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5300
                            {
5301
                                (item.Markup as IPath).LineSize = redo.LineSize;
5302
                            }
5303
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5304
                            {
5305
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5306
                            }
5307
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5308
                            {
5309
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5310
                            }
5311
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
5312
                            {
5313
                                (item.Markup as LineControl).Interval = redo.Interval;
5314
                            }
5315
                            else if (item.Markup as IShapeControl != null)
5316
                            {
5317
                                (item.Markup as IShapeControl).Paint = redo.paint;
5318
                            }
5319
                            comment.Add(item.Markup);
5320
                        }
5321
                        final = new AdornerFinal(comment);
5322
                        SelectLayer.Children.Add(final);
5323
                    }
5324
                    break;
5325
            }
5326

    
5327
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5328
            {
5329
                i.IsUndo = false;
5330
            });
5331
        }
5332

    
5333
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5334
        {
5335
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5336
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5337
            {
5338
                if (items.UserID == Select_ID)
5339
                {
5340
                    foreach (var item in items.MarkupList)
5341
                    {
5342
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5343
                        {
5344
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5345
                        }
5346
                    }
5347
                }
5348
            }
5349
        }
5350

    
5351
        public void InkControl_Convert()
5352
        {
5353
            if (inkBoard.Strokes.Count > 0)
5354
            {
5355
                inkBoard.Strokes.ToList().ForEach(stroke =>
5356
                {
5357
                    List<Stroke> removingStroke = new List<Stroke>();
5358
                    StrokeCollection stC = new StrokeCollection();
5359

    
5360
                    removingStroke.Add(stroke);
5361

    
5362
                    InkToPath ip = new InkToPath();
5363
                    List<Point> inkPointSet = new List<Point>();
5364
                    PolygonControl pc = null;
5365
                    pc = new PolygonControl()
5366
                    {
5367
                        Angle = 0,
5368
                        PointSet = new List<Point>(),
5369
                        ControlType = ControlType.Ink
5370
                    };
5371
                    foreach (var item in removingStroke)
5372
                    {
5373
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5374
                        inkBoard.Strokes.Remove(item);
5375
                    }
5376
                    if (inkPointSet.Count != 0)
5377
                    {
5378
                        //강인구 추가(PenControl Undo Redo 추가)
5379
                        UndoData = new Undo_data()
5380
                        {
5381
                            IsUndo = false,
5382
                            Event = Event_Type.Create,
5383
                            EventTime = DateTime.Now,
5384
                            Markup_List = new List<Multi_Undo_data>()
5385
                        };
5386

    
5387
                        pc.StartPoint = inkPointSet[0];
5388
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5389
                        pc.PointSet = inkPointSet;
5390
                        pc.LineSize = 3;
5391
                        pc.CommentID = Save.shortGuid();
5392
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5393
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5394
                        pc.SetPolyPath();
5395

    
5396
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5397
                        {
5398
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5399
                        });
5400
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5401
                        UndoData.Markup_List.Add(multi_Undo_Data);
5402
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5403
                    }
5404
                });
5405
            }
5406
        }
5407

    
5408
        /// <summary>
5409
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5410
        /// </summary>
5411
        /// <param name="StartP">StartPoint</param>
5412
        /// <param name="EndP">EndPoint</param>
5413
        /// <returns>Return_EndPoint</returns>
5414
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5415
        {
5416
            Point Return_Point = new Point();
5417

    
5418
            double dx = EndP.X - StartP.X;
5419
            double dy = EndP.Y - StartP.Y;
5420
            double length;
5421

    
5422
            switch (controlType)
5423
            {
5424
                case ControlType.Triangle:
5425
                    {
5426
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5427
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5428
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5429
                    }
5430
                    break;
5431
                default:
5432
                    {
5433
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5434
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5435
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5436
                    }
5437
                    break;
5438
            }
5439

    
5440
            return Return_Point;
5441
        }
5442

    
5443
        /// <summary>
5444
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5445
        /// </summary>
5446
        /// <author>humkyung</author>
5447
        /// <date>2018.04.26</date>
5448
        /// <param name="StartP"></param>
5449
        /// <param name="EndP"></param>
5450
        /// <returns></returns>
5451
        /// <history>humkyung 2018.05.11 apply axis lock</history>
5452
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
5453
        {
5454
            List<Point> res = new List<Point>();
5455

    
5456
            double dx = EndP.X - StartP.X;
5457
            double dy = EndP.Y - StartP.Y;
5458
            double length = Math.Sqrt(dx * dx + dy * dy);
5459
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
5460
            dx /= length;
5461
            dy /= length;
5462
            double tmp = dx;
5463
            dx = -dy; dy = tmp; /// rotate by 90 degree
5464

    
5465
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5466
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5467

    
5468
            return res;
5469
        }
5470
    }
5471
}
클립보드 이미지 추가 (최대 크기: 500 MB)