프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ bc664e9b

이력 | 보기 | 이력해설 | 다운로드 (265 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
            string uri = "";
492
            if (userData.COMPANY != "EXT")
493
            {
494
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
495
            }
496
            else
497
            {
498
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
499
            }
500

    
501
            var defaultBitmapImage = new BitmapImage(new Uri(uri));
502

    
503
            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
504
            ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
505
            ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
506

    
507
            if (defaultBitmapImage.IsDownloading)
508
            {
509
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
510
                {
511
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
512
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
513
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
514
                };
515
            }
516

    
517
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
518
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
519

    
520

    
521
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
522
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
523
            inkBoard.Width = zoomAndPanCanvas.Width;
524
            inkBoard.Height = zoomAndPanCanvas.Height;
525

    
526

    
527
            if (!testPanel2.IsHidden)
528
            {
529
                //PDF모드일때 잠시 대기(강인구)
530
                if (IsSyncPDFMode)
531
                {
532
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
533
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
534

    
535
                    if (pdfpath.IsDownloading)
536
                    {
537
                        pdfpath.DownloadCompleted += (ex, arg) =>
538
                        {
539
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
540
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
541
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
542
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
543
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
544
                        };
545
                    }
546
                    else
547
                    {
548
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
549
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
550
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
551

    
552
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
553
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
554
                    }
555
                }
556
                else
557
                {
558
                    string uri2 = "";
559
                    if (userData.COMPANY != "EXT")
560
                    {
561
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
562
                    }
563
                    else
564
                    {
565
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
566
                    }
567

    
568

    
569
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
570

    
571
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
572
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
573
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
574
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
575
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
576

    
577
                    zoomAndPanControl.ZoomTo(new Rect
578
                    {
579
                        X = 0,
580
                        Y = 0,
581
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
582
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
583
                    });
584

    
585
                    if (defaultBitmapImage_Compare.IsDownloading)
586
                    {
587
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
588
                        {
589

    
590
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
591
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
592
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
593

    
594
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
595
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
596

    
597
                            zoomAndPanControl.ZoomTo(new Rect
598
                            {
599
                                X = 0,
600
                                Y = 0,
601
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
602
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
603
                            });
604
                        };
605
                    }
606
                }
607
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
608
            }
609

    
610
            this.pageNavigator.SetNextPage();
611

    
612
            if (zoomAndPanCanvas2.Width.IsNaN())
613
            {
614
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
615
            }
616

    
617
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
618
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
619

    
620
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
621
            foreach (var item in gridSelectionItem)
622
            {
623
                if (item.UserID == App.ViewInfo.UserID)
624
                {
625
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
626
                    {
627
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
628
                    });
629
                }
630
                else
631
                {
632
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
633
                    {
634
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
635
                    });
636
                }
637
            }
638

    
639

    
640
            if (!testPanel2.IsHidden)
641
            {
642
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
643
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
644
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
645

    
646
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
647
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
648

    
649

    
650
                foreach (var item in gridSelectionRevItem)
651
                {
652
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
653
                    {
654
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
655
                    });
656
                }
657

    
658
            }
659

    
660

    
661

    
662
            var instanceMain = this.ParentOfType<MainWindow>();
663
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
664
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
665

    
666
            //강인구 추가
667
            instanceMain.dzTopMenu.rotateOffSet = 0;
668
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
669
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
670

    
671
            //}
672
            SetCommentPages(true);
673
        }
674

    
675
        private void SetCommentPages(bool onlyMe = false)
676
        {
677

    
678
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
679
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
680
            {
681
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
682
                instance.UserName = item.UserName;
683
                instance.Depart = item.Depatment;
684
                instance.MarkupInfoID = item.MarkupInfoID;
685
                instance.IsSelected = true;
686
                instance.isConSolidation = item.Consolidate;
687
                instance.SetColor = item.DisplayColor;
688
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
689
                {
690
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
691
                }
692
                else
693
                {
694
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
695
                }
696
                _pages.Add(instance);
697
            }
698
            this.pageNavigator.SetCommentList(_pages.ToList());
699
        }
700

    
701
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
702
        {
703
            if (e.MiddleButton == MouseButtonState.Pressed)
704
            {
705

    
706
            }
707
            e.Handled = true;
708
            if (e.Delta > 0)
709
            {
710
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
711
                ZoomIn(currentContentMousePoint);
712
            }
713
            else
714
            {
715
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
716
                ZoomOut(currentContentMousePoint);
717
            }
718
        }
719

    
720
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
721
        {
722
            e.Handled = true;
723
            if (e.Delta > 0)
724
            {
725
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
726
                ZoomIn_Sync(currentContentMousePoint);
727
            }
728
            else
729
            {
730
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
731
                ZoomOut_Sync(currentContentMousePoint);
732
            }
733
        }
734

    
735
        #region ZoomIn & ZoomOut
736

    
737
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
738
        {
739
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
740
                zoomAndPanControl.ContentZoomFocusY));
741
        }
742

    
743
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
744
        {
745
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
746
                zoomAndPanControl.ContentZoomFocusY));
747
        }
748

    
749

    
750
        //강인구 추가 (줌 인아웃 수치 변경)
751
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
752
        private void ZoomOut(Point contentZoomCenter)
753
        {
754
            if (zoomAndPanControl.ContentScale > 0.39)
755
            {
756
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
757
            }
758
            else
759
            {
760
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
761
            }
762

    
763
            if (zoomAndPanControl2 != null && Sync.IsChecked)
764
            {
765
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
766
            }
767
        }
768

    
769
        private void ZoomIn(Point contentZoomCenter)
770
        {
771
            if (zoomAndPanControl.ContentScale > 0.19)
772
            {
773
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
774
            }
775
            else
776
            {
777
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
778
            }
779

    
780
            if (zoomAndPanControl2 != null && Sync.IsChecked)
781
            {
782
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
783
            }
784

    
785
        }
786

    
787
        private void ZoomOut_Sync(Point contentZoomCenter)
788
        {
789
            if (zoomAndPanControl2.ContentScale > 0.39)
790
            {
791
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
792
            }
793
            else
794
            {
795
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
796
            }
797

    
798
            if (Sync.IsChecked)
799
            {
800
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
801
            }
802
        }
803

    
804
        private void ZoomIn_Sync(Point contentZoomCenter)
805
        {
806
            if (zoomAndPanControl2.ContentScale > 0.19)
807
            {
808
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
809
            }
810
            else
811
            {
812
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
813
            }
814

    
815
            if (Sync.IsChecked)
816
            {
817
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
818
            }
819
        }
820

    
821
        private void ZoomOut()
822
        {
823
            zoomAndPanControl.ContentScale -= 0.1;
824
            //if (zoomAndPanControl2 != null)
825
            //{
826
            //    zoomAndPanControl2.ContentScale -= 0.1;
827
            //}
828
        }
829

    
830
        private void ZoomIn()
831
        {
832
            zoomAndPanControl.ContentScale += 0.1;
833
            //if (zoomAndPanControl2 != null)
834
            //{
835
            //    zoomAndPanControl2.ContentScale += 0.1;
836
            //}
837
        }
838

    
839
        #endregion
840

    
841
        private void init()
842
        {
843
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
844
            {
845

    
846
                ControlList.Clear();
847
                listBox.Items.Clear();
848
                selected_item.Clear();
849

    
850
                (item as IMarkupCommonData).IsSelected = false;
851
            }
852

    
853
        }
854

    
855
        private HitTestResultBehavior MyCallback(HitTestResult result)
856
        {
857
            //this.cursor = Cursors.UpArrow;
858
            var element = result.VisualHit;
859
            while (element != null && !(element is CommentUserInfo))
860
                element = VisualTreeHelper.GetParent(element);
861

    
862
            if (element == null)
863
            {
864
                return HitTestResultBehavior.Stop;
865
            }
866
            else
867
            {
868
                if (element is CommentUserInfo)
869
                {
870
                    if (!hitList.Contains(element))
871
                    {
872
                        hitList.Add((CommentUserInfo)element);
873
                    }
874
                    else
875
                    {
876
                        return HitTestResultBehavior.Stop;
877
                    }
878
                    //IntersectionDetail intersectionDetail =
879
                    //((GeometryHitTestResult)result).IntersectionDetail;
880
                    //switch (intersectionDetail)
881
                    //{
882
                    //    case IntersectionDetail.FullyContains:
883
                    //        // Add the hit test result to the list:
884
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
885
                    //        return HitTestResultBehavior.Continue;
886
                    //    case IntersectionDetail.Intersects:
887
                    //        // Set the behavior to return visuals at all z-order levels:
888
                    //        return HitTestResultBehavior.Continue;
889
                    //    case IntersectionDetail.FullyInside:
890
                    //        // Set the behavior to return visuals at all z-order levels:
891
                    //        return HitTestResultBehavior.Continue;
892
                    //    default:
893
                    //        return HitTestResultBehavior.Stop;
894
                    //}
895
                }
896
            }
897
            return HitTestResultBehavior.Continue;
898
        }
899

    
900
        public void ReleaseSelectPath()
901
        {
902
            if (SelectionPath == null)
903
            {
904
                SelectionPath = new Path();
905
                SelectionPath.Name = "";
906
            }
907
            if (SelectionPath.Name != "")
908
            {
909
                SelectionPath.Name = "None";
910
            }
911
            SelectionPath.Opacity = 0.01;
912
            SelectionPath.RenderTransform = null;
913
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
914
        }
915

    
916
        #region 컨트롤 초기화 
917
        public void Control_Init(object control)
918
        {
919
            if (L_Size != 0 && (control as IPath) != null)
920
            {
921
                (control as IPath).LineSize = L_Size;
922
                L_Size = 0;
923
            }
924

    
925
            switch (control.GetType().Name)
926
            {
927
                case "RectangleControl":
928
                    {
929
                        (control as RectangleControl).StrokeColor = Brushes.Red;
930
                    }
931
                    break;
932
                case "CircleControl":
933
                    {
934
                        (control as CircleControl).StrokeColor = Brushes.Red;
935
                    }
936
                    break;
937
                case "TriControl":
938
                    {
939
                        (control as TriControl).StrokeColor = Brushes.Red;
940
                    }
941
                    break;
942
                case "RectCloudControl":
943
                    {
944
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
945
                    }
946
                    break;
947
                case "CloudControl":
948
                    {
949
                        (control as CloudControl).StrokeColor = Brushes.Red;
950
                    }
951
                    break;
952
                case "PolygonControl":
953
                    {
954
                        (control as PolygonControl).StrokeColor = Brushes.Red;
955
                    }
956
                    break;
957
                case "ArcControl":
958
                    {
959
                        (control as ArcControl).StrokeColor = Brushes.Red;
960
                    }
961
                    break;
962
                case "LineControl":
963
                    {
964
                        (control as LineControl).StrokeColor = Brushes.Red;
965
                    }
966
                    break;
967
                case "ArrowControl_Multi":
968
                    {
969
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
970
                    }
971
                    break;
972
                case "TextControl":
973
                    {
974
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
975
                    }
976
                    break;
977
                case "ArrowTextControl":
978
                    {
979
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
980
                    }
981
                    break;
982
            }
983
        }
984
        #endregion
985

    
986
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
987
        {
988
            //Control_Init(e.Source);
989
        }
990

    
991
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
992
        {
993
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
994
            {
995
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
996

    
997
                Point currentPos = e.GetPosition(rect);
998

    
999
                floatingTip.HorizontalOffset = currentPos.X + 20;
1000
                floatingTip.VerticalOffset = currentPos.Y;
1001

    
1002

    
1003
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1004
                //tool.Content = "ToolTip";
1005
                //panel.ToolTip = tool;
1006
            }
1007

    
1008
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1009
            {
1010
                #region 마우스 오버 시 색상 변경
1011
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1012
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1013

    
1014
                //if (firstCondition != null)
1015
                //{
1016
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1017

    
1018
                //    if (firstCondition.GetType().Name == "TextControl")
1019
                //    {
1020
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1021
                //        return;
1022
                //    }
1023
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1024
                //    {
1025
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1026
                //        return;
1027
                //    }
1028

    
1029
                //    if (L_Size == 0)
1030
                //    {
1031
                //        L_Size = (firstCondition as IPath).LineSize;
1032
                //        (firstCondition as IPath).LineSize *= 4;
1033
                //    }
1034
                //    switch (firstCondition.GetType().Name)
1035
                //    {
1036
                //        case "RectangleControl":
1037
                //            {
1038
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1039
                //            }
1040
                //            break;
1041
                //        case "CircleControl":
1042
                //            {
1043
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1044
                //            }
1045
                //            break;
1046
                //        case "TriControl":
1047
                //            {
1048
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1049
                //            }
1050
                //            break;
1051
                //        case "RectCloudControl":
1052
                //            {
1053
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1054
                //            }
1055
                //            break;
1056
                //        case "CloudControl":
1057
                //            {
1058
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1059
                //            }
1060
                //            break;
1061
                //        case "PolygonControl":
1062
                //            {
1063
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1064
                //            }
1065
                //            break;
1066
                //        case "ArcControl":
1067
                //            {
1068
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1069
                //            }
1070
                //            break;
1071
                //        case "LineControl":
1072
                //            {
1073
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1074
                //            }
1075
                //            break;
1076
                //        case "ArrowControl_Multi":
1077
                //            {
1078
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1079
                //            }
1080
                //            break;
1081

    
1082
                //        default:
1083
                //            {
1084

    
1085
                //            }
1086
                //            break;
1087
                //    }
1088
                //} 
1089
                #endregion
1090
            }
1091

    
1092
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1093

    
1094
            //if (mouseButtonDown == MouseButton.Middle)
1095
            //{
1096
            //    SetCursor();
1097
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1098
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1099

    
1100
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1101
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1102
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1103

    
1104
            //    //SetCursor();
1105
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1106
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1107

    
1108
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1109

    
1110
            //    //zoomAndPanControl.ContentOffsetX += 1;
1111
            //    //zoomAndPanControl.ContentOffsetY += 1;
1112

    
1113
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1114
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1115
            //}
1116
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1117
            {
1118
                SetCursor();
1119
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1120
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1121

    
1122
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1123
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1124
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1125

    
1126
                if (Sync.IsChecked)
1127
                {
1128
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1129
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1130
                }
1131
            }
1132

    
1133

    
1134
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1135
            {
1136
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1137
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1138
                SetCursor();
1139

    
1140
                if (IsDrawing)
1141
                {
1142
                    if (currentControl == null)
1143
                    {
1144
                        switch (controlType)
1145
                        {
1146
                            case ControlType.PenControl:
1147
                                {
1148
                                    if (inkBoard.Tag.ToString() == "Ink")
1149
                                    {
1150
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1151
                                    }
1152
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1153
                                    {
1154
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1155
                                    }
1156
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1157
                                    {
1158
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1159
                                    }
1160

    
1161
                                    //inkBoard.Strokes.Add(stroke);
1162
                                }
1163
                                break;
1164
                        }
1165
                        return;
1166
                    }
1167
                }
1168

    
1169
                if (currentControl != null)
1170
                {
1171
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1172
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1173
                    //강인구 추가
1174
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1175

    
1176
                    if ((currentControl as IPath) != null)
1177
                    {
1178
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1179
                    }
1180
                    if ((currentControl as LineControl) != null)
1181
                    {
1182
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1183
                    }
1184

    
1185
                    if ((currentControl as IShapeControl) != null)
1186
                    {
1187
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1188
                    }
1189
                    if ((currentControl as TextControl) != null)
1190
                    {
1191
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1192
                        {
1193
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1194
                        }
1195
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1196
                        {
1197
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1198
                        }
1199
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1200
                        {
1201
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1202
                        }
1203
                    }
1204
                    else if ((currentControl as ArrowTextControl) != null)
1205
                    {
1206
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1207
                        {
1208
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1209
                        }
1210
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1211
                        {
1212
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1213
                        }
1214
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1215
                        {
1216
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1217
                        }
1218
                    }
1219
                    else if ((currentControl as RectCloudControl) != null)
1220
                    {
1221
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1222
                    }
1223
                    else if ((currentControl as CloudControl) != null)
1224
                    {
1225
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1226
                    }
1227

    
1228
                    switch (controlType)
1229
                    {
1230
                        case ControlType.Rectangle:
1231
                            {
1232
                                var control = currentControl as RectangleControl;
1233

    
1234
                                if (control != null)
1235
                                {
1236
                                    if (move.mousemode == MouseMode.Drawing)
1237
                                    {
1238
                                        //move.control_Move(ControlList, true, moveX, moveY);
1239
                                    }
1240
                                    else
1241
                                    {
1242
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1243
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1244
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1245
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1246

    
1247

    
1248
                                        if (ViewerDataModel.Instance.IsPressShift)
1249
                                        {
1250
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1251
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1252
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1253
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1254
                                        }
1255

    
1256
                                        control.PointSet = new List<Point>
1257
                                        {
1258
                                            control.StartPoint,
1259
                                            control.LeftBottomPoint,
1260
                                            control.EndPoint,
1261
                                            control.TopRightPoint,
1262
                                        };
1263
                                        control.updateControl();
1264
                                    }
1265

    
1266
                                    //강인구 추가
1267
                                    control.ControlType = controlType;
1268
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1269
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1270
                                }
1271
                            }
1272
                            break;
1273

    
1274
                        case ControlType.RectCloud:
1275
                            {
1276
                                var control = currentControl as RectCloudControl;
1277

    
1278
                                if (control != null)
1279
                                {
1280
                                    if (move.mousemode == MouseMode.Drawing)
1281
                                    {
1282
                                        //move.control_Move(ControlList, true, moveX, moveY);
1283
                                    }
1284
                                    else
1285
                                    {
1286
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1287
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1288
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1289
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1290

    
1291
                                        if (ViewerDataModel.Instance.IsPressShift)
1292
                                        {
1293
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1294
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1295
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1296
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1297
                                        }
1298

    
1299
                                        control.PointSet = new List<Point>
1300
                                        {
1301
                                            control.StartPoint,
1302
                                            control.LeftBottomPoint,
1303
                                            control.EndPoint,
1304
                                            control.TopRightPoint,
1305
                                        };
1306
                                    }
1307
                                    //강인구 추가
1308
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1309
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1310
                                }
1311
                            }
1312
                            break;
1313

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

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

    
1338
                                        control.PointSet = new List<Point>
1339
                                        {
1340
                                            control.StartPoint,
1341
                                            control.EndPoint,
1342
                                        };
1343
                                        //강인구 추가
1344
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1345
                                    }
1346
                                }
1347

    
1348
                            }
1349
                            break;
1350

    
1351
                        case ControlType.CancelLine:
1352
                            {
1353
                                if (currentControl != null)
1354
                                {
1355
                                    var control = currentControl as LineControl;
1356
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1357
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1358
                                    control.ControlType = controlType;
1359
                                    if (control != null)
1360
                                    {
1361
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1362
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1363
                                        Point tempPoint = control.EndPoint;
1364

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

    
1376

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

    
1389
                        case ControlType.ArrowLine:
1390
                            {
1391
                                if (currentControl != null)
1392
                                {
1393
                                    var control = currentControl as LineControl;
1394
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1395
                                    control.ControlType = controlType;
1396
                                    if (control != null)
1397
                                    {
1398
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1399
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1400
                                        Point tempPoint = control.EndPoint;
1401

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

    
1413

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

    
1424
                            }
1425
                            break;
1426

    
1427
                        case ControlType.TwinLine:
1428
                            {
1429
                                if (currentControl != null)
1430
                                {
1431
                                    var control = currentControl as LineControl;
1432
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1433
                                    control.ControlType = controlType;
1434
                                    if (control != null)
1435
                                    {
1436
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1437
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1438
                                        Point tempPoint = control.EndPoint;
1439

    
1440
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1441
                                        {
1442
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1443
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1444
                                            control.EndPoint = tempPoint;
1445
                                        }
1446
                                        else
1447
                                        {
1448
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1449
                                        }
1450

    
1451

    
1452
                                        control.PointSet = new List<Point>
1453
                                            {
1454
                                                control.StartPoint,
1455
                                                control.EndPoint,
1456
                                            };
1457
                                    }
1458
                                    //강인구 추가
1459
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1460
                                }
1461

    
1462
                            }
1463
                            break;
1464

    
1465
                        case ControlType.DimLine:
1466
                            {
1467
                                if (currentControl != null)
1468
                                {
1469
                                    var control = currentControl as LineControl;
1470
                                    control.LineStyleSet = LineStyleSet.DimLine;
1471
                                    control.ControlType = controlType;
1472
                                    if (control != null)
1473
                                    {
1474
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1475
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1476
                                        Point tempPoint = control.EndPoint;
1477

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

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

    
1499
                            }
1500
                            break;
1501

    
1502
                        case ControlType.ChainLine:
1503
                            {
1504
                                var control = currentControl as PolygonControl;
1505

    
1506
                                if (control != null)
1507
                                {
1508

    
1509
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1510
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1511

    
1512
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1513

    
1514
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1515
                                    {
1516
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1517
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1518
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1519
                                        //control.EndPoint = tempPoint;
1520
                                    }
1521
                                    else
1522
                                    {
1523
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1524
                                    }
1525

    
1526
                                    control.SetPolyPath();
1527
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1528
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1529
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1530

    
1531
                                    //강인구 추가
1532
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1533
                                }
1534
                            }
1535
                            break;
1536

    
1537
                        case ControlType.ArcLine:
1538
                            {
1539
                                if (currentControl != null)
1540
                                {
1541
                                    var control = currentControl as ArcControl;
1542
                                    control.isTransOn = false;
1543
                                    control.ControlType = controlType;
1544

    
1545
                                    if (control != null)
1546
                                    {
1547
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1548
                                        control.MidPoint = new Point(0, 0);
1549
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1550
                                        Point tempPoint = control.EndPoint;
1551

    
1552
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1553
                                        {
1554
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1555
                                            control.EndPoint = tempPoint;
1556
                                        }
1557
                                        else
1558
                                        {
1559
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1560
                                        }
1561

    
1562

    
1563
                                        control.PointSet = new List<Point>
1564
                                            {
1565
                                                control.StartPoint,
1566
                                                control.MidPoint,
1567
                                                control.EndPoint,
1568
                                            };
1569
                                    }
1570
                                    //강인구 추가
1571
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1572
                                }
1573

    
1574
                            }
1575
                            break;
1576

    
1577
                        case ControlType.ArcArrow:
1578
                            {
1579
                                if (currentControl != null)
1580
                                {
1581
                                    var control = currentControl as ArcControl;
1582
                                    control.isTransOn = true;
1583
                                    control.ControlType = controlType;
1584

    
1585
                                    if (control != null)
1586
                                    {
1587
                                        if (move.mousemode == MouseMode.Drawing)
1588
                                        {
1589
                                            //move.control_Move(ControlList, true, moveX, moveY);
1590
                                        }
1591
                                        else
1592
                                        {
1593
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1594
                                            control.MidPoint = new Point(0, 0);
1595
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1596
                                        }
1597

    
1598
                                        control.PointSet = new List<Point>
1599
                                            {
1600
                                                control.StartPoint,
1601
                                                control.MidPoint,
1602
                                                control.EndPoint,
1603
                                            };
1604
                                    }
1605
                                    //강인구 추가
1606
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1607
                                }
1608
                            }
1609
                            break;
1610

    
1611
                        case ControlType.ArrowMultiLine:
1612
                            {
1613
                                if (currentControl != null)
1614
                                {
1615
                                    var control = currentControl as ArrowControl_Multi;
1616

    
1617
                                    if (control != null)
1618
                                    {
1619
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1620
                                        Point tempPoint = control.EndPoint;
1621
                                        if (control.MiddlePoint == new Point(0, 0))
1622
                                        {
1623
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1624
                                            {
1625
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1626
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1627
                                                control.EndPoint = tempPoint;
1628
                                            }
1629
                                            else
1630
                                            {
1631
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1632
                                            }
1633
                                        }
1634
                                        else
1635
                                        {
1636
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1637
                                            {
1638
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1639
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1640
                                                control.EndPoint = tempPoint;
1641
                                            }
1642
                                            else
1643
                                            {
1644
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1645
                                            }
1646

    
1647
                                        }
1648

    
1649
                                        control.PointSet = new List<Point>
1650
                                            {
1651
                                                control.StartPoint,
1652
                                                control.MiddlePoint,
1653
                                                control.EndPoint,
1654
                                            };
1655

    
1656
                                    }
1657
                                    //강인구 추가
1658
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1659
                                }
1660

    
1661
                            }
1662
                            break;
1663

    
1664
                        case ControlType.Circle:
1665
                            {
1666
                                var control = currentControl as CircleControl;
1667

    
1668
                                if (control != null)
1669
                                {
1670
                                    if (move.mousemode == MouseMode.Drawing)
1671
                                    {
1672
                                        //move.control_Move(ControlList, true, moveX, moveY);
1673
                                    }
1674
                                    else
1675
                                    {
1676
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1677
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1678
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1679
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1680

    
1681
                                        if (ViewerDataModel.Instance.IsPressShift)
1682
                                        {
1683
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1684
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1685
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1686
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1687
                                        }
1688

    
1689
                                        control.PointSet = new List<Point>
1690
                                        {
1691
                                            control.StartPoint,
1692
                                            control.LeftBottomPoint,
1693
                                            control.EndPoint,
1694
                                            control.TopRightPoint,
1695
                                        };
1696
                                    }
1697
                                    //강인구 추가
1698
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1699
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1700

    
1701
                                }
1702
                            }
1703
                            break;
1704

    
1705
                        case ControlType.PolygonCloud:
1706
                            {
1707
                                var control = currentControl as CloudControl;
1708

    
1709
                                if (control != null)
1710
                                {
1711
                                    control.isTransOn = true;
1712
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1713

    
1714
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1715

    
1716
                                    control.SetCloud();
1717
                                    //강인구 추가
1718
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1719
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1720
                                }
1721
                            }
1722
                            break;
1723

    
1724
                        case ControlType.Triangle:
1725
                            {
1726
                                var control = currentControl as TriControl;
1727

    
1728
                                if (control != null)
1729
                                {
1730
                                    if (move.mousemode == MouseMode.Drawing)
1731
                                    {
1732
                                        //move.control_Move(ControlList, true, moveX, moveY);
1733
                                    }
1734
                                    else
1735
                                    {
1736
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1737
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1738

    
1739
                                        if (ViewerDataModel.Instance.checkAxis)
1740
                                        {
1741
                                            Point tempPoint = control.EndPoint;
1742
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1743
                                            control.EndPoint = tempPoint;
1744
                                        }
1745

    
1746

    
1747
                                        if (ViewerDataModel.Instance.IsPressShift)
1748
                                        {
1749
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1750
                                            if (2 == Points.Count())
1751
                                            {
1752
                                                control.MidPoint = Points[0];
1753
                                                control.EndPoint = Points[1];
1754
                                            }
1755
                                        }
1756

    
1757
                                        control.PointSet = new List<Point>
1758
                                            {
1759
                                                control.StartPoint,
1760
                                                control.MidPoint,
1761
                                                control.EndPoint,
1762
                                            };
1763
                                    }
1764
                                    //강인구 추가
1765
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1766
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1767
                                }
1768
                            }
1769
                            break;
1770

    
1771
                        case ControlType.ImgControl:
1772
                            {
1773
                                var control = currentControl as ImgControl;
1774

    
1775
                                if (control != null)
1776
                                {
1777
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1778
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1779
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1780
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1781

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

    
1793
                        case ControlType.Date:
1794
                            {
1795
                                var control = currentControl as DateControl;
1796

    
1797
                                if (control != null)
1798
                                {
1799
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1800
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1801
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1802
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1803
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1804

    
1805
                                    control.PointSet = new List<Point>
1806
                                        {
1807
                                            control.StartPoint,
1808
                                            control.LeftBottomPoint,
1809
                                            control.EndPoint,
1810
                                            control.TopRightPoint,
1811
                                        };
1812
                                }
1813
                            }
1814
                            break;
1815

    
1816
                        case ControlType.ArrowTextControl:
1817
                            {
1818
                                var control = currentControl as ArrowTextControl;
1819

    
1820
                                if (control != null)
1821
                                {
1822
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1823
                                    Point tempPoint = control.EndPoint;
1824

    
1825
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1826

    
1827
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1828
                                    {
1829
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1830
                                        control.EndPoint = tempPoint;
1831
                                    }
1832
                                    else
1833
                                    {
1834
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1835
                                    }
1836
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1837

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

    
1848
                        case ControlType.ArrowTransTextControl:
1849
                            {
1850
                                var control = currentControl as ArrowTextControl;
1851

    
1852
                                if (control != null)
1853
                                {
1854
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1855
                                    Point tempPoint = control.EndPoint;
1856
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1857

    
1858
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1859
                                    {
1860
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1861
                                        control.EndPoint = tempPoint;
1862
                                    }
1863
                                    else
1864
                                    {
1865
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1866
                                    }
1867
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1868
                                    control.isFixed = true;
1869

    
1870
                                    control.PointSet = new List<Point>
1871
                                            {
1872
                                                control.StartPoint,
1873
                                                control.MidPoint,
1874
                                                control.EndPoint,
1875
                                            };
1876
                                }
1877
                            }
1878
                            break;
1879

    
1880
                        case ControlType.ArrowTextBorderControl:
1881
                            {
1882
                                var control = currentControl as ArrowTextControl;
1883

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

    
1906
                            }
1907
                            break;
1908
                        case ControlType.ArrowTransTextBorderControl:
1909
                            {
1910
                                var control = currentControl as ArrowTextControl;
1911

    
1912
                                if (control != null)
1913
                                {
1914
                                    control.isFixed = true;
1915
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1916
                                    Point tempPoint = control.EndPoint;
1917
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1918
                                    {
1919
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1920
                                        control.EndPoint = tempPoint;
1921
                                    }
1922
                                    else
1923
                                    {
1924
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1925
                                    }
1926

    
1927
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1928
                                    control.PointSet = new List<Point>
1929
                                            {
1930
                                                control.StartPoint,
1931
                                                control.MidPoint,
1932
                                                control.EndPoint,
1933
                                            };
1934
                                }
1935

    
1936
                            }
1937
                            break;
1938
                        case ControlType.ArrowTextCloudControl:
1939
                            {
1940
                                var control = currentControl as ArrowTextControl;
1941

    
1942
                                if (control != null)
1943
                                {
1944
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1945
                                    Point tempPoint = control.EndPoint;
1946
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1947
                                    {
1948
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1949
                                        control.EndPoint = tempPoint;
1950
                                    }
1951
                                    else
1952
                                    {
1953
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1954
                                    }
1955
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1956
                                    control.PointSet = new List<Point>
1957
                                            {
1958
                                                control.StartPoint,
1959
                                                control.MidPoint,
1960
                                                control.EndPoint,
1961
                                            };
1962
                                }
1963

    
1964
                            }
1965
                            break;
1966
                        case ControlType.ArrowTransTextCloudControl:
1967
                            {
1968
                                var control = currentControl as ArrowTextControl;
1969

    
1970
                                if (control != null)
1971
                                {
1972
                                    control.isFixed = true;
1973
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1974
                                    Point tempPoint = control.EndPoint;
1975
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1976
                                    {
1977
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1978
                                        control.EndPoint = tempPoint;
1979
                                    }
1980
                                    else
1981
                                    {
1982
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1983
                                    }
1984
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1985
                                    control.PointSet = new List<Point>
1986
                                            {
1987
                                                control.StartPoint,
1988
                                                control.MidPoint,
1989
                                                control.EndPoint,
1990
                                            };
1991
                                }
1992

    
1993
                            }
1994
                            break;
1995
                        case ControlType.PolygonControl:
1996
                            {
1997

    
1998
                                var control = currentControl as PolygonControl;
1999

    
2000
                                if (control != null)
2001
                                {
2002
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2003
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2004
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2005
                                    control.SetPolyPath();
2006
                                    //강인구 추가
2007
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2008
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2009
                                }
2010
                            }
2011
                            break;
2012
                        //강인구 추가
2013
                        case ControlType.Sign:
2014
                            {
2015
                                var control = currentControl as SignControl;
2016

    
2017
                                if (control != null)
2018
                                {
2019
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2020
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2021
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2022
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2023

    
2024
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2025
                                    {
2026
                                        GetUserSign getUser = new GetUserSign();
2027
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2028
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2029
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2030
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2031
                                        stream.Position = 0;
2032
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2033
                                        BitmapImage returnImage = new BitmapImage();
2034
                                        returnImage.BeginInit();
2035
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2036
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2037
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2038
                                        returnImage.StreamSource = ms;
2039
                                        returnImage.EndInit();
2040
                                        stream.Close();
2041

    
2042
                                        control.SignImage = returnImage;
2043
                                    }
2044
                                    control.PointSet = new List<Point>
2045
                                        {
2046
                                            control.StartPoint,
2047
                                            control.LeftBottomPoint,
2048
                                            control.EndPoint,
2049
                                            control.TopRightPoint,
2050
                                        };
2051
                                }
2052
                            }
2053
                            break;
2054
                        //TODO: 강인구 추가
2055
                        case ControlType.Symbol:
2056
                            {
2057
                                var control = currentControl as SymControl;
2058

    
2059
                                if (control != null)
2060
                                {
2061
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2062
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2063
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2064
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2065
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2066
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2067

    
2068
                                    if (control.StartPoint != control.EndPoint)
2069
                                    {
2070
                                        if (control.PathData == null)
2071
                                        {
2072
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2073
                                            {
2074
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2075
                                            }
2076
                                        }
2077
                                    }
2078

    
2079
                                    control.PointSet = new List<Point>
2080
                                        {
2081
                                            control.StartPoint,
2082
                                            control.LeftBottomPoint,
2083
                                            control.EndPoint,
2084
                                            control.TopRightPoint,
2085
                                        };
2086
                                }
2087
                            }
2088
                            break;
2089
                        ///TODO: 
2090
                        case ControlType.Stamp:
2091
                            {
2092
                                var control = currentControl as SymControlN;
2093

    
2094
                                if (control != null)
2095
                                {
2096

    
2097
                                    if (control.StartPoint == control.EndPoint)
2098
                                    {
2099
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2100

    
2101
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2102
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2103

    
2104

    
2105
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2106

    
2107
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2108
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2109
                                        writer.Write(xamlData);
2110
                                        writer.Flush();
2111
                                        stream.Position = 0;
2112

    
2113
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2114
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2115
                                        UIElement ob = obj as UIElement;
2116

    
2117
                                        //control.ApplyTemplate();
2118

    
2119
                                        control.SetViewBox();
2120
                                        control.PathXathData = appovalData;
2121
                                        control.Base_ViewBox.Child = ob;
2122
                                    }
2123

    
2124
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2125
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2126
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2127
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2128
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2129

    
2130

    
2131
                                    control.PointSet = new List<Point>
2132
                                    {
2133
                                        control.StartPoint,
2134
                                        control.LeftBottomPoint,
2135
                                        control.EndPoint,
2136
                                        control.TopRightPoint,
2137
                                    };
2138
                                }
2139
                            }
2140
                            break;
2141
                        case ControlType.Mark:
2142
                            {
2143
                                var control = currentControl as RectangleControl;
2144

    
2145
                                if (control != null)
2146
                                {
2147
                                    if (move.mousemode == MouseMode.Drawing)
2148
                                    {
2149
                                        //move.control_Move(ControlList, true, moveX, moveY);
2150
                                    }
2151
                                    else
2152
                                    {
2153
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2154
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2155
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2156
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2157

    
2158

    
2159
                                        control.PointSet = new List<Point>
2160
                                    {
2161
                                        control.StartPoint,
2162
                                        control.LeftBottomPoint,
2163
                                        control.EndPoint,
2164
                                        control.TopRightPoint,
2165
                                    };
2166
                                    }
2167

    
2168
                                    //강인구 추가
2169
                                    control.Paint = PaintSet.Fill;
2170
                                }
2171
                            }
2172
                            break;
2173
                        case ControlType.PenControl:
2174
                            {
2175
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2176
                                //inkBoard.Strokes.Add(stroke);
2177
                            }
2178
                            break;
2179
                        default:
2180
                            break;
2181
                    }
2182
                }
2183
            }
2184
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2185
            {
2186
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2187

    
2188
                if (isDraggingSelectionRect)
2189
                {
2190
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2191

    
2192
                    e.Handled = true;
2193
                }
2194
                else if (isLeftMouseButtonDownOnWindow)
2195
                {
2196
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2197
                    double dragDistance = Math.Abs(dragDelta.Length);
2198

    
2199
                    if (dragDistance > DragThreshold)
2200
                    {
2201
                        isDraggingSelectionRect = true;
2202

    
2203
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2204
                    }
2205

    
2206
                    e.Handled = true;
2207
                }
2208

    
2209

    
2210
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2211
                {
2212
                    //SelectionPath = new Path();
2213
                    //PathFigure pathFigure = new PathFigure();
2214
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2215
                    //SelectionPath.Opacity = 0.5;
2216
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2217
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2218
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2219
                }
2220
                else
2221
                {
2222
                    //List<Stroke> removingStroke = new List<Stroke>();
2223
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2224
                    //StrokeCollection stC = new StrokeCollection();
2225
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2226
                    //{
2227
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2228
                    //    p1.Intersect(p2);
2229
                    //    if (p1.IsEmpty)
2230
                    //    {
2231

    
2232

    
2233
                    //        p1 = SelectionPath.Data.Bounds;
2234
                    //        bool intersectCheck = false;
2235
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2236
                    //        {
2237
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2238
                    //            p1.Intersect(p3);
2239
                    //            if (!p1.IsEmpty)
2240
                    //            {
2241
                    //                intersectCheck = true;
2242
                    //            }
2243
                    //        }
2244
                    //        if (intersectCheck)
2245
                    //        {
2246
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2247
                    //        }
2248

    
2249
                    //    }
2250
                    //    else
2251
                    //    {
2252
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2253
                    //    }
2254
                    //}
2255

    
2256
                    e.Handled = true;
2257
                }
2258
            }
2259
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2260
            {
2261
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2262
                if (control != null)
2263
                {
2264
                    this.cursor = Cursors.Hand;
2265
                    SetCursor();
2266
                }
2267
                else
2268
                {
2269
                    this.cursor = Cursors.Arrow;
2270
                    SetCursor();
2271
                }
2272
            }
2273
            else
2274
            {
2275
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2276

    
2277
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2278
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2279

    
2280
                //if (hitList.Count > 0)
2281
                //{
2282

    
2283
                //}
2284

    
2285
                #region 조건 설정 : firstCondition
2286
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2287
                //pnts = generalTransform.Transform(pnts);
2288
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2289
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2290
                //                               this.DeepLayer._BaseLayer).ToObservable()
2291
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2292
                //                      select kkk).FirstOrDefault();
2293

    
2294
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2295
                //if (canvas !=null)
2296
                //{
2297
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2298
                //    {
2299
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2300
                //        if (uiElement!=null)
2301
                //        {
2302
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2303
                //        }
2304
                //    }
2305
                //}
2306

    
2307
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2308
                //hitResultsList.Clear();
2309

    
2310
                #endregion
2311
            }
2312
        }
2313

    
2314
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2315
        {
2316
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2317
            {
2318
                SetCursor();
2319
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2320
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2321

    
2322
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2323

    
2324
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2325
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2326

    
2327
                if (Sync.IsChecked)
2328
                {
2329
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2330
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2331
                }
2332
            }
2333
        }
2334

    
2335
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2336

    
2337
        private EllipseGeometry hitArea = new EllipseGeometry();
2338

    
2339
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2340
        {
2341
            IsDrawing = false;
2342

    
2343
            if (mouseHandlingMode != MouseHandlingMode.None)
2344
            {
2345
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2346
                {
2347
                    this.cursor = Cursors.Arrow;
2348

    
2349
                    SetCursor();
2350

    
2351
                    switch (controlType)
2352
                    {
2353
                        case ControlType.None:
2354
                            break;
2355
                        case ControlType.Rectangle:
2356
                            {
2357

    
2358
                            }
2359
                            break;
2360
                        case ControlType.PenControl:
2361
                            {
2362

    
2363
                            }
2364
                            break;
2365
                        default:
2366
                            break;
2367
                    }
2368
                }
2369
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2370
                {
2371
                    if (isLeftMouseButtonDownOnWindow)
2372
                    {
2373
                        bool wasDragSelectionApplied = false;
2374

    
2375
                        if (isDraggingSelectionRect)
2376
                        {
2377
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2378
                            {
2379
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2380
                                mouseHandlingMode = MouseHandlingMode.None;
2381
                                Set_Capture();
2382

    
2383
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2384
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2385
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2386
                            }
2387
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2388
                            {
2389
                                ApplyDragSelectionRect();
2390
                            }
2391
                            else
2392
                            {
2393
                                double x = Canvas.GetLeft(dragZoomBorder);
2394
                                double y = Canvas.GetTop(dragZoomBorder);
2395
                                double width = dragZoomBorder.Width;
2396
                                double height = dragZoomBorder.Height;
2397
                                Rect dragRect = new Rect(x, y, width, height);
2398

    
2399
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2400

    
2401
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2402
                            }
2403

    
2404
                            isDraggingSelectionRect = false;
2405
                            e.Handled = true;
2406
                            wasDragSelectionApplied = true;
2407
                        }
2408

    
2409
                        if (isLeftMouseButtonDownOnWindow)
2410
                        {
2411
                            isLeftMouseButtonDownOnWindow = false;
2412
                            this.ReleaseMouseCapture();
2413
                            e.Handled = true;
2414
                        }
2415

    
2416
                        if (!wasDragSelectionApplied)
2417
                        {
2418
                            init();
2419
                        }
2420
                    }
2421
                }
2422
                else if (mouseButtonDown == MouseButton.Right)
2423
                {
2424
                    this.cursor = Cursors.Arrow;
2425
                    SetCursor();
2426
                }
2427

    
2428
                zoomAndPanControl.ReleaseMouseCapture();
2429

    
2430

    
2431
                e.Handled = true;
2432
            }
2433
            else
2434
            {
2435
                this.cursor = Cursors.Arrow;
2436
                SetCursor();
2437
            }
2438
            mouseButtonDown = MouseButton.Left;
2439

    
2440
            //controlType = ControlType.SingleLine;
2441
        }
2442

    
2443
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2444
        {
2445
            mouseButtonDown = MouseButton.Left;
2446
        }
2447

    
2448
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2449
        {
2450
            mouseButtonDown = MouseButton.Left;
2451
            this.Cursor = Cursors.Arrow;
2452
        }
2453

    
2454
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2455
        {
2456

    
2457
        }
2458

    
2459
        private void ApplyDragSelectionRect()
2460
        {
2461
            multi_Undo_Data = new Multi_Undo_data();
2462

    
2463
            UndoData = new Undo_data()
2464
            {
2465
                IsUndo = false,
2466
                Event = Event_Type.Select,
2467
                EventTime = DateTime.Now,
2468
                Markup_List = new List<Multi_Undo_data>()
2469
            };
2470

    
2471
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2472

    
2473
            double x = Canvas.GetLeft(dragSelectionBorder);
2474
            double y = Canvas.GetTop(dragSelectionBorder);
2475
            double width = dragSelectionBorder.Width;
2476
            double height = dragSelectionBorder.Height;
2477
            Rect dragRect = new Rect(x, y, width, height);
2478
            Boolean Flag = false;
2479
            dragRect.Inflate(width / 10, height / 10);
2480
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2481
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2482

    
2483
            dragRect = new Rect(x, y, width, height);
2484
            dragRect.Inflate(width / 10, height / 10);
2485

    
2486
            foreach (var item in Items)
2487
            {
2488
                Flag = move.control_Select(item, dragRect);
2489

    
2490
                if (Flag)
2491
                {
2492
                    adornerSet.Add(item);
2493
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2494

    
2495
                    Control_Style(item);
2496
                    UndoData.Markup_List.Add(multi_Undo_Data);
2497
                    multi_Undo_Data = new Multi_Undo_data();
2498
                }
2499
            }
2500
            if (adornerSet.Count > 0)
2501
            {
2502
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2503
                {
2504
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2505
                });
2506
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2507

    
2508
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2509
                SelectLayer.Children.Add(final);
2510
            }
2511
        }
2512

    
2513
        private void InitDragSelectionRect(Point pt1, Point pt2)
2514
        {
2515
            //캡쳐 중
2516
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2517
            {
2518
                dragCaptureBorder.Visibility = Visibility.Visible;
2519
            }
2520
            //선택 중
2521
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2522
            {
2523

    
2524
                dragSelectionBorder.Visibility = Visibility.Visible;
2525
            }
2526
            else
2527
            {
2528
                dragZoomBorder.Visibility = Visibility.Visible;
2529
            }
2530
            UpdateDragSelectionRect(pt1, pt2);
2531
        }
2532

    
2533
        /// <summary>
2534
        /// Update the position and size of the rectangle used for drag selection.
2535
        /// </summary>
2536
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2537
        {
2538
            double x, y, width, height;
2539

    
2540
            //
2541
            // Determine x,y,width and height of the rect inverting the points if necessary.
2542
            // 
2543

    
2544
            if (pt2.X < pt1.X)
2545
            {
2546
                x = pt2.X;
2547
                width = pt1.X - pt2.X;
2548
            }
2549
            else
2550
            {
2551
                x = pt1.X;
2552
                width = pt2.X - pt1.X;
2553
            }
2554

    
2555
            if (pt2.Y < pt1.Y)
2556
            {
2557
                y = pt2.Y;
2558
                height = pt1.Y - pt2.Y;
2559
            }
2560
            else
2561
            {
2562
                y = pt1.Y;
2563
                height = pt2.Y - pt1.Y;
2564
            }
2565

    
2566
            //
2567
            // Update the coordinates of the rectangle used for drag selection.
2568
            //
2569
            //캡쳐 중
2570
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2571
            {
2572
                Canvas.SetLeft(dragCaptureBorder, x);
2573
                Canvas.SetTop(dragCaptureBorder, y);
2574
                dragCaptureBorder.Width = width;
2575
                dragCaptureBorder.Height = height;
2576
            }
2577
            //선택 중
2578
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2579
            {
2580
                Canvas.SetLeft(dragSelectionBorder, x);
2581
                Canvas.SetTop(dragSelectionBorder, y);
2582
                dragSelectionBorder.Width = width;
2583
                dragSelectionBorder.Height = height;
2584
            }
2585
            else
2586
            {
2587
                Canvas.SetLeft(dragZoomBorder, x);
2588
                Canvas.SetTop(dragZoomBorder, y);
2589
                dragZoomBorder.Width = width;
2590
                dragZoomBorder.Height = height;
2591
            }
2592

    
2593

    
2594
        }
2595

    
2596
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2597
        {
2598
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2599

    
2600
            bool result = false;
2601
            if (dragRect.Contains(controlRect))
2602
            {
2603
                result = true;
2604
                //잡은 객체들을 담은 리스트
2605
                try
2606
                {
2607
                    selected_item.Add(OverViewPathData, type.ToString());
2608
                }
2609
                catch (Exception)
2610
                {
2611

    
2612
                }
2613
            }
2614
            return result;
2615
        }
2616

    
2617
        private void drawingPannelRotate(double angle)
2618
        {
2619
            rotate.Angle = angle;
2620
            var rotationNum = Math.Abs((rotate.Angle / 90));
2621

    
2622
            if (angle == 90 || angle == 270)
2623
            {
2624
                double emptySize = zoomAndPanCanvas.Width;
2625
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2626
                zoomAndPanCanvas.Height = emptySize;
2627
            }
2628
            if (angle == 0)
2629
            {
2630
                translate.X = 0;
2631
                translate.Y = 0;
2632
            }
2633
            else if (angle == 90)
2634
            {
2635
                translate.X = zoomAndPanCanvas.Width;
2636
                translate.Y = 0;
2637
            }
2638
            else if (angle == 180)
2639
            {
2640
                translate.X = zoomAndPanCanvas.Width;
2641
                translate.Y = zoomAndPanCanvas.Height;
2642
            }
2643
            else
2644
            {
2645
                translate.X = 0;
2646
                translate.Y = zoomAndPanCanvas.Height;
2647
            }
2648

    
2649
            zoomAndPanControl.RotationAngle = rotate.Angle;
2650

    
2651

    
2652
            if (!testPanel2.IsHidden)
2653
            {
2654
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2655
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2656
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2657
            }
2658

    
2659
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2660
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2661
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2662
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2663
            ViewerDataModel.Instance.Angle = rotate.Angle;
2664

    
2665

    
2666
        }
2667

    
2668
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2669
        {
2670
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2671
            if (set_option != null)
2672
            {
2673
                set_option.Value = double.Parse(set_option.ContentText);
2674
            }
2675

    
2676
            InkControl_Convert();
2677

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

    
2681
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2682
            {
2683
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2684
            }
2685

    
2686
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2687
            {
2688
                if (arrow_text as ArrowTextControl != null)
2689
                {
2690
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2691
                }
2692
            }
2693

    
2694
            mouseButtonDown = e.ChangedButton;
2695
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
2696

    
2697
            //if (currentControl != null)
2698
            {
2699
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2700
                if (text_item_ != null)
2701
                {
2702
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2703
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2704
                    (text_item_ as TextControl).IsEditing = false;
2705
                    (text_item_ as TextControl).EnableEditing = false;
2706
                    currentControl = null;
2707
                }
2708

    
2709
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2710
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2711
                {
2712
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2713
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2714
                    currentControl = null;
2715
                }
2716
            }
2717

    
2718
            double Ang = 0;
2719
            if (rotate.Angle != 0)
2720
            {
2721
                Ang = 360 - rotate.Angle;
2722
            }
2723
            move = new Move();
2724

    
2725
            if (e.OriginalSource is System.Windows.Controls.Image)
2726
            {
2727
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2728
            }
2729

    
2730
            if (mouseButtonDown == MouseButton.Left)
2731
            {
2732
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2733
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2734

    
2735
                this.cursor = Cursors.Arrow;
2736
                SetCursor();
2737

    
2738
                if (!ViewerDataModel.Instance.IsPressCtrl)
2739
                {
2740
                    ReleaseAdorner();
2741
                }
2742
            }
2743
            if (mouseButtonDown == MouseButton.Middle)
2744
            {
2745
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2746
                cursor = Cursors.SizeAll;
2747
                SetCursor();
2748
            }
2749
            if (mouseButtonDown == MouseButton.Right)
2750
            {
2751
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2752
                cursor = Cursors.SizeAll;
2753
                SetCursor();
2754
            }
2755
            else if (mouseButtonDown == MouseButton.XButton1)
2756
            {
2757
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2758
                {
2759
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2760
                }
2761

    
2762
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2763

    
2764
            }
2765
            else if (mouseButtonDown == MouseButton.XButton2)
2766
            {
2767
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2768
                {
2769
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2770
                }
2771
            }
2772

    
2773
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2774
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2775
            {
2776
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2777
                {
2778
                    if (SelectLayer.Children.Count == 0)
2779
                    {
2780
                        isLeftMouseButtonDownOnWindow = true;
2781
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2782
                    }
2783

    
2784
                    if (controlType == ControlType.None)
2785
                    {
2786
                        isLeftMouseButtonDownOnWindow = true;
2787
                    }
2788
                }
2789

    
2790
                //캡쳐 모드 설정
2791
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2792
                {
2793
                    dragCaptureBorder.Visibility = Visibility.Visible;
2794
                    isLeftMouseButtonDownOnWindow = true;
2795
                }
2796

    
2797
                //줌 모드 설정
2798
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2799
                {
2800
                    //dragSelectionBorder.Visibility = Visibility.Visible;
2801
                    isLeftMouseButtonDownOnWindow = true;
2802
                }
2803

    
2804

    
2805
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2806
                if (control != null)
2807
                {
2808
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2809
                    AdornerFinal final;
2810
                    List<Point> p_set = new List<Point>();
2811
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2812
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2813
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2814
                    multi_Undo_Data = new Multi_Undo_data();
2815

    
2816
                    //강인구 Undo/Redo 보류
2817
                    UndoData = new Undo_data()
2818
                    {
2819
                        IsUndo = false,
2820
                        Event = Event_Type.Select,
2821
                        EventTime = DateTime.Now,
2822
                        Markup_List = new List<Multi_Undo_data>()
2823
                    };
2824

    
2825
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2826
                    {
2827
                        ReleaseAdorner();
2828
                        final = new AdornerFinal(control);
2829
                        //단일 컨트롤 언두 저장
2830

    
2831
                        Control_Style(control);
2832
                        UndoData.Markup_List.Add(multi_Undo_Data);
2833

    
2834
                        if ((control as IPath) != null)
2835
                        {
2836
                            if ((control as IPath).LineSize != 0)
2837
                            {
2838
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2839
                            }
2840
                        }
2841
                        if ((control as IShapeControl) != null)
2842
                        {
2843
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2844
                            {
2845
                                ViewerDataModel.Instance.checkHatchShape = true;
2846
                            }
2847
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2848
                            {
2849
                                ViewerDataModel.Instance.checkFillShape = true;
2850
                            }
2851
                            else
2852
                            {
2853
                                ViewerDataModel.Instance.checkHatchShape = false;
2854
                                ViewerDataModel.Instance.checkFillShape = false;
2855
                            }
2856
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2857
                        }
2858

    
2859
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2860

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

    
2872
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2873
                            {
2874
                                ViewerDataModel.Instance.checkTextStyle = true;
2875
                            }
2876
                            else
2877
                            {
2878
                                ViewerDataModel.Instance.checkTextStyle = false;
2879
                            }
2880
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2881
                            {
2882
                                ViewerDataModel.Instance.checkTextWeight = true;
2883
                            }
2884
                            else
2885
                            {
2886
                                ViewerDataModel.Instance.checkTextWeight = false;
2887
                            }
2888
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2889
                            {
2890
                                ViewerDataModel.Instance.checkUnderLine = true;
2891
                            }
2892
                            else
2893
                            {
2894
                                ViewerDataModel.Instance.checkUnderLine = false;
2895
                            }
2896
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2897
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2898

    
2899
                        }
2900
                        else if ((control as ArrowTextControl) != null)
2901
                        {
2902
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2903
                            {
2904
                                ViewerDataModel.Instance.checkTextStyle = true;
2905
                            }
2906
                            else
2907
                            {
2908
                                ViewerDataModel.Instance.checkTextStyle = false;
2909
                            }
2910

    
2911
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2912
                            {
2913
                                ViewerDataModel.Instance.checkTextStyle = true;
2914
                            }
2915
                            else
2916
                            {
2917
                                ViewerDataModel.Instance.checkTextStyle = false;
2918
                            }
2919
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2920
                            {
2921
                                ViewerDataModel.Instance.checkTextWeight = true;
2922
                            }
2923
                            else
2924
                            {
2925
                                ViewerDataModel.Instance.checkTextWeight = false;
2926
                            }
2927
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2928
                            {
2929
                                ViewerDataModel.Instance.checkUnderLine = true;
2930
                            }
2931
                            else
2932
                            {
2933
                                ViewerDataModel.Instance.checkUnderLine = false;
2934
                            }
2935
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2936
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2937
                        }
2938
                        else if ((control as RectCloudControl) != null)
2939
                        {
2940
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2941
                        }
2942
                        else if ((control as CloudControl) != null)
2943
                        {
2944
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2945
                        }
2946

    
2947
                    }
2948
                    else
2949
                    {
2950
                        comment = AddAdorner();
2951
                        comment.Add(control);
2952

    
2953
                        Control_Style(control);
2954
                        UndoData.Markup_List.Add(multi_Undo_Data);
2955

    
2956
                        final = new AdornerFinal(comment);
2957
                        //다중 컨트롤 언두 저장
2958
                    }
2959

    
2960
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2961
                    {
2962
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2963
                    });
2964

    
2965
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2966

    
2967
                    SelectLayer.Children.Add(final);
2968

    
2969
                    //Control_Init(control);
2970

    
2971

    
2972

    
2973

    
2974

    
2975
                    //강인구 폰트 변경 보류
2976

    
2977
                    //if ((currentControl as TextControl) != null)
2978
                    //{
2979
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2980
                    //    {
2981
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2982
                    //    }
2983
                    //    else
2984
                    //    {
2985
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2986
                    //    }
2987

    
2988
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2989
                    //    {
2990

    
2991
                    //    }
2992
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
2993
                    //    {
2994

    
2995
                    //    }
2996
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2997
                    //    {
2998

    
2999
                    //    }
3000
                    //}
3001
                    //else if ((currentControl as ArrowTextControl) != null)
3002
                    //{
3003
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
3004
                    //    {
3005
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
3006
                    //    }
3007
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
3008
                    //    {
3009
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
3010
                    //    }
3011
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
3012
                    //    {
3013
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
3014
                    //    }
3015
                    //}
3016

    
3017
                    //mouseHandlingMode = MouseHandlingMode.Adorner;
3018
                }
3019
            }
3020

    
3021
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3022
            {
3023
                init();
3024
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3025
                if (cursor != Cursors.SizeAll)
3026
                {
3027
                    cursor = Cursors.Cross;
3028
                    SetCursor();
3029
                }
3030
                bool init_user = false;
3031
                foreach (var user in gridViewMarkup.Items)
3032
                {
3033
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3034
                    {
3035
                        init_user = true;
3036
                    }
3037
                }
3038
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3039
                {
3040
                    RadWindow.Alert(new DialogParameters
3041
                    {
3042
                        Theme = new VisualStudio2013Theme(),
3043
                        Header = "안내",
3044
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3045
                    });
3046
                    return;
3047
                }
3048
                else
3049
                {
3050
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3051
                    if (item != null)
3052
                    {
3053
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3054
                    }
3055
                }
3056

    
3057
                multi_Undo_Data = new Multi_Undo_data();
3058
                //강인구 Undo/Redo 보류
3059
                UndoData = new Undo_data()
3060
                {
3061
                    IsUndo = false,
3062
                    Event = Event_Type.Create,
3063
                    EventTime = DateTime.Now,
3064
                    Markup_List = new List<Multi_Undo_data>()
3065
                };
3066

    
3067
                switch (controlType)
3068
                {
3069
                    case ControlType.Rectangle:
3070
                        {
3071
                            if (mouseButtonDown == MouseButton.Left)
3072
                            {
3073
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3074
                                {
3075
                                    if (currentControl is RectangleControl)
3076
                                    {
3077
                                        CreateControl();
3078

    
3079
                                        (currentControl as RectangleControl).ApplyOverViewData();
3080
                                        currentControl = null;
3081
                                        this.cursor = Cursors.Arrow;
3082
                                    }
3083
                                    else
3084
                                    {
3085
                                        currentControl = new RectangleControl
3086
                                        {
3087
                                            Background = new SolidColorBrush(Colors.Black),
3088
                                            ControlType = ControlType.Rectangle
3089
                                        };
3090

    
3091
                                        currentControl.CommentID = Save.shortGuid();
3092
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3093
                                        currentControl.IsNew = true;
3094
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3095

    
3096
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3097
                                    }
3098
                                }
3099
                            }
3100
                        }
3101
                        break;
3102
                    case ControlType.RectCloud:
3103
                        {
3104
                            if (mouseButtonDown == MouseButton.Left)
3105
                            {
3106
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3107
                                {
3108
                                    if (currentControl is RectCloudControl)
3109
                                    {
3110
                                        CreateControl();
3111

    
3112
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3113
                                        currentControl = null;
3114
                                        this.cursor = Cursors.Arrow;
3115
                                    }
3116
                                    else
3117
                                    {
3118
                                        currentControl = new RectCloudControl
3119
                                        {
3120
                                            Background = new SolidColorBrush(Colors.Black)
3121
                                        };
3122

    
3123
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3124
                                        currentControl.CommentID = Save.shortGuid();
3125
                                        currentControl.IsNew = true;
3126
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3127
                                    }
3128
                                }
3129
                            }
3130
                        }
3131
                        break;
3132
                    case ControlType.Circle:
3133
                        {
3134
                            if (mouseButtonDown == MouseButton.Left)
3135
                            {
3136
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3137
                                {
3138
                                    if (currentControl is CircleControl)
3139
                                    {
3140
                                        CreateControl();
3141

    
3142
                                        (currentControl as CircleControl).ApplyOverViewData();
3143
                                        currentControl = null;
3144
                                    }
3145
                                    else
3146
                                    {
3147
                                        currentControl = new CircleControl
3148
                                        {
3149
                                            Background = new SolidColorBrush(Colors.Black)
3150
                                        };
3151

    
3152
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3153
                                        currentControl.CommentID = Save.shortGuid();
3154
                                        currentControl.IsNew = true;
3155
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3156
                                    }
3157
                                }
3158
                            }
3159
                        }
3160
                        break;
3161
                    case ControlType.Triangle:
3162
                        {
3163
                            if (mouseButtonDown == MouseButton.Left)
3164
                            {
3165
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3166
                                {
3167
                                    if (currentControl is TriControl)
3168
                                    {
3169
                                        var content = currentControl as TriControl;
3170
                                        if (content.MidPoint == new Point(0, 0))
3171
                                        {
3172
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3173
                                        }
3174
                                        else
3175
                                        {
3176
                                            CreateControl();
3177

    
3178
                                            (currentControl as TriControl).ApplyOverViewData();
3179
                                            currentControl = null;
3180
                                        }
3181
                                    }
3182
                                    else
3183
                                    {
3184
                                        currentControl = new TriControl
3185
                                        {
3186
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3187
                                            Background = new SolidColorBrush(Colors.Black),
3188
                                        };
3189

    
3190
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3191
                                        currentControl.CommentID = Save.shortGuid();
3192
                                        currentControl.IsNew = true;
3193
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3194
                                    }
3195
                                }
3196
                            }
3197
                        }
3198
                        break;
3199
                    case ControlType.SingleLine:
3200
                        {
3201
                            if (mouseButtonDown == MouseButton.Left)
3202
                            {
3203
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3204
                                {
3205
                                    if (currentControl is LineControl)
3206
                                    {
3207
                                        CreateControl();
3208

    
3209
                                        (currentControl as LineControl).ApplyOverViewData();
3210
                                        currentControl = null;
3211
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3212
                                    }
3213
                                    else
3214
                                    {
3215
                                        currentControl = new LineControl
3216
                                        {
3217
                                            Background = new SolidColorBrush(Colors.Black)
3218
                                        };
3219

    
3220
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3221
                                        currentControl.CommentID = Save.shortGuid();
3222
                                        currentControl.IsNew = true;
3223
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3224
                                        this.MainAngle.Visibility = Visibility.Visible;
3225
                                    }
3226
                                }
3227
                            }
3228
                        }
3229
                        break;
3230
                    case ControlType.CancelLine:
3231
                        {
3232
                            if (mouseButtonDown == MouseButton.Left)
3233
                            {
3234
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3235
                                {
3236
                                    if (currentControl is LineControl)
3237
                                    {
3238
                                        CreateControl();
3239

    
3240
                                        (currentControl as LineControl).ApplyOverViewData();
3241
                                        currentControl = null;
3242
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3243
                                    }
3244
                                    else
3245
                                    {
3246
                                        currentControl = new LineControl
3247
                                        {
3248
                                            Background = new SolidColorBrush(Colors.Black)
3249
                                        };
3250

    
3251
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3252
                                        currentControl.CommentID = Save.shortGuid();
3253
                                        currentControl.IsNew = true;
3254
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3255
                                        this.MainAngle.Visibility = Visibility.Visible;
3256
                                    }
3257
                                }
3258
                            }
3259
                        }
3260
                        break;
3261
                    case ControlType.ArrowLine:
3262
                        {
3263
                            if (mouseButtonDown == MouseButton.Left)
3264
                            {
3265
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3266
                                {
3267
                                    if (currentControl is LineControl)
3268
                                    {
3269
                                        CreateControl();
3270

    
3271
                                        (currentControl as LineControl).ApplyOverViewData();
3272
                                        currentControl = null;
3273
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3274
                                    }
3275
                                    else
3276
                                    {
3277
                                        currentControl = new LineControl
3278
                                        {
3279
                                            Background = new SolidColorBrush(Colors.Black)
3280
                                        };
3281

    
3282
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3283
                                        currentControl.CommentID = Save.shortGuid();
3284
                                        currentControl.IsNew = true;
3285
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3286
                                        this.MainAngle.Visibility = Visibility.Visible;
3287
                                    }
3288
                                }
3289
                            }
3290
                        }
3291
                        break;
3292
                    case ControlType.TwinLine:
3293
                        {
3294
                            if (mouseButtonDown == MouseButton.Left)
3295
                            {
3296
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3297
                                {
3298
                                    if (currentControl is LineControl)
3299
                                    {
3300
                                        CreateControl();
3301

    
3302
                                        (currentControl as LineControl).ApplyOverViewData();
3303
                                        currentControl = null;
3304
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3305
                                    }
3306
                                    else
3307
                                    {
3308
                                        currentControl = new LineControl
3309
                                        {
3310
                                            Background = new SolidColorBrush(Colors.Black)
3311
                                        };
3312
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3313
                                        currentControl.CommentID = Save.shortGuid();
3314
                                        currentControl.IsNew = true;
3315
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3316
                                        this.MainAngle.Visibility = Visibility.Visible;
3317
                                    }
3318
                                }
3319
                            }
3320
                        }
3321
                        break;
3322
                    case ControlType.DimLine:
3323
                        {
3324
                            if (mouseButtonDown == MouseButton.Left)
3325
                            {
3326
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3327
                                {
3328
                                    if (currentControl is LineControl)
3329
                                    {
3330
                                        CreateControl();
3331

    
3332
                                        (currentControl as LineControl).ApplyOverViewData();
3333
                                        currentControl = null;
3334
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3335
                                    }
3336
                                    else
3337
                                    {
3338
                                        currentControl = new LineControl
3339
                                        {
3340
                                            Background = new SolidColorBrush(Colors.Black)
3341
                                        };
3342
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3343
                                        currentControl.CommentID = Save.shortGuid();
3344
                                        currentControl.IsNew = true;
3345
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3346
                                        this.MainAngle.Visibility = Visibility.Visible;
3347
                                    }
3348
                                }
3349
                            }
3350
                        }
3351
                        break;
3352
                    case ControlType.ChainLine:
3353
                        {
3354
                            if (currentControl is PolygonControl)
3355
                            {
3356
                                var control = currentControl as PolygonControl;
3357

    
3358
                                if (mouseButtonDown == MouseButton.Right)
3359
                                {
3360
                                    CreateControl();
3361

    
3362
                                    (currentControl as PolygonControl).ApplyOverViewData();
3363
                                    currentControl = null;
3364
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3365
                                    return;
3366
                                }
3367

    
3368
                                if (!control.IsCompleted)
3369
                                {
3370
                                    control.PointSet.Add(control.EndPoint);
3371
                                    this.MainAngle.Visibility = Visibility.Visible;
3372
                                }
3373
                            }
3374
                            else
3375
                            {
3376
                                if (mouseButtonDown == MouseButton.Left)
3377
                                {
3378
                                    MainAngle.Visibility = Visibility.Visible;
3379
                                    currentControl = new PolygonControl
3380
                                    {
3381
                                        PointSet = new List<Point>(),
3382
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3383
                                        ControlType = ControlType.ChainLine,
3384
                                        DashSize = ViewerDataModel.Instance.DashSize,
3385
                                        LineSize = ViewerDataModel.Instance.LineSize,
3386
                                        //PointC = new StylusPointSet()
3387
                                    };
3388

    
3389
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3390
                                    {
3391
                                        var polygonControl = (currentControl as PolygonControl);
3392
                                        currentControl.CommentID = Save.shortGuid();
3393
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3394
                                        currentControl.IsNew = true;
3395
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3396
                                        //currentControl.OnApplyTemplate();
3397
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3398
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3399
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3400
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3401
                                    }
3402
                                }
3403
                            }
3404
                        }
3405
                        break;
3406
                    case ControlType.ArcLine:
3407
                        {
3408
                            if (mouseButtonDown == MouseButton.Left)
3409
                            {
3410
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3411
                                {
3412
                                    if (currentControl is ArcControl)
3413
                                    {
3414
                                        CreateControl();
3415

    
3416
                                        (currentControl as ArcControl).ApplyOverViewData();
3417
                                        currentControl = null;
3418
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3419
                                    }
3420
                                    else
3421
                                    {
3422
                                        currentControl = new ArcControl
3423
                                        {
3424
                                            Background = new SolidColorBrush(Colors.Black)
3425
                                        };
3426
                                        currentControl.CommentID = Save.shortGuid();
3427
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3428
                                        currentControl.IsNew = true;
3429
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3430
                                        this.MainAngle.Visibility = Visibility.Visible;
3431
                                    }
3432
                                }
3433
                            }
3434
                            else if (mouseButtonDown == MouseButton.Right)
3435
                            {
3436
                                if (currentControl != null)
3437
                                {
3438
                                    (currentControl as ArcControl).setClock();
3439
                                }
3440

    
3441
                            }
3442

    
3443
                        }
3444
                        break;
3445
                    case ControlType.ArcArrow:
3446
                        {
3447
                            if (mouseButtonDown == MouseButton.Left)
3448
                            {
3449
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3450
                                {
3451
                                    if (currentControl is ArcControl)
3452
                                    {
3453
                                        CreateControl();
3454

    
3455
                                        (currentControl as ArcControl).ApplyOverViewData();
3456
                                        currentControl = null;
3457
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3458
                                    }
3459
                                    else
3460
                                    {
3461
                                        currentControl = new ArcControl
3462
                                        {
3463
                                            Background = new SolidColorBrush(Colors.Red),
3464
                                        };
3465
                                        currentControl.CommentID = Save.shortGuid();
3466
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3467
                                        currentControl.IsNew = true;
3468
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3469
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3470
                                        this.MainAngle.Visibility = Visibility.Visible;
3471
                                    }
3472
                                }
3473
                            }
3474
                            else if (mouseButtonDown == MouseButton.Right)
3475
                            {
3476
                                (currentControl as ArcControl).setClock();
3477
                            }
3478
                        }
3479
                        break;
3480
                    case ControlType.ArrowMultiLine:
3481
                        {
3482
                            if (mouseButtonDown == MouseButton.Left)
3483
                            {
3484
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3485
                                {
3486

    
3487
                                    if (currentControl is ArrowControl_Multi)
3488
                                    {
3489
                                        var content = currentControl as ArrowControl_Multi;
3490
                                        if (content.MiddlePoint == new Point(0, 0))
3491
                                        {
3492
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3493
                                            {
3494
                                                content.MiddlePoint = content.EndPoint;
3495
                                            }
3496
                                            else
3497
                                            {
3498
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3499
                                            }
3500
                                        }
3501
                                        else
3502
                                        {
3503
                                            CreateControl();
3504

    
3505
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3506
                                            currentControl = null;
3507
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3508
                                        }
3509
                                    }
3510
                                    else
3511
                                    {
3512
                                        currentControl = new ArrowControl_Multi
3513
                                        {
3514
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3515
                                            Background = new SolidColorBrush(Colors.Black)
3516
                                        };
3517
                                        currentControl.CommentID = Save.shortGuid();
3518
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3519
                                        currentControl.IsNew = true;
3520
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3521
                                        this.MainAngle.Visibility = Visibility.Visible;
3522
                                    }
3523
                                }
3524
                            }
3525
                        }
3526
                        break;
3527
                    case ControlType.PolygonCloud:
3528
                        {
3529
                            if (currentControl is CloudControl)
3530
                            {
3531
                                var control = currentControl as CloudControl;
3532
                                if (mouseButtonDown == MouseButton.Right)
3533
                                {
3534
                                    control.IsCompleted = true;
3535
                                }
3536

    
3537
                                if (!control.IsCompleted)
3538
                                {
3539
                                    control.PointSet.Add(control.EndPoint);
3540
                                }
3541
                                else
3542
                                {
3543
                                    CreateControl();
3544

    
3545
                                    control.isTransOn = true;
3546
                                    var firstPoint = control.PointSet.First();
3547

    
3548
                                    control.PointSet.Add(firstPoint);
3549
                                    control.DrawingCloud();
3550
                                    control.ApplyOverViewData();
3551

    
3552
                                    currentControl = null;
3553
                                }
3554
                            }
3555
                            else
3556
                            {
3557
                                if (mouseButtonDown == MouseButton.Left)
3558
                                {
3559
                                    currentControl = new CloudControl
3560
                                    {
3561
                                        PointSet = new List<Point>(),
3562
                                        PointC = new StylusPointSet()
3563
                                    };
3564

    
3565
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3566
                                    {
3567
                                        var polygonControl = (currentControl as CloudControl);
3568
                                        currentControl.CommentID = Save.shortGuid();
3569
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3570
                                        currentControl.IsNew = true;
3571
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3572

    
3573
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3574
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3575
                                    }
3576
                                }
3577
                            }
3578
                        }
3579
                        break;
3580
                    case ControlType.ImgControl:
3581
                        {
3582
                            if (mouseButtonDown == MouseButton.Left)
3583
                            {
3584
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3585
                                {
3586
                                    if (currentControl is ImgControl)
3587
                                    {
3588
                                        CreateControl();
3589
                                        (currentControl as ImgControl).ApplyOverViewData();
3590

    
3591
                                        currentControl = null;
3592
                                    }
3593
                                    else
3594
                                    {
3595
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3596
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3597
                                        {
3598
                                            Image img = new Image();
3599
                                            img.Source = new BitmapImage(new Uri(filename));
3600

    
3601
                                            currentControl = new ImgControl
3602
                                            {
3603
                                                Background = new SolidColorBrush(Colors.Black),
3604
                                                PointSet = new List<Point>(),
3605
                                                FilePath = filename,
3606
                                                ImageData = img.Source,
3607
                                                StartPoint = canvasDrawingMouseDownPoint,
3608
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3609
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3610
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3611
                                            };
3612

    
3613
                                            currentControl.CommentID = Save.shortGuid();
3614
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3615
                                            currentControl.IsNew = true;
3616
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3617
                                        }
3618
                                    }
3619
                                }
3620
                            }
3621
                        }
3622
                        break;
3623
                    case ControlType.Date:
3624
                        {
3625
                            if (mouseButtonDown == MouseButton.Left)
3626
                            {
3627
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3628
                                {
3629
                                    if (currentControl is DateControl)
3630
                                    {
3631
                                        CreateControl();
3632
                                        (currentControl as DateControl).ApplyOverViewData();
3633
                                        currentControl = null;
3634

    
3635
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3636
                                        {
3637
                                            controlType = ControlType.None;
3638
                                            IsSwingMode = false;
3639
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3640
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3641
                                            mouseHandlingMode = MouseHandlingMode.None;
3642
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3643
                                            txtBatch.Visibility = Visibility.Collapsed;
3644

    
3645
                                        }
3646
                                    }
3647
                                    else
3648
                                    {
3649
                                        currentControl = new DateControl
3650
                                        {
3651
                                            Background = new SolidColorBrush(Colors.Black)
3652
                                        };
3653
                                        currentControl.CommentID = Save.shortGuid();
3654
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3655
                                        currentControl.IsNew = true;
3656
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3657
                                    }
3658
                                }
3659
                            }
3660
                        }
3661
                        break;
3662
                    case ControlType.TextControl:
3663
                        {
3664
                            if (mouseButtonDown == MouseButton.Left)
3665
                            {
3666
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3667
                                {
3668
                                    currentControl = new TextControl
3669
                                    {
3670
                                        ControlType = controlType
3671
                                    };
3672
                                    currentControl.CommentID = Save.shortGuid();
3673
                                    currentControl.IsNew = true;
3674
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3675
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3676
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
3677
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3678
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3679
                                    currentControl.Focus();
3680
                                    (currentControl as TextControl).ApplyOverViewData();
3681
                                    (currentControl as TextControl).ControlType_No = 0;
3682
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3683
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3684

    
3685
                                    CreateControl();
3686

    
3687
                                    //currentControl = null;
3688
                                }
3689
                            }
3690
                        }
3691
                        break;
3692
                    case ControlType.TextBorder:
3693
                        {
3694
                            if (mouseButtonDown == MouseButton.Left)
3695
                            {
3696
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3697
                                {
3698
                                    currentControl = new TextControl
3699
                                    {
3700
                                        ControlType = controlType
3701
                                    };
3702

    
3703

    
3704
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3705
                                    currentControl.CommentID = Save.shortGuid();
3706
                                    currentControl.IsNew = true;
3707
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3708
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3709
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3710
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3711
                                    currentControl.Focus();
3712
                                    (currentControl as TextControl).ControlType_No = 1;
3713
                                    (currentControl as TextControl).Angle = Ang;
3714
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3715
                                    CreateControl();
3716

    
3717
                                    //currentControl = null;
3718
                                }
3719
                            }
3720
                        }
3721
                        break;
3722
                    case ControlType.TextCloud:
3723
                        {
3724
                            if (mouseButtonDown == MouseButton.Left)
3725
                            {
3726
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3727
                                {
3728
                                    currentControl = new TextControl
3729
                                    {
3730
                                        ControlType = controlType
3731
                                    };
3732
                                    currentControl.CommentID = Save.shortGuid();
3733
                                    currentControl.IsNew = true;
3734
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3735
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3736

    
3737
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3738
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3739
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3740
                                    currentControl.Focus();
3741

    
3742
                                    (currentControl as TextControl).Angle = Ang;
3743
                                    (currentControl as TextControl).ControlType_No = 2;
3744
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3745

    
3746
                                    CreateControl();
3747
                                    //currentControl = null;
3748
                                }
3749
                            }
3750
                        }
3751
                        break;
3752
                    case ControlType.ArrowTextControl:
3753
                        {
3754
                            if (mouseButtonDown == MouseButton.Left)
3755
                            {
3756
                                if (currentControl is ArrowTextControl)
3757
                                {
3758
                                    CreateControl();
3759

    
3760
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3761
                                    (currentControl as ArrowTextControl).IsEditing = false;
3762
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3763
                                    (currentControl as ArrowTextControl).IsNew = false;
3764
                                    currentControl = null;
3765
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3766
                                }
3767
                                else
3768
                                {
3769
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3770
                                    {
3771
                                        currentControl = new ArrowTextControl();
3772
                                        currentControl.CommentID = Save.shortGuid();
3773
                                        currentControl.IsNew = true;
3774
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3775
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3776

    
3777
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3778

    
3779
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3780

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

    
3783
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3784

    
3785
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3786

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

    
3816
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3817

    
3818
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3819

    
3820
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3821

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

    
3824
                                        (currentControl as ArrowTextControl).isFixed = true;
3825
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3826

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

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

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

    
3863
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3864
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3865

    
3866
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3867

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

    
3900
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3901

    
3902
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3903

    
3904
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3905

    
3906
                                        (currentControl as ArrowTextControl).isFixed = true;
3907
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3908

    
3909
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3910

    
3911
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3912
                                        this.MainAngle.Visibility = Visibility.Visible;
3913
                                    }
3914
                                }
3915
                            }
3916
                        }
3917
                        break;
3918
                    case ControlType.ArrowTextCloudControl:
3919
                        {
3920
                            if (mouseButtonDown == MouseButton.Left)
3921
                            {
3922
                                if (currentControl is ArrowTextControl)
3923
                                {
3924
                                    CreateControl();
3925
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3926
                                    currentControl.IsNew = false;
3927
                                    currentControl = null;
3928
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3929
                                }
3930
                                else
3931
                                {
3932
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3933
                                    {
3934
                                        currentControl = new ArrowTextControl()
3935
                                        {
3936
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3937
                                        };
3938
                                        currentControl.CommentID = Save.shortGuid();
3939
                                        currentControl.IsNew = true;
3940
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3941
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3942

    
3943
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3944

    
3945
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3946

    
3947
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3948
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3949
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3950

    
3951
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3952
                                        this.MainAngle.Visibility = Visibility.Visible;
3953
                                    }
3954
                                }
3955
                            }
3956
                        }
3957
                        break;
3958
                    case ControlType.ArrowTransTextCloudControl:
3959
                        {
3960
                            if (mouseButtonDown == MouseButton.Left)
3961
                            {
3962
                                if (currentControl is ArrowTextControl)
3963
                                {
3964
                                    CreateControl();
3965
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3966
                                    currentControl.IsNew = false;
3967
                                    currentControl = null;
3968
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3969
                                }
3970
                                else
3971
                                {
3972
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3973
                                    {
3974
                                        currentControl = new ArrowTextControl()
3975
                                        {
3976
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3977
                                        };
3978
                                        currentControl.CommentID = Save.shortGuid();
3979
                                        currentControl.IsNew = true;
3980
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3981
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3982

    
3983
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3984

    
3985
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3986

    
3987
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3988

    
3989
                                        (currentControl as ArrowTextControl).isFixed = true;
3990
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3991

    
3992
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3993

    
3994
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3995
                                        this.MainAngle.Visibility = Visibility.Visible;
3996
                                    }
3997
                                }
3998
                            }
3999
                        }
4000
                        break;
4001
                    case ControlType.PolygonControl:
4002
                        {
4003
                            if (currentControl is PolygonControl)
4004
                            {
4005
                                var control = currentControl as PolygonControl;
4006

    
4007
                                if (mouseButtonDown == MouseButton.Right)
4008
                                {
4009
                                    control.IsCompleted = true;
4010
                                }
4011

    
4012
                                if (!control.IsCompleted)
4013
                                {
4014
                                    control.PointSet.Add(control.EndPoint);
4015
                                }
4016
                                else
4017
                                {
4018
                                    var firstPoint = control.PointSet.First();
4019
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4020
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4021
                                    control.PointSet.Add(firstPoint);
4022

    
4023
                                    control.SetPolyPath();
4024

    
4025
                                    control.ApplyOverViewData();
4026

    
4027
                                    CreateControl();
4028

    
4029
                                    currentControl = null;
4030
                                }
4031
                            }
4032
                            else
4033
                            {
4034
                                if (mouseButtonDown == MouseButton.Left)
4035
                                {
4036
                                    currentControl = new PolygonControl
4037
                                    {
4038
                                        PointSet = new List<Point>(),
4039
                                        //PointC = new StylusPointSet()
4040
                                    };
4041

    
4042
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4043
                                    {
4044
                                        var polygonControl = (currentControl as PolygonControl);
4045
                                        currentControl.CommentID = Save.shortGuid();
4046
                                        currentControl.IsNew = true;
4047
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4048
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4049
                                        //currentControl.OnApplyTemplate();
4050
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4051
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4052
                                    }
4053
                                }
4054
                            }
4055
                        }
4056
                        break;
4057
                    //강인구 추가
4058
                    case ControlType.Sign:
4059
                        {
4060
                            if (mouseButtonDown == MouseButton.Left)
4061
                            {
4062
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4063
                                {
4064
                                    GetUserSign getUser = new GetUserSign();
4065
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4066

    
4067
                                    if (_sign == null)
4068
                                    {
4069
                                        txtBatch.Visibility = Visibility.Collapsed;
4070
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4071
                                        controlType = ControlType.None;
4072

    
4073
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4074
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4075
                                        return;
4076
                                    }
4077

    
4078
                                    if (currentControl is SignControl)
4079
                                    {
4080
                                        CreateControl();
4081
                                        currentControl = null;
4082
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4083
                                        {
4084
                                            txtBatch.Text = "Place Date";
4085
                                            controlType = ControlType.Date;
4086
                                        }
4087
                                    }
4088
                                    else
4089
                                    {
4090
                                        currentControl = new SignControl
4091
                                        {
4092
                                            Background = new SolidColorBrush(Colors.Black),
4093
                                            UserNumber = App.ViewInfo.UserID,
4094
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4095
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4096
                                            ControlType = ControlType.Sign
4097
                                        };
4098

    
4099
                                        currentControl.CommentID = Save.shortGuid();
4100
                                        currentControl.IsNew = true;
4101
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4102
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4103
                                    }
4104
                                }
4105
                            }
4106
                        }
4107
                        break;
4108
                    case ControlType.Mark:
4109
                        {
4110
                            if (mouseButtonDown == MouseButton.Left)
4111
                            {
4112
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4113
                                {
4114
                                    if (currentControl is RectangleControl)
4115
                                    {
4116
                                        CreateControl();
4117
                                        (currentControl as RectangleControl).ApplyOverViewData();
4118
                                        currentControl = null;
4119
                                        this.cursor = Cursors.Arrow;
4120

    
4121
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4122
                                        {
4123
                                            txtBatch.Text = "Place Signature";
4124
                                            controlType = ControlType.Sign;
4125
                                        }
4126
                                    }
4127
                                    else
4128
                                    {
4129
                                        currentControl = new RectangleControl
4130
                                        {
4131
                                            Background = new SolidColorBrush(Colors.Black),
4132
                                            Paint = PaintSet.Fill
4133
                                        };
4134

    
4135
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4136
                                        currentControl.CommentID = Save.shortGuid();
4137
                                        currentControl.IsNew = true;
4138
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4139
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4140
                                    }
4141
                                }
4142
                            }
4143
                        }
4144
                        break;
4145
                    case ControlType.Symbol:
4146
                        {
4147
                            if (mouseButtonDown == MouseButton.Left)
4148
                            {
4149
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4150
                                {
4151
                                    if (currentControl is SymControl)
4152
                                    {
4153
                                        CreateControl();
4154
                                        currentControl = null;
4155
                                        this.cursor = Cursors.Arrow;
4156
                                    }
4157
                                    else
4158
                                    {
4159
                                        currentControl = new SymControl
4160
                                        {
4161
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4162
                                            Background = new SolidColorBrush(Colors.Black),
4163
                                            ControlType = ControlType.Symbol
4164
                                        };
4165

    
4166
                                        currentControl.IsNew = true;
4167
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4168
                                        currentControl.CommentID = Save.shortGuid();
4169
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4170
                                    }
4171
                                }
4172
                            }
4173
                        }
4174
                        break;
4175
                    case ControlType.Stamp:
4176
                        {
4177
                            if (mouseButtonDown == MouseButton.Left)
4178
                            {
4179
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4180
                                {
4181
                                    if (currentControl is SymControlN)
4182
                                    {
4183
                                        CreateControl();
4184
                                        currentControl = null;
4185
                                        this.cursor = Cursors.Arrow;
4186
                                    }
4187
                                    else
4188
                                    {
4189
                                        currentControl = new SymControlN
4190
                                        {
4191
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4192
                                            Background = new SolidColorBrush(Colors.Black),
4193
                                            ControlType = ControlType.Stamp
4194
                                        };
4195

    
4196
                                        currentControl.IsNew = true;
4197
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4198
                                        currentControl.CommentID = Save.shortGuid();
4199
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4200
                                    }
4201
                                }
4202
                            }
4203
                        }
4204
                        break;
4205
                    case ControlType.PenControl:
4206
                        {
4207
                            if (inkBoard.Tag.ToString() == "Ink")
4208
                            {
4209
                                inkBoard.IsEnabled = true;
4210
                                StartNewStroke(canvasDrawingMouseDownPoint);
4211
                            }
4212
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4213
                            {
4214
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4215
                            }
4216
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4217
                            {
4218
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4219
                            }
4220
                            IsDrawing = true;
4221
                            return;
4222
                        }
4223
                    default:
4224
                        if (currentControl != null)
4225
                        {
4226
                            currentControl.CommentID = null;
4227
                            currentControl.IsNew = false;
4228
                        }
4229
                        break;
4230
                }
4231

    
4232
            }
4233

    
4234
            //else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4235
            //{
4236
            //    if (controlType == ControlType.None)
4237
            //    {
4238
            //        mouseHandlingMode = MouseHandlingMode.Selecting;
4239
            //        this.cursor = Cursors.Arrow;
4240
            //        inkDrawingCanvas.IsEnabled = false;
4241
            //        isLeftMouseButtonDownOnWindow = true;
4242
            //    }
4243
            //}
4244

    
4245
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4246
            {
4247
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4248
                {
4249
                    bool mouseOff = false;
4250
                    foreach (var item in SelectLayer.Children)
4251
                    {
4252
                        if (item is AdornerFinal)
4253
                        {
4254

    
4255
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4256
                            if (over != null)
4257
                            {
4258
                                mouseOff = true;
4259
                            }
4260
                        }
4261
                    }
4262

    
4263
                    if (!mouseOff)
4264
                    {
4265
                        ReleaseAdorner();
4266
                    }
4267
                }
4268
                zoomAndPanControl.CaptureMouse();
4269
                e.Handled = true;
4270
            }
4271
        }
4272

    
4273
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4274
        {
4275
            mouseButtonDown = e.ChangedButton;
4276
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4277
        }
4278

    
4279
        private void RemoveLineStroke(Point P)
4280
        {
4281
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4282
            if (control != null)
4283
            {
4284
                UndoData = new Undo_data()
4285
                {
4286
                    IsUndo = false,
4287
                    Event = Event_Type.Delete,
4288
                    EventTime = DateTime.Now,
4289
                    Markup_List = new List<Multi_Undo_data>()
4290
                };
4291

    
4292

    
4293
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4294
                UndoData.Markup_List.Add(multi_Undo_Data);
4295
                multi_Undo_Data = new Multi_Undo_data();
4296

    
4297
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4298
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4299
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4300

    
4301

    
4302
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4303
                {
4304
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4305
                });
4306
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4307

    
4308
            }
4309
        }
4310

    
4311
        private void RemovePointStroke(Point P)
4312
        {
4313
            foreach (Stroke hits in inkBoard.Strokes)
4314
            {
4315
                foreach (StylusPoint sty in hits.StylusPoints)
4316
                {
4317

    
4318
                }
4319
                if (hits.HitTest(P))
4320
                {
4321
                    inkBoard.Strokes.Remove(hits);
4322
                    return;
4323
                }
4324
            }
4325
        }
4326

    
4327
        private void StartNewStroke(Point P)
4328
        {
4329
            strokePoints = new StylusPointCollection();
4330
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4331
            strokePoints.Add(segment1Start);
4332
            stroke = new Stroke(strokePoints);
4333

    
4334
            stroke.DrawingAttributes.Color = Colors.Red;
4335
            stroke.DrawingAttributes.Width = 4;
4336
            stroke.DrawingAttributes.Height = 4;
4337

    
4338
            inkBoard.Strokes.Add(stroke);
4339

    
4340
        }
4341

    
4342
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4343
        {
4344
            ConsolidationMethod();
4345
        }
4346

    
4347
        public void ConsolidationMethod()
4348
        {
4349
            ChangeCommentReact();
4350

    
4351
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4352
            {
4353
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4354
            }
4355
            else
4356
            {
4357

    
4358
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4359
                {
4360
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4361
                }
4362

    
4363
                ViewerDataModel.Instance.IsConsolidate = true;
4364
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4365
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4366
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4367
                {
4368
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4369
                    if (markupInfo.CONSOLIDATE == 1)
4370
                    {
4371
                        markupInfo.AVOID_CONSOLIDATE = 1;
4372
                    }
4373

    
4374
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4375
                    {
4376
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4377
                          {
4378
                              instanceDataSet.Add(d);
4379
                          });
4380
                    }
4381

    
4382
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4383
                    info.ID = Save.shortGuid();
4384
                    info.CONSOLIDATE = 1;
4385
                    info.CREATE_TIME = DateTime.Now;
4386
                    info.DOCINFO_ID = _DocInfo.ID;
4387
                    info.UPDATE_TIME = DateTime.Now;
4388
                    info.USER_ID = App.ViewInfo.UserID;
4389
                    info.AVOID_CONSOLIDATE = 0;
4390

    
4391
                    Entity.MARKUP_INFO.AddObject(info);
4392
                    Entity.SaveChanges();
4393

    
4394

    
4395
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4396
                    {
4397
                        ID = Save.shortGuid(),
4398
                        CREATE_DATE = DateTime.Now,
4399
                        MARKUP_INFO = info,
4400
                    };
4401
                    Entity.SaveChanges();
4402

    
4403
                    foreach (var item in instanceDataSet)
4404
                    {
4405
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4406
                        {
4407
                            ID = Save.shortGuid(),
4408
                            DATA = item.DATA,
4409
                            DATA_TYPE = item.DATA_TYPE,
4410
                            PAGENUMBER = item.PAGENUMBER,
4411
                            MARKUP_INFO_VERSION = info2
4412
                        });
4413
                    }
4414
                    Entity.SaveChanges();
4415
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4416
                }
4417
            }
4418
        }
4419

    
4420
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4421
        {
4422
            if (App.ViewInfo != null)
4423
            {
4424
                btnConsolidate = (sender as RadRibbonButton);
4425
                if (!App.ViewInfo.NewCommentPermission)
4426
                {
4427
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4428
                }
4429
            }
4430
        }
4431

    
4432
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4433
        {
4434

    
4435
        }
4436

    
4437
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4438
        {
4439
            btnTeamConsolidate = sender as RadRibbonButton;
4440
            if (App.ViewInfo != null)
4441
            {
4442
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4443
                {
4444
                    if (btnConsolidate != null)
4445
                    {
4446
                        btnConsolidate.Visibility = Visibility.Collapsed;
4447
                    }
4448

    
4449
                    if (!App.ViewInfo.NewCommentPermission)
4450
                    {
4451
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4452
                    }
4453
                }
4454
                else
4455
                {
4456
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4457
                }
4458
            }
4459
        }
4460

    
4461
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4462
        {
4463
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4464
            if (item != null)
4465
            {
4466
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4467
            }
4468
            else
4469
            {
4470
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4471
            }
4472
        }
4473

    
4474
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4475
        {
4476
            btnFinalPDF = sender as RadRibbonButton;
4477
            if (App.ViewInfo != null)
4478
            {
4479
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4480
                {
4481
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4482
                    if (btnConsolidate != null)
4483
                    {
4484
                        btnConsolidate.Visibility = Visibility.Collapsed;
4485
                    }
4486
                }
4487
            }
4488
        }
4489

    
4490
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4491
        {
4492
            if (CompareMode.IsChecked)
4493
            {
4494
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4495
                {
4496
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4497
                }
4498
                if (ViewerDataModel.Instance.PageNumber == 0)
4499
                {
4500
                    ViewerDataModel.Instance.PageNumber = 1;
4501
                }
4502

    
4503
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? true : false);
4504
            }
4505
            else
4506
            {
4507
                da.From = 1;
4508
                da.To = 1;
4509
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4510
                da.AutoReverse = false;
4511
                canvas_compareBorder.Children.Clear();
4512
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4513
            }
4514
        }
4515

    
4516
        private void Sync_Click(object sender, RoutedEventArgs e)
4517
        {
4518
            if (Sync.IsChecked)
4519
            {
4520
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4521
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4522
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4523
            }
4524
        }
4525

    
4526
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4527
        {
4528
            if (UserList.IsChecked)
4529
            {
4530
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4531
            }
4532
            else
4533
            {
4534
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4535
            }
4536
        }
4537

    
4538
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4539
        {
4540

    
4541
            if (BalanceMode.IsChecked)
4542
            {
4543
                ViewerDataModel.Instance.PageBalanceMode = true;
4544
            }
4545
            else
4546
            {
4547
                ViewerDataModel.Instance.PageBalanceMode = false;
4548
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4549
            }
4550
        }
4551

    
4552
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4553
        {
4554
            //초기화
4555
            testPanel2.IsHidden = true;
4556
            ViewerDataModel.Instance.PageBalanceMode = false;
4557
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4558
            ViewerDataModel.Instance.PageNumber = 0;
4559
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4560
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4561
            UserList.IsChecked = false;
4562
            BalanceMode.IsChecked = false;
4563
        }
4564

    
4565
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4566
        {
4567
            if ((sender as System.Windows.Controls.Control).Tag != null)
4568
            {
4569
                //Compare 초기화
4570
                CompareMode.IsChecked = false;
4571
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4572

    
4573
                if (ViewerDataModel.Instance.PageNumber == 0)
4574
                {
4575
                    ViewerDataModel.Instance.PageNumber = 1;
4576
                }
4577

    
4578
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4579
                {
4580
                }
4581
                else
4582
                {
4583
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4584
                }
4585

    
4586
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4587
                {
4588

    
4589
                }
4590
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4591
                {
4592
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4593
                }
4594

    
4595
                if (!testPanel2.IsHidden)
4596
                {
4597
                    if (IsSyncPDFMode)
4598
                    {
4599
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4600
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4601

    
4602
                        if (pdfpath.IsDownloading)
4603
                        {
4604
                            pdfpath.DownloadCompleted += (ex, arg) =>
4605
                            {
4606
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4607
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4608
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4609
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4610
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4611
                            };
4612
                        }
4613
                        else
4614
                        {
4615
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4616
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4617
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4618

    
4619
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4620
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4621
                        }
4622

    
4623
                    }
4624
                    else
4625
                    {
4626
                        string uri = "";
4627

    
4628
                        if (userData.COMPANY != "EXT")
4629
                        {
4630
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4631
                        }
4632
                        else
4633
                        {
4634
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4635
                        }
4636

    
4637
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4638

    
4639
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4640
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4641
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4642

    
4643
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4644
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4645

    
4646
                        if (defaultBitmapImage_Compare.IsDownloading)
4647
                        {
4648
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4649
                            {
4650
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4651
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4652
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4653

    
4654
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4655
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4656
                            };
4657
                        }
4658
                    }
4659

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

    
4664
                    foreach (var item in gridSelectionRevItem)
4665
                    {
4666
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4667
                        {
4668
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4669
                        });
4670
                    }
4671

    
4672
                    //강인구 추가
4673
                    zoomAndPanControl2.ZoomTo(new Rect
4674
                    {
4675
                        X = 0,
4676
                        Y = 0,
4677
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4678
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4679
                    });
4680

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

    
4683
                }
4684
            }
4685
        }
4686

    
4687
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4688
        {
4689
            if (MarkupMode.IsChecked)
4690
            {
4691
                IsSyncPDFMode = true;
4692

    
4693
                var uri = CurrentRev.TO_VENDOR;
4694

    
4695
                if (ViewerDataModel.Instance.PageNumber == 0)
4696
                {
4697
                    ViewerDataModel.Instance.PageNumber = 1;
4698
                }
4699

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

    
4704
                if (pdfpath.IsDownloading)
4705
                {
4706
                    pdfpath.DownloadCompleted += (ex, arg) =>
4707
                    {
4708
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4709
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4710
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4711
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4712
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4713
                    };
4714
                }
4715
                else
4716
                {
4717
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4718
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4719
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4720

    
4721
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4722
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4723
                }
4724
            }
4725
            else
4726
            {
4727
                IsSyncPDFMode = false;
4728
                string uri = "";
4729
                if (userData.COMPANY != "EXT")
4730
                {
4731
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4732
                }
4733
                else
4734
                {
4735
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4736
                }
4737

    
4738
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4739

    
4740
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4741
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4742
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4743

    
4744
                if (defaultBitmapImage_Compare.IsDownloading)
4745
                {
4746
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4747
                    {
4748
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4749
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4750
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4751
                    };
4752
                }
4753
                zoomAndPanControl2.ApplyTemplate();
4754
                zoomAndPanControl2.UpdateLayout();
4755
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4756
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4757
            }
4758
        }
4759

    
4760
        private void RadButton_Click(object sender, RoutedEventArgs e)
4761
        {
4762
            gridViewHistory_Busy.IsBusy = true;
4763

    
4764
            RadButton instance = sender as RadButton;
4765
            if (instance.CommandParameter != null)
4766
            {
4767
                CurrentRev = instance.CommandParameter as VPRevision;
4768
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4769
                {
4770
                    if (ea.Error == null && ea.Result != null)
4771
                    {
4772
                        testPanel2.IsHidden = false;
4773

    
4774
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4775
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4776

    
4777
                        string uri = "";
4778
                        if (userData.COMPANY != "EXT")
4779
                        {
4780
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4781
                        }
4782
                        else
4783
                        {
4784
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4785
                        }
4786

    
4787
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4788

    
4789
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4790

    
4791
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4792
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4793
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4794

    
4795
                        if (defaultBitmapImage_Compare.IsDownloading)
4796
                        {
4797
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4798
                            {
4799
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4800
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4801
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4802
                            };
4803
                        }
4804

    
4805
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4806
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4807
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4808
                        zoomAndPanControl2.ApplyTemplate();
4809
                        zoomAndPanControl2.UpdateLayout();
4810

    
4811
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4812
                        {
4813
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4814
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4815
                        }
4816

    
4817
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4818
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4819
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4820

    
4821
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4822
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4823
                        gridViewHistory_Busy.IsBusy = false;
4824
                    }
4825
                };
4826
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4827
            }
4828
        }
4829

    
4830
        public void Sync_Event(VPRevision Currnet_Rev)
4831
        {
4832
            CurrentRev = Currnet_Rev;
4833

    
4834
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4835
            {
4836
                if (ea.Error == null && ea.Result != null)
4837
                {
4838
                    testPanel2.IsHidden = false;
4839

    
4840
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4841
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4842

    
4843
                    string uri = "";
4844
                    if (userData.COMPANY != "EXT")
4845
                    {
4846
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4847
                    }
4848
                    else
4849
                    {
4850
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4851
                    }
4852

    
4853
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4854

    
4855
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4856

    
4857
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4858
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4859
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4860

    
4861
                    if (defaultBitmapImage_Compare.IsDownloading)
4862
                    {
4863
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4864
                        {
4865
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4866
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4867
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4868
                        };
4869
                    }
4870

    
4871
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4872
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4873
                    zoomAndPanControl2.ApplyTemplate();
4874
                    zoomAndPanControl2.UpdateLayout();
4875

    
4876
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4877
                    {
4878
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4879
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4880
                    }
4881
                    //}
4882

    
4883
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4884
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4885
                    gridViewHistory_Busy.IsBusy = false;
4886
                }
4887
            };
4888
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4889

    
4890

    
4891
        }
4892

    
4893
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4894
        {
4895
            if (sender is Image)
4896
            {
4897
                if ((sender as Image).Tag != null)
4898
                {
4899
                    var pdfUrl = (sender as Image).Tag.ToString();
4900
                    System.Diagnostics.Process.Start(pdfUrl);
4901
                }
4902
                else
4903
                {
4904
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4905
                }
4906
            }
4907
        }
4908

    
4909
        private void Create_Symbol(object sender, RoutedEventArgs e)
4910
        {
4911
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4912
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4913

    
4914
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4915
            {
4916
                DialogMessage_Alert("Please Select Controls", "Alert");
4917
            }
4918
            else //선택된 것이 있으면
4919
            {
4920
                string MarkupData = "";
4921
                adorner_ = new AdornerFinal();
4922

    
4923
                foreach (var item in SelectLayer.Children)
4924
                {
4925
                    if (item.GetType().Name == "AdornerFinal")
4926
                    {
4927
                        adorner_ = (item as Controls.AdornerFinal);
4928
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4929
                        {
4930
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4931
                            {
4932
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4933
                                MarkupData += markupReturn.ConvertData;
4934
                            }
4935
                        }
4936
                    }
4937
                }
4938
                DialogParameters parameters = new DialogParameters()
4939
                {
4940
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4941
                    DefaultPromptResultValue = "Custom State",
4942
                    Content = "Name :",
4943
                    Header = "Insert Custom Symbol Name",
4944
                    Theme = new VisualStudio2013Theme(),
4945
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4946
                };
4947
                RadWindow.Prompt(parameters);
4948
            }
4949

    
4950
        }
4951

    
4952
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4953
        {
4954
            Save save = new Save();
4955

    
4956
            if (args.DialogResult.Value)
4957
            {
4958
                PngBitmapEncoder _Encoder = symImage(data);
4959

    
4960
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
4961
                _Encoder.Save(fs);
4962
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4963

    
4964
                byte[] Img_byte = fs.ToArray();
4965

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

    
4969
                save.SymbolSave(args.PromptResult, filename, data);
4970
            }
4971
        }
4972

    
4973
        public PngBitmapEncoder symImage(string data)
4974
        {
4975

    
4976
            Canvas _canvas = new Canvas();
4977
            _canvas.Background = Brushes.White;
4978
            _canvas.Width = adorner_.BorderSize.Width;
4979
            _canvas.Height = adorner_.BorderSize.Height;
4980
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4981

    
4982
            BitmapEncoder encoder = new PngBitmapEncoder();
4983

    
4984

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

    
4987
            DrawingVisual dv = new DrawingVisual();
4988

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

    
4992
            using (DrawingContext ctx = dv.RenderOpen())
4993
            {
4994
                VisualBrush vb = new VisualBrush(_canvas);
4995
                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)));
4996
            }
4997

    
4998
            try
4999
            {
5000
                renderBitmap.Render(dv);
5001

    
5002
                GC.Collect();
5003
                GC.WaitForPendingFinalizers();
5004
                GC.Collect();
5005
                // encode png data
5006
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5007
                // puch rendered bitmap into it
5008
                pngEncoder.Interlace = PngInterlaceOption.Off;
5009
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5010
                return pngEncoder;
5011

    
5012
            }
5013
            catch (Exception ex)
5014
            {
5015
                return null;
5016
            }
5017

    
5018
        }
5019

    
5020
        public void DialogMessage_Alert(string content, string header)
5021
        {
5022
            var box = new TextBlock();
5023
            box.MinWidth = 400;
5024
            box.FontSize = 11;
5025
            //box.FontSize = 12;
5026
            box.Text = content;
5027
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5028

    
5029
            DialogParameters parameters = new DialogParameters()
5030
            {
5031
                Content = box,
5032
                Header = header,
5033
                Theme = new VisualStudio2013Theme(),
5034
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5035
            };
5036
            RadWindow.Alert(parameters);
5037
        }
5038

    
5039
        #region 캡쳐 기능
5040

    
5041
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5042
        {
5043
            if (x < 0)
5044
            {
5045
                width += x;
5046
                x = 0;
5047
            }
5048
            if (y < 0)
5049
            {
5050
                height += y;
5051
                y = 0;
5052

    
5053
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5054
            }
5055
            if (x + width > zoomAndPanCanvas.ActualWidth)
5056
            {
5057
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5058
            }
5059
            if (y + height > zoomAndPanCanvas.ActualHeight)
5060
            {
5061
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5062
            }
5063

    
5064
            byte[] pixels = CopyPixels(x, y, width, height);
5065

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

    
5068
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5069
        }
5070

    
5071
        public byte[] CopyPixels(int x, int y, int width, int height)
5072
        {
5073
            byte[] pixels = new byte[width * height * 4];
5074
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5075

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

    
5079
            return pixels;
5080
        }
5081

    
5082
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5083
        {
5084
            DrawingVisual drawingVisual = new DrawingVisual();
5085
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5086

    
5087
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5088
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5089
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5090
            drawingContext.Close();
5091

    
5092
            // 비트맵으로 변환합니다.
5093
            RenderTargetBitmap target =
5094
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5095
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5096

    
5097
            target.Render(drawingVisual);
5098
            return target;
5099
        }
5100

    
5101
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5102
        {
5103
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5104
            KCOMDataModel.DataModel.CHECK_LIST check_;
5105
            string Result = streamToBase64.ImageToBase64(source);
5106
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5107

    
5108
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
5109
            {
5110
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
5111

    
5112
                //새로운 데이터 추가
5113
                if (Item == null)
5114
                {
5115
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
5116
                    {
5117
                        ID = Save.shortGuid(),
5118
                        USER_ID = App.ViewInfo.UserID,
5119
                        IMAGE_URL = Result,
5120
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5121
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5122
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5123
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5124
                        PROJECT_NO = App.ViewInfo.ProjectNO,
5125
                        STATUS = "False",
5126
                        CREATE_TIME = DateTime.Now,
5127
                        UPDATE_TIME = DateTime.Now,
5128
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5129
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
5130
                    };
5131

    
5132
                    Entity.CHECK_LIST.AddObject(check_);
5133
                }
5134
                //기존에 있던 데이터 업데이트
5135
                else
5136
                {
5137
                    Item.IMAGE_URL = Result;
5138
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5139
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5140
                }
5141

    
5142
                //Item.REV_0 = "Test";
5143

    
5144
                try
5145
                {
5146
                    Entity.SaveChanges();
5147
                }
5148
                catch (Exception ex)
5149
                {
5150

    
5151
                }
5152
                //Entity.SaveChanges();
5153
            }
5154
        }
5155

    
5156
        public void Set_Capture()
5157
        {
5158
            //double x = Canvas.GetLeft(dragCaptureBorder);
5159
            //double y = Canvas.GetTop(dragCaptureBorder);
5160
            double x = canvasDrawingMouseDownPoint.X;
5161
            double y = canvasDrawingMouseDownPoint.Y;
5162
            double width = dragCaptureBorder.Width;
5163
            double height = dragCaptureBorder.Height;
5164

    
5165
            if (width > 5 || height > 5)
5166
            {
5167
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5168
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5169
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5170
            }
5171
        }
5172
        #endregion
5173

    
5174
        public void CreateControl()
5175
        {
5176
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5177
            {
5178
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5179
            });
5180
            multi_Undo_Data.Markup = currentControl;
5181
            UndoData.Markup_List.Add(multi_Undo_Data);
5182
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5183
        }
5184

    
5185
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5186
        {
5187
            multi_Undo_Data = new Multi_Undo_data();
5188

    
5189
            multi_Undo_Data.Markup = control;
5190

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

    
5208
            return multi_Undo_Data;
5209
        }
5210

    
5211
        public void Undo()
5212
        {
5213
            Undo_data undo = new Undo_data();
5214
            AdornerFinal final;
5215
            ReleaseAdorner();
5216

    
5217
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5218
            if (undo == null)
5219
                return;
5220

    
5221
            switch (undo.Event)
5222
            {
5223
                case (Event_Type.Create):
5224
                    {
5225
                        foreach (var item in undo.Markup_List)
5226
                        {
5227
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5228
                        }
5229
                    }
5230
                    break;
5231
                case (Event_Type.Delete):
5232
                    {
5233
                        foreach (var item in undo.Markup_List)
5234
                        {
5235
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5236
                        }
5237
                    }
5238
                    break;
5239
                case (Event_Type.Thumb):
5240
                    {
5241
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5242

    
5243
                        foreach (var item in undo.Markup_List)
5244
                        {
5245
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5246

    
5247
                            if ((item.Markup as IViewBox) != null)
5248
                            {
5249
                                (item.Markup as IViewBox).Angle = item.Angle;
5250
                            }
5251
                            if ((item.Markup as TextControl) != null)
5252
                            {
5253
                                (item.Markup as TextControl).Angle = item.Angle;
5254
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5255
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5256
                            }
5257
                            else
5258
                            {
5259
                                (item.Markup as IPath).PointSet = item.PointSet;
5260
                                (item.Markup as IPath).updateControl();
5261
                            }
5262

    
5263
                            comment.Add(item.Markup);
5264
                        }
5265
                        final = new AdornerFinal(comment);
5266
                        SelectLayer.Children.Add(final);
5267
                        ReleaseAdorner();
5268
                    }
5269
                    break;
5270
                case (Event_Type.Select):
5271
                    {
5272
                        ReleaseAdorner();
5273
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5274

    
5275
                        foreach (var item in undo.Markup_List)
5276
                        {
5277
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5278

    
5279
                            if ((item.Markup as IPath) != null)
5280
                            {
5281
                                (item.Markup as IPath).LineSize = item.LineSize;
5282
                            }
5283
                            if ((item.Markup as UIElement) != null)
5284
                            {
5285
                                (item.Markup as UIElement).Opacity = item.Opacity;
5286
                            }
5287
                            if ((item.Markup as IDashControl) != null)
5288
                            {
5289
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5290
                            }
5291
                            if ((item.Markup as IShapeControl) != null)
5292
                            {
5293
                                (item.Markup as IShapeControl).Paint = item.paint;
5294
                            }
5295

    
5296
                            comment.Add(item.Markup);
5297
                        }
5298

    
5299
                        final = new AdornerFinal(comment);
5300
                        SelectLayer.Children.Add(final);
5301
                    }
5302
                    break;
5303
                case (Event_Type.Option):
5304
                    {
5305
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5306

    
5307
                        foreach (var item in undo.Markup_List)
5308
                        {
5309
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5310

    
5311
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5312
                            {
5313
                                (item.Markup as IPath).LineSize = undo.LineSize;
5314
                            }
5315
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5316
                            {
5317
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5318
                            }
5319
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5320
                            {
5321
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5322
                            }
5323
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5324
                            {
5325
                                (item.Markup as LineControl).Interval = undo.Interval;
5326
                            }
5327
                            else if (item.Markup as IShapeControl != null)
5328
                            {
5329
                                (item.Markup as IShapeControl).Paint = undo.paint;
5330
                            }
5331
                            comment.Add(item.Markup);
5332
                        }
5333
                        final = new AdornerFinal(comment);
5334
                        SelectLayer.Children.Add(final);
5335
                    }
5336
                    break;
5337
            }
5338
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5339
           {
5340
               i.IsUndo = true;
5341
           });
5342
        }
5343

    
5344
        public void Redo()
5345
        {
5346
            AdornerFinal final;
5347
            Undo_data redo = new Undo_data();
5348
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5349
            ReleaseAdorner();
5350
            if (redo == null)
5351
                return;
5352

    
5353
            switch (redo.Event)
5354
            {
5355
                case (Event_Type.Create):
5356
                    {
5357
                        foreach (var item in redo.Markup_List)
5358
                        {
5359
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5360
                        }
5361
                    }
5362
                    break;
5363
                case (Event_Type.Delete):
5364
                    {
5365
                        foreach (var item in redo.Markup_List)
5366
                        {
5367
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5368
                        }
5369
                    }
5370
                    break;
5371
                case (Event_Type.Thumb):
5372
                    {
5373
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5374

    
5375
                        foreach (var item in redo.Markup_List)
5376
                        {
5377
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5378

    
5379
                            if ((item.Markup as IViewBox) != null)
5380
                            {
5381
                                (item.Markup as IViewBox).Angle = item.Angle;
5382
                            }
5383
                            if ((item.Markup as TextControl) != null)
5384
                            {
5385
                                (item.Markup as TextControl).Angle = item.Angle;
5386

    
5387
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5388
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5389
                            }
5390
                            else
5391
                            {
5392
                                (item.Markup as IPath).PointSet = item.PointSet;
5393
                                (item.Markup as IPath).updateControl();
5394
                            }
5395
                            comment.Add(item.Markup);
5396
                        }
5397
                        final = new AdornerFinal(comment);
5398
                        SelectLayer.Children.Add(final);
5399
                        ReleaseAdorner();
5400
                    }
5401
                    break;
5402
                case (Event_Type.Select):
5403
                    {
5404
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5405

    
5406
                        foreach (var item in redo.Markup_List)
5407
                        {
5408
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5409

    
5410
                            if ((item.Markup as IPath) != null)
5411
                            {
5412
                                (item.Markup as IPath).LineSize = item.LineSize;
5413
                            }
5414
                            if ((item.Markup as UIElement) != null)
5415
                            {
5416
                                (item.Markup as UIElement).Opacity = item.Opacity;
5417
                            }
5418
                            if ((item.Markup as IDashControl) != null)
5419
                            {
5420
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5421
                            }
5422
                            if ((item.Markup as IShapeControl) != null)
5423
                            {
5424
                                (item.Markup as IShapeControl).Paint = item.paint;
5425
                            }
5426

    
5427
                            comment.Add(item.Markup);
5428
                        }
5429
                        final = new AdornerFinal(comment);
5430
                        SelectLayer.Children.Add(final);
5431
                    }
5432
                    break;
5433
                case (Event_Type.Option):
5434
                    {
5435
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5436

    
5437
                        foreach (var item in redo.Markup_List)
5438
                        {
5439
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5440
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5441
                            {
5442
                                (item.Markup as IPath).LineSize = redo.LineSize;
5443
                            }
5444
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5445
                            {
5446
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5447
                            }
5448
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5449
                            {
5450
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5451
                            }
5452
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
5453
                            {
5454
                                (item.Markup as LineControl).Interval = redo.Interval;
5455
                            }
5456
                            else if (item.Markup as IShapeControl != null)
5457
                            {
5458
                                (item.Markup as IShapeControl).Paint = redo.paint;
5459
                            }
5460
                            comment.Add(item.Markup);
5461
                        }
5462
                        final = new AdornerFinal(comment);
5463
                        SelectLayer.Children.Add(final);
5464
                    }
5465
                    break;
5466
            }
5467

    
5468
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5469
            {
5470
                i.IsUndo = false;
5471
            });
5472
        }
5473

    
5474
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5475
        {
5476
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5477
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5478
            {
5479
                if (items.UserID == Select_ID)
5480
                {
5481
                    foreach (var item in items.MarkupList)
5482
                    {
5483
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5484
                        {
5485
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5486
                        }
5487
                    }
5488
                }
5489
            }
5490
        }
5491

    
5492
        public void InkControl_Convert()
5493
        {
5494
            if (inkBoard.Strokes.Count > 0)
5495
            {
5496
                inkBoard.Strokes.ToList().ForEach(stroke =>
5497
                {
5498
                    List<Stroke> removingStroke = new List<Stroke>();
5499
                    StrokeCollection stC = new StrokeCollection();
5500

    
5501
                    removingStroke.Add(stroke);
5502

    
5503
                    InkToPath ip = new InkToPath();
5504
                    List<Point> inkPointSet = new List<Point>();
5505
                    PolygonControl pc = null;
5506
                    pc = new PolygonControl()
5507
                    {
5508
                        Angle = 0,
5509
                        PointSet = new List<Point>(),
5510
                        ControlType = ControlType.Ink
5511
                    };
5512
                    foreach (var item in removingStroke)
5513
                    {
5514
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5515
                        inkBoard.Strokes.Remove(item);
5516
                    }
5517
                    if (inkPointSet.Count != 0)
5518
                    {
5519
                        //강인구 추가(PenControl Undo Redo 추가)
5520
                        UndoData = new Undo_data()
5521
                        {
5522
                            IsUndo = false,
5523
                            Event = Event_Type.Create,
5524
                            EventTime = DateTime.Now,
5525
                            Markup_List = new List<Multi_Undo_data>()
5526
                        };
5527

    
5528
                        pc.StartPoint = inkPointSet[0];
5529
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5530
                        pc.PointSet = inkPointSet;
5531
                        pc.LineSize = 3;
5532
                        pc.CommentID = Save.shortGuid();
5533
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5534
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5535
                        pc.SetPolyPath();
5536

    
5537
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5538
                        {
5539
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5540
                        });
5541
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5542
                        UndoData.Markup_List.Add(multi_Undo_Data);
5543
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5544
                    }
5545
                });
5546
            }
5547
        }
5548

    
5549
        /// <summary>
5550
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5551
        /// </summary>
5552
        /// <param name="StartP">StartPoint</param>
5553
        /// <param name="EndP">EndPoint</param>
5554
        /// <returns>Return_EndPoint</returns>
5555
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5556
        {
5557
            Point Return_Point = new Point();
5558

    
5559
            double dx = EndP.X - StartP.X;
5560
            double dy = EndP.Y - StartP.Y;
5561
            double length;
5562

    
5563
            switch (controlType)
5564
            {
5565
                case ControlType.Triangle:
5566
                    {
5567
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5568
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5569
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5570
                    }
5571
                    break;
5572
                default:
5573
                    {
5574
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
5575
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
5576
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
5577
                    }
5578
                    break;
5579
            }
5580

    
5581
            return Return_Point;
5582
        }
5583

    
5584
        /// <summary>
5585
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
5586
        /// </summary>
5587
        /// <author>humkyung</author>
5588
        /// <date>2018.04.26</date>
5589
        /// <param name="StartP"></param>
5590
        /// <param name="EndP"></param>
5591
        /// <returns></returns>
5592
        /// <history>humkyung 2018.05.11 apply axis lock</history>
5593
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
5594
        {
5595
            List<Point> res = new List<Point>();
5596

    
5597
            double dx = EndP.X - StartP.X;
5598
            double dy = EndP.Y - StartP.Y;
5599
            double length = Math.Sqrt(dx * dx + dy * dy);
5600
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
5601
            dx /= length;
5602
            dy /= length;
5603
            double tmp = dx;
5604
            dx = -dy; dy = tmp; /// rotate by 90 degree
5605

    
5606
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
5607
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
5608

    
5609
            return res;
5610
        }
5611

    
5612
       
5613
    }
5614
}
클립보드 이미지 추가 (최대 크기: 500 MB)