프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 4ca11b36

이력 | 보기 | 이력해설 | 다운로드 (295 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
using KCOMDataModel.DataModel;
31
using System.Xml;
32

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

    
42
            T instance = Activator.CreateInstance<T>();
43

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

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

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

    
80
        public TextBox Gui { get; private set; }
81

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

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

    
103
            Gui.Text += line + Environment.NewLine;
104
        }
105
    }
106

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

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

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

    
169
                }
170
            }
171
        }
172

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

    
197
        public bool IsSyncPDFMode { get; set; }
198

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

    
223
        #endregion
224

    
225

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

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

    
246
            return false;
247
        }
248

    
249
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
250
        {
251
            if (rotate.Angle == 90 || rotate.Angle == 270)
252
            {
253
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
254
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
255
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
256
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
257
                {
258
                    return true;
259
                }
260
            }
261
            else
262
            {
263
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
264
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
265
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
266
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
267
                {
268
                    return true;
269
                }
270
            }               
271

    
272
            return false;
273
        }
274

    
275
       
276
        public void DeleteItem(MarkupInfoItem item)
277
        {
278
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
279
            {
280
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
281
            }
282

    
283
            ViewerDataModel.Instance._markupInfoList.Remove(item);
284

    
285
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
286
            {
287
                ViewerDataModel.Instance.MarkupControls.Remove(a);
288
            });
289

    
290
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
291
            {
292
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
293
            });
294

    
295
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
296
            {
297
                ComingNewBieEnd = false;
298
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
299
            });
300

    
301
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
302
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
303
            {
304
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
305
                {
306
                    var infoId = Events.Save.shortGuid();
307
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
308
                    {
309
                        CreateTime = DateTime.Now,
310
                        Depatment = userData.DEPARTMENT,
311
                        UpdateTime = DateTime.Now,
312
                        DisplayColor = "#FFFF0000",
313
                        UserID = userData.ID,
314
                        UserName = userData.NAME,
315
                        PageCount = 1,
316
                        Description = "",
317
                        MarkupInfoID = infoId,
318
                        MarkupList = null,
319
                        MarkupVersionID = Events.Save.shortGuid(),
320
                        Consolidate = 0,
321
                        PartConsolidate = 0,
322
                        userDelete = true,
323
                        AvoidConsolidate = 0,
324
                        IsPreviewUser = true
325
                    };
326
                    App.Custom_ViewInfoId = infoId;
327
                }
328
            }
329
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
330
        }
331

    
332
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
333
        {
334
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
335
            this.ReleaseAdorner();
336

    
337
            Button content = (sender as Button);
338
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
339

    
340
            DeleteItem(item);
341
        }
342

    
343
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
344

    
345
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
346
        {
347
            if (App.ParameterMode)
348
            {          
349
                if (System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "ControlLog.xml")) //임시파일이 있는가?
350
                {
351
                    //this.pageNavigator.PageChanging += pageNavigator_PageChanging;
352
                    this.pageNavigator.PageChanging += TempLoad;
353
                    
354
                }
355
                else
356
                {
357
                    this.pageNavigator.PageChanging += pageNavigator_PageChanging;
358
                    imageViewer_Compare = new Image();
359

    
360
                    layerControl.ProjectNo = App.ViewInfo.ProjectNO;
361
                    ViewerDataModel.Instance.Capture_Opacity = 0;
362

    
363
                    da.From = 0.8;
364
                    da.To = 0;
365
                    da.Duration = new Duration(TimeSpan.FromSeconds(1));
366
                    da.AutoReverse = true;
367
                    da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
368
                }
369
            }
370
        }
371

    
372
        //private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
373
        private void TempLoad(object sender, Controls.Sample.PageChangeEventArgs e)
374
        {
375
            MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
376
            XmlDocument xdoc = new XmlDocument();
377
            xdoc.Load(AppDomain.CurrentDomain.BaseDirectory + "ControlLog.xml"); // XML 데이타를 파일에서 로드                
378
            XmlNodeList nodes = xdoc.SelectNodes("/Root/CommentID"); // 특정 노드들을 필터링
379

    
380
            int PageNumber = 0;
381

    
382
            foreach (XmlNode node in nodes) //파일안에 데이터가 있는가?
383
            {
384
                string sCommentID = node.Attributes["Value"].Value;
385
                string ConvertData = node.SelectSingleNode("ConvertData").InnerText;
386
                string DATA_TYPE = node.SelectSingleNode("DATA_TYPE").InnerText;
387
                PageNumber = Convert.ToInt32(node.SelectSingleNode("PageNumber").InnerText);
388
                string MarkupInfoID = node.SelectSingleNode("MarkupInfoID").InnerText;
389

    
390
                layerControl.markupParseEx(ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", MarkupInfoID, sCommentID);                
391
            }
392

    
393

    
394
            //  ViewerDataModel.Instance.PageBalanceNumber = PageNumber;
395
            ViewerDataModel.Instance.PageNumber = ViewerDataModel.Instance.PageBalanceNumber = PageNumber;
396
          //  BalancePoint = 
397
            // BalancePoint = 2
398
            var BalancePoint = pageNavigator.PageCount;
399

    
400
            /*
401
            if (BalancePoint < 1)
402
            {
403
                BalancePoint = 1;
404
                ViewerDataModel.Instance.PageBalanceNumber = 0;
405
            }
406

    
407
            if (pageNavigator.PageCount < BalancePoint)
408
            {
409
                BalancePoint = pageNavigator.PageCount;
410
                ViewerDataModel.Instance.PageBalanceNumber = 0;
411
            }
412
            */
413

    
414
            string uri = "";
415
            if (userData.COMPANY != "EXT")
416
            {
417
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, PageNumber);
418
            }
419
            else
420
            {
421
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, PageNumber);
422
            }
423

    
424
            var defaultBitmapImage = new BitmapImage();
425
            defaultBitmapImage.BeginInit();
426
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
427
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
428
            defaultBitmapImage.UriSource = new Uri(uri);
429
            defaultBitmapImage.EndInit();
430

    
431
            ViewerDataModel.Instance.ImageViewPath = null;
432
            GC.Collect();
433

    
434
            if (defaultBitmapImage.IsDownloading)
435
            {
436
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
437
                {
438
                    defaultBitmapImage.Freeze();
439
                    mainPanel.UpdateLayout();
440
                    GC.Collect();
441
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
442
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
443
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
444
                };
445
            }
446

    
447
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
448
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
449

    
450

    
451
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
452
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
453
            inkBoard.Width = zoomAndPanCanvas.Width;
454
            inkBoard.Height = zoomAndPanCanvas.Height;
455

    
456

    
457
            if (!testPanel2.IsHidden)
458
            {
459
                //PDF모드일때 잠시 대기(강인구)
460
                if (IsSyncPDFMode)
461
                {
462
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
463
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
464

    
465
                    if (pdfpath.IsDownloading)
466
                    {
467
                        pdfpath.DownloadCompleted += (ex, arg) =>
468
                        {
469
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
470
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
471
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
472
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
473
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
474
                        };
475
                    }
476
                    else
477
                    {
478
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
479
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
480
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
481

    
482
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
483
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
484
                    }
485
                }
486
                else
487
                {
488
                    string uri2 = "";
489
                    if (userData.COMPANY != "EXT")
490
                    {
491
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
492
                    }
493
                    else
494
                    {
495
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
496
                    }
497

    
498

    
499
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
500

    
501
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
502
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
503
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
504
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
505
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
506

    
507
                    zoomAndPanControl.ZoomTo(new Rect
508
                    {
509
                        X = 0,
510
                        Y = 0,
511
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
512
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
513
                    });
514

    
515
                    if (defaultBitmapImage_Compare.IsDownloading)
516
                    {
517
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
518
                        {
519

    
520
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
521
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
522
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
523

    
524
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
525
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
526

    
527
                            zoomAndPanControl.ZoomTo(new Rect
528
                            {
529
                                X = 0,
530
                                Y = 0,
531
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
532
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
533
                            });
534
                        };
535
                    }
536
                }
537
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
538
            }
539

    
540
            this.pageNavigator.SetNextPage();
541

    
542

    
543

    
544
        }
545

    
546

    
547
        public void ReleaseAdorner()
548
        {
549
            if (SelectLayer.Children.Count > 0)
550
            {
551
                foreach (var item in SelectLayer.Children)
552
                {
553
                    if (item.GetType().Name == "AdornerFinal")
554
                    {
555
                        (item as AdornerFinal).unRegister();
556

    
557
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
558
                        {
559
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
560
                            {
561
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
562
                                {
563
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
564
                                    {
565
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
566
                                    }
567
                                }
568

    
569
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
570
                            }
571
                        }
572
                    }
573
                }
574
                SelectLayer.Children.Clear();
575
            }
576
        }
577

    
578
        public List<CommentUserInfo> AddAdorner()
579
        {
580
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
581

    
582
            if (SelectLayer.Children.Count > 0)
583
            {
584
                foreach (var item in SelectLayer.Children)
585
                {
586
                    if (item.GetType().Name == "AdornerFinal")
587
                    {
588
                        (item as AdornerFinal).unRegister();
589

    
590
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
591
                        {
592
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
593
                            {
594
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
595
                            }
596

    
597
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
598

    
599
                            UndoData.Markup_List.Add(multi_Undo_Data);
600
                            multi_Undo_Data = new Multi_Undo_data();
601
                        }
602
                    }
603
                }
604
                SelectLayer.Children.Clear();
605
            }
606
            return adornerSet;
607
        }
608

    
609
        public void ChangeCommentReact()
610
        {
611
            bool isComingNewBie = false;
612

    
613
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
614
            {
615
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
616
                {
617
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
618

    
619
                   
620
                        var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
621
                        if (existItem != null) //신규 추가 된 코멘트
622
                        {
623
                            if (existItem.Data != root.ConvertData) //코멘트가 같은지
624
                            {
625
                                existItem.Data = root.ConvertData;
626
                                existItem.IsUpdate = true;
627
                            }
628
                        }
629
                        else
630
                        {
631
                            if (root.CommentID != null)
632
                            {
633
                                isComingNewBie = true;
634
                                var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
635
                                if (currentCommentCheck != null)
636
                                {
637
                                    currentCommentCheck.Data = root.ConvertData;
638
                                }
639
                                else
640
                                {
641
                                    ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
642
                                    {
643
                                        ID = control.CommentID,
644
                                        Data = root.ConvertData,
645
                                        Data_Type = root.DATA_TYPE,
646
                                        MarkupInfoID = App.Custom_ViewInfoId,
647
                                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
648
                                    });
649
                                }
650
                            }
651
                        }
652
                    
653

    
654
                    
655
                }
656
            }
657

    
658
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
659
            {
660
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
661
                {
662
                    ComingNewBieEnd = true;
663
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
664
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
665
                    gridViewMarkup.ItemsSource = null;
666
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
667
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
668
                }
669
            }
670

    
671
        }
672

    
673
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
674
        bool ComingNewBieEnd = false;
675

    
676
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
677
        {            
678
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
679
            {   
680
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
681
            }
682

    
683
            ViewerDataModel.Instance.UndoDataList.Clear();
684

    
685
            InkControl_Convert();
686

    
687
            ReleaseAdorner();
688
            ChangeCommentReact();
689
            CompareMode.IsChecked = false;
690
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
691

    
692

    
693
            #region 페이지가 벗어난 경우
694

    
695
            if (BalancePoint < 1)
696
            {
697
                BalancePoint = 1;
698
                ViewerDataModel.Instance.PageBalanceNumber = 0;
699
            }
700

    
701
            if (pageNavigator.PageCount < BalancePoint)
702
            {
703
                BalancePoint = pageNavigator.PageCount;
704
                ViewerDataModel.Instance.PageBalanceNumber = 0;
705
            }
706

    
707
            #endregion
708

    
709
            ViewerDataModel.Instance.PageNumber = BalancePoint;
710

    
711
            string uri = "";
712
            if (userData.COMPANY != "EXT")
713
            {
714
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
715
            }
716
            else
717
            {
718
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
719
            }
720

    
721
            var defaultBitmapImage = new BitmapImage();
722
            defaultBitmapImage.BeginInit();
723
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
724
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
725
            defaultBitmapImage.UriSource = new Uri(uri);
726
            defaultBitmapImage.EndInit();
727

    
728
            ViewerDataModel.Instance.ImageViewPath = null;
729
            GC.Collect();            
730

    
731
            if (defaultBitmapImage.IsDownloading)
732
            {
733
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
734
                {
735
                    defaultBitmapImage.Freeze();
736
                    mainPanel.UpdateLayout();
737
                    GC.Collect();                    
738
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
739
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
740
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
741
                };
742
            }
743

    
744
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
745
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
746

    
747

    
748
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
749
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
750
            inkBoard.Width = zoomAndPanCanvas.Width;
751
            inkBoard.Height = zoomAndPanCanvas.Height;
752

    
753

    
754
            if (!testPanel2.IsHidden)
755
            {
756
                //PDF모드일때 잠시 대기(강인구)
757
                if (IsSyncPDFMode)
758
                {
759
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
760
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
761

    
762
                    if (pdfpath.IsDownloading)
763
                    {
764
                        pdfpath.DownloadCompleted += (ex, arg) =>
765
                        {
766
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
767
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
768
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
769
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
770
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
771
                        };
772
                    }
773
                    else
774
                    {
775
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
776
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
777
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
778

    
779
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
780
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
781
                    }
782
                }
783
                else
784
                {
785
                    string uri2 = "";
786
                    if (userData.COMPANY != "EXT")
787
                    {
788
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
789
                    }
790
                    else
791
                    {
792
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
793
                    }
794

    
795

    
796
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
797

    
798
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
799
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
800
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
801
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
802
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
803

    
804
                    zoomAndPanControl.ZoomTo(new Rect
805
                    {
806
                        X = 0,
807
                        Y = 0,
808
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
809
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
810
                    });
811

    
812
                    if (defaultBitmapImage_Compare.IsDownloading)
813
                    {
814
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
815
                        {
816

    
817
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
818
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
819
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
820

    
821
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
822
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
823

    
824
                            zoomAndPanControl.ZoomTo(new Rect
825
                            {
826
                                X = 0,
827
                                Y = 0,
828
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
829
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
830
                            });
831
                        };
832
                    }
833
                }
834
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
835
            }
836

    
837
            this.pageNavigator.SetNextPage();
838

    
839
            if (zoomAndPanCanvas2.Width.IsNaN())
840
            {
841
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
842
            }
843

    
844
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
845
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
846

    
847
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
848
 
849
            foreach (var item in gridSelectionItem)
850
            {
851
                if (item.UserID == App.ViewInfo.UserID)
852
                {
853
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
854
                    {
855
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
856
                    });
857
                }
858
                else
859
                {
860
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
861
                    {
862
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
863
                    });
864
                }
865
            }
866

    
867
            if (!testPanel2.IsHidden)
868
            {
869
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
870
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
871
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
872

    
873
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
874
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
875

    
876

    
877
                foreach (var item in gridSelectionRevItem)
878
                {
879
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
880
                    {
881
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
882
                    });
883
                }
884

    
885
            }
886

    
887
            var instanceMain = this.ParentOfType<MainWindow>();
888
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
889
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
890

    
891
            //강인구 추가
892
            instanceMain.dzTopMenu.rotateOffSet = 0;
893
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
894
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
895

    
896
            //}
897
            SetCommentPages(true);
898
        }
899

    
900
        private void SetCommentPages(bool onlyMe = false)
901
        {
902

    
903
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
904
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
905
            {
906
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
907
                instance.UserName = item.UserName;
908
                instance.Depart = item.Depatment;
909
                instance.MarkupInfoID = item.MarkupInfoID;
910
                instance.IsSelected = true;
911
                instance.isConSolidation = item.Consolidate;
912
                instance.SetColor = item.DisplayColor;
913
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
914
                {
915
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
916
                }
917
                else
918
                {
919
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
920
                }
921
                _pages.Add(instance);
922
            }
923
            this.pageNavigator.SetCommentList(_pages.ToList());
924
        }
925

    
926
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
927
        {
928
            if (e.MiddleButton == MouseButtonState.Pressed)
929
            {
930

    
931
            }
932
            e.Handled = true;
933
            if (e.Delta > 0)
934
            {
935
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
936
                ZoomIn(currentContentMousePoint);
937
            }
938
            else
939
            {
940
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
941
                ZoomOut(currentContentMousePoint);
942
            }
943
        }
944

    
945
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
946
        {
947
            e.Handled = true;
948
            if (e.Delta > 0)
949
            {
950
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
951
                ZoomIn_Sync(currentContentMousePoint);
952
            }
953
            else
954
            {
955
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
956
                ZoomOut_Sync(currentContentMousePoint);
957
            }
958
        }
959

    
960
        #region ZoomIn & ZoomOut
961

    
962
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
963
        {
964
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
965
                zoomAndPanControl.ContentZoomFocusY));
966
        }
967

    
968
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
969
        {
970
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
971
                zoomAndPanControl.ContentZoomFocusY));
972
        }
973

    
974

    
975
        //강인구 추가 (줌 인아웃 수치 변경)
976
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
977
        private void ZoomOut(Point contentZoomCenter)
978
        {
979
            if (zoomAndPanControl.ContentScale > 0.39)
980
            {
981
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
982
            }
983
            else
984
            {
985
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
986
            }
987

    
988
            if (zoomAndPanControl2 != null && Sync.IsChecked)
989
            {
990
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
991
            }
992
        }
993

    
994
        private void ZoomIn(Point contentZoomCenter)
995
        {
996
            if (zoomAndPanControl.ContentScale > 0.19)
997
            {
998
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
999
            }
1000
            else
1001
            {
1002
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1003
            }
1004

    
1005
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1006
            {
1007
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1008
            }
1009

    
1010
        }
1011

    
1012
        private void ZoomOut_Sync(Point contentZoomCenter)
1013
        {
1014
            if (zoomAndPanControl2.ContentScale > 0.39)
1015
            {
1016
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1017
            }
1018
            else
1019
            {
1020
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1021
            }
1022

    
1023
            if (Sync.IsChecked)
1024
            {
1025
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1026
            }
1027
        }
1028

    
1029
        private void ZoomIn_Sync(Point contentZoomCenter)
1030
        {
1031
            if (zoomAndPanControl2.ContentScale > 0.19)
1032
            {
1033
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1034
            }
1035
            else
1036
            {
1037
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1038
            }
1039

    
1040
            if (Sync.IsChecked)
1041
            {
1042
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1043
            }
1044
        }
1045

    
1046
        private void ZoomOut()
1047
        {
1048
            zoomAndPanControl.ContentScale -= 0.1;
1049
            //if (zoomAndPanControl2 != null)
1050
            //{
1051
            //    zoomAndPanControl2.ContentScale -= 0.1;
1052
            //}
1053
        }
1054

    
1055
        private void ZoomIn()
1056
        {
1057
            zoomAndPanControl.ContentScale += 0.1;
1058
            //if (zoomAndPanControl2 != null)
1059
            //{
1060
            //    zoomAndPanControl2.ContentScale += 0.1;
1061
            //}
1062
        }
1063

    
1064
        #endregion
1065

    
1066
        private void init()
1067
        {
1068
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1069
            {
1070

    
1071
                ControlList.Clear();
1072
                listBox.Items.Clear();
1073
                selected_item.Clear();
1074

    
1075
                (item as IMarkupCommonData).IsSelected = false;
1076
            }
1077

    
1078
        }
1079

    
1080
        private HitTestResultBehavior MyCallback(HitTestResult result)
1081
        {
1082
            //this.cursor = Cursors.UpArrow;
1083
            var element = result.VisualHit;
1084
            while (element != null && !(element is CommentUserInfo))
1085
                element = VisualTreeHelper.GetParent(element);
1086

    
1087
            if (element == null)
1088
            {
1089
                return HitTestResultBehavior.Stop;
1090
            }
1091
            else
1092
            {
1093
                if (element is CommentUserInfo)
1094
                {
1095
                    if (!hitList.Contains(element))
1096
                    {
1097
                        hitList.Add((CommentUserInfo)element);
1098
                    }
1099
                    else
1100
                    {
1101
                        return HitTestResultBehavior.Stop;
1102
                    }
1103
                    //IntersectionDetail intersectionDetail =
1104
                    //((GeometryHitTestResult)result).IntersectionDetail;
1105
                    //switch (intersectionDetail)
1106
                    //{
1107
                    //    case IntersectionDetail.FullyContains:
1108
                    //        // Add the hit test result to the list:
1109
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
1110
                    //        return HitTestResultBehavior.Continue;
1111
                    //    case IntersectionDetail.Intersects:
1112
                    //        // Set the behavior to return visuals at all z-order levels:
1113
                    //        return HitTestResultBehavior.Continue;
1114
                    //    case IntersectionDetail.FullyInside:
1115
                    //        // Set the behavior to return visuals at all z-order levels:
1116
                    //        return HitTestResultBehavior.Continue;
1117
                    //    default:
1118
                    //        return HitTestResultBehavior.Stop;
1119
                    //}
1120
                }
1121
            }
1122
            return HitTestResultBehavior.Continue;
1123
        }
1124

    
1125
        public void ReleaseSelectPath()
1126
        {
1127
            if (SelectionPath == null)
1128
            {
1129
                SelectionPath = new Path();
1130
                SelectionPath.Name = "";
1131
            }
1132
            if (SelectionPath.Name != "")
1133
            {
1134
                SelectionPath.Name = "None";
1135
            }
1136
            SelectionPath.Opacity = 0.01;
1137
            SelectionPath.RenderTransform = null;
1138
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1139
        }
1140

    
1141
        #region 컨트롤 초기화 
1142
        public void Control_Init(object control)
1143
        {
1144
            if (L_Size != 0 && (control as IPath) != null)
1145
            {
1146
                (control as IPath).LineSize = L_Size;
1147
                L_Size = 0;
1148
            }
1149

    
1150
            switch (control.GetType().Name)
1151
            {
1152
                case "RectangleControl":
1153
                    {
1154
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1155
                    }
1156
                    break;
1157
                case "CircleControl":
1158
                    {
1159
                        (control as CircleControl).StrokeColor = Brushes.Red;
1160
                    }
1161
                    break;
1162
                case "TriControl":
1163
                    {
1164
                        (control as TriControl).StrokeColor = Brushes.Red;
1165
                    }
1166
                    break;
1167
                case "RectCloudControl":
1168
                    {
1169
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1170
                    }
1171
                    break;
1172
                case "CloudControl":
1173
                    {
1174
                        (control as CloudControl).StrokeColor = Brushes.Red;
1175
                    }
1176
                    break;
1177
                case "PolygonControl":
1178
                    {
1179
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1180
                    }
1181
                    break;
1182
                case "ArcControl":
1183
                    {
1184
                        (control as ArcControl).StrokeColor = Brushes.Red;
1185
                    }
1186
                    break;
1187
                case "LineControl":
1188
                    {
1189
                        (control as LineControl).StrokeColor = Brushes.Red;
1190
                    }
1191
                    break;
1192
                case "ArrowControl_Multi":
1193
                    {
1194
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1195
                    }
1196
                    break;
1197
                case "TextControl":
1198
                    {
1199
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1200
                    }
1201
                    break;
1202
                case "ArrowTextControl":
1203
                    {
1204
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1205
                    }
1206
                    break;
1207
            }
1208
        }
1209
        #endregion
1210

    
1211
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1212
        {
1213
            //Control_Init(e.Source);
1214
        }
1215

    
1216
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1217
        {
1218
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1219
            {
1220
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1221

    
1222
                Point currentPos = e.GetPosition(rect);
1223
                
1224
                floatingTip.HorizontalOffset = currentPos.X + 20;
1225
                floatingTip.VerticalOffset = currentPos.Y;
1226

    
1227

    
1228
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1229
                //tool.Content = "ToolTip";
1230
                //panel.ToolTip = tool;
1231
            }
1232

    
1233
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1234
            {
1235
                #region 마우스 오버 시 색상 변경
1236
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1237
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1238

    
1239
                //if (firstCondition != null)
1240
                //{
1241
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1242

    
1243
                //    if (firstCondition.GetType().Name == "TextControl")
1244
                //    {
1245
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1246
                //        return;
1247
                //    }
1248
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1249
                //    {
1250
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1251
                //        return;
1252
                //    }
1253

    
1254
                //    if (L_Size == 0)
1255
                //    {
1256
                //        L_Size = (firstCondition as IPath).LineSize;
1257
                //        (firstCondition as IPath).LineSize *= 4;
1258
                //    }
1259
                //    switch (firstCondition.GetType().Name)
1260
                //    {
1261
                //        case "RectangleControl":
1262
                //            {
1263
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1264
                //            }
1265
                //            break;
1266
                //        case "CircleControl":
1267
                //            {
1268
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1269
                //            }
1270
                //            break;
1271
                //        case "TriControl":
1272
                //            {
1273
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1274
                //            }
1275
                //            break;
1276
                //        case "RectCloudControl":
1277
                //            {
1278
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1279
                //            }
1280
                //            break;
1281
                //        case "CloudControl":
1282
                //            {
1283
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1284
                //            }
1285
                //            break;
1286
                //        case "PolygonControl":
1287
                //            {
1288
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1289
                //            }
1290
                //            break;
1291
                //        case "ArcControl":
1292
                //            {
1293
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1294
                //            }
1295
                //            break;
1296
                //        case "LineControl":
1297
                //            {
1298
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1299
                //            }
1300
                //            break;
1301
                //        case "ArrowControl_Multi":
1302
                //            {
1303
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1304
                //            }
1305
                //            break;
1306

    
1307
                //        default:
1308
                //            {
1309

    
1310
                //            }
1311
                //            break;
1312
                //    }
1313
                //} 
1314
                #endregion
1315
            }
1316

    
1317
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1318

    
1319
            //if (mouseButtonDown == MouseButton.Middle)
1320
            //{
1321
            //    SetCursor();
1322
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1323
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1324

    
1325
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1326
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1327
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1328

    
1329
            //    //SetCursor();
1330
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1331
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1332

    
1333
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1334

    
1335
            //    //zoomAndPanControl.ContentOffsetX += 1;
1336
            //    //zoomAndPanControl.ContentOffsetY += 1;
1337

    
1338
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1339
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1340
            //}
1341
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1342
            {
1343
                SetCursor();
1344
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1345
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1346

    
1347
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1348
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1349
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1350

    
1351
                if (Sync.IsChecked)
1352
                {
1353
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1354
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1355
                }
1356
            }
1357

    
1358

    
1359
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1360
            {
1361
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1362
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1363
                SetCursor();
1364

    
1365
                if (IsDrawing)
1366
                {
1367
                    if (currentControl == null)
1368
                    {
1369
                        switch (controlType)
1370
                        {
1371
                            case ControlType.PenControl:
1372
                                {
1373
                                    if (inkBoard.Tag.ToString() == "Ink")
1374
                                    {
1375
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1376
                                    }
1377
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1378
                                    {
1379
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1380
                                    }
1381
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1382
                                    {
1383
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1384
                                    }
1385

    
1386
                                    //inkBoard.Strokes.Add(stroke);
1387
                                }
1388
                                break;
1389
                        }
1390
                        return;
1391
                    }
1392
                }
1393

    
1394
                if (currentControl != null)
1395
                {
1396
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1397
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1398
                    //강인구 추가
1399
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1400

    
1401
                    if ((currentControl as IPath) != null)
1402
                    {
1403
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1404
                    }
1405
                    if ((currentControl as LineControl) != null)
1406
                    {
1407
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1408
                    }
1409

    
1410
                    if ((currentControl as IShapeControl) != null)
1411
                    {
1412
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1413
                    }
1414
                    if ((currentControl as TextControl) != null)
1415
                    {
1416
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1417
                        {
1418
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1419
                        }
1420
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1421
                        {
1422
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1423
                        }
1424
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1425
                        {
1426
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1427
                        }
1428
                    }
1429
                    else if ((currentControl as ArrowTextControl) != null)
1430
                    {
1431
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1432
                        {
1433
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1434
                        }
1435
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1436
                        {
1437
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1438
                        }
1439
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1440
                        {
1441
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1442
                        }
1443
                    }
1444
                    else if ((currentControl as RectCloudControl) != null)
1445
                    {
1446
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1447
                    }
1448
                    else if ((currentControl as CloudControl) != null)
1449
                    {
1450
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1451
                    }
1452

    
1453
                    switch (controlType)
1454
                    {
1455
                        case ControlType.Rectangle:
1456
                            {
1457
                                var control = currentControl as RectangleControl;
1458

    
1459
                                if (control != null)
1460
                                {
1461
                                    if (move.mousemode == MouseMode.Drawing)
1462
                                    {
1463
                                        //move.control_Move(ControlList, true, moveX, moveY);
1464
                                    }
1465
                                    else
1466
                                    {
1467
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1468
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1469
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1470
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1471

    
1472

    
1473
                                        if (ViewerDataModel.Instance.IsPressShift)
1474
                                        {
1475
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1476
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1477
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1478
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1479
                                        }
1480

    
1481
                                        control.PointSet = new List<Point>
1482
                                        {
1483
                                            control.StartPoint,
1484
                                            control.LeftBottomPoint,
1485
                                            control.EndPoint,
1486
                                            control.TopRightPoint,
1487
                                        };
1488
                                        control.updateControl();
1489
                                    }
1490

    
1491
                                    //강인구 추가
1492
                                    control.ControlType = controlType;
1493
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1494
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1495
                                }
1496
                            }
1497
                            break;
1498

    
1499
                        case ControlType.RectCloud:
1500
                            {
1501
                                var control = currentControl as RectCloudControl;
1502

    
1503
                                if (control != null)
1504
                                {
1505
                                    if (move.mousemode == MouseMode.Drawing)
1506
                                    {
1507
                                        //move.control_Move(ControlList, true, moveX, moveY);
1508
                                    }
1509
                                    else
1510
                                    {
1511
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1512
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1513
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1514
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1515

    
1516
                                        if (ViewerDataModel.Instance.IsPressShift)
1517
                                        {
1518
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1519
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1520
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1521
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1522
                                        }
1523

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

    
1539
                        case ControlType.SingleLine:
1540
                            {
1541
                                if (currentControl != null)
1542
                                {
1543
                                    var control = currentControl as LineControl;
1544
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1545
                                    control.ControlType = controlType;
1546
                                    if (control != null)
1547
                                    {
1548
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
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
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1555
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1556
                                            control.EndPoint = tempPoint;
1557
                                        }
1558
                                        else
1559
                                        {
1560
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1561
                                        }
1562

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

    
1573
                            }
1574
                            break;
1575

    
1576
                        case ControlType.CancelLine:
1577
                            {
1578
                                if (currentControl != null)
1579
                                {
1580
                                    var control = currentControl as LineControl;
1581
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1582
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1583
                                    control.ControlType = controlType;
1584
                                    if (control != null)
1585
                                    {
1586
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1587
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1588
                                        Point tempPoint = control.EndPoint;
1589

    
1590
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1591
                                        {
1592
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1593
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1594
                                            control.EndPoint = tempPoint;
1595
                                        }
1596
                                        else
1597
                                        {
1598
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1599
                                        }
1600

    
1601

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

    
1614
                        case ControlType.ArrowLine:
1615
                            {
1616
                                if (currentControl != null)
1617
                                {
1618
                                    var control = currentControl as LineControl;
1619
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1620
                                    control.ControlType = controlType;
1621
                                    if (control != null)
1622
                                    {
1623
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1624
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1625
                                        Point tempPoint = control.EndPoint;
1626

    
1627
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1628
                                        {
1629
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1630
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1631
                                            control.EndPoint = tempPoint;
1632
                                        }
1633
                                        else
1634
                                        {
1635
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1636
                                        }
1637

    
1638

    
1639
                                        control.PointSet = new List<Point>
1640
                                            {
1641
                                                control.StartPoint,
1642
                                                control.EndPoint,
1643
                                            };
1644
                                    }
1645
                                    //강인구 추가
1646
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1647
                                }
1648

    
1649
                            }
1650
                            break;
1651

    
1652
                        case ControlType.TwinLine:
1653
                            {
1654
                                if (currentControl != null)
1655
                                {
1656
                                    var control = currentControl as LineControl;
1657
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1658
                                    control.ControlType = controlType;
1659
                                    if (control != null)
1660
                                    {
1661
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1662
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1663
                                        Point tempPoint = control.EndPoint;
1664

    
1665
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1666
                                        {
1667
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1668
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1669
                                            control.EndPoint = tempPoint;
1670
                                        }
1671
                                        else
1672
                                        {
1673
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1674
                                        }
1675

    
1676

    
1677
                                        control.PointSet = new List<Point>
1678
                                            {
1679
                                                control.StartPoint,
1680
                                                control.EndPoint,
1681
                                            };
1682
                                    }
1683
                                    //강인구 추가
1684
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1685
                                }
1686

    
1687
                            }
1688
                            break;
1689

    
1690
                        case ControlType.DimLine:
1691
                            {
1692
                                if (currentControl != null)
1693
                                {
1694
                                    var control = currentControl as LineControl;
1695
                                    control.LineStyleSet = LineStyleSet.DimLine;
1696
                                    control.ControlType = controlType;
1697
                                    if (control != null)
1698
                                    {
1699
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1700
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1701
                                        Point tempPoint = control.EndPoint;
1702

    
1703
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1704
                                        {
1705
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1706
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1707
                                            control.EndPoint = tempPoint;
1708
                                        }
1709
                                        else
1710
                                        {
1711
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1712
                                        }
1713

    
1714
                                        control.PointSet = new List<Point>
1715
                                            {
1716
                                                control.StartPoint,
1717
                                                control.EndPoint,
1718
                                            };
1719
                                    }
1720
                                    //강인구 추가
1721
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1722
                                }
1723

    
1724
                            }
1725
                            break;
1726

    
1727
                        case ControlType.ChainLine:
1728
                            {
1729
                                var control = currentControl as PolygonControl;
1730

    
1731
                                if (control != null)
1732
                                {
1733

    
1734
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1735
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1736

    
1737
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1738

    
1739
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1740
                                    {
1741
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1742
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1743
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1744
                                        //control.EndPoint = tempPoint;
1745
                                    }
1746
                                    else
1747
                                    {
1748
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1749
                                    }
1750

    
1751
                                    control.SetPolyPath();
1752
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1753
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1754
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1755

    
1756
                                    //강인구 추가
1757
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1758
                                }
1759
                            }
1760
                            break;
1761

    
1762
                        case ControlType.ArcLine:
1763
                            {
1764
                                if (currentControl != null)
1765
                                {
1766
                                    var control = currentControl as ArcControl;
1767
                                    control.isTransOn = false;
1768
                                    control.ControlType = controlType;
1769

    
1770
                                    if (control != null)
1771
                                    {
1772
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1773
                                        control.MidPoint = new Point(0, 0);
1774
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1775
                                        Point tempPoint = control.EndPoint;
1776

    
1777
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1778
                                        {
1779
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1780
                                            control.EndPoint = tempPoint;
1781
                                        }
1782
                                        else
1783
                                        {
1784
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1785
                                        }
1786

    
1787

    
1788
                                        control.PointSet = new List<Point>
1789
                                            {
1790
                                                control.StartPoint,
1791
                                                control.MidPoint,
1792
                                                control.EndPoint,
1793
                                            };
1794
                                    }
1795
                                    //강인구 추가
1796
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1797
                                }
1798

    
1799
                            }
1800
                            break;
1801

    
1802
                        case ControlType.ArcArrow:
1803
                            {
1804
                                if (currentControl != null)
1805
                                {
1806
                                    var control = currentControl as ArcControl;
1807
                                    control.isTransOn = true;
1808
                                    control.ControlType = controlType;
1809

    
1810
                                    if (control != null)
1811
                                    {
1812
                                        if (move.mousemode == MouseMode.Drawing)
1813
                                        {
1814
                                            //move.control_Move(ControlList, true, moveX, moveY);
1815
                                        }
1816
                                        else
1817
                                        {
1818
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1819
                                            control.MidPoint = new Point(0, 0);
1820
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1821
                                        }
1822

    
1823
                                        control.PointSet = new List<Point>
1824
                                            {
1825
                                                control.StartPoint,
1826
                                                control.MidPoint,
1827
                                                control.EndPoint,
1828
                                            };
1829
                                    }
1830
                                    //강인구 추가
1831
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1832
                                }
1833
                            }
1834
                            break;
1835

    
1836
                        case ControlType.ArrowMultiLine:
1837
                            {
1838
                                if (currentControl != null)
1839
                                {
1840
                                    var control = currentControl as ArrowControl_Multi;
1841

    
1842
                                    if (control != null)
1843
                                    {
1844
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1845
                                        Point tempPoint = control.EndPoint;
1846
                                        if (control.MiddlePoint == new Point(0, 0))
1847
                                        {
1848
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1849
                                            {
1850
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1851
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1852
                                                control.EndPoint = tempPoint;
1853
                                            }
1854
                                            else
1855
                                            {
1856
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1857
                                            }
1858
                                        }
1859
                                        else
1860
                                        {
1861
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1862
                                            {
1863
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1864
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1865
                                                control.EndPoint = tempPoint;
1866
                                            }
1867
                                            else
1868
                                            {
1869
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1870
                                            }
1871

    
1872
                                        }
1873

    
1874
                                        control.PointSet = new List<Point>
1875
                                            {
1876
                                                control.StartPoint,
1877
                                                control.MiddlePoint,
1878
                                                control.EndPoint,
1879
                                            };
1880

    
1881
                                    }
1882
                                    //강인구 추가
1883
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1884
                                }
1885

    
1886
                            }
1887
                            break;
1888

    
1889
                        case ControlType.Circle:
1890
                            {
1891
                                var control = currentControl as CircleControl;
1892

    
1893
                                if (control != null)
1894
                                {
1895
                                    if (move.mousemode == MouseMode.Drawing)
1896
                                    {
1897
                                        //move.control_Move(ControlList, true, moveX, moveY);
1898
                                    }
1899
                                    else
1900
                                    {
1901
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1902
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1903
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1904
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1905

    
1906
                                        if (ViewerDataModel.Instance.IsPressShift)
1907
                                        {
1908
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1909
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1910
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1911
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1912
                                        }
1913

    
1914
                                        control.PointSet = new List<Point>
1915
                                        {
1916
                                            control.StartPoint,
1917
                                            control.LeftBottomPoint,
1918
                                            control.EndPoint,
1919
                                            control.TopRightPoint,
1920
                                        };
1921
                                    }
1922
                                    //강인구 추가
1923
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1924
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1925

    
1926
                                }
1927
                            }
1928
                            break;
1929

    
1930
                        case ControlType.PolygonCloud:
1931
                            {
1932
                                var control = currentControl as CloudControl;
1933

    
1934
                                if (control != null)
1935
                                {
1936
                                    control.isTransOn = true;
1937
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1938

    
1939
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1940

    
1941
                                    control.SetCloud();
1942
                                    //강인구 추가
1943
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1944
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1945
                                }
1946
                            }
1947
                            break;
1948

    
1949
                        case ControlType.Triangle:
1950
                            {
1951
                                var control = currentControl as TriControl;
1952

    
1953
                                if (control != null)
1954
                                {
1955
                                    if (move.mousemode == MouseMode.Drawing)
1956
                                    {
1957
                                        //move.control_Move(ControlList, true, moveX, moveY);
1958
                                    }
1959
                                    else
1960
                                    {
1961
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1962
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1963

    
1964
                                        if (ViewerDataModel.Instance.checkAxis)
1965
                                        {
1966
                                            Point tempPoint = control.EndPoint;
1967
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1968
                                            control.EndPoint = tempPoint;
1969
                                        }
1970

    
1971

    
1972
                                        if (ViewerDataModel.Instance.IsPressShift)
1973
                                        {
1974
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1975
                                            if (2 == Points.Count())
1976
                                            {
1977
                                                control.MidPoint = Points[0];
1978
                                                control.EndPoint = Points[1];
1979
                                            }
1980
                                        }
1981

    
1982
                                        control.PointSet = new List<Point>
1983
                                            {
1984
                                                control.StartPoint,
1985
                                                control.MidPoint,
1986
                                                control.EndPoint,
1987
                                            };
1988
                                    }
1989
                                    //강인구 추가
1990
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1991
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1992
                                }
1993
                            }
1994
                            break;
1995

    
1996
                        case ControlType.ImgControl:
1997
                            {
1998
                                var control = currentControl as ImgControl;
1999

    
2000
                                if (control != null)
2001
                                {
2002
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2003
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2004
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2005
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2006

    
2007
                                    control.PointSet = new List<Point>
2008
                                        {
2009
                                            control.StartPoint,
2010
                                            control.LeftBottomPoint,
2011
                                            control.EndPoint,
2012
                                            control.TopRightPoint,
2013
                                        };
2014
                                }
2015
                            }
2016
                            break;
2017

    
2018
                        case ControlType.Date:
2019
                            {
2020
                                var control = currentControl as DateControl;
2021

    
2022
                                if (control != null)
2023
                                {
2024
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2025
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2026
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2027
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2028
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2029

    
2030
                                    control.PointSet = new List<Point>
2031
                                        {
2032
                                            control.StartPoint,
2033
                                            control.LeftBottomPoint,
2034
                                            control.EndPoint,
2035
                                            control.TopRightPoint,
2036
                                        };
2037
                                }
2038
                            }
2039
                            break;
2040

    
2041
                        case ControlType.ArrowTextControl:
2042
                            {
2043
                                var control = currentControl as ArrowTextControl;
2044

    
2045
                                if (control != null)
2046
                                {
2047
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2048
                                    Point tempPoint = control.EndPoint;
2049

    
2050
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2051

    
2052
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2053
                                    {
2054
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2055
                                        control.EndPoint = tempPoint;
2056
                                    }
2057
                                    else
2058
                                    {
2059
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2060
                                    }
2061
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2062

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

    
2073
                        case ControlType.ArrowTransTextControl:
2074
                            {
2075
                                var control = currentControl as ArrowTextControl;
2076

    
2077
                                if (control != null)
2078
                                {
2079
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2080
                                    Point tempPoint = control.EndPoint;
2081
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2082

    
2083
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2084
                                    {
2085
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2086
                                        control.EndPoint = tempPoint;
2087
                                    }
2088
                                    else
2089
                                    {
2090
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2091
                                    }
2092
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2093
                                    control.isFixed = true;
2094

    
2095
                                    control.PointSet = new List<Point>
2096
                                            {
2097
                                                control.StartPoint,
2098
                                                control.MidPoint,
2099
                                                control.EndPoint,
2100
                                            };
2101
                                }
2102
                            }
2103
                            break;
2104

    
2105
                        case ControlType.ArrowTextBorderControl:
2106
                            {
2107
                                var control = currentControl as ArrowTextControl;
2108

    
2109
                                if (control != null)
2110
                                {
2111
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2112
                                    Point tempPoint = control.EndPoint;
2113
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2114
                                    {
2115
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2116
                                        control.EndPoint = tempPoint;
2117
                                    }
2118
                                    else
2119
                                    {
2120
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2121
                                    }
2122
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2123
                                    control.PointSet = new List<Point>
2124
                                            {
2125
                                                control.StartPoint,
2126
                                                control.MidPoint,
2127
                                                control.EndPoint,
2128
                                            };
2129
                                }
2130

    
2131
                            }
2132
                            break;
2133
                        case ControlType.ArrowTransTextBorderControl:
2134
                            {
2135
                                var control = currentControl as ArrowTextControl;
2136

    
2137
                                if (control != null)
2138
                                {
2139
                                    control.isFixed = true;
2140
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2141
                                    Point tempPoint = control.EndPoint;
2142
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2143
                                    {
2144
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2145
                                        control.EndPoint = tempPoint;
2146
                                    }
2147
                                    else
2148
                                    {
2149
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2150
                                    }
2151

    
2152
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2153
                                    control.PointSet = new List<Point>
2154
                                            {
2155
                                                control.StartPoint,
2156
                                                control.MidPoint,
2157
                                                control.EndPoint,
2158
                                            };
2159
                                }
2160

    
2161
                            }
2162
                            break;
2163
                        case ControlType.ArrowTextCloudControl:
2164
                            {
2165
                                var control = currentControl as ArrowTextControl;
2166

    
2167
                                if (control != null)
2168
                                {
2169
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2170
                                    Point tempPoint = control.EndPoint;
2171
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2172
                                    {
2173
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2174
                                        control.EndPoint = tempPoint;
2175
                                    }
2176
                                    else
2177
                                    {
2178
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2179
                                    }
2180
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2181
                                    control.PointSet = new List<Point>
2182
                                            {
2183
                                                control.StartPoint,
2184
                                                control.MidPoint,
2185
                                                control.EndPoint,
2186
                                            };
2187
                                }
2188

    
2189
                            }
2190
                            break;
2191
                        case ControlType.ArrowTransTextCloudControl:
2192
                            {
2193
                                var control = currentControl as ArrowTextControl;
2194

    
2195
                                if (control != null)
2196
                                {
2197
                                    control.isFixed = true;
2198
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2199
                                    Point tempPoint = control.EndPoint;
2200
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2201
                                    {
2202
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2203
                                        control.EndPoint = tempPoint;
2204
                                    }
2205
                                    else
2206
                                    {
2207
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2208
                                    }
2209
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2210
                                    control.PointSet = new List<Point>
2211
                                            {
2212
                                                control.StartPoint,
2213
                                                control.MidPoint,
2214
                                                control.EndPoint,
2215
                                            };
2216
                                }
2217

    
2218
                            }
2219
                            break;
2220
                        case ControlType.PolygonControl:
2221
                            {
2222

    
2223
                                var control = currentControl as PolygonControl;
2224

    
2225
                                if (control != null)
2226
                                {
2227
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2228
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2229
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2230
                                    control.SetPolyPath();
2231
                                    //강인구 추가
2232
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2233
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2234
                                }
2235
                            }
2236
                            break;
2237
                        //강인구 추가
2238
                        case ControlType.Sign:
2239
                            {
2240
                                var control = currentControl as SignControl;
2241

    
2242
                                if (control != null)
2243
                                {
2244
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2245
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2246
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2247
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2248

    
2249
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2250
                                    {
2251
                                        GetUserSign getUser = new GetUserSign();
2252
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2253
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2254
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2255
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2256
                                        stream.Position = 0;
2257
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2258
                                        BitmapImage returnImage = new BitmapImage();
2259
                                        returnImage.BeginInit();
2260
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2261
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2262
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2263
                                        returnImage.StreamSource = ms;
2264
                                        returnImage.EndInit();
2265
                                        stream.Close();
2266

    
2267
                                        control.SignImage = returnImage;
2268
                                    }
2269
                                    control.PointSet = new List<Point>
2270
                                        {
2271
                                            control.StartPoint,
2272
                                            control.LeftBottomPoint,
2273
                                            control.EndPoint,
2274
                                            control.TopRightPoint,
2275
                                        };
2276
                                }
2277
                            }
2278
                            break;
2279
                        //TODO: 강인구 추가
2280
                        case ControlType.Symbol:
2281
                            {
2282
                                var control = currentControl as SymControl;
2283

    
2284
                                if (control != null)
2285
                                {
2286
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2287
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2288
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2289
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2290
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2291
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2292

    
2293
                                    if (control.StartPoint != control.EndPoint)
2294
                                    {
2295
                                        if (control.PathData == null)
2296
                                        {
2297
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2298
                                            {
2299
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2300
                                            }
2301
                                        }
2302
                                    }
2303

    
2304
                                    control.PointSet = new List<Point>
2305
                                        {
2306
                                            control.StartPoint,
2307
                                            control.LeftBottomPoint,
2308
                                            control.EndPoint,
2309
                                            control.TopRightPoint,
2310
                                        };
2311
                                }
2312
                            }
2313
                            break;
2314
                        ///TODO: 
2315
                        case ControlType.Stamp:
2316
                            {
2317
                                var control = currentControl as SymControlN;
2318

    
2319
                                if (control != null)
2320
                                {
2321

    
2322
                                    if (control.StartPoint == control.EndPoint)
2323
                                    {
2324
                                        string appovalData = "";
2325

    
2326
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2327
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2328

    
2329

    
2330
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2331

    
2332
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2333
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2334
                                        writer.Write(xamlData);
2335
                                        writer.Flush();
2336
                                        stream.Position = 0;
2337

    
2338
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2339
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2340
                                        UIElement ob = obj as UIElement;
2341

    
2342
                                        //control.ApplyTemplate();
2343

    
2344
                                        control.SetViewBox();
2345
                                        control.PathXathData = App.SystemInfo.STAMP;
2346
                                        control.Base_ViewBox.Child = ob;
2347
                                    }
2348

    
2349
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2350
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2351
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2352
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2353
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2354

    
2355

    
2356
                                    control.PointSet = new List<Point>
2357
                                    {
2358
                                        control.StartPoint,
2359
                                        control.LeftBottomPoint,
2360
                                        control.EndPoint,
2361
                                        control.TopRightPoint,
2362
                                    };
2363
                                }
2364
                            }
2365
                            break;
2366
                        case ControlType.Mark:
2367
                            {
2368
                                var control = currentControl as RectangleControl;
2369

    
2370
                                if (control != null)
2371
                                {
2372
                                    if (move.mousemode == MouseMode.Drawing)
2373
                                    {
2374
                                        //move.control_Move(ControlList, true, moveX, moveY);
2375
                                    }
2376
                                    else
2377
                                    {
2378
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2379
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2380
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2381
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2382

    
2383

    
2384
                                        control.PointSet = new List<Point>
2385
                                    {
2386
                                        control.StartPoint,
2387
                                        control.LeftBottomPoint,
2388
                                        control.EndPoint,
2389
                                        control.TopRightPoint,
2390
                                    };
2391
                                    }
2392

    
2393
                                    //강인구 추가
2394
                                    control.Paint = PaintSet.Fill;
2395
                                }
2396
                            }
2397
                            break;
2398
                        case ControlType.PenControl:
2399
                            {
2400
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2401
                                //inkBoard.Strokes.Add(stroke);
2402
                            }
2403
                            break;
2404
                        default:
2405
                            break;
2406
                    }
2407
                }
2408
            }
2409
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2410
            {
2411
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2412

    
2413
                if (isDraggingSelectionRect)
2414
                {
2415
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2416

    
2417
                    e.Handled = true;
2418
                }
2419
                else if (isLeftMouseButtonDownOnWindow)
2420
                {
2421
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2422
                    double dragDistance = Math.Abs(dragDelta.Length);
2423

    
2424
                    if (dragDistance > DragThreshold)
2425
                    {
2426
                        isDraggingSelectionRect = true;
2427

    
2428
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2429
                    }
2430

    
2431
                    e.Handled = true;
2432
                }
2433

    
2434

    
2435
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2436
                {
2437
                    //SelectionPath = new Path();
2438
                    //PathFigure pathFigure = new PathFigure();
2439
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2440
                    //SelectionPath.Opacity = 0.5;
2441
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2442
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2443
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2444
                }
2445
                else
2446
                {
2447
                    //List<Stroke> removingStroke = new List<Stroke>();
2448
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2449
                    //StrokeCollection stC = new StrokeCollection();
2450
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2451
                    //{
2452
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2453
                    //    p1.Intersect(p2);
2454
                    //    if (p1.IsEmpty)
2455
                    //    {
2456

    
2457

    
2458
                    //        p1 = SelectionPath.Data.Bounds;
2459
                    //        bool intersectCheck = false;
2460
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2461
                    //        {
2462
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2463
                    //            p1.Intersect(p3);
2464
                    //            if (!p1.IsEmpty)
2465
                    //            {
2466
                    //                intersectCheck = true;
2467
                    //            }
2468
                    //        }
2469
                    //        if (intersectCheck)
2470
                    //        {
2471
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2472
                    //        }
2473

    
2474
                    //    }
2475
                    //    else
2476
                    //    {
2477
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2478
                    //    }
2479
                    //}
2480

    
2481
                    e.Handled = true;
2482
                }
2483
            }
2484
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2485
            {
2486
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2487
                if (control != null)
2488
                {
2489
                    this.cursor = Cursors.Hand;
2490
                    SetCursor();
2491
                }
2492
                else
2493
                {
2494
                    this.cursor = Cursors.Arrow;
2495
                    SetCursor();
2496
                }
2497
            }
2498
            else
2499
            {
2500
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2501

    
2502
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2503
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2504

    
2505
                //if (hitList.Count > 0)
2506
                //{
2507

    
2508
                //}
2509

    
2510
                #region 조건 설정 : firstCondition
2511
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2512
                //pnts = generalTransform.Transform(pnts);
2513
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2514
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2515
                //                               this.DeepLayer._BaseLayer).ToObservable()
2516
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2517
                //                      select kkk).FirstOrDefault();
2518

    
2519
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2520
                //if (canvas !=null)
2521
                //{
2522
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2523
                //    {
2524
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2525
                //        if (uiElement!=null)
2526
                //        {
2527
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2528
                //        }
2529
                //    }
2530
                //}
2531

    
2532
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2533
                //hitResultsList.Clear();
2534

    
2535
                #endregion
2536
            }
2537
        }
2538

    
2539
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2540
        {
2541
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2542
            {
2543
                SetCursor();
2544
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2545
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2546

    
2547
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2548

    
2549
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2550
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2551

    
2552
                if (Sync.IsChecked)
2553
                {
2554
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2555
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2556
                }
2557
            }
2558
        }
2559

    
2560
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2561

    
2562
        private EllipseGeometry hitArea = new EllipseGeometry();
2563

    
2564
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2565
        {
2566
            IsDrawing = false;
2567

    
2568
            if (mouseHandlingMode != MouseHandlingMode.None)
2569
            {
2570
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2571
                {
2572
                    this.cursor = Cursors.Arrow;
2573

    
2574
                    SetCursor();
2575

    
2576
                    switch (controlType)
2577
                    {
2578
                        case ControlType.None:
2579
                            break;
2580
                        case ControlType.Rectangle:
2581
                            {
2582

    
2583
                            }
2584
                            break;
2585
                        case ControlType.PenControl:
2586
                            {
2587

    
2588
                            }
2589
                            break;
2590
                        default:
2591
                            break;
2592
                    }
2593
                }
2594
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2595
                {
2596
                    if (isLeftMouseButtonDownOnWindow)
2597
                    {
2598
                        bool wasDragSelectionApplied = false;
2599

    
2600
                        if (isDraggingSelectionRect)
2601
                        {
2602
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2603
                            {
2604
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2605
                                mouseHandlingMode = MouseHandlingMode.None;
2606
                                Set_Capture();
2607

    
2608
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2609
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2610
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2611
                            }
2612
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2613
                            {
2614
                                ApplyDragSelectionRect();
2615
                            }
2616
                            else
2617
                            {
2618
                                double x = Canvas.GetLeft(dragZoomBorder);
2619
                                double y = Canvas.GetTop(dragZoomBorder);
2620
                                double width = dragZoomBorder.Width;
2621
                                double height = dragZoomBorder.Height;
2622
                                Rect dragRect = new Rect(x, y, width, height);
2623

    
2624
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2625

    
2626
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2627
                            }
2628

    
2629
                            isDraggingSelectionRect = false;
2630
                            e.Handled = true;
2631
                            wasDragSelectionApplied = true;
2632
                        }
2633

    
2634
                        if (isLeftMouseButtonDownOnWindow)
2635
                        {
2636
                            isLeftMouseButtonDownOnWindow = false;
2637
                            this.ReleaseMouseCapture();
2638
                            e.Handled = true;
2639
                        }
2640

    
2641
                        if (!wasDragSelectionApplied)
2642
                        {
2643
                            init();
2644
                        }
2645
                    }
2646
                }
2647
                else if (mouseButtonDown == MouseButton.Right)
2648
                {
2649
                    this.cursor = Cursors.Arrow;
2650
                    SetCursor();
2651
                }
2652

    
2653
                zoomAndPanControl.ReleaseMouseCapture();
2654

    
2655

    
2656
                e.Handled = true;
2657
            }
2658
            else
2659
            {
2660
                this.cursor = Cursors.Arrow;
2661
                SetCursor();
2662
            }
2663
            mouseButtonDown = MouseButton.Left;
2664

    
2665
            //controlType = ControlType.SingleLine;
2666
        }
2667

    
2668
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2669
        {
2670
            mouseButtonDown = MouseButton.Left;
2671
        }
2672

    
2673
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2674
        {
2675
            mouseButtonDown = MouseButton.Left;
2676
            this.Cursor = Cursors.Arrow;
2677
        }
2678

    
2679
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2680
        {
2681

    
2682
        }
2683

    
2684
        /// <summary>
2685
        /// select item which's bouding rectangle is equal to given rectangle
2686
        /// </summary>
2687
        /// <author>humkyung</author>
2688
        /// <date>2018.06.14</date>
2689
        /// <param name="rect"></param>
2690
        public void SelecteItemByRect(Rect rect)
2691
        {
2692
            multi_Undo_Data = new Multi_Undo_data();
2693

    
2694
            UndoData = new Undo_data()
2695
            {
2696
                IsUndo = false,
2697
                Event = Event_Type.Select,
2698
                EventTime = DateTime.Now,
2699
                Markup_List = new List<Multi_Undo_data>()
2700
            };
2701
           
2702
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2703

    
2704
            CommentUserInfo selected = null;
2705
            double dMinDiff = double.MaxValue;
2706
            Move tmp = new Move();
2707
            foreach (var item in Items)
2708
            {
2709
                Rect boundingBox = tmp.ItemRect(item);
2710
                double dx = rect.X - boundingBox.X;
2711
                double dy = rect.Y - boundingBox.Y;
2712
                double dxx = rect.Right - boundingBox.Right;
2713
                double dyy = rect.Bottom - boundingBox.Bottom;
2714
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
2715
                if (dDiff < dMinDiff)
2716
                {
2717
                    dMinDiff = dDiff;
2718
                    selected = item;
2719
                }
2720
            }
2721

    
2722
            if (selected != null)
2723
            {
2724
                this.ReleaseAdorner();
2725

    
2726
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2727
                adornerSet.Add(selected);
2728
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
2729

    
2730
                Control_Style(selected);
2731
                UndoData.Markup_List.Add(multi_Undo_Data);
2732
                multi_Undo_Data = new Multi_Undo_data();
2733

    
2734
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2735
                {
2736
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2737
                });
2738
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2739

    
2740
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2741
                SelectLayer.Children.Add(final);
2742
            }
2743
        }
2744

    
2745
        private void ApplyDragSelectionRect()
2746
        {
2747
            multi_Undo_Data = new Multi_Undo_data();
2748

    
2749
            UndoData = new Undo_data()
2750
            {
2751
                IsUndo = false,
2752
                Event = Event_Type.Select,
2753
                EventTime = DateTime.Now,
2754
                Markup_List = new List<Multi_Undo_data>()
2755
            };
2756

    
2757
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2758

    
2759
            double x = Canvas.GetLeft(dragSelectionBorder);
2760
            double y = Canvas.GetTop(dragSelectionBorder);
2761
            double width = dragSelectionBorder.Width;
2762
            double height = dragSelectionBorder.Height;
2763
            Rect dragRect = new Rect(x, y, width, height);
2764
            Boolean Flag = false;
2765
            dragRect.Inflate(width / 10, height / 10);
2766
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2767
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2768

    
2769
            dragRect = new Rect(x, y, width, height);
2770
            dragRect.Inflate(width / 10, height / 10);
2771

    
2772
            foreach (var item in Items)
2773
            {
2774
                Flag = move.control_Select(item, dragRect);
2775

    
2776
                if (Flag)
2777
                {
2778
                    adornerSet.Add(item);
2779
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2780

    
2781
                    Control_Style(item);
2782
                    UndoData.Markup_List.Add(multi_Undo_Data);
2783
                    multi_Undo_Data = new Multi_Undo_data();
2784
                }
2785
            }
2786
            if (adornerSet.Count > 0)
2787
            {
2788
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2789
                {
2790
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2791
                });
2792
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2793

    
2794
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2795
                SelectLayer.Children.Add(final);
2796
            }
2797
        }
2798

    
2799
        private void InitDragSelectionRect(Point pt1, Point pt2)
2800
        {
2801
            //캡쳐 중
2802
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2803
            {
2804
                dragCaptureBorder.Visibility = Visibility.Visible;
2805
            }
2806
            //선택 중
2807
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2808
            {
2809

    
2810
                dragSelectionBorder.Visibility = Visibility.Visible;
2811
            }
2812
            else
2813
            {
2814
                dragZoomBorder.Visibility = Visibility.Visible;
2815
            }
2816
            UpdateDragSelectionRect(pt1, pt2);
2817
        }
2818

    
2819
        /// <summary>
2820
        /// Update the position and size of the rectangle used for drag selection.
2821
        /// </summary>
2822
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2823
        {
2824
            double x, y, width, height;
2825

    
2826
            //
2827
            // Determine x,y,width and height of the rect inverting the points if necessary.
2828
            // 
2829

    
2830
            if (pt2.X < pt1.X)
2831
            {
2832
                x = pt2.X;
2833
                width = pt1.X - pt2.X;
2834
            }
2835
            else
2836
            {
2837
                x = pt1.X;
2838
                width = pt2.X - pt1.X;
2839
            }
2840

    
2841
            if (pt2.Y < pt1.Y)
2842
            {
2843
                y = pt2.Y;
2844
                height = pt1.Y - pt2.Y;
2845
            }
2846
            else
2847
            {
2848
                y = pt1.Y;
2849
                height = pt2.Y - pt1.Y;
2850
            }
2851

    
2852
            //
2853
            // Update the coordinates of the rectangle used for drag selection.
2854
            //
2855
            //캡쳐 중
2856
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2857
            {
2858
                Canvas.SetLeft(dragCaptureBorder, x);
2859
                Canvas.SetTop(dragCaptureBorder, y);
2860
                dragCaptureBorder.Width = width;
2861
                dragCaptureBorder.Height = height;
2862
            }
2863
            //선택 중
2864
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2865
            {
2866
                Canvas.SetLeft(dragSelectionBorder, x);
2867
                Canvas.SetTop(dragSelectionBorder, y);
2868
                dragSelectionBorder.Width = width;
2869
                dragSelectionBorder.Height = height;
2870
            }
2871
            else
2872
            {
2873
                Canvas.SetLeft(dragZoomBorder, x);
2874
                Canvas.SetTop(dragZoomBorder, y);
2875
                dragZoomBorder.Width = width;
2876
                dragZoomBorder.Height = height;
2877
            }
2878
        }
2879

    
2880
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2881
        {
2882
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2883

    
2884
            bool result = false;
2885
            if (dragRect.Contains(controlRect))
2886
            {
2887
                result = true;
2888
                //잡은 객체들을 담은 리스트
2889
                try
2890
                {
2891
                    selected_item.Add(OverViewPathData, type.ToString());
2892
                }
2893
                catch (Exception)
2894
                {
2895

    
2896
                }
2897
            }
2898
            return result;
2899
        }
2900

    
2901
        private void drawingPannelRotate(double angle)
2902
        {
2903
            rotate.Angle = angle;
2904
            var rotationNum = Math.Abs((rotate.Angle / 90));
2905

    
2906
            if (angle == 90 || angle == 270)
2907
            {
2908
                double emptySize = zoomAndPanCanvas.Width;
2909
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2910
                zoomAndPanCanvas.Height = emptySize;
2911
            }
2912
            if (angle == 0)
2913
            {
2914
                translate.X = 0;
2915
                translate.Y = 0;
2916
            }
2917
            else if (angle == 90)
2918
            {
2919
                translate.X = zoomAndPanCanvas.Width;
2920
                translate.Y = 0;
2921
            }
2922
            else if (angle == 180)
2923
            {
2924
                translate.X = zoomAndPanCanvas.Width;
2925
                translate.Y = zoomAndPanCanvas.Height;
2926
            }
2927
            else
2928
            {
2929
                translate.X = 0;
2930
                translate.Y = zoomAndPanCanvas.Height;
2931
            }
2932

    
2933
            zoomAndPanControl.RotationAngle = rotate.Angle;
2934

    
2935

    
2936
            if (!testPanel2.IsHidden)
2937
            {
2938
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2939
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2940
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2941
            }
2942

    
2943
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2944
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2945
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2946
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2947
            ViewerDataModel.Instance.Angle = rotate.Angle;
2948
        }
2949

    
2950
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2951
        {
2952
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2953
            if (set_option != null)
2954
            {
2955
                set_option.Value = double.Parse(set_option.ContentText);
2956
            }
2957

    
2958
            InkControl_Convert();
2959

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

    
2963
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2964
            {
2965
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2966
            }
2967

    
2968
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2969
            {
2970
                if (arrow_text as ArrowTextControl != null)
2971
                {
2972
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2973
                }
2974
            }
2975

    
2976
            mouseButtonDown = e.ChangedButton;
2977
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
2978

    
2979
            //if (currentControl != null)
2980
            {
2981
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2982
                if (text_item_ != null)
2983
                {
2984
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2985
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2986
                    (text_item_ as TextControl).IsEditing = false;
2987
                    (text_item_ as TextControl).EnableEditing = false;
2988
                    currentControl = null;
2989
                }
2990

    
2991
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2992
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2993
                {
2994
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2995
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2996
                    currentControl = null;
2997
                }
2998
            }
2999

    
3000
            double Ang = 0;                                          
3001
            if (rotate.Angle != 0)
3002
            {
3003
                Ang = 360 - rotate.Angle;
3004
            }
3005
            move = new Move();
3006

    
3007
            if (e.OriginalSource is System.Windows.Controls.Image)
3008
            {
3009
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3010
            }
3011

    
3012
            if (mouseButtonDown == MouseButton.Left)
3013
            {
3014
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3015
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3016

    
3017
                this.cursor = Cursors.Arrow;
3018
                SetCursor();
3019

    
3020
                if (!ViewerDataModel.Instance.IsPressCtrl)
3021
                {
3022
                    ReleaseAdorner();
3023
                }
3024
            }
3025
            if (mouseButtonDown == MouseButton.Middle)
3026
            {
3027
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3028
                cursor = Cursors.SizeAll;
3029
                SetCursor();
3030
            }
3031
            if (mouseButtonDown == MouseButton.Right)
3032
            {
3033
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3034
                cursor = Cursors.SizeAll;
3035
                SetCursor();
3036
            }
3037
            else if (mouseButtonDown == MouseButton.XButton1)
3038
            {
3039
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3040
                {
3041
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3042
                }
3043

    
3044
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3045

    
3046
            }
3047
            else if (mouseButtonDown == MouseButton.XButton2)
3048
            {
3049
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3050
                {
3051
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3052
                }
3053
            }
3054

    
3055
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3056
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3057
            {
3058
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3059
                {
3060
                    if (SelectLayer.Children.Count == 0)
3061
                    {
3062
                        isLeftMouseButtonDownOnWindow = true;
3063
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3064
                    }
3065

    
3066
                    if (controlType == ControlType.None)
3067
                    {
3068
                        isLeftMouseButtonDownOnWindow = true;
3069
                    }
3070
                }
3071

    
3072
                //캡쳐 모드 설정
3073
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3074
                {
3075
                    dragCaptureBorder.Visibility = Visibility.Visible;
3076
                    isLeftMouseButtonDownOnWindow = true;
3077
                }
3078

    
3079
                //줌 모드 설정
3080
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3081
                {
3082
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3083
                    isLeftMouseButtonDownOnWindow = true;
3084
                }
3085

    
3086

    
3087
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3088
                if (control != null)
3089
                {
3090
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3091
                    AdornerFinal final;
3092
                    List<Point> p_set = new List<Point>();
3093
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3094
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3095
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3096
                    multi_Undo_Data = new Multi_Undo_data();
3097

    
3098
                    //강인구 Undo/Redo 보류
3099
                    UndoData = new Undo_data()
3100
                    {
3101
                        IsUndo = false,
3102
                        Event = Event_Type.Select,
3103
                        EventTime = DateTime.Now,
3104
                        Markup_List = new List<Multi_Undo_data>()
3105
                    };
3106

    
3107
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3108
                    {
3109
                        ReleaseAdorner();
3110
                        final = new AdornerFinal(control);
3111
                        //단일 컨트롤 언두 저장
3112

    
3113
                        Control_Style(control);
3114
                        UndoData.Markup_List.Add(multi_Undo_Data);
3115

    
3116
                        if ((control as IPath) != null)
3117
                        {
3118
                            if ((control as IPath).LineSize != 0)
3119
                            {
3120
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3121
                            }
3122
                        }
3123
                        if ((control as IShapeControl) != null)
3124
                        {
3125
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3126
                            {
3127
                                ViewerDataModel.Instance.checkHatchShape = true;
3128
                            }
3129
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3130
                            {
3131
                                ViewerDataModel.Instance.checkFillShape = true;
3132
                            }
3133
                            else
3134
                            {
3135
                                ViewerDataModel.Instance.checkHatchShape = false;
3136
                                ViewerDataModel.Instance.checkFillShape = false;
3137
                            }
3138
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3139
                        }
3140

    
3141
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3142

    
3143
                        if ((control as TextControl) != null)
3144
                        {
3145
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3146
                            {
3147
                                ViewerDataModel.Instance.checkTextStyle = true;
3148
                            }
3149
                            else
3150
                            {
3151
                                ViewerDataModel.Instance.checkTextStyle = false;
3152
                            }
3153

    
3154
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3155
                            {
3156
                                ViewerDataModel.Instance.checkTextStyle = true;
3157
                            }
3158
                            else
3159
                            {
3160
                                ViewerDataModel.Instance.checkTextStyle = false;
3161
                            }
3162
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3163
                            {
3164
                                ViewerDataModel.Instance.checkTextWeight = true;
3165
                            }
3166
                            else
3167
                            {
3168
                                ViewerDataModel.Instance.checkTextWeight = false;
3169
                            }
3170
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3171
                            {
3172
                                ViewerDataModel.Instance.checkUnderLine = true;
3173
                            }
3174
                            else
3175
                            {
3176
                                ViewerDataModel.Instance.checkUnderLine = false;
3177
                            }
3178
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3179
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3180

    
3181
                        }
3182
                        else if ((control as ArrowTextControl) != null)
3183
                        {
3184
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3185
                            {
3186
                                ViewerDataModel.Instance.checkTextStyle = true;
3187
                            }
3188
                            else
3189
                            {
3190
                                ViewerDataModel.Instance.checkTextStyle = false;
3191
                            }
3192

    
3193
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3194
                            {
3195
                                ViewerDataModel.Instance.checkTextStyle = true;
3196
                            }
3197
                            else
3198
                            {
3199
                                ViewerDataModel.Instance.checkTextStyle = false;
3200
                            }
3201
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3202
                            {
3203
                                ViewerDataModel.Instance.checkTextWeight = true;
3204
                            }
3205
                            else
3206
                            {
3207
                                ViewerDataModel.Instance.checkTextWeight = false;
3208
                            }
3209
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3210
                            {
3211
                                ViewerDataModel.Instance.checkUnderLine = true;
3212
                            }
3213
                            else
3214
                            {
3215
                                ViewerDataModel.Instance.checkUnderLine = false;
3216
                            }
3217
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3218
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3219
                        }
3220
                        else if ((control as RectCloudControl) != null)
3221
                        {
3222
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3223
                        }
3224
                        else if ((control as CloudControl) != null)
3225
                        {
3226
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3227
                        }
3228

    
3229
                    }
3230
                    else
3231
                    {
3232
                        comment = AddAdorner();
3233
                        comment.Add(control);
3234

    
3235
                        Control_Style(control);
3236
                        UndoData.Markup_List.Add(multi_Undo_Data);
3237

    
3238
                        final = new AdornerFinal(comment);
3239
                        //다중 컨트롤 언두 저장
3240
                    }
3241

    
3242
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3243
                    {
3244
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3245
                    });
3246

    
3247
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3248

    
3249
                    SelectLayer.Children.Add(final);
3250
                }
3251
            }
3252

    
3253
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3254
            {
3255
                init();
3256
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3257
                if (cursor != Cursors.SizeAll)
3258
                {
3259
                    cursor = Cursors.Cross;
3260
                    SetCursor();
3261
                }
3262
                bool init_user = false;
3263
                foreach (var user in gridViewMarkup.Items)
3264
                {
3265
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3266
                    {
3267
                        init_user = true;
3268
                    }
3269
                }
3270
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3271
                {
3272
                    RadWindow.Alert(new DialogParameters
3273
                    {
3274
                        Theme = new VisualStudio2013Theme(),
3275
                        Header = "안내",
3276
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3277
                    });
3278
                    return;
3279
                }
3280
                else
3281
                {
3282
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3283
                    if (item != null)
3284
                    {
3285
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3286
                    }
3287
                }
3288

    
3289
                multi_Undo_Data = new Multi_Undo_data();
3290
                //강인구 Undo/Redo 보류
3291
                UndoData = new Undo_data()
3292
                {
3293
                    IsUndo = false,
3294
                    Event = Event_Type.Create,
3295
                    EventTime = DateTime.Now,
3296
                    Markup_List = new List<Multi_Undo_data>()
3297
                };
3298

    
3299
                 switch (controlType)
3300
                {
3301
                    case ControlType.Rectangle:
3302
                        {
3303
                            if (mouseButtonDown == MouseButton.Left)
3304
                            {
3305
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3306
                                //{
3307
                                    if (currentControl is RectangleControl)
3308
                                    {
3309
                                        //20180906 LJY TEST IsRotationDrawingEnable
3310
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3311
                                        {
3312
                                            return;
3313
                                        }
3314

    
3315
                                        CreateControl();
3316

    
3317
                                        (currentControl as RectangleControl).ApplyOverViewData();
3318
                                        currentControl = null;
3319
                                        this.cursor = Cursors.Arrow;
3320
                                    }
3321
                                    else
3322
                                    {
3323
                                        currentControl = new RectangleControl
3324
                                        {
3325
                                            Background = new SolidColorBrush(Colors.Black),
3326
                                            ControlType = ControlType.Rectangle
3327
                                        };
3328

    
3329
                                        currentControl.CommentID = Save.shortGuid();
3330
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3331
                                        currentControl.IsNew = true;
3332
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3333

    
3334
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3335
                                    }
3336
                                //}
3337
                            }
3338
                        }
3339
                        break;
3340
                    case ControlType.RectCloud:
3341
                        {
3342
                            if (mouseButtonDown == MouseButton.Left)
3343
                            {
3344
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3345
                                //{
3346
                                    if (currentControl is RectCloudControl)
3347
                                    {
3348
                                        //20180906 LJY TEST IsRotationDrawingEnable
3349
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3350
                                        {
3351
                                            return;
3352
                                        }
3353

    
3354
                                        CreateControl();
3355

    
3356
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3357
                                        currentControl = null;
3358
                                        this.cursor = Cursors.Arrow;
3359
                                    }
3360
                                    else
3361
                                    {
3362
                                        currentControl = new RectCloudControl
3363
                                        {
3364
                                            Background = new SolidColorBrush(Colors.Black)
3365
                                        };
3366

    
3367
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3368
                                        currentControl.CommentID = Save.shortGuid();
3369
                                        currentControl.IsNew = true;
3370
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3371
                                    }
3372
                                //}
3373
                            }
3374
                        }
3375
                        break;
3376
                    case ControlType.Circle:
3377
                        {
3378
                            if (mouseButtonDown == MouseButton.Left)
3379
                            {
3380
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3381
                                //{
3382
                                    if (currentControl is CircleControl)
3383
                                    {
3384
                                        //20180906 LJY TEST IsRotationDrawingEnable
3385
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3386
                                        {
3387
                                            return;
3388
                                        }
3389

    
3390
                                        CreateControl();
3391

    
3392
                                        (currentControl as CircleControl).ApplyOverViewData();
3393
                                        currentControl = null;
3394
                                    }
3395
                                    else
3396
                                    {
3397
                                        currentControl = new CircleControl
3398
                                        {
3399
                                            Background = new SolidColorBrush(Colors.Black)
3400
                                        };
3401

    
3402
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3403
                                        currentControl.CommentID = Save.shortGuid();
3404
                                        currentControl.IsNew = true;
3405
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3406
                                    }
3407
                                //}
3408
                            }
3409
                        }
3410
                        break;
3411
                    case ControlType.Triangle:
3412
                        {
3413
                            if (mouseButtonDown == MouseButton.Left)
3414
                            {
3415
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3416
                                //{
3417
                                    if (currentControl is TriControl)
3418
                                    {
3419
                                        var content = currentControl as TriControl;
3420
                                        if (content.MidPoint == new Point(0, 0))
3421
                                        {
3422
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3423
                                        }
3424
                                        else
3425
                                        {
3426
                                            //20180906 LJY TEST IsRotationDrawingEnable
3427
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3428
                                            {
3429
                                                return;
3430
                                            }
3431

    
3432
                                            CreateControl();
3433

    
3434
                                            (currentControl as TriControl).ApplyOverViewData();
3435
                                            currentControl = null;
3436
                                        }
3437
                                    }
3438
                                    else
3439
                                    {
3440
                                        currentControl = new TriControl
3441
                                        {
3442
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3443
                                            Background = new SolidColorBrush(Colors.Black),
3444
                                        };
3445

    
3446
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3447
                                        currentControl.CommentID = Save.shortGuid();
3448
                                        currentControl.IsNew = true;
3449
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3450
                                    }
3451
                                //}
3452
                            }
3453
                        }
3454
                        break;
3455
                    case ControlType.SingleLine:
3456
                        {
3457
                            if (mouseButtonDown == MouseButton.Left)
3458
                            {
3459
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3460
                                //{
3461
                                    if (currentControl is LineControl)
3462
                                    {
3463
                                        //20180906 LJY TEST IsRotationDrawingEnable
3464
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3465
                                        {
3466
                                            return;
3467
                                        }
3468

    
3469
                                        CreateControl();
3470

    
3471
                                        (currentControl as LineControl).ApplyOverViewData();
3472
                                        currentControl = null;
3473
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3474
                                    }
3475
                                    else
3476
                                    {
3477
                                        currentControl = new LineControl
3478
                                        {
3479
                                            Background = new SolidColorBrush(Colors.Black)
3480
                                        };
3481

    
3482
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3483
                                        currentControl.CommentID = Save.shortGuid();
3484
                                        currentControl.IsNew = true;
3485
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3486
                                        this.MainAngle.Visibility = Visibility.Visible;
3487
                                    }
3488
                                //}
3489
                            }
3490
                        }
3491
                        break;
3492
                    case ControlType.CancelLine:
3493
                        {
3494
                            if (mouseButtonDown == MouseButton.Left)
3495
                            {
3496
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3497
                                //{
3498
                                    if (currentControl is LineControl)
3499
                                    {
3500
                                        //20180906 LJY TEST IsRotationDrawingEnable
3501
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3502
                                        {
3503
                                            return;
3504
                                        }
3505

    
3506
                                        CreateControl();
3507

    
3508
                                        (currentControl as LineControl).ApplyOverViewData();
3509
                                        currentControl = null;
3510
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3511
                                    }
3512
                                    else
3513
                                    {
3514
                                        currentControl = new LineControl
3515
                                        {
3516
                                            Background = new SolidColorBrush(Colors.Black)
3517
                                        };
3518

    
3519
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3520
                                        currentControl.CommentID = Save.shortGuid();
3521
                                        currentControl.IsNew = true;
3522
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3523
                                        this.MainAngle.Visibility = Visibility.Visible;
3524
                                    }
3525
                                //}
3526
                            }
3527
                        }
3528
                        break;
3529
                    case ControlType.ArrowLine:
3530
                        {
3531
                            if (mouseButtonDown == MouseButton.Left)
3532
                            {
3533
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3534
                                //{
3535
                                    if (currentControl is LineControl)
3536
                                    {
3537
                                        //20180906 LJY TEST IsRotationDrawingEnable
3538
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3539
                                        {
3540
                                            return;
3541
                                        }
3542

    
3543
                                        CreateControl();
3544

    
3545
                                        (currentControl as LineControl).ApplyOverViewData();
3546
                                        currentControl = null;
3547
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3548
                                    }
3549
                                    else
3550
                                    {
3551
                                        currentControl = new LineControl
3552
                                        {
3553
                                            Background = new SolidColorBrush(Colors.Black)
3554
                                        };
3555

    
3556
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3557
                                        currentControl.CommentID = Save.shortGuid();
3558
                                        currentControl.IsNew = true;
3559
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3560
                                        this.MainAngle.Visibility = Visibility.Visible;
3561
                                    }
3562
                                //}
3563
                            }
3564
                        }
3565
                        break;
3566
                    case ControlType.TwinLine:
3567
                        {
3568
                            if (mouseButtonDown == MouseButton.Left)
3569
                            {
3570
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3571
                                //{
3572
                                    if (currentControl is LineControl)
3573
                                    {
3574
                                        //20180906 LJY TEST IsRotationDrawingEnable
3575
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3576
                                        {
3577
                                            return;
3578
                                        }
3579

    
3580
                                        CreateControl();
3581

    
3582
                                        (currentControl as LineControl).ApplyOverViewData();
3583
                                        currentControl = null;
3584
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3585
                                    }
3586
                                    else
3587
                                    {
3588
                                        currentControl = new LineControl
3589
                                        {
3590
                                            Background = new SolidColorBrush(Colors.Black)
3591
                                        };
3592
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3593
                                        currentControl.CommentID = Save.shortGuid();
3594
                                        currentControl.IsNew = true;
3595
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3596
                                        this.MainAngle.Visibility = Visibility.Visible;
3597
                                    }
3598
                                //}
3599
                            }
3600
                        }
3601
                        break;
3602
                    case ControlType.DimLine:
3603
                        {
3604
                            if (mouseButtonDown == MouseButton.Left)
3605
                            {
3606
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3607
                                //{
3608
                                    if (currentControl is LineControl)
3609
                                    {
3610
                                        //20180906 LJY TEST IsRotationDrawingEnable
3611
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3612
                                        {
3613
                                            return;
3614
                                        }
3615
                                        CreateControl();
3616

    
3617
                                        (currentControl as LineControl).ApplyOverViewData();
3618
                                        currentControl = null;
3619
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3620
                                    }
3621
                                    else
3622
                                    {
3623
                                        currentControl = new LineControl
3624
                                        {
3625
                                            Background = new SolidColorBrush(Colors.Black)
3626
                                        };
3627
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3628
                                        currentControl.CommentID = Save.shortGuid();
3629
                                        currentControl.IsNew = true;
3630
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3631
                                        this.MainAngle.Visibility = Visibility.Visible;
3632
                                    }
3633
                                //}
3634
                            }
3635
                        }
3636
                        break;
3637
                    case ControlType.ChainLine:
3638
                        {
3639
                            if (currentControl is PolygonControl)
3640
                            {
3641
                                var control = currentControl as PolygonControl;
3642

    
3643
                                if (mouseButtonDown == MouseButton.Right)
3644
                                {
3645
                                    //20180906 LJY TEST IsRotationDrawingEnable
3646
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3647
                                    {
3648
                                        return;
3649
                                    }
3650

    
3651
                                    CreateControl();
3652

    
3653
                                    (currentControl as PolygonControl).ApplyOverViewData();
3654
                                    currentControl = null;
3655
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3656
                                    return;
3657
                                }
3658

    
3659
                                if (!control.IsCompleted)
3660
                                {
3661
                                    control.PointSet.Add(control.EndPoint);
3662
                                    this.MainAngle.Visibility = Visibility.Visible;
3663
                                }
3664
                            }
3665
                            else
3666
                            {
3667
                                if (mouseButtonDown == MouseButton.Left)
3668
                                {
3669
                                    MainAngle.Visibility = Visibility.Visible;
3670
                                    currentControl = new PolygonControl
3671
                                    {
3672
                                        PointSet = new List<Point>(),
3673
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3674
                                        ControlType = ControlType.ChainLine,
3675
                                        DashSize = ViewerDataModel.Instance.DashSize,
3676
                                        LineSize = ViewerDataModel.Instance.LineSize,
3677
                                        //PointC = new StylusPointSet()
3678
                                    };
3679

    
3680
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3681
                                    //{
3682
                                        var polygonControl = (currentControl as PolygonControl);
3683
                                        currentControl.CommentID = Save.shortGuid();
3684
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3685
                                        currentControl.IsNew = true;
3686
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3687
                                        //currentControl.OnApplyTemplate();
3688
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3689
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3690
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3691
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3692
                                    //}
3693
                                }
3694
                            }
3695
                        }
3696
                        break;
3697
                    case ControlType.ArcLine:
3698
                        {
3699
                            if (mouseButtonDown == MouseButton.Left)
3700
                            {
3701
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3702
                                //{
3703
                                    if (currentControl is ArcControl)
3704
                                    {
3705
                                        //20180906 LJY TEST IsRotationDrawingEnable
3706
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3707
                                        {
3708
                                            return;
3709
                                        }
3710

    
3711
                                        CreateControl();
3712

    
3713
                                        (currentControl as ArcControl).ApplyOverViewData();
3714
                                        currentControl = null;
3715
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3716
                                    }
3717
                                    else
3718
                                    {
3719
                                        currentControl = new ArcControl
3720
                                        {
3721
                                            Background = new SolidColorBrush(Colors.Black)
3722
                                        };
3723
                                        currentControl.CommentID = Save.shortGuid();
3724
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3725
                                        currentControl.IsNew = true;
3726
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3727
                                        this.MainAngle.Visibility = Visibility.Visible;
3728
                                    }
3729
                                //}
3730
                            }
3731
                            else if (mouseButtonDown == MouseButton.Right)
3732
                            {
3733
                                if (currentControl != null)
3734
                                {
3735
                                    (currentControl as ArcControl).setClock();
3736
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3737
                                    //(currentControl as ArcControl).ApplyTemplate();
3738
                                }
3739
                            }
3740
                        }
3741
                        break;
3742
                    case ControlType.ArcArrow:
3743
                        {
3744
                            if (mouseButtonDown == MouseButton.Left)
3745
                            {
3746
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3747
                                //{
3748
                                    if (currentControl is ArcControl)
3749
                                    {
3750
                                        //20180906 LJY TEST IsRotationDrawingEnable
3751
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3752
                                        {
3753
                                            return;
3754
                                        }
3755

    
3756
                                        CreateControl();
3757

    
3758
                                        (currentControl as ArcControl).ApplyOverViewData();
3759
                                        currentControl = null;
3760
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3761
                                    }
3762
                                    else
3763
                                    {
3764
                                        currentControl = new ArcControl
3765
                                        {
3766
                                            Background = new SolidColorBrush(Colors.Red),
3767
                                        };
3768
                                        currentControl.CommentID = Save.shortGuid();
3769
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3770
                                        currentControl.IsNew = true;
3771
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3772
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3773
                                        this.MainAngle.Visibility = Visibility.Visible;
3774
                                    }
3775
                                //}
3776
                            }
3777
                            else if (mouseButtonDown == MouseButton.Right)
3778
                            {
3779
                                (currentControl as ArcControl).setClock();
3780
                            }
3781
                        }
3782
                        break;
3783
                    case ControlType.ArrowMultiLine:
3784
                        {
3785
                            if (mouseButtonDown == MouseButton.Left)
3786
                            {
3787
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3788
                                //{
3789

    
3790
                                    if (currentControl is ArrowControl_Multi)
3791
                                    {
3792
                                        var content = currentControl as ArrowControl_Multi;
3793
                                        if (content.MiddlePoint == new Point(0, 0))
3794
                                        {
3795
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3796
                                            {
3797
                                                content.MiddlePoint = content.EndPoint;
3798
                                            }
3799
                                            else
3800
                                            {
3801
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3802
                                            }
3803
                                        }
3804
                                        else
3805
                                        {
3806
                                            //20180906 LJY TEST IsRotationDrawingEnable
3807
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3808
                                            {
3809
                                                return;
3810
                                            }
3811

    
3812
                                            CreateControl();
3813

    
3814
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3815
                                            currentControl = null;
3816
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3817
                                        }
3818
                                    }
3819
                                    else
3820
                                    {
3821
                                        currentControl = new ArrowControl_Multi
3822
                                        {
3823
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3824
                                            Background = new SolidColorBrush(Colors.Black)
3825
                                        };
3826
                                        currentControl.CommentID = Save.shortGuid();
3827
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3828
                                        currentControl.IsNew = true;
3829
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3830
                                        this.MainAngle.Visibility = Visibility.Visible;
3831
                                    }
3832
                                //}
3833
                            }
3834
                        }
3835
                        break;
3836
                    case ControlType.PolygonCloud:
3837
                        {
3838
                            if (currentControl is CloudControl)
3839
                            {
3840
                                var control = currentControl as CloudControl;
3841
                                if (mouseButtonDown == MouseButton.Right)
3842
                                {
3843
                                    control.IsCompleted = true;
3844
                                }
3845

    
3846
                                if (!control.IsCompleted)
3847
                                {
3848
                                    control.PointSet.Add(control.EndPoint);
3849
                                }
3850
                                else
3851
                                {
3852
                                    //20180906 LJY TEST IsRotationDrawingEnable
3853
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3854
                                    {
3855
                                        return;
3856
                                    }
3857

    
3858
                                    CreateControl();
3859

    
3860
                                    control.isTransOn = true;
3861
                                    var firstPoint = control.PointSet.First();
3862

    
3863
                                    control.PointSet.Add(firstPoint);
3864
                                    control.DrawingCloud();
3865
                                    control.ApplyOverViewData();
3866

    
3867
                                    currentControl = null;
3868
                                }
3869
                            }
3870
                            else
3871
                            {
3872
                                if (mouseButtonDown == MouseButton.Left)
3873
                                {
3874
                                    currentControl = new CloudControl
3875
                                    {
3876
                                        PointSet = new List<Point>(),
3877
                                        PointC = new StylusPointSet()
3878
                                    };
3879

    
3880
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3881
                                    //{
3882
                                        var polygonControl = (currentControl as CloudControl);
3883
                                        currentControl.CommentID = Save.shortGuid();
3884
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3885
                                        currentControl.IsNew = true;
3886
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3887

    
3888
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3889
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3890
                                    //}
3891
                                }
3892
                            }
3893
                        }
3894
                        break;
3895
                    case ControlType.ImgControl:
3896
                        {
3897
                            if (mouseButtonDown == MouseButton.Left)
3898
                            {
3899
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3900
                                //{
3901
                                    if (currentControl is ImgControl)
3902
                                    {
3903
                                        //20180906 LJY TEST IsRotationDrawingEnable
3904
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3905
                                        {
3906
                                            return;
3907
                                        }
3908

    
3909
                                        CreateControl();
3910
                                        (currentControl as ImgControl).ApplyOverViewData();
3911

    
3912
                                        currentControl = null;
3913
                                    }
3914
                                    else
3915
                                    {
3916
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3917
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3918
                                        {
3919
                                            Image img = new Image();
3920
                                            img.Source = new BitmapImage(new Uri(filename));
3921

    
3922
                                            currentControl = new ImgControl
3923
                                            {
3924
                                                Background = new SolidColorBrush(Colors.Black),
3925
                                                PointSet = new List<Point>(),
3926
                                                FilePath = filename,
3927
                                                ImageData = img.Source,
3928
                                                StartPoint = canvasDrawingMouseDownPoint,
3929
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3930
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3931
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3932
                                            };
3933

    
3934
                                            currentControl.CommentID = Save.shortGuid();
3935
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3936
                                            currentControl.IsNew = true;
3937
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3938

    
3939
                                            //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3940
                                            (currentControl as ImgControl).Angle -= rotate.Angle;
3941
                                    }
3942
                                    }
3943
                                //}
3944
                            }
3945
                        }
3946
                        break;
3947
                    case ControlType.Date:
3948
                        {
3949
                            if (mouseButtonDown == MouseButton.Left)
3950
                            {
3951
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3952
                                //{
3953
                                    if (currentControl is DateControl)
3954
                                    {
3955
                                        //20180906 LJY TEST IsRotationDrawingEnable
3956
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3957
                                        {
3958
                                            return;
3959
                                        }
3960

    
3961
                                        CreateControl();
3962
                                        (currentControl as DateControl).ApplyOverViewData();
3963
                                        currentControl = null;
3964

    
3965
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3966
                                        {
3967
                                            controlType = ControlType.None;
3968
                                            IsSwingMode = false;
3969
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3970
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3971
                                            mouseHandlingMode = MouseHandlingMode.None;
3972
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3973
                                            txtBatch.Visibility = Visibility.Collapsed;
3974

    
3975
                                        }
3976
                                    }
3977
                                    else
3978
                                    {
3979
                                        currentControl = new DateControl
3980
                                        {
3981
                                            Background = new SolidColorBrush(Colors.Black)
3982
                                        };
3983
                                        currentControl.CommentID = Save.shortGuid();
3984
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3985
                                        currentControl.IsNew = true;
3986
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3987

    
3988
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3989
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3990
                                }
3991
                                //}
3992
                            }
3993
                        }
3994
                        break;
3995
                    case ControlType.TextControl:
3996
                        {
3997
                            if (mouseButtonDown == MouseButton.Left)
3998
                            {
3999
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4000
                                {
4001
                                    currentControl = new TextControl
4002
                                    {
4003
                                        ControlType = controlType
4004
                                    };
4005
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4006
                                    currentControl.CommentID = Save.shortGuid();
4007
                                    currentControl.IsNew = true;
4008
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4009
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4010
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4011
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4012
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4013
                                    currentControl.Focus();
4014
                                    (currentControl as TextControl).ApplyOverViewData();
4015
                                    (currentControl as TextControl).ControlType_No = 0;
4016
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4017
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4018

    
4019
                                    CreateControl();
4020

    
4021
                                    //currentControl = null;
4022
                                }
4023
                            }
4024
                        }
4025
                        break;
4026
                    case ControlType.TextBorder:
4027
                        {
4028
                            if (mouseButtonDown == MouseButton.Left)
4029
                            {
4030
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4031
                                {
4032
                                    currentControl = new TextControl
4033
                                    {
4034
                                        ControlType = controlType
4035
                                    };
4036

    
4037
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4038
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4039
                                    currentControl.CommentID = Save.shortGuid();
4040
                                    currentControl.IsNew = true;
4041
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4042
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4043
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4044
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4045
                                    currentControl.Focus();
4046
                                    (currentControl as TextControl).ControlType_No = 1;
4047
                                    (currentControl as TextControl).Angle = Ang;
4048
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4049
                                    CreateControl();
4050

    
4051
                                    //currentControl = null;
4052
                                }
4053
                            }
4054
                        }
4055
                        break;
4056
                    case ControlType.TextCloud:
4057
                        {
4058
                            if (mouseButtonDown == MouseButton.Left)
4059
                            {
4060
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4061
                                {
4062
                                    currentControl = new TextControl
4063
                                    {
4064
                                        ControlType = controlType
4065
                                    };
4066

    
4067
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4068
                                    currentControl.CommentID = Save.shortGuid();
4069
                                    currentControl.IsNew = true;
4070
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4071
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4072

    
4073
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4074
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4075
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4076
                                    currentControl.Focus();
4077

    
4078
                                    (currentControl as TextControl).Angle = Ang;
4079
                                    (currentControl as TextControl).ControlType_No = 2;
4080
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4081

    
4082
                                    CreateControl();
4083
                                    //currentControl = null;
4084
                                }
4085
                            }
4086
                        }
4087
                        break;
4088
                    case ControlType.ArrowTextControl:
4089
                         {
4090
                            if (mouseButtonDown == MouseButton.Left)
4091
                            {
4092
                                if (currentControl is ArrowTextControl)
4093
                                {
4094
                                    //20180906 LJY TEST IsRotationDrawingEnable
4095
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4096
                                    {
4097
                                        return;
4098
                                    }                                    
4099

    
4100
                                    CreateControl();
4101

    
4102
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4103
                                    (currentControl as ArrowTextControl).IsEditing = false;
4104
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4105
                                    (currentControl as ArrowTextControl).IsNew = false;
4106
                                    currentControl = null;
4107
                                }
4108
                                else
4109
                                {
4110
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4111
                                    //{
4112
                                        currentControl = new ArrowTextControl();
4113
                                        currentControl.CommentID = Save.shortGuid();
4114
                                        currentControl.IsNew = true;
4115
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4116
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4117

    
4118
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4119
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4120
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4121
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4122
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4123

    
4124
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4125
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4126

    
4127
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4128
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4129
                                        this.MainAngle.Visibility = Visibility.Visible;
4130

    
4131
                                    
4132
                                    //}
4133
                                }
4134
                            }
4135
                        }
4136
                        break;
4137
                    case ControlType.ArrowTransTextControl:
4138
                        {
4139
                            if (mouseButtonDown == MouseButton.Left)
4140
                            {
4141
                                if (currentControl is ArrowTextControl)
4142
                                {
4143
                                    //20180906 LJY TEST IsRotationDrawingEnable
4144
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4145
                                    {
4146
                                        return;
4147
                                    }                                    
4148

    
4149
                                    CreateControl();
4150
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4151
                                    currentControl.IsNew = false;
4152
                                    currentControl = null;
4153
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4154
                                }
4155
                                else
4156
                                {
4157
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4158
                                    //{
4159
                                         currentControl = new ArrowTextControl();
4160
                                        currentControl.CommentID = Save.shortGuid();
4161
                                        currentControl.IsNew = true;
4162
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4163
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4164
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4165
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4166
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4167
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4168
                                        (currentControl as ArrowTextControl).isFixed = true;
4169
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4170

    
4171
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4172
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4173

    
4174
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4175
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4176
                                        (currentControl as ArrowTextControl).isTrans = true;
4177
                                }
4178
                            }
4179
                        }
4180
                        break;
4181
                    case ControlType.ArrowTextBorderControl:
4182
                         {
4183
                            if (mouseButtonDown == MouseButton.Left)
4184
                            {
4185
                                if (currentControl is ArrowTextControl)
4186
                                {
4187
                                    //20180906 LJY TEST IsRotationDrawingEnable
4188
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4189
                                    {
4190
                                        return;
4191
                                    }
4192

    
4193
                                    CreateControl();
4194
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4195
                                    currentControl.IsNew = false;
4196
                                    currentControl = null;
4197
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4198
                                }
4199
                                else
4200
                                {
4201
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4202
                                    //{
4203
                                        currentControl = new ArrowTextControl()
4204
                                        {
4205
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4206
                                        };
4207
                                        currentControl.CommentID = Save.shortGuid();
4208
                                        currentControl.IsNew = true;
4209
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4210
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4211

    
4212
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4213

    
4214
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4215

    
4216
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4217
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4218
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4219

    
4220
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4221
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4222
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4223
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4224
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4225
                                    //}
4226
                                }
4227
                            }
4228
                        }
4229
                        break;
4230
                    case ControlType.ArrowTransTextBorderControl:
4231
                        {
4232
                            if (mouseButtonDown == MouseButton.Left)
4233
                            {
4234
                                if (currentControl is ArrowTextControl)
4235
                                {
4236
                                    //20180906 LJY TEST IsRotationDrawingEnable
4237
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4238
                                    {
4239
                                        return;
4240
                                    }
4241
                                    CreateControl();
4242
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4243
                                    currentControl.IsNew = false;
4244
                                    currentControl = null;
4245
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4246
                                }
4247
                                else
4248
                                {
4249
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4250
                                    //{
4251
                                    
4252

    
4253
                                    currentControl = new ArrowTextControl()
4254
                                        {
4255
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4256
                                        };
4257
                                        currentControl.CommentID = Save.shortGuid();
4258
                                        currentControl.IsNew = true;
4259
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4260
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4261

    
4262
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4263

    
4264
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4265
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4266
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4267
                                        (currentControl as ArrowTextControl).isFixed = true;
4268
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4269
                                     
4270
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4271
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4272
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4273

    
4274
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4275
                                        this.MainAngle.Visibility = Visibility.Visible;
4276
                                    
4277
                                    //20180911 LJY
4278
                                        (currentControl as ArrowTextControl).isTrans = true;
4279
                                    
4280

    
4281
                                    //}
4282
                                }
4283
                            }
4284
                        }
4285
                        break;
4286
                    case ControlType.ArrowTextCloudControl:
4287
                        {
4288
                            if (mouseButtonDown == MouseButton.Left)
4289
                            {
4290
                                if (currentControl is ArrowTextControl)
4291
                                {
4292
                                    //20180906 LJY TEST IsRotationDrawingEnable
4293
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4294
                                    {
4295
                                        return;
4296
                                    }
4297
                                    CreateControl();
4298
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4299
                                    currentControl.IsNew = false;
4300
                                    currentControl = null;
4301
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4302
                                }
4303
                                else
4304
                                {
4305
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4306
                                    //{
4307
                                        currentControl = new ArrowTextControl()
4308
                                        {
4309
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4310
                                        };
4311
                                        currentControl.CommentID = Save.shortGuid();
4312
                                        currentControl.IsNew = true;
4313
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4314
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4315

    
4316
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4317
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4318
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4319
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4320
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4321

    
4322
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4323
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4324
                                    
4325
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4326
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4327
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4328
                                    //}
4329
                                }
4330
                            }
4331
                        }
4332
                        break;
4333
                    case ControlType.ArrowTransTextCloudControl:
4334
                        {
4335
                            if (mouseButtonDown == MouseButton.Left)
4336
                            {
4337
                                if (currentControl is ArrowTextControl)
4338
                                {
4339
                                    //20180906 LJY TEST IsRotationDrawingEnable
4340
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4341
                                    {
4342
                                        return;
4343
                                    }
4344
                                    CreateControl();
4345
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4346
                                    currentControl.IsNew = false;
4347
                                    currentControl = null;
4348
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4349
                                }
4350
                                else
4351
                                {
4352
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4353
                                    //{
4354
                                        currentControl = new ArrowTextControl()
4355
                                        {
4356
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4357
                                        };
4358
                                        currentControl.CommentID = Save.shortGuid();
4359
                                        currentControl.IsNew = true; 
4360
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4361
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4362
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4363

    
4364
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4365
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4366
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4367
                                        (currentControl as ArrowTextControl).isFixed = true;
4368
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4369

    
4370
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4371
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4372

    
4373
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4374
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4375
                                        this.MainAngle.Visibility = Visibility.Visible;  
4376
                                    
4377
                                    //20180911 LJY
4378
                                        (currentControl as ArrowTextControl).isTrans = true;
4379
                                    //}
4380
                                }
4381
                            }
4382
                        }
4383
                        break;
4384
                    case ControlType.PolygonControl:
4385
                        {
4386
                            if (currentControl is PolygonControl)
4387
                            {
4388
                                var control = currentControl as PolygonControl;
4389

    
4390
                                if (mouseButtonDown == MouseButton.Right)
4391
                                {
4392
                                    control.IsCompleted = true;
4393
                                }
4394

    
4395
                                if (!control.IsCompleted)
4396
                                {
4397
                                    control.PointSet.Add(control.EndPoint);
4398
                                }
4399
                                else
4400
                                {
4401
                                    //20180906 LJY TEST IsRotationDrawingEnable
4402
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4403
                                    {
4404
                                        return;
4405
                                    }
4406

    
4407
                                    var firstPoint = control.PointSet.First();
4408
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4409
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4410
                                    control.PointSet.Add(firstPoint);
4411

    
4412
                                    control.SetPolyPath();
4413

    
4414
                                    control.ApplyOverViewData();
4415

    
4416
                                    CreateControl();
4417

    
4418
                                    currentControl = null;
4419
                                }
4420
                            }
4421
                            else
4422
                            {
4423
                                if (mouseButtonDown == MouseButton.Left)
4424
                                {
4425
                                    currentControl = new PolygonControl
4426
                                    {
4427
                                        PointSet = new List<Point>(),
4428
                                        //PointC = new StylusPointSet()
4429
                                    };
4430

    
4431
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4432
                                    //{
4433
                                        var polygonControl = (currentControl as PolygonControl);
4434
                                        currentControl.CommentID = Save.shortGuid();
4435
                                        currentControl.IsNew = true;
4436
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4437
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4438
                                        //currentControl.OnApplyTemplate();
4439
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4440
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4441
                                    //}
4442
                                }
4443
                            }
4444
                        }
4445
                        break;
4446
                    //강인구 추가
4447
                    case ControlType.Sign:
4448
                        {
4449
                            if (mouseButtonDown == MouseButton.Left)
4450
                            {
4451
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4452
                                //{
4453
                                    GetUserSign getUser = new GetUserSign();
4454
                                    var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4455

    
4456
                                    if (_sign == null)
4457
                                    {
4458
                                        txtBatch.Visibility = Visibility.Collapsed;
4459
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4460
                                        controlType = ControlType.None;
4461

    
4462
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4463
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4464
                                        return;
4465
                                    }
4466

    
4467
                                    if (currentControl is SignControl)
4468
                                    {
4469
                                        //20180906 LJY TEST IsRotationDrawingEnable
4470
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4471
                                        {
4472
                                            return;
4473
                                        }
4474

    
4475
                                        CreateControl();
4476
                                        currentControl = null;
4477
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4478
                                        {
4479
                                            txtBatch.Text = "Place Date";
4480
                                            controlType = ControlType.Date;
4481
                                        }
4482
                                    }
4483
                                    else
4484
                                    {
4485
                                        currentControl = new SignControl
4486
                                        {
4487
                                            Background = new SolidColorBrush(Colors.Black),
4488
                                            UserNumber = App.ViewInfo.UserID,
4489
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4490
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4491
                                            ControlType = ControlType.Sign
4492
                                        };
4493

    
4494
                                        currentControl.CommentID = Save.shortGuid();
4495
                                        currentControl.IsNew = true;
4496
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4497
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4498

    
4499
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4500
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4501
                                }
4502
                                //}
4503
                            }
4504
                        }
4505
                        break;
4506
                    case ControlType.Mark:
4507
                        {
4508
                            if (mouseButtonDown == MouseButton.Left)
4509
                            {
4510
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4511
                                //{
4512
                                    if (currentControl is RectangleControl)
4513
                                    {
4514
                                        //20180906 LJY TEST IsRotationDrawingEnable
4515
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4516
                                        {
4517
                                            return;
4518
                                        }
4519

    
4520
                                        CreateControl();
4521
                                        (currentControl as RectangleControl).ApplyOverViewData();
4522
                                        currentControl = null;
4523
                                        this.cursor = Cursors.Arrow;
4524

    
4525
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4526
                                        {
4527
                                            txtBatch.Text = "Place Signature";
4528
                                            controlType = ControlType.Sign;
4529
                                        }
4530
                                    }
4531
                                    else
4532
                                    {
4533
                                        currentControl = new RectangleControl
4534
                                        {
4535
                                            Background = new SolidColorBrush(Colors.Black),
4536
                                            Paint = PaintSet.Fill
4537
                                        };
4538

    
4539
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4540
                                        currentControl.CommentID = Save.shortGuid();
4541
                                        currentControl.IsNew = true;
4542
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4543
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4544
                                    }
4545
                                //}
4546
                            }
4547
                        }
4548
                        break;
4549
                    case ControlType.Symbol:
4550
                        {
4551
                            if (mouseButtonDown == MouseButton.Left)
4552
                            {
4553
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4554
                                //{
4555
                                    if (currentControl is SymControl)
4556
                                    {
4557
                                        //20180906 LJY TEST IsRotationDrawingEnable
4558
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4559
                                        {
4560
                                            return;
4561
                                        }
4562
                                        CreateControl();
4563
                                        currentControl = null;
4564
                                        this.cursor = Cursors.Arrow;
4565
                                    }
4566
                                    else
4567
                                    {
4568
                                        currentControl = new SymControl
4569
                                        {
4570
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4571
                                            Background = new SolidColorBrush(Colors.Black),
4572
                                            ControlType = ControlType.Symbol
4573
                                        };
4574

    
4575
                                        currentControl.IsNew = true;
4576
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4577
                                        currentControl.CommentID = Save.shortGuid();
4578
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4579

    
4580
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4581
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4582
                                }
4583
                                //}
4584
                            }
4585
                        }
4586
                        break;
4587
                    case ControlType.Stamp:
4588
                        {
4589
                            if (mouseButtonDown == MouseButton.Left)
4590
                            {
4591
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4592
                                //{
4593
                                    if (currentControl is SymControlN)
4594
                                    {
4595
                                        //20180906 LJY TEST IsRotationDrawingEnable
4596
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4597
                                        {
4598
                                            return;
4599
                                        }
4600

    
4601
                                        CreateControl();
4602
                                        currentControl = null;
4603
                                        this.cursor = Cursors.Arrow;
4604
                                    }
4605
                                    else
4606
                                    {
4607
                                        currentControl = new SymControlN
4608
                                        {
4609
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4610
                                            Background = new SolidColorBrush(Colors.Black),
4611
                                            ControlType = ControlType.Stamp
4612
                                        };
4613

    
4614
                                        currentControl.IsNew = true;
4615
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4616
                                        currentControl.CommentID = Save.shortGuid();
4617
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4618
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4619
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4620
                                }                                    
4621
                                //}
4622
                            }
4623
                        }
4624
                        break;
4625
                    case ControlType.PenControl:
4626
                        {
4627
                            if (inkBoard.Tag.ToString() == "Ink")
4628
                            {
4629
                                inkBoard.IsEnabled = true;
4630
                                StartNewStroke(canvasDrawingMouseDownPoint);
4631
                            }
4632
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4633
                            {
4634
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4635
                            }
4636
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4637
                            {
4638
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4639
                            }
4640
                            IsDrawing = true;
4641

    
4642
                            temp.AddTemp(currentControl, pageNavigator.CurrentPage.PageNumber);
4643
                            return;
4644
                        }
4645
                    default:
4646
                        if (currentControl != null)
4647
                        {
4648
                            currentControl.CommentID = null;
4649
                            currentControl.IsNew = false;
4650
                        }
4651
                        break;
4652
                }
4653
            }
4654
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4655
            {
4656
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4657
                {
4658
                    bool mouseOff = false;
4659
                    foreach (var item in SelectLayer.Children)
4660
                    {
4661
                        if (item is AdornerFinal)
4662
                        {
4663

    
4664
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4665
                            if (over != null)
4666
                            {
4667
                                mouseOff = true;
4668
                            }
4669
                        }
4670
                    }
4671

    
4672
                    if (!mouseOff)
4673
                    {
4674
                        ReleaseAdorner();
4675
                    }
4676
                }
4677
                zoomAndPanControl.CaptureMouse();
4678
                e.Handled = true;
4679
            }
4680
        }
4681

    
4682
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4683
        {
4684
            mouseButtonDown = e.ChangedButton;
4685
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4686
        }
4687

    
4688
        private void RemoveLineStroke(Point P)
4689
        {
4690
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4691
            if (control != null)
4692
            {
4693
                UndoData = new Undo_data()
4694
                {
4695
                    IsUndo = false,
4696
                    Event = Event_Type.Delete,
4697
                    EventTime = DateTime.Now,
4698
                    Markup_List = new List<Multi_Undo_data>()
4699
                };
4700

    
4701

    
4702
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4703
                UndoData.Markup_List.Add(multi_Undo_Data);
4704
                multi_Undo_Data = new Multi_Undo_data();
4705

    
4706
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4707
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4708
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4709

    
4710

    
4711
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4712
                {
4713
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4714
                });
4715
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4716

    
4717
            }
4718
        }
4719

    
4720
        private void RemovePointStroke(Point P)
4721
        {
4722
            foreach (Stroke hits in inkBoard.Strokes)
4723
            {
4724
                foreach (StylusPoint sty in hits.StylusPoints)
4725
                {
4726

    
4727
                }
4728
                if (hits.HitTest(P))
4729
                {
4730
                    inkBoard.Strokes.Remove(hits);
4731
                    return;
4732
                }
4733
            }
4734
        }
4735

    
4736
        private void StartNewStroke(Point P)
4737
        {
4738
            strokePoints = new StylusPointCollection();
4739
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4740
            strokePoints.Add(segment1Start);
4741
            stroke = new Stroke(strokePoints);
4742

    
4743
            stroke.DrawingAttributes.Color = Colors.Red;
4744
            stroke.DrawingAttributes.Width = 4;
4745
            stroke.DrawingAttributes.Height = 4;
4746

    
4747
            inkBoard.Strokes.Add(stroke);
4748

    
4749
        }
4750

    
4751
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4752
        {
4753
            ConsolidationMethod();
4754
        }
4755

    
4756
        public void TeamConsolidationMethod()
4757
        {
4758
            ChangeCommentReact();
4759
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4760
            {
4761
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4762
            }
4763
            else
4764
            {
4765
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4766
                {
4767
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4768
                    {
4769
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4770
                        return;
4771
                    }                    
4772
                }
4773
                ViewerDataModel.Instance.IsConsolidate = true;
4774
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4775
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4776

    
4777
                string project_no = App.ViewInfo.ProjectNO;
4778
                string doc_id = _DocInfo.ID;
4779
                string user_id = App.ViewInfo.UserID;
4780
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4781
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4782
                {                    
4783
                    markupInfoItems.Add(item);
4784
                }
4785
                this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
4786

    
4787
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4788
            }
4789
        }
4790
        public void ConsolidationMethod()
4791
        {
4792
            ChangeCommentReact();
4793

    
4794
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4795
            {
4796
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4797
            }
4798
            else
4799
            {                                
4800
                ViewerDataModel.Instance.IsConsolidate = true;
4801
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4802
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4803

    
4804
                string project_no = App.ViewInfo.ProjectNO;
4805
                string doc_id = _DocInfo.ID;
4806
                string user_id = App.ViewInfo.UserID;
4807
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4808
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4809
                {
4810
                    markupInfoItems.Add(item);
4811
                }
4812
                this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4813
                
4814
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4815
                
4816
            }
4817
        }
4818

    
4819
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4820
        {
4821
            if (App.ViewInfo != null)
4822
            {
4823
                btnConsolidate = (sender as RadRibbonButton);
4824
                if (!App.ViewInfo.NewCommentPermission)
4825
                {
4826
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4827
                }
4828
            }
4829
        }
4830

    
4831
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4832
        {
4833
            TeamConsolidationMethod();
4834
        }
4835

    
4836
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4837
        {
4838
            btnTeamConsolidate = sender as RadRibbonButton;
4839
            if (App.ViewInfo != null)
4840
            {
4841
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4842
                {
4843
                    if (btnConsolidate != null)
4844
                    {
4845
                        btnConsolidate.Visibility = Visibility.Collapsed;
4846
                    }
4847

    
4848
                    if (!App.ViewInfo.NewCommentPermission)
4849
                    {
4850
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4851
                    }
4852
                }
4853
                else
4854
                {
4855
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4856
                }
4857
            }
4858
        }
4859

    
4860
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4861
        {
4862
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4863
            if (item != null)
4864
            {
4865
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4866
            }
4867
            else
4868
            {
4869
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4870
            }
4871
        }
4872

    
4873
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4874
        {
4875
            btnFinalPDF = sender as RadRibbonButton;
4876
            if (App.ViewInfo != null)
4877
            {
4878
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4879
                {
4880
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4881
                    if (btnConsolidate != null)
4882
                    {
4883
                        btnConsolidate.Visibility = Visibility.Collapsed;
4884
                    }
4885
                }
4886
            }
4887
        }
4888

    
4889
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4890
        {
4891
            if (CompareMode.IsChecked)
4892
            {
4893
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4894
                {
4895
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4896
                }
4897
                if (ViewerDataModel.Instance.PageNumber == 0)
4898
                {
4899
                    ViewerDataModel.Instance.PageNumber = 1;
4900
                }
4901

    
4902
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4903
            }
4904
            else
4905
            {
4906
                da.From = 1;
4907
                da.To = 1;
4908
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4909
                da.AutoReverse = false;
4910
                canvas_compareBorder.Children.Clear();
4911
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4912
            }
4913
        }
4914

    
4915
        private void Sync_Click(object sender, RoutedEventArgs e)
4916
        {
4917
            if (Sync.IsChecked)
4918
            {
4919
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4920
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4921
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4922
            }
4923
        }
4924

    
4925
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4926
        {
4927
            if (UserList.IsChecked)
4928
            {
4929
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4930
            }
4931
            else
4932
            {
4933
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4934
            }
4935
        }
4936

    
4937
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4938
        {
4939

    
4940
            if (BalanceMode.IsChecked)
4941
            {
4942
                ViewerDataModel.Instance.PageBalanceMode = true;
4943
            }
4944
            else
4945
            {
4946
                ViewerDataModel.Instance.PageBalanceMode = false;
4947
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4948
            }
4949
        }
4950

    
4951
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4952
        {
4953
            //초기화
4954
            testPanel2.IsHidden = true;
4955
            ViewerDataModel.Instance.PageBalanceMode = false;
4956
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4957
            ViewerDataModel.Instance.PageNumber = 0;
4958
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4959
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4960
            UserList.IsChecked = false;
4961
            BalanceMode.IsChecked = false;
4962
        }
4963

    
4964
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4965
        {
4966
            if ((sender as System.Windows.Controls.Control).Tag != null)
4967
            {
4968
                //Compare 초기화
4969
                CompareMode.IsChecked = false;
4970
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4971

    
4972
                if (ViewerDataModel.Instance.PageNumber == 0)
4973
                {
4974
                    ViewerDataModel.Instance.PageNumber = 1;
4975
                }
4976

    
4977
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4978
                {
4979
                }
4980
                else
4981
                {
4982
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4983
                }
4984

    
4985
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4986
                {
4987

    
4988
                }
4989
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4990
                {
4991
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4992
                }
4993

    
4994
                if (!testPanel2.IsHidden)
4995
                {
4996
                    if (IsSyncPDFMode)
4997
                    {
4998
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4999
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5000

    
5001
                        if (pdfpath.IsDownloading)
5002
                        {
5003
                            pdfpath.DownloadCompleted += (ex, arg) =>
5004
                            {
5005
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5006
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5007
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5008
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5009
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5010
                            };
5011
                        }
5012
                        else
5013
                        {
5014
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5015
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5016
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5017

    
5018
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5019
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5020
                        }
5021

    
5022
                    }
5023
                    else
5024
                    {
5025
                        string uri = "";
5026

    
5027
                        if (userData.COMPANY != "EXT")
5028
                        {
5029
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5030
                        }
5031
                        else
5032
                        {
5033
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5034
                        }
5035

    
5036
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5037

    
5038
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5039
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5040
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5041

    
5042
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5043
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5044

    
5045
                        if (defaultBitmapImage_Compare.IsDownloading)
5046
                        {
5047
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5048
                            {
5049
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5050
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5051
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5052

    
5053
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5054
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5055
                            };
5056
                        }
5057
                    }
5058

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

    
5063
                    foreach (var item in gridSelectionRevItem)
5064
                    {
5065
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5066
                        {
5067
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5068
                        });
5069
                    }
5070

    
5071
                    //강인구 추가
5072
                    zoomAndPanControl2.ZoomTo(new Rect
5073
                    {
5074
                        X = 0,
5075
                        Y = 0,
5076
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5077
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5078
                    });
5079

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

    
5082
                }
5083
            }
5084
        }
5085

    
5086
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5087
        {
5088
            if (MarkupMode.IsChecked)
5089
            {
5090
                IsSyncPDFMode = true;
5091

    
5092
                var uri = CurrentRev.TO_VENDOR;
5093

    
5094
                if (ViewerDataModel.Instance.PageNumber == 0)
5095
                {
5096
                    ViewerDataModel.Instance.PageNumber = 1;
5097
                }
5098

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

    
5103
                if (pdfpath.IsDownloading)
5104
                {
5105
                    pdfpath.DownloadCompleted += (ex, arg) =>
5106
                    {
5107
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5108
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5109
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5110
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5111
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5112
                    };
5113
                }
5114
                else
5115
                {
5116
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5117
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5118
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5119

    
5120
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5121
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5122
                }
5123
            }
5124
            else
5125
            {
5126
                IsSyncPDFMode = false;
5127
                string uri = "";
5128
                if (userData.COMPANY != "EXT")
5129
                {
5130
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5131
                }
5132
                else
5133
                {
5134
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5135
                }
5136

    
5137
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5138

    
5139
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5140
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5141
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5142

    
5143
                if (defaultBitmapImage_Compare.IsDownloading)
5144
                {
5145
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5146
                    {
5147
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5148
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5149
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5150
                    };
5151
                }
5152
                zoomAndPanControl2.ApplyTemplate();
5153
                zoomAndPanControl2.UpdateLayout();
5154
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5155
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5156
            }
5157
        }
5158

    
5159
        private void RadButton_Click(object sender, RoutedEventArgs e)
5160
        {
5161
            gridViewHistory_Busy.IsBusy = true;
5162

    
5163
            RadButton instance = sender as RadButton;
5164
            if (instance.CommandParameter != null)
5165
            {
5166
                CurrentRev = instance.CommandParameter as VPRevision;
5167
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5168
                {
5169
                    if (ea.Error == null && ea.Result != null)
5170
                    {
5171
                        testPanel2.IsHidden = false;
5172

    
5173
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5174
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5175

    
5176
                        string uri = "";
5177
                        if (userData.COMPANY != "EXT")
5178
                        {
5179
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5180
                        }
5181
                        else
5182
                        {
5183
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5184
                        }
5185

    
5186
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5187

    
5188
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5189

    
5190
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5191
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5192
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5193

    
5194
                        if (defaultBitmapImage_Compare.IsDownloading)
5195
                        {
5196
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5197
                            {
5198
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5199
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5200
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5201
                            };
5202
                        }
5203

    
5204
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5205
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5206
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5207
                        zoomAndPanControl2.ApplyTemplate();
5208
                        zoomAndPanControl2.UpdateLayout();
5209

    
5210
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5211
                        {
5212
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5213
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5214
                        }
5215

    
5216
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5217
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5218
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5219

    
5220
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5221
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5222
                        gridViewHistory_Busy.IsBusy = false;
5223
                    }
5224
                };
5225
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5226
            }
5227
        }
5228

    
5229
        public void Sync_Event(VPRevision Currnet_Rev)
5230
        {
5231
            CurrentRev = Currnet_Rev;
5232

    
5233
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5234
            {
5235
                if (ea.Error == null && ea.Result != null)
5236
                {
5237
                    testPanel2.IsHidden = false;
5238

    
5239
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5240
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5241

    
5242
                    string uri = "";
5243
                    if (userData.COMPANY != "EXT")
5244
                    {
5245
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5246
                    }
5247
                    else
5248
                    {
5249
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5250
                    }
5251

    
5252
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5253

    
5254
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5255

    
5256
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5257
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5258
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5259

    
5260
                    if (defaultBitmapImage_Compare.IsDownloading)
5261
                    {
5262
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5263
                        {
5264
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5265
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5266
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5267
                        };
5268
                    }
5269
                    
5270
                    
5271
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5272
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5273
                    zoomAndPanControl2.ApplyTemplate();
5274
                    zoomAndPanControl2.UpdateLayout();
5275

    
5276
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5277
                    {
5278
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5279
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5280
                    }
5281
                    //}
5282

    
5283
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5284
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5285
                    gridViewHistory_Busy.IsBusy = false;
5286
                }
5287
            };
5288
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5289

    
5290

    
5291
        }
5292

    
5293
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5294
        {
5295
            if (sender is Image)
5296
            {
5297
                if ((sender as Image).Tag != null)
5298
                {
5299
                    var pdfUrl = (sender as Image).Tag.ToString();
5300
                    System.Diagnostics.Process.Start(pdfUrl);
5301
                }
5302
                else
5303
                {
5304
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5305
                }
5306
            }
5307
        }
5308

    
5309
        private void Create_Symbol(object sender, RoutedEventArgs e)
5310
        {
5311
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5312
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5313

    
5314
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5315
            {
5316
                DialogMessage_Alert("Please Select Controls", "Alert");
5317
            }
5318
            else //선택된 것이 있으면
5319
            {
5320
                string MarkupData = "";
5321
                adorner_ = new AdornerFinal();
5322

    
5323
                foreach (var item in SelectLayer.Children)
5324
                {
5325
                    if (item.GetType().Name == "AdornerFinal")
5326
                    {
5327
                        adorner_ = (item as Controls.AdornerFinal);
5328
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5329
                        {
5330
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5331
                            {
5332
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5333
                                MarkupData += markupReturn.ConvertData;
5334
                            }
5335
                        }
5336
                    }
5337
                }
5338
                DialogParameters parameters = new DialogParameters()
5339
                {
5340
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5341
                    DefaultPromptResultValue = "Custom State",
5342
                    Content = "Name :",
5343
                    Header = "Insert Custom Symbol Name",
5344
                    Theme = new VisualStudio2013Theme(),
5345
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5346
                };
5347
                RadWindow.Prompt(parameters);
5348
            }
5349

    
5350
        }
5351

    
5352
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5353
        {
5354
            Save save = new Save();
5355

    
5356
            if (args.DialogResult.Value)
5357
            {
5358
                PngBitmapEncoder _Encoder = symImage(data);
5359

    
5360
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5361
                _Encoder.Save(fs);
5362
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5363

    
5364
                byte[] Img_byte = fs.ToArray();
5365

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

    
5369
                save.SymbolSave(args.PromptResult, filename, data);
5370
            }
5371
        }
5372

    
5373
        public PngBitmapEncoder symImage(string data)
5374
        {
5375

    
5376
            Canvas _canvas = new Canvas();
5377
            _canvas.Background = Brushes.White;
5378
            _canvas.Width = adorner_.BorderSize.Width;
5379
            _canvas.Height = adorner_.BorderSize.Height;
5380
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5381

    
5382
            BitmapEncoder encoder = new PngBitmapEncoder();
5383

    
5384

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

    
5387
            DrawingVisual dv = new DrawingVisual();
5388

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

    
5392
            using (DrawingContext ctx = dv.RenderOpen())
5393
            {
5394
                VisualBrush vb = new VisualBrush(_canvas);
5395
                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)));
5396
            }
5397

    
5398
            try
5399
            {
5400
                renderBitmap.Render(dv);
5401

    
5402
                GC.Collect();
5403
                GC.WaitForPendingFinalizers();
5404
                GC.Collect();
5405
                // encode png data
5406
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5407
                // puch rendered bitmap into it
5408
                pngEncoder.Interlace = PngInterlaceOption.Off;
5409
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5410
                return pngEncoder;
5411

    
5412
            }
5413
            catch (Exception ex)
5414
            {
5415
                return null;
5416
            }
5417

    
5418
        }
5419

    
5420
        public void DialogMessage_Alert(string content, string header)
5421
        {
5422
            var box = new TextBlock();
5423
            box.MinWidth = 400;
5424
            box.FontSize = 11;
5425
            //box.FontSize = 12;
5426
            box.Text = content;
5427
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5428

    
5429
            DialogParameters parameters = new DialogParameters()
5430
            {
5431
                Content = box,
5432
                Header = header,
5433
                Theme = new VisualStudio2013Theme(),
5434
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5435
            };
5436
            RadWindow.Alert(parameters);
5437
        }
5438

    
5439
        #region 캡쳐 기능
5440

    
5441
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5442
        {
5443
            if (x < 0)
5444
            {
5445
                width += x;
5446
                x = 0;
5447
            }
5448
            if (y < 0)
5449
            {
5450
                height += y;
5451
                y = 0;
5452

    
5453
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5454
            }
5455
            if (x + width > zoomAndPanCanvas.ActualWidth)
5456
            {
5457
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5458
            }
5459
            if (y + height > zoomAndPanCanvas.ActualHeight)
5460
            {
5461
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5462
            }
5463

    
5464
            byte[] pixels = CopyPixels(x, y, width, height);
5465

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

    
5468
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5469
        }
5470

    
5471
        public byte[] CopyPixels(int x, int y, int width, int height)
5472
        {
5473
            byte[] pixels = new byte[width * height * 4];
5474
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5475

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

    
5479
            return pixels;
5480
        }
5481

    
5482
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5483
        {
5484
            DrawingVisual drawingVisual = new DrawingVisual();
5485
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5486

    
5487
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5488
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5489
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5490
            drawingContext.Close();
5491

    
5492
            // 비트맵으로 변환합니다.
5493
            RenderTargetBitmap target =
5494
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5495
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5496

    
5497
            target.Render(drawingVisual);
5498
            return target;
5499
        }
5500

    
5501
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5502
        {
5503
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5504
            KCOMDataModel.DataModel.CHECK_LIST check_;
5505
            string Result = streamToBase64.ImageToBase64(source);
5506
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5507
            string projectno = App.ViewInfo.ProjectNO;
5508
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5509
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5510
            if (Item == null)
5511
            {
5512
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5513
                {
5514
                    ID = Save.shortGuid(),
5515
                    USER_ID = App.ViewInfo.UserID,
5516
                    IMAGE_URL = Result,
5517
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5518
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5519
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5520
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5521
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5522
                    STATUS = "False",
5523
                    CREATE_TIME = DateTime.Now,
5524
                    UPDATE_TIME = DateTime.Now,
5525
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5526
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5527
                };
5528
                this.BaseClient.AddCheckList(projectno, check_);
5529
            }
5530
            else
5531
            {
5532
                Item.IMAGE_URL = Result;
5533
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5534
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5535
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5536
            }
5537
            
5538
        }
5539

    
5540
        public void Set_Capture()
5541
        {            
5542
            double x = canvasDrawingMouseDownPoint.X;
5543
            double y = canvasDrawingMouseDownPoint.Y;
5544
            double width = dragCaptureBorder.Width;
5545
            double height = dragCaptureBorder.Height;
5546

    
5547
            if (width > 5 || height > 5)
5548
            {
5549
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5550
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5551
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5552
            }
5553
        }
5554
        #endregion
5555

    
5556
        TempFile temp = new TempFile();
5557
        //MarkupInfoItem
5558
        public void CreateControl()
5559
        {
5560
            
5561
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5562
            {
5563
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5564
            });
5565
            multi_Undo_Data.Markup = currentControl;
5566
            UndoData.Markup_List.Add(multi_Undo_Data);
5567
           
5568
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5569

    
5570
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5571

    
5572
            temp.AddTemp(currentControl, pageNavigator.CurrentPage.PageNumber);
5573
        }
5574

    
5575
        
5576
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5577
        {
5578
            multi_Undo_Data = new Multi_Undo_data();
5579

    
5580
            multi_Undo_Data.Markup = control;
5581

    
5582
            if ((control as IShapeControl) != null)
5583
            {
5584
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5585
            }
5586
            if ((control as IDashControl) != null)
5587
            {
5588
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5589
            }
5590
            if ((control as IPath) != null)
5591
            {
5592
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5593
            }
5594
            if ((control as UIElement) != null)
5595
            {
5596
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5597
            }
5598

    
5599
            return multi_Undo_Data;
5600
        }
5601

    
5602
        public void Undo()
5603
        {
5604
            if (ViewerDataModel.Instance.IsPressCtrl)
5605
            {
5606
                ViewerDataModel.Instance.IsPressCtrl = false;
5607
            }
5608
            Undo_data undo = new Undo_data();
5609
            AdornerFinal final;
5610
            ReleaseAdorner();
5611

    
5612
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5613
            if (undo == null)
5614
                return;
5615

    
5616
            
5617

    
5618
            switch (undo.Event)
5619
            {
5620
                case (Event_Type.Create):
5621
                    {
5622
                        foreach (var item in undo.Markup_List)
5623
                        {
5624
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5625
                            //임시파일에서도 삭제한다.
5626
                            temp.DataDel(item.Markup.CommentID);
5627
                        }
5628
                    }
5629
                    break;
5630
                case (Event_Type.Delete):
5631
                    {
5632
                        foreach (var item in undo.Markup_List)
5633
                        {
5634
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5635
                        }
5636
                    }
5637
                    break;
5638
                case (Event_Type.Thumb):
5639
                    {
5640
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5641

    
5642
                        foreach (var item in undo.Markup_List)
5643
                        {
5644
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5645

    
5646
                            if ((item.Markup as IViewBox) != null)
5647
                            {
5648
                                (item.Markup as IViewBox).Angle = item.Angle;
5649
                            }
5650
                            if ((item.Markup as TextControl) != null)
5651
                            {
5652
                                (item.Markup as TextControl).Angle = item.Angle;
5653
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5654
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5655
                            }
5656
                            else
5657
                            {
5658
                                (item.Markup as IPath).PointSet = item.PointSet;
5659
                                (item.Markup as IPath).updateControl();
5660
                            }
5661

    
5662
                            comment.Add(item.Markup);
5663
                        }
5664
                        final = new AdornerFinal(comment);
5665
                        SelectLayer.Children.Add(final);
5666
                        ReleaseAdorner();
5667
                    }
5668
                    break;
5669
                case (Event_Type.Select):
5670
                    {
5671
                        ReleaseAdorner();
5672
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5673

    
5674
                        foreach (var item in undo.Markup_List)
5675
                        {
5676
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5677

    
5678
                            if ((item.Markup as IPath) != null)
5679
                            {
5680
                                (item.Markup as IPath).LineSize = item.LineSize;
5681
                            }
5682
                            if ((item.Markup as UIElement) != null)
5683
                            {
5684
                                (item.Markup as UIElement).Opacity = item.Opacity;
5685
                            }
5686
                            if ((item.Markup as IDashControl) != null)
5687
                            {
5688
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5689
                            }
5690
                            if ((item.Markup as IShapeControl) != null)
5691
                            {
5692
                                (item.Markup as IShapeControl).Paint = item.paint;
5693
                            }
5694

    
5695
                            comment.Add(item.Markup);
5696
                        }
5697

    
5698
                        final = new AdornerFinal(comment);
5699
                        SelectLayer.Children.Add(final);
5700
                    }
5701
                    break;
5702
                case (Event_Type.Option):
5703
                    {
5704
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5705

    
5706
                        foreach (var item in undo.Markup_List)
5707
                        {
5708
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5709

    
5710
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5711
                            {
5712
                                (item.Markup as IPath).LineSize = undo.LineSize;
5713
                            }
5714
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5715
                            {
5716
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5717
                            }
5718
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5719
                            {
5720
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5721
                            }
5722
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5723
                            {
5724
                                (item.Markup as LineControl).Interval = undo.Interval;
5725
                            }
5726
                            else if (item.Markup as IShapeControl != null)
5727
                            {
5728
                                (item.Markup as IShapeControl).Paint = undo.paint;
5729
                            }
5730
                            comment.Add(item.Markup);
5731
                        }
5732
                        final = new AdornerFinal(comment);
5733
                        SelectLayer.Children.Add(final);
5734
                    }
5735
                    break;
5736
            }
5737
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5738
           {
5739
               i.IsUndo = true;
5740
           });
5741
        }
5742

    
5743
        public void Redo()
5744
        {
5745
            if (ViewerDataModel.Instance.IsPressCtrl)
5746
            {
5747
                ViewerDataModel.Instance.IsPressCtrl = false;
5748
            }
5749
            AdornerFinal final;
5750
            Undo_data redo = new Undo_data();
5751
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5752
            ReleaseAdorner();
5753
            if (redo == null)
5754
                return;
5755

    
5756
            switch (redo.Event)
5757
            {
5758
                case (Event_Type.Create):
5759
                    {
5760
                        foreach (var item in redo.Markup_List)
5761
                        {
5762
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5763
                            temp.AddTemp(item.Markup, pageNavigator.CurrentPage.PageNumber);
5764
                        }
5765
                    }
5766
                    break;
5767
                case (Event_Type.Delete):
5768
                    {
5769
                        foreach (var item in redo.Markup_List)
5770
                        {
5771
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5772
                        }
5773
                    }
5774
                    break;
5775
                case (Event_Type.Thumb):
5776
                    {
5777
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5778

    
5779
                        foreach (var item in redo.Markup_List)
5780
                        {
5781
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5782

    
5783
                            if ((item.Markup as IViewBox) != null)
5784
                            {
5785
                                (item.Markup as IViewBox).Angle = item.Angle;
5786
                            }
5787
                            if ((item.Markup as TextControl) != null)
5788
                            {
5789
                                (item.Markup as TextControl).Angle = item.Angle;
5790

    
5791
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5792
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5793
                            }
5794
                            else
5795
                            {
5796
                                (item.Markup as IPath).PointSet = item.PointSet;
5797
                                (item.Markup as IPath).updateControl();
5798
                            }
5799
                            comment.Add(item.Markup);
5800
                        }
5801
                        final = new AdornerFinal(comment);
5802
                        SelectLayer.Children.Add(final);
5803
                        ReleaseAdorner();
5804
                    }
5805
                    break;
5806
                case (Event_Type.Select):
5807
                    {
5808
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5809

    
5810
                        foreach (var item in redo.Markup_List)
5811
                        {
5812
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5813

    
5814
                            if ((item.Markup as IPath) != null)
5815
                            {
5816
                                (item.Markup as IPath).LineSize = item.LineSize;
5817
                            }
5818
                            if ((item.Markup as UIElement) != null)
5819
                            {
5820
                                (item.Markup as UIElement).Opacity = item.Opacity;
5821
                            }
5822
                            if ((item.Markup as IDashControl) != null)
5823
                            {
5824
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5825
                            }
5826
                            if ((item.Markup as IShapeControl) != null)
5827
                            {
5828
                                (item.Markup as IShapeControl).Paint = item.paint;
5829
                            }
5830

    
5831
                            comment.Add(item.Markup);
5832
                        }
5833
                        final = new AdornerFinal(comment);
5834
                        SelectLayer.Children.Add(final);
5835
                    }
5836
                    break;
5837
                case (Event_Type.Option):
5838
                    {
5839
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5840

    
5841
                        foreach (var item in redo.Markup_List)
5842
                        {
5843
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5844
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5845
                            {
5846
                                (item.Markup as IPath).LineSize = redo.LineSize;
5847
                            }
5848
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5849
                            {
5850
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5851
                            }
5852
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5853
                            {
5854
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5855
                            }
5856
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
5857
                            {
5858
                                (item.Markup as LineControl).Interval = redo.Interval;
5859
                            }
5860
                            else if (item.Markup as IShapeControl != null)
5861
                            {
5862
                                (item.Markup as IShapeControl).Paint = redo.paint;
5863
                            }
5864
                            comment.Add(item.Markup);
5865
                        }
5866
                        final = new AdornerFinal(comment);
5867
                        SelectLayer.Children.Add(final);
5868
                    }
5869
                    break;
5870
            }
5871

    
5872
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5873
            {
5874
                i.IsUndo = false;
5875
            });
5876
        }
5877

    
5878
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5879
        {
5880
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5881
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5882
            {
5883
                if (items.UserID == Select_ID)
5884
                {
5885
                    foreach (var item in items.MarkupList)
5886
                    {
5887
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5888
                        {
5889
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5890
                        }
5891
                    }
5892
                }
5893
            }
5894
        }
5895
        public void EmptyControlCheck()
5896
        {
5897
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
5898
            {
5899
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
5900
                {
5901
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
5902
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
5903
                    {
5904
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
5905
                    }
5906
                }
5907
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
5908
                {
5909
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
5910
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
5911
                    {
5912
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
5913
                    }
5914
                }
5915
            }
5916
        }
5917
        public void InkControl_Convert()
5918
        {
5919
            if (inkBoard.Strokes.Count > 0)
5920
            {
5921
                inkBoard.Strokes.ToList().ForEach(stroke =>
5922
                {
5923
                    List<Stroke> removingStroke = new List<Stroke>();
5924
                    StrokeCollection stC = new StrokeCollection();
5925

    
5926
                    removingStroke.Add(stroke);
5927

    
5928
                    InkToPath ip = new InkToPath();
5929
                    List<Point> inkPointSet = new List<Point>();
5930
                    PolygonControl pc = null;
5931
                    pc = new PolygonControl()
5932
                    {
5933
                        Angle = 0,
5934
                        PointSet = new List<Point>(),
5935
                        ControlType = ControlType.Ink
5936
                    };
5937
                    foreach (var item in removingStroke)
5938
                    {
5939
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5940
                        inkBoard.Strokes.Remove(item);
5941
                    }
5942
                    if (inkPointSet.Count != 0)
5943
                    {
5944
                        //강인구 추가(PenControl Undo Redo 추가)
5945
                        UndoData = new Undo_data()
5946
                        {
5947
                            IsUndo = false,
5948
                            Event = Event_Type.Create,
5949
                            EventTime = DateTime.Now,
5950
                            Markup_List = new List<Multi_Undo_data>()
5951
                        };
5952

    
5953
                        pc.StartPoint = inkPointSet[0];
5954
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5955
                        pc.PointSet = inkPointSet;
5956
                        pc.LineSize = 3;
5957
                        pc.CommentID = Save.shortGuid();
5958
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5959
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5960
                        pc.SetPolyPath();
5961

    
5962
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5963
                        {
5964
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5965
                        });
5966
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5967
                        UndoData.Markup_List.Add(multi_Undo_Data);
5968
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5969
                    }
5970
                });
5971
            }
5972
        }
5973

    
5974
        /// <summary>
5975
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
5976
        /// </summary>
5977
        /// <param name="StartP">StartPoint</param>
5978
        /// <param name="EndP">EndPoint</param>
5979
        /// <returns>Return_EndPoint</returns>
5980
        private Point GetSquareEndPoint(Point StartP, Point EndP)
5981
        {
5982
            Point Return_Point = new Point();
5983

    
5984
            double dx = EndP.X - StartP.X;
5985
            double dy = EndP.Y - StartP.Y;
5986
            double length;
5987

    
5988
            switch (controlType)
5989
            {
5990
                case ControlType.Triangle:
5991
                    {
5992
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
5993
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
5994
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
5995
                    }
5996
                    break;
5997
                default:
5998
                    {
5999
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6000
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6001
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6002
                    }
6003
                    break;
6004
            }
6005

    
6006
            return Return_Point;
6007
        }
6008

    
6009
        /// <summary>
6010
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6011
        /// </summary>
6012
        /// <author>humkyung</author>
6013
        /// <date>2018.04.26</date>
6014
        /// <param name="StartP"></param>
6015
        /// <param name="EndP"></param>
6016
        /// <returns></returns>
6017
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6018
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6019
        {
6020
            List<Point> res = new List<Point>();
6021

    
6022
            double dx = EndP.X - StartP.X;
6023
            double dy = EndP.Y - StartP.Y;
6024
            double length = Math.Sqrt(dx * dx + dy * dy);
6025
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6026
            dx /= length;
6027
            dy /= length;
6028
            double tmp = dx;
6029
            dx = -dy; dy = tmp; /// rotate by 90 degree
6030

    
6031
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6032
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6033

    
6034
            return res;
6035
        }
6036

    
6037
        /// <summary>
6038
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6039
        /// </summary>
6040
        /// <author>ingu</author>
6041
        /// <date>2018.06.05</date>
6042
        /// <param name="getPoint"></param>
6043
        /// <returns></returns>
6044
        private bool IsGetoutpoint(Point getPoint)
6045
        {
6046
            if (getPoint == new Point())
6047
            {
6048
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6049
                currentControl = null;
6050
                return true;
6051
            }
6052

    
6053
            return false;
6054
        }
6055

    
6056
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6057
        {
6058
            e.Effects = DragDropEffects.Copy;
6059
        }
6060

    
6061
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6062
        {
6063
            e.Effects = DragDropEffects.Copy;
6064
        }
6065

    
6066
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6067
        {
6068
            e.Effects = DragDropEffects.None;
6069
        }
6070

    
6071
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6072
        {
6073
            if (e.Data.GetDataPresent(typeof(string)))
6074
            {
6075
                this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6076
                string dragData = e.Data.GetData(typeof(string)) as string;
6077
                Move_Symbol(sender, dragData);
6078
            }
6079
        }
6080

    
6081
        private void Move_Symbol(object sender, string dragData)
6082
        {
6083
            if (dragData.Contains("|DZ|"))
6084
            {
6085
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6086

    
6087
                string[] delimiterChars = { "|DZ|" };
6088
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6089

    
6090
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
6091

    
6092
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6093

    
6094
                //강인구 Undo/Redo 보류
6095
                UndoData = new Undo_data()
6096
                {
6097
                    IsUndo = false,
6098
                    Event = Event_Type.Create,
6099
                    EventTime = DateTime.Now,
6100
                    Markup_List = new List<Multi_Undo_data>()
6101
                };
6102

    
6103
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6104
                {
6105
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
6106
                });
6107

    
6108
                foreach (string parse in data)
6109
                {
6110
                    if (parse != "")
6111
                    {
6112
                        System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
6113
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
6114

    
6115
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6116
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6117

    
6118
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6119

    
6120
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
6121

    
6122
                        UndoData.Markup_List.Add(multi_Undo_Data);
6123
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6124
                    }
6125
                }
6126
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6127

    
6128
                /// move symbol to current mouse point
6129
                double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6130
                double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6131
                final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6132

    
6133
                if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6134
                {
6135
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6136
                }
6137
                /// up to here
6138
                
6139
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6140
            }
6141
        }
6142
    }
6143
}
클립보드 이미지 추가 (최대 크기: 500 MB)