프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 2eac4f76

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

    
9
using System;
10
using System.Collections.Generic;
11
using System.Linq;
12
using System.Text;
13
using System.Windows;
14
using System.Windows.Controls;
15
using System.Windows.Data;
16
using System.Windows.Documents;
17
using System.Windows.Input;
18
using System.Windows.Media;
19
using System.Windows.Media.Imaging;
20
using System.Windows.Navigation;
21
using System.Windows.Shapes;
22
using KCOM.Common;
23
//using MarkupToPDF.Controls.Event;
24
using IKCOM;
25
using System.Windows.Ink;
26
using System.Collections.ObjectModel;
27
using Telerik.Windows.Controls;
28
using KCOM.Events;
29
using System.Reflection;
30
using MarkupToPDF.Common;
31
using KCOM.Controls;
32
//using MARKUS;
33

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

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

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

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

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

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

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

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

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

    
108
    /// <summary>
109
    /// MainMenu.xaml에 대한 상호 작용 논리
110
    /// </summary>
111
    public partial class MainMenu : UserControl
112
    {
113
        #region 프로퍼티
114
        //public List<Undo_data> UndoDataList { get; set; }
115
        public Undo_data UndoData { get; set; }
116

    
117
        public CommentUserInfo currentControl { get; set; }
118
        public ControlType controlType { get; set; }
119
        private Move move;
120
        private double[] rotateValue = { 0, 90, 180, 270 };
121
        //private OverView overview = new OverView();
122
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
123
        public MouseButton mouseButtonDown { get; set; }
124
        private static readonly double DragThreshold = 5;
125
        private Cursor cursor { get; set; }
126
        private Point canvasDrawingMouseDownPoint;
127
        public string filename { get; set; }
128
        private Point canvasZoomPanningMouseDownPoint;
129
        public Point getCurrentPoint;
130
        private Point canvasZoommovingMouseDownPoint;
131
        private int rotateOffSet = 0;
132
        List<object> ControlList = new List<object>();
133
        private ListBox listBox = new ListBox();
134
        //public ObservableCollection<MarkupInfoItem> _markupInfoList = new ObservableCollection<MarkupInfoItem>();
135
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
136
        private bool isDraggingSelectionRect = false;
137
        DrawingAttributes inkDA = new DrawingAttributes();
138
        private VPRevision CurrentRev { get; set; }
139
        public RadRibbonButton btnConsolidate { get; set; }
140
        public RadRibbonButton btnFinalPDF { get; set; }
141
        public RadRibbonButton btnTeamConsolidate { get; set; }
142
        public string Filename_ { get; set; }
143
        public double L_Size = 0;
144
        public AdornerFinal adorner_;
145
        public Multi_Undo_data multi_Undo_Data;
146
        public string Symbol_ID = "";
147
        /// <summary>
148
        /// Set to 'true' when the left mouse-button is down.
149
        /// </summary>
150
        private bool isLeftMouseButtonDownOnWindow = false;
151
        //public int currnetNo = 1;
152

    
153
        public InkPresenter _InkBoard = null;
154
        Stroke stroke;
155
        Boolean IsDrawing = false;
156
        StylusPointCollection strokePoints;
157
        StylusPointCollection erasePoints;
158
        RenderTargetBitmap canvasImage;
159
        Point Sync_Offset_Point;
160

    
161
        //강인구 테스트
162
        private Path _SelectionPath { get; set; }
163
        public Path SelectionPath
164
        {
165
            get
166
            {
167
                return _SelectionPath;
168
            }
169
            set
170
            {
171
                if (_SelectionPath != value)
172
                {
173
                    _SelectionPath = value;
174
                    RaisePropertyChanged("SelectionPath");
175

    
176
                }
177
            }
178
        }
179

    
180
        //private RasterImageViewer _imageViewer { get; set; }
181
        //public RasterImageViewer imageViewer
182
        //{
183
        //    get
184
        //    {
185
        //        if (_imageViewer == null)
186
        //        {
187
        //            _imageViewer = new RasterImageViewer();
188
        //            return _imageViewer;
189
        //        }
190
        //        else
191
        //        {
192
        //            return _imageViewer;
193
        //        }
194
        //    }
195
        //    set
196
        //    {
197
        //        if (_imageViewer != value)
198
        //        {
199
        //            _imageViewer = value;
200
        //        }
201
        //    }
202
        //}
203

    
204
        private System.Windows.Controls.Image _imageViewer { get; set; }
205
        public System.Windows.Controls.Image imageViewer
206
        {
207
            get
208
            {
209
                if (_imageViewer == null)
210
                {
211
                    _imageViewer = new System.Windows.Controls.Image();
212
                    return _imageViewer;
213
                }
214
                else
215
                {
216
                    return _imageViewer;
217
                }
218
            }
219
            set
220
            {
221
                if (_imageViewer != value)
222
                {
223
                    _imageViewer = value;
224
                }
225
            }
226
        }
227

    
228
        public bool IsSyncPDFMode { get; set; }
229

    
230

    
231
        //private RasterImageViewer _imageViewer_Compare { get; set; }
232
        //public RasterImageViewer imageViewer_Compare
233
        //{
234
        //    get
235
        //    {
236
        //        if (_imageViewer_Compare == null)
237
        //        {
238
        //            _imageViewer_Compare = new RasterImageViewer();
239
        //            return _imageViewer_Compare;
240
        //        }
241
        //        else
242
        //        {
243
        //            return _imageViewer_Compare;
244
        //        }
245
        //    }
246
        //    set
247
        //    {
248
        //        if (_imageViewer_Compare != value)
249
        //        {
250
        //            _imageViewer_Compare = value;
251
        //        }
252
        //    }
253
        //}
254

    
255
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
256
        public System.Windows.Controls.Image imageViewer_Compare
257
        {
258
            get
259
            {
260
                if (_imageViewer_Compare == null)
261
                {
262
                    _imageViewer_Compare = new System.Windows.Controls.Image();
263
                    return _imageViewer_Compare;
264
                }
265
                else
266
                {
267
                    return _imageViewer_Compare;
268
                }
269
            }
270
            set
271
            {
272
                if (_imageViewer_Compare != value)
273
                {
274
                    _imageViewer_Compare = value;
275
                }
276
            }
277
        }
278

    
279
        #endregion
280

    
281

    
282
        public MainMenu()
283
        {
284
            InitializeComponent();
285
            this.Loaded += MainMenu_Loaded;
286
            //UndoDataList = new List<Undo_data>();
287

    
288
            //var console = new MyConsole();
289
            //this.Content = console.Gui;
290
            //var read = console.ReadLine();
291
            //console.WriteLine(read);
292

    
293
        }
294
        private void SetCursor()
295
        {
296
            this.Cursor = cursor;
297
        }
298

    
299
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
300
        {
301
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
302
                             zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
303
                             (_canvasZoomPanningMouseDownPoint.Y > 0 &&
304
                             zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
305
            {
306
                return true;
307
            }
308

    
309
            return false;
310
        }
311

    
312
        public void DeleteItem(MarkupInfoItem item)
313
        {
314
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
315
            {
316
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
317
            }
318

    
319
            ViewerDataModel.Instance._markupInfoList.Remove(item);
320

    
321
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
322
            {
323
                ViewerDataModel.Instance.MarkupControls.Remove(a);
324
            });
325

    
326
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
327
            {
328
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
329
            });
330

    
331
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
332
            {
333
                ComingNewBieEnd = false;
334
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
335
            });
336

    
337
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
338
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
339
            {
340
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
341
                {
342
                    var infoId = Events.Save.shortGuid();
343
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
344
                    {
345
                        CreateTime = DateTime.Now,
346
                        Depatment = userData.DEPARTMENT,
347
                        DisplayColor = "#FFFF0000",
348
                        UserID = userData.ID,
349
                        UserName = userData.NAME,
350
                        PageCount = 1,
351
                        Description = "",
352
                        MarkupInfoID = infoId,
353
                        MarkupList = null,
354
                        MarkupVersionID = Events.Save.shortGuid(),
355
                        Consolidate = 0,
356
                        PartConsolidate = 0,
357
                        userDelete = true,
358
                        AvoidConsolidate = 0,
359
                        IsPreviewUser = true
360
                    };
361
                    App.Custom_ViewInfoId = infoId;
362
                }
363
            }
364
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
365
        }
366

    
367
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
368
        {
369
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
370
            this.ReleaseAdorner();
371

    
372
            Button content = (sender as Button);
373
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
374

    
375
            DeleteItem(item);
376
        }
377

    
378
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
379

    
380
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
381
        {
382
            if (App.ParameterMode)
383
            {
384
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
385
                imageViewer_Compare = new Image();
386

    
387
                //drawingRotateCanvas.Children.Add(imageViewer);
388
                //imageViewer1 = imageViewer;
389

    
390
                //drawingRotateCanvas2.Children.Add(imageViewer_Compare);
391

    
392
                //zoomAndPanCanvas.Children.Add(imageViewer);
393
                //zoomAndPanCanvas2.Children.Add(imageViewer_Compare);
394

    
395
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
396
                ViewerDataModel.Instance.Capture_Opacity = 0;
397
                //ViewerDataModel.Instance.Capture_Opacity = 0.5;
398

    
399
                //testPanel.Visibility = Visibility.Collapsed;
400
                //testPanel2.IsHidden = false;
401
                //testPanel2.Visibility = Visibility.Visible;
402
                //testPanel3.Visibility = Visibility.Collapsed;
403

    
404

    
405
                da.From = 0.8;
406
                da.To = 0;
407
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
408
                da.AutoReverse = true;
409
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
410
            }
411

    
412

    
413
        }
414

    
415
        public void ReleaseAdorner()
416
        {
417
            if (SelectLayer.Children.Count > 0)
418
            {
419
                foreach (var item in SelectLayer.Children)
420
                {
421
                    if (item.GetType().Name == "AdornerFinal")
422
                    {
423
                        (item as AdornerFinal).unRegister();
424

    
425
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
426
                        {
427
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
428
                            {
429
                                //if (InnerItem.DrawingData.GetType().Name == "InkControl")
430
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
431
                                {
432
                                    if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
433
                                    {
434
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
435
                                    }
436
                                }
437

    
438
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
439
                            }
440
                        }
441
                    }
442
                }
443
                SelectLayer.Children.Clear();
444
            }
445
        }
446

    
447
        public List<CommentUserInfo> AddAdorner()
448
        {
449
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
450

    
451
            if (SelectLayer.Children.Count > 0)
452
            {
453
                foreach (var item in SelectLayer.Children)
454
                {
455
                    if (item.GetType().Name == "AdornerFinal")
456
                    {
457
                        (item as AdornerFinal).unRegister();
458

    
459
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
460
                        {
461
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
462
                            {
463
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
464
                            }
465

    
466
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
467

    
468
                            UndoData.Markup_List.Add(multi_Undo_Data);
469
                            multi_Undo_Data = new Multi_Undo_data();
470
                        }
471
                    }
472
                }
473
                SelectLayer.Children.Clear();
474
            }
475
            return adornerSet;
476
        }
477

    
478
        public void ChangeCommentReact()
479
        {
480
            bool isComingNewBie = false;
481
            //if (PreviewUserMarkupInfoItem != null) // 신규 임시 저장인 경우
482
            //{
483

    
484
            //}
485
            //else //기존 게시물에 추가하는 경우
486
            //{
487

    
488
            //}
489

    
490
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
491
            {
492
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
493
                {
494
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
495
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
496
                    if (existItem != null) //신규 추가 된 코멘트
497
                    {
498
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
499
                        {
500
                            existItem.Data = root.ConvertData;
501
                            existItem.IsUpdate = true;
502
                        }
503
                    }
504
                    else
505
                    {
506
                        if (root.CommentID != null)
507
                        {
508
                            isComingNewBie = true;
509
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
510
                            if (currentCommentCheck != null)
511
                            {
512
                                currentCommentCheck.Data = root.ConvertData;
513
                            }
514
                            else
515
                            {
516
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
517
                                {
518
                                    ID = control.CommentID,
519
                                    Data = root.ConvertData,
520
                                    Data_Type = root.DATA_TYPE,
521
                                    MarkupInfoID = App.Custom_ViewInfoId,
522
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
523
                                });
524
                            }
525
                        }
526
                    }
527
                }
528
            }
529
            else
530
            {
531
                //gridViewMarkup.SelectedItems.Clear();
532
            }
533

    
534

    
535
            //if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
536
            //{
537
            //    foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
538
            //    {
539
            //        var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
540
            //        var existItem = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.ID == root.CommentID).FirstOrDefault();
541
            //        if (existItem != null) //신규 추가 된 코멘트
542
            //        {
543
            //            if (existItem.Data != root.ConvertData) //코멘트가 같은지
544
            //            {
545
            //                existItem.Data = root.ConvertData;
546
            //                existItem.IsUpdate = true;
547
            //            }
548
            //        }
549
            //        else //신규 코멘트
550
            //        {
551
            //            if (root.CommentID != null)
552
            //            {
553
            //                isComingNewBie = true;
554
            //                var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
555
            //                if (currentCommentCheck!=null)
556
            //                {
557
            //                    currentCommentCheck.Data = root.ConvertData;
558
            //                }
559
            //                else
560
            //                {
561
            //                    ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
562
            //                    {
563
            //                        ID = control.CommentID,
564
            //                        Data = root.ConvertData,
565
            //                        Data_Type = root.DATA_TYPE,
566
            //                        MarkupInfoID = App.Custom_ViewInfoId,
567
            //                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
568
            //                    });
569
            //                }
570
            //            }
571

    
572
            //        }
573
            //    }
574

    
575
            //}
576

    
577
            //if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
578
            //if (PreviewUserMarkupInfoItem != null && isComingNewBie)
579
            //{
580
            //    if (PreviewUserMarkupInfoItem.MarkupList == null)
581
            //    {
582
            //        PreviewUserMarkupInfoItem.MarkupList = new List<MarkupItem>();
583
            //    }
584
            //    foreach (var item in ViewerDataModel.Instance.MarkupList_USER)
585
            //    {
586
            //        PreviewUserMarkupInfoItem.MarkupList.Add(item);
587
            //    }
588
            //    if(!ComingNewBieEnd)
589
            //    {
590

    
591
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
592
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
593
            //        gridViewMarkup.ItemsSource = null;
594
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
595
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
596
            //    }
597
            //}
598

    
599
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
600
            {
601
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
602
                {
603
                    ComingNewBieEnd = true;
604
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
605
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
606
                    gridViewMarkup.ItemsSource = null;
607
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
608
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
609
                }
610
            }
611

    
612
        }
613

    
614
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
615
        bool ComingNewBieEnd = false;
616

    
617
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
618
        {
619
            ViewerDataModel.Instance.UndoDataList.Clear();
620

    
621
            InkControl_Convert();
622

    
623
            ReleaseAdorner();
624
            ChangeCommentReact();
625
            CompareMode.IsChecked = false;
626
            //if (ViewerDataModel.Instance.PageBalanceMode)
627
            //{
628
            //    //ViewerDataModel.Instance.PageBalanceNumber = e.PageNumber + (ViewerDataModel.Instance.PageBalanceNumber - e.PageNumber);
629
            //    //ViewerDataModel.Instance.PageBalanceNumber = e.CurrentPage.PAGE_NUMBER;
630
            //}
631
            //else
632
            //{
633
            //    //ViewerDataModel.Instance.PageBalanceNumber = e.PageNumber + (ViewerDataModel.Instance.PageBalanceNumber - e.PageNumber);
634
            //    ViewerDataModel.Instance.PageBalanceNumber = e.CurrentPage.PAGE_NUMBER;
635
            //}
636

    
637

    
638

    
639
            //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
640
            //{
641

    
642
            //var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber - 1 : e.PageNumber;
643
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
644

    
645

    
646
            #region 페이지가 벗어난 경우
647

    
648
            if (BalancePoint < 1)
649
            {
650
                BalancePoint = 1;
651
                ViewerDataModel.Instance.PageBalanceNumber = 0;
652
            }
653

    
654
            if (pageNavigator.PageCount < BalancePoint)
655
            {
656
                BalancePoint = pageNavigator.PageCount;
657
                ViewerDataModel.Instance.PageBalanceNumber = 0;
658
            }
659

    
660
            #endregion
661

    
662
            ViewerDataModel.Instance.PageNumber = BalancePoint;
663

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

    
666
            var defaultBitmapImage = new BitmapImage(new Uri(uri));
667

    
668
            ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
669
            ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
670
            ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
671

    
672
            if (defaultBitmapImage.IsDownloading)
673
            {
674
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
675
                {
676
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
677
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
678
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
679
                };
680
            }
681

    
682
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
683
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
684

    
685

    
686
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
687
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
688
            //inkDrawingCanvas.Width = zoomAndPanCanvas.Width;
689
            //inkDrawingCanvas.Height = zoomAndPanCanvas.Height;
690
            inkBoard.Width = zoomAndPanCanvas.Width;
691
            inkBoard.Height = zoomAndPanCanvas.Height;
692

    
693

    
694
            if (!testPanel2.IsHidden)
695
            {
696
                //ViewerDataModel.Instance.PageBalanceNumber = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + (ViewerDataModel.Instance.PageBalanceNumber - e.PageNumber) : e.PageNumber;
697

    
698
                //PDF모드일때 잠시 대기(강인구)
699
                if (IsSyncPDFMode)
700
                {
701
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
702
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
703

    
704
                    if (pdfpath.IsDownloading)
705
                    {
706
                        pdfpath.DownloadCompleted += (ex, arg) =>
707
                        {
708
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
709
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
710
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
711
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
712
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
713
                        };
714
                    }
715
                    else
716
                    {
717
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
718
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
719
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
720

    
721
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
722
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
723
                    }
724

    
725
                    //Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(CurrentRev.TO_VENDOR));
726

    
727
                    //var image = dpc.GetPageImage(codecs, BalancePoint);
728
                    //Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
729
                    //size.Run(image);
730
                    //image.XResolution = 150;
731
                    //image.YResolution = 150;
732
                    //imageViewer_Compare.Image = image;
733
                }
734
                else
735
                {
736
                    //var uri2 = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
737
                    var uri2 = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
738

    
739
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
740

    
741
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
742
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
743
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
744
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
745
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
746

    
747
                    zoomAndPanControl.ZoomTo(new Rect
748
                    {
749
                        X = 0,
750
                        Y = 0,
751
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
752
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
753
                    });
754

    
755
                    if (defaultBitmapImage_Compare.IsDownloading)
756
                    {
757
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
758
                        {
759

    
760
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
761
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
762
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
763

    
764
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
765
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
766

    
767
                            zoomAndPanControl.ZoomTo(new Rect
768
                            {
769
                                X = 0,
770
                                Y = 0,
771
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
772
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
773
                            });
774
                        };
775
                    }
776

    
777
                    //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri2), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
778

    
779
                    //zoomAndPanCanvas2.Width = imageViewer_Compare.Image.Width;
780
                    //zoomAndPanCanvas2.Height = imageViewer_Compare.Image.Height;
781
                }
782
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
783
            }
784

    
785
            this.pageNavigator.SetNextPage();
786

    
787
            //강인구 수정
788
            //if (!zoomAndPanCanvas2.Width.IsNaN())
789
            //{
790
            //    zoomAndPanControl.ZoomTo(new Rect
791
            //    {
792
            //        X = 0,
793
            //        Y = 0,
794
            //        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
795
            //        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
796
            //    });
797
            //}
798
            //else
799
            //{
800
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
801
            //}
802

    
803
            if (zoomAndPanCanvas2.Width.IsNaN())
804
            {
805
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
806
            }
807

    
808
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
809
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
810

    
811
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
812
            foreach (var item in gridSelectionItem)
813
            {
814
                if (item.UserID == App.ViewInfo.UserID)
815
                {
816
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
817
                    {
818
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
819
                    });
820
                }
821
                else
822
                {
823
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
824
                    {
825
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
826
                    });
827
                }
828
            }
829

    
830

    
831
            if (!testPanel2.IsHidden)
832
            {
833
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
834
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
835

    
836

    
837
                foreach (var item in gridSelectionRevItem)
838
                {
839
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
840
                    {
841
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
842
                    });
843
                }
844

    
845
            }
846

    
847

    
848

    
849
            var instanceMain = this.ParentOfType<MainWindow>();
850
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
851

    
852
            //강인구 추가
853
            instanceMain.dzTopMenu.rotateOffSet = 0;
854
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
855
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
856

    
857
            //}
858
            SetCommentPages(true);
859
        }
860

    
861
        private void SetCommentPages(bool onlyMe = false)
862
        {
863

    
864
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
865
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
866
            {
867
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
868
                instance.UserName = item.UserName;
869
                instance.Depart = item.Depatment;
870
                instance.MarkupInfoID = item.MarkupInfoID;
871
                instance.IsSelected = true;
872
                instance.isConSolidation = item.Consolidate;
873
                instance.SetColor = item.DisplayColor;
874
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
875
                {
876
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
877
                }
878
                else
879
                {
880
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
881
                }
882
                _pages.Add(instance);
883
            }
884
            this.pageNavigator.SetCommentList(_pages.ToList());
885
        }
886

    
887
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
888
        {
889
            if (e.MiddleButton == MouseButtonState.Pressed)
890
            {
891

    
892
            }
893
            e.Handled = true;
894
            if (e.Delta > 0)
895
            {
896
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
897
                ZoomIn(currentContentMousePoint);
898
            }
899
            else
900
            {
901
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
902
                ZoomOut(currentContentMousePoint);
903
            }
904
        }
905

    
906
        #region ZoomIn & ZoomOut
907

    
908
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
909
        {
910
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
911
                zoomAndPanControl.ContentZoomFocusY));
912
        }
913

    
914
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
915
        {
916
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
917
                zoomAndPanControl.ContentZoomFocusY));
918
        }
919

    
920

    
921
        //강인구 추가 (줌 인아웃 수치 변경)
922
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
923
        private void ZoomOut(Point contentZoomCenter)
924
        {
925
            if (zoomAndPanControl.ContentScale > 0.39)
926
            {
927
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
928
            }
929
            else
930
            {
931
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
932
            }
933

    
934
            if (zoomAndPanControl2 != null)
935
            {
936
                if (zoomAndPanControl2.ContentScale > 0.39)
937
                {
938
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
939
                }
940
                else
941
                {
942
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
943
                }
944
            }
945
        }
946

    
947
        private void ZoomIn(Point contentZoomCenter)
948
        {
949
            if (zoomAndPanControl.ContentScale > 0.19)
950
            {
951
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
952
            }
953
            else
954
            {
955
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
956
            }
957

    
958
            if (zoomAndPanControl2 != null)
959
            {
960
                if (zoomAndPanControl2.ContentScale > 0.19)
961
                {
962
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
963
                }
964
                else
965
                {
966
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
967
                }
968
            }
969
        }
970

    
971
        private void ZoomOut()
972
        {
973
            zoomAndPanControl.ContentScale -= 0.1;
974
            //if (zoomAndPanControl2 != null)
975
            //{
976
            //    zoomAndPanControl2.ContentScale -= 0.1;
977
            //}
978
        }
979

    
980
        private void ZoomIn()
981
        {
982
            zoomAndPanControl.ContentScale += 0.1;
983
            //if (zoomAndPanControl2 != null)
984
            //{
985
            //    zoomAndPanControl2.ContentScale += 0.1;
986
            //}
987
        }
988

    
989
        #endregion
990

    
991
        private void init()
992
        {
993
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
994
            {
995

    
996
                ControlList.Clear();
997
                listBox.Items.Clear();
998
                selected_item.Clear();
999

    
1000
                (item as IMarkupCommonData).IsSelected = false;
1001
            }
1002

    
1003
        }
1004

    
1005
        private HitTestResultBehavior MyCallback(HitTestResult result)
1006
        {
1007
            //this.cursor = Cursors.UpArrow;
1008
            var element = result.VisualHit;
1009
            while (element != null && !(element is CommentUserInfo))
1010
                element = VisualTreeHelper.GetParent(element);
1011

    
1012
            if (element == null)
1013
            {
1014
                return HitTestResultBehavior.Stop;
1015
            }
1016
            else
1017
            {
1018
                if (element is CommentUserInfo)
1019
                {
1020
                    if (!hitList.Contains(element))
1021
                    {
1022
                        hitList.Add((CommentUserInfo)element);
1023
                    }
1024
                    else
1025
                    {
1026
                        return HitTestResultBehavior.Stop;
1027
                    }
1028
                    //IntersectionDetail intersectionDetail =
1029
                    //((GeometryHitTestResult)result).IntersectionDetail;
1030
                    //switch (intersectionDetail)
1031
                    //{
1032
                    //    case IntersectionDetail.FullyContains:
1033
                    //        // Add the hit test result to the list:
1034
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
1035
                    //        return HitTestResultBehavior.Continue;
1036
                    //    case IntersectionDetail.Intersects:
1037
                    //        // Set the behavior to return visuals at all z-order levels:
1038
                    //        return HitTestResultBehavior.Continue;
1039
                    //    case IntersectionDetail.FullyInside:
1040
                    //        // Set the behavior to return visuals at all z-order levels:
1041
                    //        return HitTestResultBehavior.Continue;
1042
                    //    default:
1043
                    //        return HitTestResultBehavior.Stop;
1044
                    //}
1045
                }
1046
            }
1047
            return HitTestResultBehavior.Continue;
1048
        }
1049

    
1050
        public void ReleaseSelectPath()
1051
        {
1052
            if (SelectionPath == null)
1053
            {
1054
                SelectionPath = new Path();
1055
                SelectionPath.Name = "";
1056
            }
1057
            if (SelectionPath.Name != "")
1058
            {
1059
                SelectionPath.Name = "None";
1060
            }
1061
            SelectionPath.Opacity = 0.01;
1062
            SelectionPath.RenderTransform = null;
1063
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1064
        }
1065

    
1066
        #region 컨트롤 초기화 
1067
        public void Control_Init(object control)
1068
        {
1069
            if (L_Size != 0 && (control as IPath) != null)
1070
            {
1071
                (control as IPath).LineSize = L_Size;
1072
                L_Size = 0;
1073
            }
1074

    
1075
            switch (control.GetType().Name)
1076
            {
1077
                case "RectangleControl":
1078
                    {
1079
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1080
                    }
1081
                    break;
1082
                case "CircleControl":
1083
                    {
1084
                        (control as CircleControl).StrokeColor = Brushes.Red;
1085
                    }
1086
                    break;
1087
                case "TriControl":
1088
                    {
1089
                        (control as TriControl).StrokeColor = Brushes.Red;
1090
                    }
1091
                    break;
1092
                case "RectCloudControl":
1093
                    {
1094
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1095
                    }
1096
                    break;
1097
                case "CloudControl":
1098
                    {
1099
                        (control as CloudControl).StrokeColor = Brushes.Red;
1100
                    }
1101
                    break;
1102
                case "PolygonControl":
1103
                    {
1104
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1105
                    }
1106
                    break;
1107
                case "ArcControl":
1108
                    {
1109
                        (control as ArcControl).StrokeColor = Brushes.Red;
1110
                    }
1111
                    break;
1112
                case "LineControl":
1113
                    {
1114
                        (control as LineControl).StrokeColor = Brushes.Red;
1115
                    }
1116
                    break;
1117
                case "ArrowControl_Multi":
1118
                    {
1119
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1120
                    }
1121
                    break;
1122
                case "TextControl":
1123
                    {
1124
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1125
                    }
1126
                    break;
1127
                case "ArrowTextControl":
1128
                    {
1129
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1130
                    }
1131
                    break;
1132
            }
1133
        }
1134
        #endregion
1135

    
1136
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1137
        {
1138
            //Control_Init(e.Source);
1139
        }
1140

    
1141
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1142
        {
1143

    
1144
            //if(e.LeftButton == MouseButtonState.Pressed && Symbol_ID != "")
1145
            //{
1146

    
1147

    
1148
            //}
1149

    
1150

    
1151
            //var ct = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1152
            //if (ct != null)
1153
            //{
1154
            //    this.cursor = Cursors.Hand;
1155
            //    SetCursor();
1156
            //}
1157
            //else
1158
            //{
1159
            //    this.cursor = Cursors.Arrow;
1160
            //    SetCursor();
1161
            //}
1162

    
1163
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1164
            {
1165
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1166

    
1167
                Point currentPos = e.GetPosition(rect);
1168

    
1169
                floatingTip.HorizontalOffset = currentPos.X + 20;
1170
                floatingTip.VerticalOffset = currentPos.Y;
1171

    
1172

    
1173
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1174
                //tool.Content = "ToolTip";
1175
                //panel.ToolTip = tool;
1176
            }
1177

    
1178
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1179
            {
1180
                #region 마우스 오버 시 색상 변경
1181
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1182
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1183

    
1184
                //if (firstCondition != null)
1185
                //{
1186
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1187

    
1188
                //    if (firstCondition.GetType().Name == "TextControl")
1189
                //    {
1190
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1191
                //        return;
1192
                //    }
1193
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1194
                //    {
1195
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1196
                //        return;
1197
                //    }
1198

    
1199
                //    if (L_Size == 0)
1200
                //    {
1201
                //        L_Size = (firstCondition as IPath).LineSize;
1202
                //        (firstCondition as IPath).LineSize *= 4;
1203
                //    }
1204
                //    switch (firstCondition.GetType().Name)
1205
                //    {
1206
                //        case "RectangleControl":
1207
                //            {
1208
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1209
                //            }
1210
                //            break;
1211
                //        case "CircleControl":
1212
                //            {
1213
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1214
                //            }
1215
                //            break;
1216
                //        case "TriControl":
1217
                //            {
1218
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1219
                //            }
1220
                //            break;
1221
                //        case "RectCloudControl":
1222
                //            {
1223
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1224
                //            }
1225
                //            break;
1226
                //        case "CloudControl":
1227
                //            {
1228
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1229
                //            }
1230
                //            break;
1231
                //        case "PolygonControl":
1232
                //            {
1233
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1234
                //            }
1235
                //            break;
1236
                //        case "ArcControl":
1237
                //            {
1238
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1239
                //            }
1240
                //            break;
1241
                //        case "LineControl":
1242
                //            {
1243
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1244
                //            }
1245
                //            break;
1246
                //        case "ArrowControl_Multi":
1247
                //            {
1248
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1249
                //            }
1250
                //            break;
1251

    
1252
                //        default:
1253
                //            {
1254

    
1255
                //            }
1256
                //            break;
1257
                //    }
1258
                //} 
1259
                #endregion
1260
            }
1261

    
1262
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1263

    
1264
            if (mouseButtonDown == MouseButton.Middle)
1265
            {
1266
                SetCursor();
1267
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1268
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1269

    
1270
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1271

    
1272
                zoomAndPanControl.ContentOffsetX += 1;
1273
                zoomAndPanControl.ContentOffsetY += 1;
1274

    
1275
                //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1276
                //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1277
            }
1278

    
1279
            if (mouseButtonDown == MouseButton.Right)
1280
            {
1281
                SetCursor();
1282
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1283
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1284

    
1285
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1286
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1287
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1288
            }
1289
            //else if (currentControl != null && mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1290
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1291
            {
1292
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1293
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1294
                SetCursor();
1295

    
1296
                if (IsDrawing)
1297
                {
1298
                    if (currentControl == null)
1299
                    {
1300
                        switch (controlType)
1301
                        {
1302
                            case ControlType.PenControl:
1303
                                {
1304
                                    if (inkBoard.Tag.ToString() == "Ink")
1305
                                    {
1306
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1307
                                    }
1308
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1309
                                    {
1310
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1311
                                    }
1312
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1313
                                    {
1314
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1315
                                    }
1316

    
1317
                                    //inkBoard.Strokes.Add(stroke);
1318
                                }
1319
                                break;
1320
                        }
1321
                        return;
1322
                    }
1323
                }
1324

    
1325
                if (currentControl != null)
1326
                {
1327
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1328
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1329
                    //강인구 추가
1330
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1331

    
1332
                    if ((currentControl as IPath) != null)
1333
                    {
1334
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1335
                    }
1336
                    if ((currentControl as LineControl) != null)
1337
                    {
1338
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1339
                    }
1340

    
1341
                    if ((currentControl as IShapeControl) != null)
1342
                    {
1343
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1344
                    }
1345
                    if ((currentControl as TextControl) != null)
1346
                    {
1347
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1348
                        {
1349
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1350
                        }
1351
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1352
                        {
1353
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1354
                        }
1355
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1356
                        {
1357
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1358
                        }
1359
                    }
1360
                    else if ((currentControl as ArrowTextControl) != null)
1361
                    {
1362
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1363
                        {
1364
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1365
                        }
1366
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1367
                        {
1368
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1369
                        }
1370
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1371
                        {
1372
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1373
                        }
1374
                    }
1375

    
1376
                    switch (controlType)
1377
                    {
1378
                        case ControlType.Rectangle:
1379
                            {
1380
                                var control = currentControl as RectangleControl;
1381

    
1382
                                if (control != null)
1383
                                {
1384
                                    if (move.mousemode == MouseMode.Drawing)
1385
                                    {
1386
                                        //move.control_Move(ControlList, true, moveX, moveY);
1387
                                    }
1388
                                    else
1389
                                    {
1390
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1391
                                        //control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1392
                                        //control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1393
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1394

    
1395

    
1396
                                        //control.PointSet = new List<Point>
1397
                                        //{
1398
                                        //    control.StartPoint,
1399
                                        //    control.LeftBottomPoint,
1400
                                        //    control.EndPoint,
1401
                                        //    control.TopRightPoint,
1402
                                        //};
1403
                                        control.PointSet = new List<Point>
1404
                                        {
1405
                                            new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
1406
                                            new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y),
1407
                                            new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y),
1408
                                            new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y),
1409
                                        };
1410
                                        control.updateControl();
1411
                                    }
1412

    
1413
                                    //강인구 추가
1414
                                    control.ControlType = controlType;
1415
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1416
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1417
                                }
1418
                            }
1419
                            break;
1420

    
1421
                        case ControlType.RectCloud:
1422
                            {
1423
                                var control = currentControl as RectCloudControl;
1424

    
1425
                                if (control != null)
1426
                                {
1427
                                    if (move.mousemode == MouseMode.Drawing)
1428
                                    {
1429
                                        //move.control_Move(ControlList, true, moveX, moveY);
1430
                                    }
1431
                                    else
1432
                                    {
1433
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1434
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1435
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1436
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1437

    
1438
                                        control.PointSet = new List<Point>
1439
                                        {
1440
                                            control.StartPoint,
1441
                                            control.LeftBottomPoint,
1442
                                            control.EndPoint,
1443
                                            control.TopRightPoint,
1444
                                        };
1445
                                    }
1446
                                    //강인구 추가
1447
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1448
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1449
                                }
1450
                            }
1451
                            break;
1452

    
1453
                        case ControlType.SingleLine:
1454
                            {
1455
                                if (currentControl != null)
1456
                                {
1457
                                    var control = currentControl as LineControl;
1458
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1459
                                    control.ControlType = controlType;
1460
                                    if (control != null)
1461
                                    {
1462
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1463
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1464
                                        Point tempPoint = control.EndPoint;
1465

    
1466
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1467
                                        {
1468
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1469
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1470
                                            control.EndPoint = tempPoint;
1471
                                        }
1472
                                        else
1473
                                        {
1474
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1475
                                        }
1476

    
1477
                                       control.PointSet = new List<Point>
1478
                                        {
1479
                                            control.StartPoint,
1480
                                            control.EndPoint,
1481
                                        };
1482
                                        //강인구 추가
1483
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1484
                                    }
1485
                                }
1486

    
1487
                            }
1488
                            break;
1489

    
1490
                        case ControlType.CancelLine:
1491
                            {
1492
                                if (currentControl != null)
1493
                                {
1494
                                    var control = currentControl as LineControl;
1495
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1496
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1497
                                    control.ControlType = controlType;
1498
                                    if (control != null)
1499
                                    {
1500
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1501
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1502
                                        Point tempPoint = control.EndPoint;
1503

    
1504
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1505
                                        {
1506
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1507
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1508
                                            control.EndPoint = tempPoint;
1509
                                        }
1510
                                        else
1511
                                        {
1512
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1513
                                        }
1514

    
1515

    
1516
                                        control.PointSet = new List<Point>
1517
                                            {
1518
                                                control.StartPoint,
1519
                                                control.EndPoint,
1520
                                            };
1521
                                    }
1522
                                    //강인구 추가
1523
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1524
                                }
1525
                            }
1526
                            break;
1527

    
1528
                        case ControlType.ArrowLine:
1529
                            {
1530
                                if (currentControl != null)
1531
                                {
1532
                                    var control = currentControl as LineControl;
1533
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1534
                                    control.ControlType = controlType;
1535
                                    if (control != null)
1536
                                    {
1537
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1538
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1539
                                        Point tempPoint = control.EndPoint;
1540

    
1541
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1542
                                        {
1543
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1544
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1545
                                            control.EndPoint = tempPoint;
1546
                                        }
1547
                                        else
1548
                                        {
1549
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1550
                                        }
1551

    
1552

    
1553
                                        control.PointSet = new List<Point>
1554
                                            {
1555
                                                control.StartPoint,
1556
                                                control.EndPoint,
1557
                                            };
1558
                                    }
1559
                                    //강인구 추가
1560
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1561
                                }
1562

    
1563
                            }
1564
                            break;
1565

    
1566
                        case ControlType.TwinLine:
1567
                            {
1568
                                if (currentControl != null)
1569
                                {
1570
                                    var control = currentControl as LineControl;
1571
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1572
                                    control.ControlType = controlType;
1573
                                    if (control != null)
1574
                                    {
1575
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1576
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1577
                                        Point tempPoint = control.EndPoint;
1578

    
1579
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1580
                                        {
1581
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1582
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1583
                                            control.EndPoint = tempPoint;
1584
                                        }
1585
                                        else
1586
                                        {
1587
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1588
                                        }
1589

    
1590

    
1591
                                        control.PointSet = new List<Point>
1592
                                            {
1593
                                                control.StartPoint,
1594
                                                control.EndPoint,
1595
                                            };
1596
                                    }
1597
                                    //강인구 추가
1598
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1599
                                }
1600

    
1601
                            }
1602
                            break;
1603

    
1604
                        case ControlType.DimLine:
1605
                            {
1606
                                if (currentControl != null)
1607
                                {
1608
                                    var control = currentControl as LineControl;
1609
                                    control.LineStyleSet = LineStyleSet.DimLine;
1610
                                    control.ControlType = controlType;
1611
                                    if (control != null)
1612
                                    {
1613
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1614
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1615
                                        Point tempPoint = control.EndPoint;
1616

    
1617
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1618
                                        {
1619
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1620
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1621
                                            control.EndPoint = tempPoint;
1622
                                        }
1623
                                        else
1624
                                        {
1625
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1626
                                        }
1627

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

    
1638
                            }
1639
                            break;
1640

    
1641
                        case ControlType.ChainLine:
1642
                            {
1643
                                var control = currentControl as PolygonControl;
1644

    
1645
                                if (control != null)
1646
                                {
1647

    
1648
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1649
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1650

    
1651
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1652

    
1653
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1654
                                    {
1655
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1656
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count-2], ref tempPoint, true);
1657
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1658
                                        //control.EndPoint = tempPoint;
1659
                                    }
1660
                                    else
1661
                                    {
1662
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1663
                                    }
1664

    
1665
                                    control.SetPolyPath();
1666
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1667
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1668
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1669

    
1670
                                    //강인구 추가
1671
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1672
                                }
1673
                            }
1674
                            break;
1675

    
1676
                        case ControlType.ArcLine:
1677
                            {
1678
                                if (currentControl != null)
1679
                                {
1680
                                    var control = currentControl as ArcControl;
1681
                                    control.isTransOn = false;
1682
                                    control.ControlType = controlType;
1683

    
1684
                                    if (control != null)
1685
                                    {
1686
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1687
                                        control.MidPoint = new Point(0, 0);
1688
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1689
                                        Point tempPoint = control.EndPoint;
1690

    
1691
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1692
                                        {
1693
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1694
                                            control.EndPoint = tempPoint;
1695
                                        }
1696
                                        else
1697
                                        {
1698
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1699
                                        }
1700

    
1701

    
1702
                                        control.PointSet = new List<Point>
1703
                                            {
1704
                                                control.StartPoint,
1705
                                                control.MidPoint,
1706
                                                control.EndPoint,
1707
                                            };
1708
                                    }
1709
                                    //강인구 추가
1710
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1711
                                }
1712

    
1713
                            }
1714
                            break;
1715

    
1716
                        case ControlType.ArcArrow:
1717
                            {
1718
                                if (currentControl != null)
1719
                                {
1720
                                    var control = currentControl as ArcControl;
1721
                                    control.isTransOn = true;
1722
                                    control.ControlType = controlType;
1723

    
1724
                                    if (control != null)
1725
                                    {
1726
                                        if (move.mousemode == MouseMode.Drawing)
1727
                                        {
1728
                                            //move.control_Move(ControlList, true, moveX, moveY);
1729
                                        }
1730
                                        else
1731
                                        {
1732
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1733
                                            control.MidPoint = new Point(0, 0);
1734
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1735
                                        }
1736

    
1737
                                        control.PointSet = new List<Point>
1738
                                            {
1739
                                                control.StartPoint,
1740
                                                control.MidPoint,
1741
                                                control.EndPoint,
1742
                                            };
1743
                                    }
1744
                                    //강인구 추가
1745
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1746
                                }
1747
                            }
1748
                            break;
1749

    
1750
                        case ControlType.ArrowMultiLine:
1751
                            {
1752
                                if (currentControl != null)
1753
                                {
1754
                                    var control = currentControl as ArrowControl_Multi;
1755

    
1756
                                    if (control != null)
1757
                                    {
1758
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1759
                                        Point tempPoint = control.EndPoint;
1760
                                        if (control.MiddlePoint == new Point(0, 0))
1761
                                        {
1762
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1763
                                            {
1764
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1765
                                                //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1766
                                                control.EndPoint = tempPoint;
1767
                                            }
1768
                                            else
1769
                                            {
1770
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1771
                                            }
1772
                                        }
1773
                                        else
1774
                                        {
1775
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1776
                                            {
1777
                                                //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1778
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1779
                                                control.EndPoint = tempPoint;
1780
                                            }
1781
                                            else
1782
                                            {
1783
                                                ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1784
                                            }
1785

    
1786
                                        }
1787

    
1788
                                        control.PointSet = new List<Point>
1789
                                            {
1790
                                                control.StartPoint,
1791
                                                control.MiddlePoint,
1792
                                                control.EndPoint,
1793
                                            };
1794

    
1795
                                    }
1796
                                    //강인구 추가
1797
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1798
                                }
1799

    
1800
                            }
1801
                            break;
1802

    
1803
                        case ControlType.Circle:
1804
                            {
1805
                                var control = currentControl as CircleControl;
1806

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

    
1820
                                        control.PointSet = new List<Point>
1821
                                        {
1822
                                            control.StartPoint,
1823
                                            control.LeftBottomPoint,
1824
                                            control.EndPoint,
1825
                                            control.TopRightPoint,
1826
                                        };
1827
                                    }
1828
                                    //강인구 추가
1829
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1830
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1831

    
1832
                                }
1833
                            }
1834
                            break;
1835

    
1836
                        case ControlType.PolygonCloud:
1837
                            {
1838
                                var control = currentControl as CloudControl;
1839

    
1840
                                if (control != null)
1841
                                {
1842
                                    control.isTransOn = true;
1843
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1844

    
1845
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1846

    
1847
                                    control.SetCloud();
1848
                                    //강인구 추가
1849
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1850
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1851
                                }
1852
                            }
1853
                            break;
1854

    
1855
                        case ControlType.Triangle:
1856
                            {
1857
                                var control = currentControl as TriControl;
1858

    
1859
                                if (control != null)
1860
                                {
1861
                                    if (move.mousemode == MouseMode.Drawing)
1862
                                    {
1863
                                        //move.control_Move(ControlList, true, moveX, moveY);
1864
                                    }
1865
                                    else
1866
                                    {
1867
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1868
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1869

    
1870
                                        control.PointSet = new List<Point>
1871
                                            {
1872
                                                control.StartPoint,
1873
                                                control.MidPoint,
1874
                                                control.EndPoint,
1875
                                            };
1876
                                    }
1877
                                    //강인구 추가
1878
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1879
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1880
                                }
1881
                            }
1882
                            break;
1883

    
1884
                        case ControlType.ImgControl:
1885
                            {
1886
                                var control = currentControl as ImgControl;
1887

    
1888
                                if (control != null)
1889
                                {
1890
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1891
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1892
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1893
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1894

    
1895
                                    control.PointSet = new List<Point>
1896
                                        {
1897
                                            control.StartPoint,
1898
                                            control.LeftBottomPoint,
1899
                                            control.EndPoint,
1900
                                            control.TopRightPoint,
1901
                                        };
1902
                                }
1903
                            }
1904
                            break;
1905

    
1906
                        case ControlType.Date:
1907
                            {
1908
                                var control = currentControl as DateControl;
1909

    
1910
                                if (control != null)
1911
                                {
1912
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1913
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1914
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1915
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1916
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1917

    
1918
                                    control.PointSet = new List<Point>
1919
                                        {
1920
                                            control.StartPoint,
1921
                                            control.LeftBottomPoint,
1922
                                            control.EndPoint,
1923
                                            control.TopRightPoint,
1924
                                        };
1925
                                }
1926
                            }
1927
                            break;
1928

    
1929
                        case ControlType.ArrowTextControl:
1930
                            {
1931
                                var control = currentControl as ArrowTextControl;
1932

    
1933
                                if (control != null)
1934
                                {
1935
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1936
                                    Point tempPoint = control.EndPoint;
1937
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1938
                                    {
1939
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1940
                                        control.EndPoint = tempPoint;
1941
                                    }
1942
                                    else
1943
                                    {
1944
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1945
                                    }
1946

    
1947
                                    control.PointSet = new List<Point>
1948
                                            {
1949
                                                control.StartPoint,
1950
                                                control.MidPoint,
1951
                                                control.EndPoint,
1952
                                            };
1953
                                }
1954
                            }
1955
                            break;
1956

    
1957
                        case ControlType.ArrowTransTextControl:
1958
                            {
1959
                                var control = currentControl as ArrowTextControl;
1960

    
1961
                                if (control != null)
1962
                                {
1963
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1964
                                    Point tempPoint = control.EndPoint;
1965
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1966
                                    {
1967
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1968
                                        control.EndPoint = tempPoint;
1969
                                    }
1970
                                    else
1971
                                    {
1972
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1973
                                    }
1974
                                    control.isFixed = true;
1975

    
1976
                                    control.PointSet = new List<Point>
1977
                                            {
1978
                                                control.StartPoint,
1979
                                                control.MidPoint,
1980
                                                control.EndPoint,
1981
                                            };
1982
                                }
1983
                            }
1984
                            break;
1985

    
1986
                        case ControlType.ArrowTextBorderControl:
1987
                            {
1988
                                var control = currentControl as ArrowTextControl;
1989

    
1990
                                if (control != null)
1991
                                {
1992
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1993
                                    Point tempPoint = control.EndPoint;
1994
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1995
                                    {
1996
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1997
                                        control.EndPoint = tempPoint;
1998
                                    }
1999
                                    else
2000
                                    {
2001
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2002
                                    }
2003
                                    control.PointSet = new List<Point>
2004
                                            {
2005
                                                control.StartPoint,
2006
                                                control.MidPoint,
2007
                                                control.EndPoint,
2008
                                            };
2009
                                }
2010

    
2011
                            }
2012
                            break;
2013
                        case ControlType.ArrowTransTextBorderControl:
2014
                            {
2015
                                var control = currentControl as ArrowTextControl;
2016

    
2017
                                if (control != null)
2018
                                {
2019
                                    control.isFixed = true;
2020
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2021
                                    Point tempPoint = control.EndPoint;
2022
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2023
                                    {
2024
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2025
                                        control.EndPoint = tempPoint;
2026
                                    }
2027
                                    else
2028
                                    {
2029
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2030
                                    }
2031
                                    control.PointSet = new List<Point>
2032
                                            {
2033
                                                control.StartPoint,
2034
                                                control.MidPoint,
2035
                                                control.EndPoint,
2036
                                            };
2037
                                }
2038

    
2039
                            }
2040
                            break;
2041
                        case ControlType.ArrowTextCloudControl:
2042
                            {
2043
                                var control = currentControl as ArrowTextControl;
2044

    
2045
                                if (control != null)
2046
                                {
2047
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2048
                                    Point tempPoint = control.EndPoint;
2049
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2050
                                    {
2051
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2052
                                        control.EndPoint = tempPoint;
2053
                                    }
2054
                                    else
2055
                                    {
2056
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2057
                                    }
2058
                                    control.PointSet = new List<Point>
2059
                                            {
2060
                                                control.StartPoint,
2061
                                                control.MidPoint,
2062
                                                control.EndPoint,
2063
                                            };
2064
                                }
2065

    
2066
                            }
2067
                            break;
2068
                        case ControlType.ArrowTransTextCloudControl:
2069
                            {
2070
                                var control = currentControl as ArrowTextControl;
2071

    
2072
                                if (control != null)
2073
                                {
2074
                                    control.isFixed = true;
2075
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2076
                                    Point tempPoint = control.EndPoint;
2077
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2078
                                    {
2079
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2080
                                        control.EndPoint = tempPoint;
2081
                                    }
2082
                                    else
2083
                                    {
2084
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2085
                                    }
2086
                                    control.PointSet = new List<Point>
2087
                                            {
2088
                                                control.StartPoint,
2089
                                                control.MidPoint,
2090
                                                control.EndPoint,
2091
                                            };
2092
                                }
2093

    
2094
                            }
2095
                            break;
2096
                        case ControlType.PolygonControl:
2097
                            {
2098
                                var control = currentControl as PolygonControl;
2099

    
2100
                                if (control != null)
2101
                                {
2102
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2103
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2104
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2105
                                    control.SetPolyPath();
2106
                                    //강인구 추가
2107
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2108
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2109
                                }
2110
                            }
2111
                            break;
2112
                        //강인구 추가
2113
                        case ControlType.Sign:
2114
                            {
2115
                                var control = currentControl as SignControl;
2116

    
2117
                                if (control != null)
2118
                                {
2119
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2120
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2121
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2122
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2123

    
2124
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2125
                                    {
2126
                                        GetUserSign getUser = new GetUserSign();
2127
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2128
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2129
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2130
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2131
                                        stream.Position = 0;
2132
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2133
                                        BitmapImage returnImage = new BitmapImage();
2134
                                        returnImage.BeginInit();
2135
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2136
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2137
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2138
                                        returnImage.StreamSource = ms;
2139
                                        returnImage.EndInit();
2140
                                        stream.Close();
2141

    
2142
                                        control.SignImage = returnImage;
2143
                                    }
2144
                                    control.PointSet = new List<Point>
2145
                                        {
2146
                                            control.StartPoint,
2147
                                            control.LeftBottomPoint,
2148
                                            control.EndPoint,
2149
                                            control.TopRightPoint,
2150
                                        };
2151
                                }
2152
                            }
2153
                            break;
2154
                        //강인구 추가
2155
                        case ControlType.Symbol:
2156
                            {
2157
                                var control = currentControl as SymControl;
2158

    
2159
                                if (control != null)
2160
                                {
2161
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2162
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2163
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2164
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2165
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2166
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2167

    
2168
                                    if (control.StartPoint != control.EndPoint)
2169
                                    {
2170
                                        if (control.PathData == null)
2171
                                        {
2172
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2173
                                            {
2174
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2175
                                            }
2176
                                        }
2177
                                    }
2178

    
2179
                                    control.PointSet = new List<Point>
2180
                                        {
2181
                                            control.StartPoint,
2182
                                            control.LeftBottomPoint,
2183
                                            control.EndPoint,
2184
                                            control.TopRightPoint,
2185
                                        };
2186
                                }
2187
                            }
2188
                            break;
2189
                        case ControlType.Stamp:
2190
                            {
2191
                                var control = currentControl as SymControlN;
2192

    
2193
                                if (control != null)
2194
                                {
2195

    
2196
                                    if (control.StartPoint == control.EndPoint)
2197
                                    {
2198
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2199

    
2200
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2201
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2202

    
2203

    
2204
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2205

    
2206
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2207
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2208
                                        writer.Write(xamlData);
2209
                                        writer.Flush();
2210
                                        stream.Position = 0;
2211

    
2212
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2213
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2214
                                        UIElement ob = obj as UIElement;
2215

    
2216
                                        //control.ApplyTemplate();
2217

    
2218
                                        control.SetViewBox();
2219
                                        control.PathXathData = appovalData;
2220
                                        control.Base_ViewBox.Child = ob;
2221
                                    }
2222

    
2223
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2224
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2225
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2226
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2227
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2228

    
2229

    
2230
                                    control.PointSet = new List<Point>
2231
                                    {
2232
                                        control.StartPoint,
2233
                                        control.LeftBottomPoint,
2234
                                        control.EndPoint,
2235
                                        control.TopRightPoint,
2236
                                    };
2237
                                }
2238
                            }
2239
                            break;
2240
                        case ControlType.Mark:
2241
                            {
2242
                                var control = currentControl as RectangleControl;
2243

    
2244
                                if (control != null)
2245
                                {
2246
                                    if (move.mousemode == MouseMode.Drawing)
2247
                                    {
2248
                                        //move.control_Move(ControlList, true, moveX, moveY);
2249
                                    }
2250
                                    else
2251
                                    {
2252
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2253
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2254
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2255
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2256

    
2257

    
2258
                                        control.PointSet = new List<Point>
2259
                                    {
2260
                                        control.StartPoint,
2261
                                        control.LeftBottomPoint,
2262
                                        control.EndPoint,
2263
                                        control.TopRightPoint,
2264
                                    };
2265
                                    }
2266

    
2267
                                    //강인구 추가
2268
                                    control.Paint = PaintSet.Fill;
2269
                                }
2270
                            }
2271
                            break;
2272
                        case ControlType.PenControl:
2273
                            {
2274
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2275
                                //inkBoard.Strokes.Add(stroke);
2276
                            }
2277
                            break;
2278
                        default:
2279
                            break;
2280
                    }
2281
                }
2282
            }
2283
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture)
2284
            {
2285
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2286

    
2287
                if (isDraggingSelectionRect)
2288
                {
2289
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2290

    
2291
                    e.Handled = true;
2292
                }
2293
                else if (isLeftMouseButtonDownOnWindow)
2294
                {
2295
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2296
                    double dragDistance = Math.Abs(dragDelta.Length);
2297

    
2298
                    if (dragDistance > DragThreshold)
2299
                    {
2300
                        isDraggingSelectionRect = true;
2301

    
2302
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2303
                    }
2304

    
2305
                    e.Handled = true;
2306
                }
2307

    
2308

    
2309
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2310
                {
2311
                    //SelectionPath = new Path();
2312
                    //PathFigure pathFigure = new PathFigure();
2313
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2314
                    //SelectionPath.Opacity = 0.5;
2315
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2316
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2317
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2318
                }
2319
                else
2320
                {
2321
                    //List<Stroke> removingStroke = new List<Stroke>();
2322
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2323
                    //StrokeCollection stC = new StrokeCollection();
2324
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2325
                    //{
2326
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2327
                    //    p1.Intersect(p2);
2328
                    //    if (p1.IsEmpty)
2329
                    //    {
2330

    
2331

    
2332
                    //        p1 = SelectionPath.Data.Bounds;
2333
                    //        bool intersectCheck = false;
2334
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2335
                    //        {
2336
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2337
                    //            p1.Intersect(p3);
2338
                    //            if (!p1.IsEmpty)
2339
                    //            {
2340
                    //                intersectCheck = true;
2341
                    //            }
2342
                    //        }
2343
                    //        if (intersectCheck)
2344
                    //        {
2345
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2346
                    //        }
2347

    
2348
                    //    }
2349
                    //    else
2350
                    //    {
2351
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2352
                    //    }
2353
                    //}
2354

    
2355
                    e.Handled = true;
2356
                }
2357
            }
2358
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2359
            {
2360
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2361
                if (control != null)
2362
                {
2363
                    this.cursor = Cursors.Hand;
2364
                    SetCursor();
2365
                }
2366
                else
2367
                {
2368
                    this.cursor = Cursors.Arrow;
2369
                    SetCursor();
2370
                }
2371
            }
2372
            else
2373
            {
2374
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2375

    
2376
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2377
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2378

    
2379
                //if (hitList.Count > 0)
2380
                //{
2381

    
2382
                //}
2383

    
2384
                #region 조건 설정 : firstCondition
2385
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2386
                //pnts = generalTransform.Transform(pnts);
2387
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2388
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2389
                //                               this.DeepLayer._BaseLayer).ToObservable()
2390
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2391
                //                      select kkk).FirstOrDefault();
2392

    
2393
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2394
                //if (canvas !=null)
2395
                //{
2396
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2397
                //    {
2398
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2399
                //        if (uiElement!=null)
2400
                //        {
2401
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2402
                //        }
2403
                //    }
2404
                //}
2405

    
2406
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2407
                //hitResultsList.Clear();
2408

    
2409
                #endregion
2410
            }
2411
        }
2412

    
2413
        //private void Point_StateChanged(object sender, MyEventArgs e)
2414
        //{
2415
        //    //if (e.isMouseOver)
2416
        //    //{
2417
        //    //    this.cursor = Cursors.Hand;
2418
        //    //}
2419
        //    //else
2420
        //    //{
2421
        //    //    this.cursor = Cursors.Arrow;
2422
        //    //    (sender as CommentUserInfo).StateChanged -= Point_StateChanged;
2423
        //    //}
2424
        //}
2425
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2426

    
2427
        private EllipseGeometry hitArea = new EllipseGeometry();
2428

    
2429
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2430
        {
2431
            IsDrawing = false;
2432

    
2433
            if (mouseHandlingMode != MouseHandlingMode.None)
2434
            {
2435
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2436
                {
2437
                    this.cursor = Cursors.Arrow;
2438

    
2439
                    SetCursor();
2440

    
2441
                    switch (controlType)
2442
                    {
2443
                        case ControlType.None:
2444
                            break;
2445
                        case ControlType.Rectangle:
2446
                            {
2447

    
2448
                            }
2449
                            break;
2450
                        case ControlType.PenControl:
2451
                            {
2452

    
2453
                            }
2454
                            break;
2455
                        default:
2456
                            break;
2457
                    }
2458
                }
2459
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left)
2460
                {
2461
                    if (isLeftMouseButtonDownOnWindow)
2462
                    {
2463
                        bool wasDragSelectionApplied = false;
2464

    
2465
                        if (isDraggingSelectionRect)
2466
                        {
2467
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2468
                            {
2469
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2470
                                mouseHandlingMode = MouseHandlingMode.None;
2471
                                Set_Capture();
2472

    
2473
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2474
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2475
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2476
                            }
2477

    
2478
                            isDraggingSelectionRect = false;
2479
                            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2480
                            {
2481
                                ApplyDragSelectionRect();
2482
                            }
2483

    
2484
                            e.Handled = true;
2485
                            wasDragSelectionApplied = true;
2486
                        }
2487

    
2488
                        if (isLeftMouseButtonDownOnWindow)
2489
                        {
2490
                            isLeftMouseButtonDownOnWindow = false;
2491
                            this.ReleaseMouseCapture();
2492
                            e.Handled = true;
2493
                        }
2494

    
2495
                        if (!wasDragSelectionApplied)
2496
                        {
2497
                            init();
2498
                        }
2499
                    }
2500
                }
2501
                else if (mouseButtonDown == MouseButton.Right)
2502
                {
2503
                    this.cursor = Cursors.Arrow;
2504
                    SetCursor();
2505
                }
2506

    
2507
                zoomAndPanControl.ReleaseMouseCapture();
2508

    
2509

    
2510
                e.Handled = true;
2511
            }
2512
            else
2513
            {
2514
                this.cursor = Cursors.Arrow;
2515
                SetCursor();
2516
            }
2517
            mouseButtonDown = MouseButton.Left;
2518

    
2519
            //controlType = ControlType.SingleLine;
2520
        }
2521

    
2522
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2523
        {
2524
            mouseButtonDown = MouseButton.Left;
2525
            this.Cursor = Cursors.Arrow;
2526
        }
2527

    
2528
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2529
        {
2530

    
2531
        }
2532

    
2533
        private void ApplyDragSelectionRect()
2534
        {
2535
            multi_Undo_Data = new Multi_Undo_data();
2536

    
2537
            UndoData = new Undo_data()
2538
            {
2539
                IsUndo = false,
2540
                Event = Event_Type.Select,
2541
                EventTime = DateTime.Now,
2542
                Markup_List = new List<Multi_Undo_data>()
2543
            };
2544

    
2545
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2546

    
2547
            double x = Canvas.GetLeft(dragSelectionBorder);
2548
            double y = Canvas.GetTop(dragSelectionBorder);
2549
            double width = dragSelectionBorder.Width;
2550
            double height = dragSelectionBorder.Height;
2551
            Rect dragRect = new Rect(x, y, width, height);
2552
            Boolean Flag = false;
2553
            dragRect.Inflate(width / 10, height / 10);
2554
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2555
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2556

    
2557

    
2558

    
2559

    
2560
            //#region 잉크 불필요
2561

    
2562
            ////#region Ink Canvas Select
2563
            //List<Stroke> removingStroke = new List<Stroke>();
2564
            //StrokeCollection stC = new StrokeCollection();
2565

    
2566

    
2567
            //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2568
            //{
2569
            //    dragRect = new Rect(x, y, width, height);
2570
            //    dragRect.Inflate(width / 10, height / 10);
2571

    
2572
            //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2573
            //    dragRect.Intersect(p2);
2574
            //    if (dragRect.IsEmpty)
2575
            //    {
2576
            //        //dragRect = SelectionPath.Data.Bounds;
2577
            //        bool intersectCheck = false;
2578
            //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2579
            //        {
2580
            //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2581
            //            dragRect.Intersect(p3);
2582
            //            if (!dragRect.IsEmpty)
2583
            //            {
2584
            //                intersectCheck = true;
2585
            //            }
2586
            //        }
2587
            //        if (intersectCheck)
2588
            //        {
2589
            //            removingStroke.Add(inkBoard.Strokes[i]);
2590
            //        }
2591
            //    }
2592
            //    else
2593
            //    {
2594
            //        removingStroke.Add(inkBoard.Strokes[i]);
2595
            //    }
2596
            //}
2597

    
2598
            //InkToPath ip = new InkToPath();
2599
            //List<Point> inkPointSet = new List<Point>();
2600
            //PolygonControl pc = null;
2601
            ////InkControl pc = null;
2602
            ////pc = new InkControl()
2603
            //pc = new PolygonControl()
2604
            //{
2605
            //    //PointC = new List<StylusPointSet>(),
2606
            //    Angle = 0,
2607
            //    StartPoint = dragRect.TopLeft,
2608
            //    EndPoint = dragRect.BottomRight,
2609
            //    PointSet = new List<Point>(),
2610
            //    CommentID = Save.shortGuid(),
2611
            //    ControlType = ControlType.Ink,
2612
            //};
2613
            //foreach (var item in removingStroke)
2614
            //{
2615
            //    //pc.PointC.Add(new StylusPointSet() { pointSet = ip.StrokeGetPointsPlus(item) });
2616
            //    inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
2617
            //    inkBoard.Strokes.Remove(item);
2618
            //}
2619
            //if (inkPointSet.Count != 0)
2620
            //{
2621
            //    pc.StartPoint = inkPointSet[0];
2622
            //    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
2623
            //    pc.PointSet = inkPointSet;
2624
            //    pc.LineSize = 3;
2625
            //    //pc.StrokeColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("ff18b7fc"));
2626
            //    pc.StrokeColor = new SolidColorBrush(Colors.Red);
2627
            //    ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
2628
            //    pc.SetPolyPath();
2629

    
2630
            //    adornerSet.Add(pc);
2631
            //    ViewerDataModel.Instance.MarkupControls_USER.Remove(pc);
2632

    
2633
            //    //Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2634
            //    //SelectLayer.Children.Add(final);
2635
            //}
2636
            ////#endregion 
2637
            //#endregion
2638

    
2639

    
2640
            dragRect = new Rect(x, y, width, height);
2641
            dragRect.Inflate(width / 10, height / 10);
2642

    
2643
            foreach (var item in Items)
2644
            {
2645
                //switch ((item as IMarkupCommonData).ControlType)
2646
                //{
2647
                //case ControlType.Rectangle:
2648
                //    {
2649
                //var rectangleControl = (item as RectangleControl);
2650
                //Flag = move.control_Select(rectangleControl,  dragRect);
2651
                Flag = move.control_Select(item, dragRect);
2652

    
2653
                if (Flag)
2654
                {
2655
                    adornerSet.Add(item);
2656
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2657

    
2658
                    Control_Style(item);
2659
                    UndoData.Markup_List.Add(multi_Undo_Data);
2660
                    multi_Undo_Data = new Multi_Undo_data();
2661

    
2662
                    //SelectLayer.Children.Add(final);
2663
                }
2664
                //}
2665
                //break;
2666
                //}
2667
            }
2668
            if (adornerSet.Count > 0)
2669
            {
2670
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2671
                {
2672
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2673
                });
2674
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2675

    
2676
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2677
                SelectLayer.Children.Add(final);
2678
                //mouseHandlingMode = MouseHandlingMode.Adorner;
2679
            }
2680
        }
2681

    
2682
        private void InitDragSelectionRect(Point pt1, Point pt2)
2683
        {
2684
            //선택 중
2685
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2686
            {
2687
                dragSelectionBorder.Visibility = Visibility.Visible;
2688
            }
2689
            //캡쳐 중
2690
            else
2691
            {
2692
                dragCaptureBorder.Visibility = Visibility.Visible;
2693
            }
2694
            UpdateDragSelectionRect(pt1, pt2);
2695
        }
2696

    
2697
        /// <summary>
2698
        /// Update the position and size of the rectangle used for drag selection.
2699
        /// </summary>
2700
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2701
        {
2702
            double x, y, width, height;
2703

    
2704
            //
2705
            // Determine x,y,width and height of the rect inverting the points if necessary.
2706
            // 
2707

    
2708
            if (pt2.X < pt1.X)
2709
            {
2710
                x = pt2.X;
2711
                width = pt1.X - pt2.X;
2712
            }
2713
            else
2714
            {
2715
                x = pt1.X;
2716
                width = pt2.X - pt1.X;
2717
            }
2718

    
2719
            if (pt2.Y < pt1.Y)
2720
            {
2721
                y = pt2.Y;
2722
                height = pt1.Y - pt2.Y;
2723
            }
2724
            else
2725
            {
2726
                y = pt1.Y;
2727
                height = pt2.Y - pt1.Y;
2728
            }
2729

    
2730

    
2731
            //
2732
            // Update the coordinates of the rectangle used for drag selection.
2733
            //
2734
            //선택 중
2735
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2736
            {
2737
                Canvas.SetLeft(dragSelectionBorder, x);
2738
                Canvas.SetTop(dragSelectionBorder, y);
2739
                dragSelectionBorder.Width = width;
2740
                dragSelectionBorder.Height = height;
2741
            }
2742
            //캡쳐 중
2743
            else
2744
            {
2745
                Canvas.SetLeft(dragCaptureBorder, x);
2746
                Canvas.SetTop(dragCaptureBorder, y);
2747
                dragCaptureBorder.Width = width;
2748
                dragCaptureBorder.Height = height;
2749
            }
2750

    
2751
            //System.Diagnostics.Debug.WriteLine("x : {0},  y : {1} , Width : {2}, Height : {3} ", x, y, width,height);
2752
        }
2753

    
2754
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2755
        {
2756
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2757

    
2758
            bool result = false;
2759
            if (dragRect.Contains(controlRect))
2760
            {
2761
                result = true;
2762
                //잡은 객체들을 담은 리스트
2763
                //selected_item.Add(OverViewPathData, type);
2764
                try
2765
                {
2766
                    //controlType = type;
2767
                    selected_item.Add(OverViewPathData, type.ToString());
2768
                }
2769
                catch (Exception)
2770
                {
2771

    
2772
                }
2773
                //listBox.Items.Add(OverViewPathData, commonData.ControlType.ToString());
2774
                //listBox.SelectedItems.Add(rectangleViewModel);
2775
            }
2776
            return result;
2777
        }
2778

    
2779
        private void drawingPannelRotate(double angle)
2780
        {
2781
            rotate.Angle = angle;
2782
            var rotationNum = Math.Abs((rotate.Angle / 90));
2783

    
2784
            if (angle == 90 || angle == 270)
2785
            {
2786
                double emptySize = zoomAndPanCanvas.Width;
2787
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2788
                zoomAndPanCanvas.Height = emptySize;
2789
            }
2790
            if (angle == 0)
2791
            {
2792
                translate.X = 0;
2793
                translate.Y = 0;
2794
            }
2795
            else if (angle == 90)
2796
            {
2797
                translate.X = zoomAndPanCanvas.Width;
2798
                translate.Y = 0;
2799
            }
2800
            else if (angle == 180)
2801
            {
2802
                translate.X = zoomAndPanCanvas.Width;
2803
                translate.Y = zoomAndPanCanvas.Height;
2804
            }
2805
            else
2806
            {
2807
                translate.X = 0;
2808
                translate.Y = zoomAndPanCanvas.Height;
2809
            }
2810

    
2811
            zoomAndPanControl.RotationAngle = rotate.Angle;
2812
            //회전 잠시 대기(강인구)
2813
            //_imageViewer.RotateAngle = rotate.Angle;
2814

    
2815
            //RotateTransform rotateTransform = new RotateTransform(rotate.Angle);
2816
            //_imageViewer1.RenderTransform = rotateTransform;
2817

    
2818
            if (!testPanel2.IsHidden)
2819
            {
2820
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2821
                //회전 잠시 대기(강인구)
2822
                //_imageViewer_Compare.RotateAngle = rotate.Angle;
2823

    
2824
                //_imageViewer_Compare.RenderTransform = rotateTransform;
2825

    
2826
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2827
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2828
            }
2829

    
2830
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2831
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2832
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2833
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2834
            ViewerDataModel.Instance.Angle = rotate.Angle;
2835

    
2836

    
2837
        }
2838

    
2839
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2840
        {
2841
            InkControl_Convert();
2842

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

    
2846
            if(text_item != null && (currentControl as ArrowTextControl) == null)
2847
            {
2848
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2849
            }
2850

    
2851
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2852
            {
2853
                if (arrow_text as ArrowTextControl != null)
2854
                {
2855
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2856
                    //(arrow_text as ArrowTextControl).Base_TextBox.Focusable = true;
2857
                }
2858
            }
2859

    
2860
            if(currentControl == null)
2861
            {
2862
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2863
                if (text_item_ != null)
2864
                {
2865
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2866
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2867
                    (text_item_ as TextControl).IsEditing = false;
2868
                    (text_item_ as TextControl).EnableEditing = false;
2869
                }
2870

    
2871
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2872
                if (Arrowtext_item_ != null)
2873
                {
2874
                    //(text_item_ as ArrowTextControl).Base_TextBlock.Visibility = Visibility.Visible;
2875
                    //(text_item_ as ArrowTextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2876
                    //(Arrowtext_item_ as ArrowTextControl).IsEditing = false;
2877
                    //(Arrowtext_item_ as ArrowTextControl).EnableEditing = false;
2878
                    //(Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2879

    
2880
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2881
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2882
                }
2883
            }
2884

    
2885

    
2886
            if (currentControl != null && currentControl.GetType().Name == "TextControl")
2887
            {
2888
                //(currentControl as TextControl).Base_TextBlock.Visibility = System.Windows.Visibility.Visible;
2889
                //(currentControl as TextControl).Base_TextBox.Visibility = System.Windows.Visibility.Collapsed;
2890
                //(currentControl as TextControl).IsEditing = false;
2891
                //(currentControl as TextControl).EnableEditing = false;
2892
                //currentControl = null;
2893
            }
2894

    
2895
            double Ang = 0;
2896
            if (rotate.Angle != 0)
2897
            {
2898
                Ang = 360 - rotate.Angle;
2899
            }
2900

    
2901
            move = new Move();
2902

    
2903
            //if (e.OriginalSource is Canvas)
2904
            //{
2905
            //    (e.OriginalSource as Canvas).Focus();
2906
            //}
2907

    
2908
            if (e.OriginalSource is System.Windows.Controls.Image)
2909
            {
2910
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2911
            }
2912

    
2913
            mouseButtonDown = e.ChangedButton;
2914
            if (mouseButtonDown == MouseButton.Left)
2915
            {
2916
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2917
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2918

    
2919
                this.cursor = Cursors.Arrow;
2920
                SetCursor();
2921

    
2922
                if (!ViewerDataModel.Instance.IsPressCtrl)
2923
                {
2924
                    ReleaseAdorner();
2925
                }
2926
            }
2927
            if (mouseButtonDown == MouseButton.Middle)
2928
            {
2929
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2930
                cursor = Cursors.SizeAll;
2931
                SetCursor();
2932
            }
2933
            if (mouseButtonDown == MouseButton.Right)
2934
            {
2935
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2936
                cursor = Cursors.SizeAll;
2937
                SetCursor();
2938
            }
2939
            else if (mouseButtonDown == MouseButton.XButton1)
2940
            {
2941
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2942
                {
2943
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2944
                }
2945

    
2946
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2947

    
2948
            }
2949
            else if (mouseButtonDown == MouseButton.XButton2)
2950
            {
2951
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2952
                {
2953
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2954
                }
2955
            }
2956

    
2957
            //캡쳐 모드 설정
2958
            if (mouseHandlingMode == MouseHandlingMode.Capture && mouseButtonDown == MouseButton.Left)
2959
            {
2960
                dragCaptureBorder.Visibility = Visibility.Visible;
2961
                isLeftMouseButtonDownOnWindow = true;
2962
            }
2963

    
2964
            if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2965
            {
2966

    
2967
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2968
                {
2969
                    if (SelectLayer.Children.Count == 0)
2970
                    {
2971
                        isLeftMouseButtonDownOnWindow = true;
2972
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2973
                    }
2974

    
2975
                    if (controlType == ControlType.None)
2976
                    {
2977
                        isLeftMouseButtonDownOnWindow = true;
2978
                    }
2979
                }
2980

    
2981

    
2982
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2983
                if (control != null)
2984
                {
2985
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2986
                    AdornerFinal final;
2987
                    List<Point> p_set = new List<Point>();
2988
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2989
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2990
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2991
                    multi_Undo_Data = new Multi_Undo_data();
2992

    
2993
                    //강인구 Undo/Redo 보류
2994
                    UndoData = new Undo_data()
2995
                    {
2996
                        IsUndo = false,
2997
                        Event = Event_Type.Select,
2998
                        EventTime = DateTime.Now,
2999
                        Markup_List = new List<Multi_Undo_data>()
3000
                    };
3001

    
3002
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3003
                    {
3004
                        ReleaseAdorner();
3005
                        final = new AdornerFinal(control);
3006
                        //단일 컨트롤 언두 저장
3007

    
3008
                        Control_Style(control);
3009
                        UndoData.Markup_List.Add(multi_Undo_Data);
3010

    
3011
                        if ((control as IPath) != null)
3012
                        {
3013
                            if ((control as IPath).LineSize != 0)
3014
                            {
3015
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3016
                            }
3017
                        }
3018
                        if ((control as IShapeControl) != null)
3019
                        {
3020
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3021
                            {
3022
                                ViewerDataModel.Instance.checkHatchShape = true;
3023
                            }
3024
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3025
                            {
3026
                                ViewerDataModel.Instance.checkFillShape = true;
3027
                            }
3028
                            else
3029
                            {
3030
                                ViewerDataModel.Instance.checkHatchShape = false;
3031
                                ViewerDataModel.Instance.checkFillShape = false;
3032
                            }
3033
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3034
                        }
3035
                        //SelectLayer.Children.Add(final);
3036
                        if ((control as IPath) != null)
3037
                        {
3038
                            if ((control as IPath).LineSize != 0)
3039
                            {
3040
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3041
                            }
3042
                        }
3043
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3044

    
3045
                        if ((control as TextControl) != null)
3046
                        {
3047
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3048
                            {
3049
                                ViewerDataModel.Instance.checkTextStyle = true;
3050
                            }
3051
                            else
3052
                            {
3053
                                ViewerDataModel.Instance.checkTextStyle = false;
3054
                            }
3055

    
3056
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3057
                            {
3058
                                ViewerDataModel.Instance.checkTextStyle = true;
3059
                            }
3060
                            else
3061
                            {
3062
                                ViewerDataModel.Instance.checkTextStyle = false;
3063
                            }
3064
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3065
                            {
3066
                                ViewerDataModel.Instance.checkTextWeight = true;
3067
                            }
3068
                            else
3069
                            {
3070
                                ViewerDataModel.Instance.checkTextWeight = false;
3071
                            }
3072
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3073
                            {
3074
                                ViewerDataModel.Instance.checkUnderLine = true;
3075
                            }
3076
                            else
3077
                            {
3078
                                ViewerDataModel.Instance.checkUnderLine = false;
3079
                            }
3080

    
3081
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3082
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3083
                            
3084
                        }
3085
                        else if ((control as ArrowTextControl) != null)
3086
                        {
3087
                            //if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
3088
                            //{
3089
                            //    (control as ArrowTextControl).TextStyle = FontStyles.Italic;
3090
                            //}
3091
                            //if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
3092
                            //{
3093
                            //    (control as ArrowTextControl).TextWeight = FontWeights.Bold;
3094
                            //}
3095
                            //if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
3096
                            //{
3097
                            //    (control as ArrowTextControl).UnderLine = TextDecorations.Underline;
3098
                            //}
3099
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3100
                            {
3101
                                ViewerDataModel.Instance.checkTextStyle = true;
3102
                            }
3103
                            else
3104
                            {
3105
                                ViewerDataModel.Instance.checkTextStyle = false;
3106
                            }
3107

    
3108
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3109
                            {
3110
                                ViewerDataModel.Instance.checkTextStyle = true;
3111
                            }
3112
                            else
3113
                            {
3114
                                ViewerDataModel.Instance.checkTextStyle = false;
3115
                            }
3116
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3117
                            {
3118
                                ViewerDataModel.Instance.checkTextWeight = true;
3119
                            }
3120
                            else
3121
                            {
3122
                                ViewerDataModel.Instance.checkTextWeight = false;
3123
                            }
3124
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3125
                            {
3126
                                ViewerDataModel.Instance.checkUnderLine = true;
3127
                            }
3128
                            else
3129
                            {
3130
                                ViewerDataModel.Instance.checkUnderLine = false;
3131
                            }
3132
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3133
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3134
                        }
3135

    
3136
                    }
3137
                    else
3138
                    {
3139
                        comment = AddAdorner();
3140
                        comment.Add(control);
3141

    
3142
                        Control_Style(control);
3143
                        UndoData.Markup_List.Add(multi_Undo_Data);
3144

    
3145
                        final = new AdornerFinal(comment);
3146
                        //다중 컨트롤 언두 저장
3147
                    }
3148

    
3149
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3150
                    {
3151
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3152
                    });
3153

    
3154
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3155

    
3156
                    SelectLayer.Children.Add(final);
3157

    
3158
                    //Control_Init(control);
3159

    
3160

    
3161
                    
3162

    
3163

    
3164
                    //강인구 폰트 변경 보류
3165

    
3166
                    //if ((currentControl as TextControl) != null)
3167
                    //{
3168
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
3169
                    //    {
3170
                    //        ViewerDataModel.Instance.checkTextStyle = true;
3171
                    //    }
3172
                    //    else
3173
                    //    {
3174
                    //        ViewerDataModel.Instance.checkTextStyle = false;
3175
                    //    }
3176

    
3177
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
3178
                    //    {
3179

    
3180
                    //    }
3181
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Bold)
3182
                    //    {
3183

    
3184
                    //    }
3185
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
3186
                    //    {
3187

    
3188
                    //    }
3189
                    //}
3190
                    //else if ((currentControl as ArrowTextControl) != null)
3191
                    //{
3192
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
3193
                    //    {
3194
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
3195
                    //    }
3196
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
3197
                    //    {
3198
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
3199
                    //    }
3200
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
3201
                    //    {
3202
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
3203
                    //    }
3204
                    //}
3205

    
3206
                    mouseHandlingMode = MouseHandlingMode.Adorner;
3207
                }
3208
            }
3209

    
3210
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3211
            {
3212
                init();
3213
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3214
                if (cursor != Cursors.SizeAll)
3215
                {
3216
                    cursor = Cursors.Cross;
3217
                    SetCursor();
3218
                }
3219
                //currentControl.IsNew = true;
3220
                bool init_user = false;
3221
                foreach (var user in gridViewMarkup.Items)
3222
                {
3223
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3224
                    {
3225
                        init_user = true;
3226
                    }
3227
                }
3228
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3229
                //if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3230
                //if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
3231
                {
3232
                    RadWindow.Alert(new DialogParameters
3233
                    {
3234
                        Theme = new VisualStudio2013Theme(),
3235
                        Header = "안내",
3236
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3237
                    });
3238
                    return;
3239
                }
3240
                else
3241
                {
3242
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3243
                    if (item != null)
3244
                    {
3245
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3246
                    }
3247
                }
3248

    
3249
                multi_Undo_Data = new Multi_Undo_data();
3250
                //강인구 Undo/Redo 보류
3251
                UndoData = new Undo_data()
3252
                {
3253
                    IsUndo = false,
3254
                    Event = Event_Type.Create,
3255
                    EventTime = DateTime.Now,
3256
                    Markup_List = new List<Multi_Undo_data>()
3257
                };
3258

    
3259
                switch (controlType)
3260
                {
3261
                    case ControlType.Rectangle:
3262
                        {
3263
                            if (mouseButtonDown == MouseButton.Left)
3264
                            {
3265
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3266
                                {
3267
                                    if (currentControl is RectangleControl)
3268
                                    {
3269
                                        CreateControl();
3270

    
3271
                                        (currentControl as RectangleControl).ApplyOverViewData();
3272
                                        currentControl = null;
3273
                                        this.cursor = Cursors.Arrow;
3274
                                    }
3275
                                    else
3276
                                    {
3277
                                        currentControl = new RectangleControl
3278
                                        {
3279
                                            Background = new SolidColorBrush(Colors.Black),
3280
                                            ControlType = ControlType.Rectangle
3281
                                        };
3282

    
3283
                                        currentControl.CommentID = Save.shortGuid();
3284
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3285
                                        currentControl.IsNew = true;
3286
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3287

    
3288
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3289
                                    }
3290
                                }
3291
                            }
3292
                        }
3293
                        break;
3294
                    case ControlType.RectCloud:
3295
                        {
3296
                            if (mouseButtonDown == MouseButton.Left)
3297
                            {
3298
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3299
                                {
3300
                                    if (currentControl is RectCloudControl)
3301
                                    {
3302
                                        CreateControl();
3303

    
3304
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3305
                                        //controlType = ControlType.None;
3306
                                        currentControl = null;
3307
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
3308
                                        this.cursor = Cursors.Arrow;
3309
                                    }
3310
                                    else
3311
                                    {
3312
                                        currentControl = new RectCloudControl
3313
                                        {
3314
                                            Background = new SolidColorBrush(Colors.Black)
3315
                                        };
3316

    
3317
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3318
                                        currentControl.CommentID = Save.shortGuid();
3319
                                        currentControl.IsNew = true;
3320
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3321
                                    }
3322
                                }
3323
                            }
3324
                        }
3325
                        break;
3326
                    case ControlType.Circle:
3327
                        {
3328
                            if (mouseButtonDown == MouseButton.Left)
3329
                            {
3330
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3331
                                {
3332
                                    if (currentControl is CircleControl)
3333
                                    {
3334
                                        CreateControl();
3335

    
3336
                                        (currentControl as CircleControl).ApplyOverViewData();
3337
                                        //controlType = ControlType.None;
3338
                                        currentControl = null;
3339
                                    }
3340
                                    else
3341
                                    {
3342
                                        currentControl = new CircleControl
3343
                                        {
3344
                                            Background = new SolidColorBrush(Colors.Black)
3345
                                        };
3346

    
3347
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3348
                                        currentControl.CommentID = Save.shortGuid();
3349
                                        currentControl.IsNew = true;
3350
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3351
                                    }
3352
                                }
3353
                            }
3354
                        }
3355
                        break;
3356
                    case ControlType.Triangle:
3357
                        {
3358
                            if (mouseButtonDown == MouseButton.Left)
3359
                            {
3360
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3361
                                {
3362
                                    if (currentControl is TriControl)
3363
                                    {
3364
                                        var content = currentControl as TriControl;
3365
                                        if (content.MidPoint == new Point(0, 0))
3366
                                        {
3367
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3368
                                        }
3369
                                        else
3370
                                        {
3371
                                            CreateControl();
3372

    
3373
                                            (currentControl as TriControl).ApplyOverViewData();
3374
                                            //controlType = ControlType.None;
3375
                                            currentControl = null;
3376
                                        }
3377
                                    }
3378
                                    else
3379
                                    {
3380
                                        currentControl = new TriControl
3381
                                        {
3382
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3383
                                            Background = new SolidColorBrush(Colors.Black),
3384
                                        };
3385

    
3386
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3387
                                        currentControl.CommentID = Save.shortGuid();
3388
                                        currentControl.IsNew = true;
3389
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3390
                                    }
3391
                                }
3392
                            }
3393
                        }
3394
                        break;
3395
                    case ControlType.SingleLine:
3396
                        {
3397
                            if (mouseButtonDown == MouseButton.Left)
3398
                            {
3399
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3400
                                {
3401
                                    if (currentControl is LineControl)
3402
                                    {
3403
                                        CreateControl();
3404

    
3405
                                        (currentControl as LineControl).ApplyOverViewData();
3406
                                        //controlType = ControlType.None;
3407
                                        currentControl = null;
3408
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3409
                                    }
3410
                                    else
3411
                                    {
3412
                                        currentControl = new LineControl
3413
                                        {
3414
                                            Background = new SolidColorBrush(Colors.Black)
3415
                                        };
3416

    
3417
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3418
                                        currentControl.CommentID = Save.shortGuid();
3419
                                        currentControl.IsNew = true;
3420
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3421
                                        this.MainAngle.Visibility = Visibility.Visible;
3422
                                    }
3423
                                }
3424
                            }
3425
                        }
3426
                        break;
3427
                    case ControlType.CancelLine:
3428
                        {
3429
                            if (mouseButtonDown == MouseButton.Left)
3430
                            {
3431
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3432
                                {
3433
                                    if (currentControl is LineControl)
3434
                                    {
3435
                                        CreateControl();
3436

    
3437
                                        (currentControl as LineControl).ApplyOverViewData();
3438
                                        //controlType = ControlType.None;
3439
                                        currentControl = null;
3440
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3441
                                    }
3442
                                    else
3443
                                    {
3444
                                        currentControl = new LineControl
3445
                                        {
3446
                                            Background = new SolidColorBrush(Colors.Black)
3447
                                        };
3448

    
3449
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3450
                                        currentControl.CommentID = Save.shortGuid();
3451
                                        currentControl.IsNew = true;
3452
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3453
                                        this.MainAngle.Visibility = Visibility.Visible;
3454
                                    }
3455
                                }
3456
                            }
3457
                        }
3458
                        break;
3459
                    case ControlType.ArrowLine:
3460
                        {
3461
                            if (mouseButtonDown == MouseButton.Left)
3462
                            {
3463
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3464
                                {
3465
                                    if (currentControl is LineControl)
3466
                                    {
3467
                                        CreateControl();
3468

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

    
3481
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3482
                                        currentControl.CommentID = Save.shortGuid();
3483
                                        currentControl.IsNew = true;
3484
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3485
                                        this.MainAngle.Visibility = Visibility.Visible;
3486
                                    }
3487
                                }
3488
                            }
3489
                        }
3490
                        break;
3491
                    case ControlType.TwinLine:
3492
                        {
3493
                            if (mouseButtonDown == MouseButton.Left)
3494
                            {
3495
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3496
                                {
3497
                                    if (currentControl is LineControl)
3498
                                    {
3499
                                        CreateControl();
3500

    
3501
                                        (currentControl as LineControl).ApplyOverViewData();
3502
                                        //controlType = ControlType.None;
3503
                                        currentControl = null;
3504
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3505
                                    }
3506
                                    else
3507
                                    {
3508
                                        currentControl = new LineControl
3509
                                        {
3510
                                            Background = new SolidColorBrush(Colors.Black)
3511
                                        };
3512
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3513
                                        currentControl.CommentID = Save.shortGuid();
3514
                                        currentControl.IsNew = true;
3515
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3516
                                        this.MainAngle.Visibility = Visibility.Visible;
3517
                                    }
3518
                                }
3519
                            }
3520
                        }
3521
                        break;
3522
                    case ControlType.DimLine:
3523
                        {
3524
                            if (mouseButtonDown == MouseButton.Left)
3525
                            {
3526
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3527
                                {
3528
                                    if (currentControl is LineControl)
3529
                                    {
3530
                                        CreateControl();
3531

    
3532
                                        (currentControl as LineControl).ApplyOverViewData();
3533
                                        //controlType = ControlType.None;
3534
                                        currentControl = null;
3535
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3536
                                    }
3537
                                    else
3538
                                    {
3539
                                        currentControl = new LineControl
3540
                                        {
3541
                                            Background = new SolidColorBrush(Colors.Black)
3542
                                        };
3543
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3544
                                        currentControl.CommentID = Save.shortGuid();
3545
                                        currentControl.IsNew = true;
3546
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3547
                                        this.MainAngle.Visibility = Visibility.Visible;
3548
                                    }
3549
                                }
3550
                            }
3551
                        }
3552
                        break;
3553
                    case ControlType.ChainLine:
3554
                        {
3555
                            if (currentControl is PolygonControl)
3556
                            {
3557
                                var control = currentControl as PolygonControl;
3558

    
3559
                                if (mouseButtonDown == MouseButton.Right)
3560
                                {
3561
                                    CreateControl();
3562

    
3563
                                    (currentControl as PolygonControl).ApplyOverViewData();
3564
                                    //controlType = ControlType.None;
3565
                                    currentControl = null;
3566
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3567
                                    return;
3568
                                }
3569

    
3570
                                if (!control.IsCompleted)
3571
                                {
3572
                                    //control.PointC.pointSet.Add(control.EndPoint);
3573
                                    control.PointSet.Add(control.EndPoint);
3574
                                    this.MainAngle.Visibility = Visibility.Visible;
3575
                                }
3576
                                //else
3577
                                //{
3578
                                //    var firstPoint = control.PointC.pointSet.First();
3579

    
3580
                                //    //control.PointC.pointSet.Add(new Point(firstPoint.X, firstPoint.Y));
3581
                                //    control.PointC.pointSet.Add(firstPoint);
3582

    
3583
                                //    control.SetPolyPath();
3584

    
3585
                                //    controlType = ControlType.None;
3586

    
3587
                                //    currentControl = null;
3588
                                //}
3589
                            }
3590
                            else
3591
                            {
3592
                                if (mouseButtonDown == MouseButton.Left)
3593
                                {
3594
                                    MainAngle.Visibility = Visibility.Visible;
3595
                                    currentControl = new PolygonControl
3596
                                    {
3597
                                        PointSet = new List<Point>(),
3598
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3599
                                        ControlType = ControlType.ChainLine,
3600
                                        DashSize = ViewerDataModel.Instance.DashSize,
3601
                                        LineSize = ViewerDataModel.Instance.LineSize,
3602
                                        //PointC = new StylusPointSet()
3603
                                    };
3604

    
3605
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3606
                                    {
3607
                                        var polygonControl = (currentControl as PolygonControl);
3608
                                        currentControl.CommentID = Save.shortGuid();
3609
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3610
                                        currentControl.IsNew = true;
3611
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3612
                                        //currentControl.OnApplyTemplate();
3613
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3614
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3615
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3616
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3617
                                    }
3618
                                }
3619
                            }
3620
                        }
3621
                        break;
3622
                    case ControlType.ArcLine:
3623
                        {
3624
                            if (mouseButtonDown == MouseButton.Left)
3625
                            {
3626
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3627
                                {
3628
                                    if (currentControl is ArcControl)
3629
                                    {
3630
                                        CreateControl();
3631

    
3632
                                        (currentControl as ArcControl).ApplyOverViewData();
3633
                                        //controlType = ControlType.None;
3634
                                        currentControl = null;
3635
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3636
                                    }
3637
                                    else
3638
                                    {
3639
                                        currentControl = new ArcControl
3640
                                        {
3641
                                            Background = new SolidColorBrush(Colors.Black)
3642
                                        };
3643
                                        currentControl.CommentID = Save.shortGuid();
3644
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3645
                                        currentControl.IsNew = true;
3646
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3647
                                        this.MainAngle.Visibility = Visibility.Visible;
3648
                                    }
3649
                                }
3650
                            }
3651
                            else if (mouseButtonDown == MouseButton.Right)
3652
                            {
3653
                                if (currentControl != null)
3654
                                {
3655
                                    (currentControl as ArcControl).setClock();
3656
                                }
3657

    
3658
                            }
3659

    
3660
                        }
3661
                        break;
3662
                    case ControlType.ArcArrow:
3663
                        {
3664
                            if (mouseButtonDown == MouseButton.Left)
3665
                            {
3666
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3667
                                {
3668
                                    if (currentControl is ArcControl)
3669
                                    {
3670
                                        CreateControl();
3671

    
3672
                                        (currentControl as ArcControl).ApplyOverViewData();
3673
                                        //controlType = ControlType.None;
3674
                                        currentControl = null;
3675
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3676
                                    }
3677
                                    else
3678
                                    {
3679
                                        currentControl = new ArcControl
3680
                                        {
3681
                                            Background = new SolidColorBrush(Colors.Red),
3682
                                        };
3683
                                        currentControl.CommentID = Save.shortGuid();
3684
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3685
                                        currentControl.IsNew = true;
3686
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3687
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3688
                                        this.MainAngle.Visibility = Visibility.Visible;
3689
                                    }
3690
                                }
3691
                            }
3692
                            else if (mouseButtonDown == MouseButton.Right)
3693
                            {
3694
                                (currentControl as ArcControl).setClock();
3695
                            }
3696
                        }
3697
                        break;
3698
                    case ControlType.ArrowMultiLine:
3699
                        {
3700
                            if (mouseButtonDown == MouseButton.Left)
3701
                            {
3702
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3703
                                {
3704

    
3705
                                    if (currentControl is ArrowControl_Multi)
3706
                                    {
3707
                                        var content = currentControl as ArrowControl_Multi;
3708
                                        if (content.MiddlePoint == new Point(0, 0))
3709
                                        {
3710
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3711
                                            {
3712
                                                content.MiddlePoint = content.EndPoint;
3713
                                            }
3714
                                            else
3715
                                            {
3716
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3717
                                            }
3718
                                        }
3719
                                        else
3720
                                        {
3721
                                            CreateControl();
3722

    
3723
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3724
                                            //controlType = ControlType.None;
3725
                                            currentControl = null;
3726
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3727
                                        }
3728
                                    }
3729
                                    else
3730
                                    {
3731
                                        currentControl = new ArrowControl_Multi
3732
                                        {
3733
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3734
                                            Background = new SolidColorBrush(Colors.Black)
3735
                                        };
3736
                                        currentControl.CommentID = Save.shortGuid();
3737
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3738
                                        currentControl.IsNew = true;
3739
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3740
                                        this.MainAngle.Visibility = Visibility.Visible;
3741
                                    }
3742

    
3743
                                    //if (currentControl is ArrowControl_Multi)
3744
                                    //{
3745
                                    //    (currentControl as ArrowControl_Multi).ApplyOverViewData();
3746
                                    //    controlType = ControlType.None;
3747
                                    //    currentControl = null;
3748
                                    //}
3749
                                    //else
3750
                                    //{
3751
                                    //    currentControl = new ArrowControl_Multi
3752
                                    //    {
3753
                                    //        Background = new SolidColorBrush(Colors.Black)
3754
                                    //    };
3755

    
3756
                                    //    DataModel.Instance.MarkupControls.Add(currentControl);
3757
                                    //}
3758

    
3759

    
3760

    
3761
                                }
3762
                            }
3763
                        }
3764
                        break;
3765
                    case ControlType.PolygonCloud:
3766
                        {
3767
                            if (currentControl is CloudControl)
3768
                            {
3769
                                var control = currentControl as CloudControl;
3770
                                //control.Paint = PaintSet.Cloud;
3771
                                if (mouseButtonDown == MouseButton.Right)
3772
                                {
3773
                                    control.IsCompleted = true;
3774
                                }
3775

    
3776
                                if (!control.IsCompleted)
3777
                                {
3778
                                    //control.PointC.pointSet.Add(control.EndPoint);
3779
                                    control.PointSet.Add(control.EndPoint);
3780
                                }
3781
                                else
3782
                                {
3783
                                    CreateControl();
3784

    
3785
                                    control.isTransOn = true;
3786
                                    //var firstPoint = control.PointC.pointSet.First();
3787
                                    var firstPoint = control.PointSet.First();
3788

    
3789
                                    //control.PointC.pointSet.Add(firstPoint);
3790
                                    control.PointSet.Add(firstPoint);
3791
                                    control.DrawingCloud();
3792
                                    control.ApplyOverViewData();
3793

    
3794
                                    //controlType = ControlType.None;
3795

    
3796
                                    currentControl = null;
3797
                                }
3798
                            }
3799
                            else
3800
                            {
3801
                                if (mouseButtonDown == MouseButton.Left)
3802
                                {
3803
                                    currentControl = new CloudControl
3804
                                    {
3805
                                        PointSet = new List<Point>(),
3806
                                        PointC = new StylusPointSet()
3807
                                    };
3808

    
3809
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3810
                                    {
3811
                                        var polygonControl = (currentControl as CloudControl);
3812
                                        currentControl.CommentID = Save.shortGuid();
3813
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3814
                                        currentControl.IsNew = true;
3815
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3816
                                        //currentControl.OnApplyTemplate();
3817

    
3818
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3819
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3820
                                        //polygonControl.PointC.pointSet.Add(canvasZoomPanningMouseDownPoint);
3821
                                        //polygonControl.PointC.pointSet.Add(canvasZoomPanningMouseDownPoint);
3822

    
3823
                                    }
3824
                                }
3825
                            }
3826
                        }
3827
                        break;
3828
                    case ControlType.ImgControl:
3829
                        {
3830
                            if (mouseButtonDown == MouseButton.Left)
3831
                            {
3832
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3833
                                {
3834
                                    if (currentControl is ImgControl)
3835
                                    {
3836
                                        CreateControl();
3837
                                        (currentControl as ImgControl).ApplyOverViewData();
3838

    
3839
                                        //controlType = ControlType.None;
3840
                                        currentControl = null;
3841
                                    }
3842
                                    else
3843
                                    {
3844
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3845
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3846
                                        {
3847
                                            Image img = new Image();
3848
                                            img.Source = new BitmapImage(new Uri(filename));
3849

    
3850
                                            currentControl = new ImgControl
3851
                                            {
3852
                                                Background = new SolidColorBrush(Colors.Black),
3853
                                                PointSet = new List<Point>(),
3854
                                                FilePath = filename,
3855
                                                ImageData = img.Source,
3856
                                                StartPoint = canvasDrawingMouseDownPoint,
3857
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3858
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3859
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3860
                                            };
3861

    
3862
                                            currentControl.CommentID = Save.shortGuid();
3863
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3864
                                            currentControl.IsNew = true;
3865
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3866
                                        }
3867
                                    }
3868
                                }
3869
                            }
3870
                        }
3871
                        break;
3872
                    case ControlType.Date:
3873
                        {
3874
                            if (mouseButtonDown == MouseButton.Left)
3875
                            {
3876
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3877
                                {
3878
                                    if (currentControl is DateControl)
3879
                                    {
3880
                                        CreateControl();
3881
                                        (currentControl as DateControl).ApplyOverViewData();
3882
                                        //controlType = ControlType.None;
3883
                                        currentControl = null;
3884

    
3885
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3886
                                        {
3887
                                            controlType = ControlType.None;
3888
                                            IsSwingMode = false;
3889
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3890
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3891
                                            mouseHandlingMode = MouseHandlingMode.None;
3892
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3893
                                            txtBatch.Visibility = Visibility.Collapsed;
3894

    
3895
                                        }
3896
                                    }
3897
                                    else
3898
                                    {
3899
                                        currentControl = new DateControl
3900
                                        {
3901
                                            Background = new SolidColorBrush(Colors.Black)
3902
                                        };
3903
                                        //inkDrawingCanvas.Children.Add(currentControl);
3904
                                        //InkCanvas.SetLeft(currentControl, canvasDrawingMouseDownPoint.X);
3905
                                        //InkCanvas.SetTop(currentControl, canvasDrawingMouseDownPoint.Y);
3906
                                        currentControl.CommentID = Save.shortGuid();
3907
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3908
                                        currentControl.IsNew = true;
3909
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3910
                                        //DataModel.Instance.MarkupControls.Add(currentControl);
3911
                                    }
3912
                                }
3913
                            }
3914
                        }
3915
                        break;
3916
                    case ControlType.TextControl:
3917
                        {
3918
                            if (mouseButtonDown == MouseButton.Left)
3919
                            {
3920
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3921
                                {
3922

    
3923
                                    currentControl = new TextControl
3924
                                    {
3925
                                        //ControlType = PaintSet.Rect
3926
                                        ControlType = controlType
3927
                                    };
3928

    
3929
                                    //if (currentControl is TextControl)
3930
                                    //{
3931
                                    //    //currentControl.SetValue(Canvas.ZIndexProperty, 2);
3932
                                    //    //(currentControl as TextControl).Base_TextBox.Text = (currentControl as TextControl).Text;
3933
                                    //    //(currentControl as TextControl).Base_TextBox.Visibility = System.Windows.Visibility.Visible;
3934
                                    //    //(currentControl as TextControl).Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed;
3935
                                    //    //(currentControl as TextControl).Angle = Ang;
3936
                                    //    //currentControl.Focus();
3937
                                    //}
3938
                                    //else
3939
                                    //{
3940
                                    //currentControl = new TextControl();
3941
                                        currentControl.CommentID = Save.shortGuid();
3942
                                        currentControl.IsNew = true;
3943
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3944
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3945
                                        currentControl.SetValue(Canvas.ZIndexProperty, 2);
3946
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3947
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3948
                                        currentControl.Focus();
3949
                                        (currentControl as TextControl).ApplyOverViewData();
3950
                                        (currentControl as TextControl).ControlType_No = 0;
3951
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3952
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3953

    
3954
                                        CreateControl();
3955

    
3956
                                        currentControl = null;
3957
                                    //}
3958

    
3959
                                    //controlType = ControlType.None;
3960
                                    //currentControl = null;
3961

    
3962
                                }
3963
                            }
3964
                        }
3965
                        break;
3966
                    case ControlType.TextBorder:
3967
                        {
3968
                            if (mouseButtonDown == MouseButton.Left)
3969
                            {
3970
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3971
                                {
3972
                                    currentControl = new TextControl
3973
                                    {
3974
                                        //ControlType = PaintSet.Rect
3975
                                        ControlType = controlType
3976
                                    };
3977

    
3978

    
3979
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3980
                                    currentControl.CommentID = Save.shortGuid();
3981
                                    currentControl.IsNew = true;
3982
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3983
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3984
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3985
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3986
                                    currentControl.Focus();
3987
                                    (currentControl as TextControl).ControlType_No = 1;
3988
                                    (currentControl as TextControl).Angle = Ang;
3989
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3990
                                    //controlType = ControlType.None;
3991
                                    CreateControl();
3992

    
3993
                                    currentControl = null;
3994
                                }
3995
                            }
3996
                        }
3997
                        break;
3998
                    case ControlType.TextCloud:
3999
                        {
4000
                            if (mouseButtonDown == MouseButton.Left)
4001
                            {
4002
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4003
                                {
4004
                                    currentControl = new TextControl
4005
                                    {
4006
                                        //Paint = PaintSet.Cloud
4007
                                        ControlType = controlType
4008
                                    };
4009
                                    currentControl.CommentID = Save.shortGuid();
4010
                                    currentControl.IsNew = true;
4011
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4012
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4013

    
4014
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4015
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4016
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4017
                                    currentControl.Focus();
4018

    
4019
                                    (currentControl as TextControl).Angle = Ang;
4020
                                    (currentControl as TextControl).ControlType_No = 2;
4021
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4022

    
4023
                                    CreateControl();
4024
                                    //controlType = ControlType.None;
4025
                                    currentControl = null;
4026
                                }
4027
                            }
4028
                        }
4029
                        break;
4030
                    case ControlType.ArrowTextControl:
4031
                        {
4032
                            if (mouseButtonDown == MouseButton.Left)
4033
                            {
4034
                                if (currentControl is ArrowTextControl)
4035
                                {
4036
                                    CreateControl();
4037
                                    //controlType = ControlType.None;
4038

    
4039
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4040
                                    (currentControl as ArrowTextControl).IsEditing = false;
4041
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4042
                                    currentControl = null;
4043
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4044

    
4045
                                }
4046
                                else
4047
                                {
4048
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4049
                                    {
4050
                                        currentControl = new ArrowTextControl();
4051
                                        currentControl.CommentID = Save.shortGuid();
4052
                                        currentControl.IsNew = true;
4053
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4054
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4055

    
4056
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4057

    
4058
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4059

    
4060
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4061

    
4062
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4063

    
4064
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4065

    
4066
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4067
                                        this.MainAngle.Visibility = Visibility.Visible;
4068
                                        //currentControl.Focus();
4069
                                    }
4070
                                }
4071
                            }
4072
                        }
4073
                        break;
4074
                    case ControlType.ArrowTransTextControl:
4075
                        {
4076
                            if (mouseButtonDown == MouseButton.Left)
4077
                            {
4078
                                if (currentControl is ArrowTextControl)
4079
                                {
4080
                                    CreateControl();
4081
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4082
                                    //controlType = ControlType.None;
4083
                                    currentControl = null;
4084
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4085
                                }
4086
                                else
4087
                                {
4088
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4089
                                    {
4090
                                        currentControl = new ArrowTextControl();
4091
                                        currentControl.CommentID = Save.shortGuid();
4092
                                        currentControl.IsNew = true;
4093
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4094
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4095

    
4096
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4097

    
4098
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4099

    
4100
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4101

    
4102
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4103

    
4104
                                        (currentControl as ArrowTextControl).isFixed = true;
4105
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4106

    
4107
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4108
                                        this.MainAngle.Visibility = Visibility.Visible;
4109
                                        //currentControl.Focus();
4110
                                    }
4111
                                }
4112
                            }
4113
                        }
4114
                        break;
4115
                    case ControlType.ArrowTextBorderControl:
4116
                        {
4117
                            if (mouseButtonDown == MouseButton.Left)
4118
                            {
4119
                                if (currentControl is ArrowTextControl)
4120
                                {
4121
                                    CreateControl();
4122
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4123
                                    //controlType = ControlType.None;
4124
                                    currentControl = null;
4125
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4126
                                }
4127
                                else
4128
                                {
4129
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4130
                                    {
4131
                                        currentControl = new ArrowTextControl()
4132
                                        {
4133
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4134
                                        };
4135
                                        currentControl.CommentID = Save.shortGuid();
4136
                                        currentControl.IsNew = true;
4137
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4138
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4139

    
4140
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4141

    
4142
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4143

    
4144
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4145
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4146

    
4147
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4148

    
4149
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4150
                                        this.MainAngle.Visibility = Visibility.Visible;
4151
                                        //currentControl.Focus();
4152
                                    }
4153
                                }
4154
                            }
4155
                        }
4156
                        break;
4157
                    case ControlType.ArrowTransTextBorderControl:
4158
                        {
4159
                            if (mouseButtonDown == MouseButton.Left)
4160
                            {
4161
                                if (currentControl is ArrowTextControl)
4162
                                {
4163
                                    CreateControl();
4164
                                    //controlType = ControlType.None;
4165
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4166
                                    currentControl = null;
4167
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4168
                                }
4169
                                else
4170
                                {
4171
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4172
                                    {
4173
                                        currentControl = new ArrowTextControl()
4174
                                        {
4175
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4176
                                        };
4177
                                        currentControl.CommentID = Save.shortGuid();
4178
                                        currentControl.IsNew = true;
4179
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4180
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4181

    
4182
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4183

    
4184
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4185

    
4186
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4187

    
4188
                                        (currentControl as ArrowTextControl).isFixed = true;
4189
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4190

    
4191
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4192

    
4193
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4194
                                        this.MainAngle.Visibility = Visibility.Visible;
4195
                                        //currentControl.Focus();
4196
                                    }
4197
                                }
4198
                            }
4199
                        }
4200
                        break;
4201
                    case ControlType.ArrowTextCloudControl:
4202
                        {
4203
                            if (mouseButtonDown == MouseButton.Left)
4204
                            {
4205
                                if (currentControl is ArrowTextControl)
4206
                                {
4207
                                    CreateControl();
4208
                                    //controlType = ControlType.None;
4209
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4210
                                    currentControl = null;
4211
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4212
                                }
4213
                                else
4214
                                {
4215
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4216
                                    {
4217
                                        currentControl = new ArrowTextControl()
4218
                                        {
4219
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4220
                                        };
4221
                                        currentControl.CommentID = Save.shortGuid();
4222
                                        currentControl.IsNew = true;
4223
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4224
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4225

    
4226
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4227

    
4228
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4229

    
4230
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4231
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4232
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4233

    
4234
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4235
                                        this.MainAngle.Visibility = Visibility.Visible;
4236
                                        //currentControl.Focus();
4237
                                    }
4238
                                }
4239
                            }
4240
                        }
4241
                        break;
4242
                    case ControlType.ArrowTransTextCloudControl:
4243
                        {
4244
                            if (mouseButtonDown == MouseButton.Left)
4245
                            {
4246
                                if (currentControl is ArrowTextControl)
4247
                                {
4248
                                    CreateControl();
4249
                                    //controlType = ControlType.None;
4250
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4251
                                    currentControl = null;
4252
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4253
                                }
4254
                                else
4255
                                {
4256
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4257
                                    {
4258
                                        currentControl = new ArrowTextControl()
4259
                                        {
4260
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4261
                                        };
4262
                                        currentControl.CommentID = Save.shortGuid();
4263
                                        currentControl.IsNew = true;
4264
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4265
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4266

    
4267
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4268

    
4269
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4270

    
4271
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4272

    
4273
                                        (currentControl as ArrowTextControl).isFixed = true;
4274
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4275

    
4276
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4277

    
4278
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4279
                                        //currentControl.Focus();
4280
                                        this.MainAngle.Visibility = Visibility.Visible;
4281
                                    }
4282
                                }
4283
                            }
4284
                        }
4285
                        break;
4286
                    case ControlType.PolygonControl:
4287
                        {
4288
                            if (currentControl is PolygonControl)
4289
                            {
4290
                                var control = currentControl as PolygonControl;
4291

    
4292
                                if (mouseButtonDown == MouseButton.Right)
4293
                                {
4294
                                    control.IsCompleted = true;
4295
                                }
4296

    
4297
                                if (!control.IsCompleted)
4298
                                {
4299
                                    //control.PointC.pointSet.Add(control.EndPoint);
4300
                                    control.PointSet.Add(control.EndPoint);
4301
                                }
4302
                                else
4303
                                {
4304
                                    //control.IsSelected = true;
4305
                                    var firstPoint = control.PointSet.First();
4306
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4307
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4308
                                    control.PointSet.Add(firstPoint);
4309

    
4310
                                    control.SetPolyPath();
4311

    
4312
                                    control.ApplyOverViewData();
4313

    
4314
                                    CreateControl();
4315

    
4316
                                    //controlType = ControlType.None;
4317

    
4318
                                    currentControl = null;
4319
                                }
4320
                            }
4321
                            else
4322
                            {
4323
                                if (mouseButtonDown == MouseButton.Left)
4324
                                {
4325
                                    currentControl = new PolygonControl
4326
                                    {
4327
                                        PointSet = new List<Point>(),
4328
                                        //PointC = new StylusPointSet()
4329
                                    };
4330

    
4331
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4332
                                    {
4333
                                        var polygonControl = (currentControl as PolygonControl);
4334
                                        currentControl.CommentID = Save.shortGuid();
4335
                                        currentControl.IsNew = true;
4336
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4337
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4338
                                        //currentControl.OnApplyTemplate();
4339
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4340
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4341
                                    }
4342
                                }
4343
                            }
4344
                        }
4345
                        break;
4346
                    //강인구 추가
4347
                    case ControlType.Sign:
4348
                        {
4349
                            if (mouseButtonDown == MouseButton.Left)
4350
                            {
4351
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4352
                                {
4353
                                    if (currentControl is SignControl)
4354
                                    {
4355
                                        CreateControl();
4356
                                        currentControl = null;
4357
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4358
                                        {
4359
                                            txtBatch.Text = "Date Control을 그립니다.";
4360
                                            controlType = ControlType.Date;
4361
                                        }
4362
                                    }
4363
                                    else
4364
                                    {
4365
                                        currentControl = new SignControl
4366
                                        {
4367
                                            Background = new SolidColorBrush(Colors.Black),
4368
                                            //UserNumber = "H2011357",
4369
                                            UserNumber = App.ViewInfo.UserID,
4370
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4371
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4372
                                            ControlType = ControlType.Sign
4373
                                        };
4374

    
4375
                                        currentControl.CommentID = Save.shortGuid();
4376
                                        currentControl.IsNew = true;
4377
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4378
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4379
                                        //currentControl.ApplyTemplate();
4380
                                    }
4381
                                }
4382
                            }
4383
                        }
4384
                        break;
4385
                    case ControlType.Mark:
4386
                        {
4387
                            if (mouseButtonDown == MouseButton.Left)
4388
                            {
4389
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4390
                                {
4391
                                    if (currentControl is RectangleControl)
4392
                                    {
4393
                                        CreateControl();
4394
                                        (currentControl as RectangleControl).ApplyOverViewData();
4395
                                        //controlType = ControlType.None;
4396
                                        currentControl = null;
4397
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
4398
                                        this.cursor = Cursors.Arrow;
4399

    
4400
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4401
                                        {
4402
                                            txtBatch.Text = "Sign Control을 그립니다.";
4403
                                            controlType = ControlType.Sign;
4404
                                        }
4405
                                    }
4406
                                    else
4407
                                    {
4408
                                        currentControl = new RectangleControl
4409
                                        {
4410
                                            Background = new SolidColorBrush(Colors.Black),
4411
                                            Paint = PaintSet.Fill
4412
                                        };
4413

    
4414
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4415
                                        currentControl.CommentID = Save.shortGuid();
4416
                                        currentControl.IsNew = true;
4417
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4418
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4419
                                    }
4420
                                }
4421
                            }
4422
                        }
4423
                        break;
4424
                    case ControlType.Symbol:
4425
                        {
4426
                            if (mouseButtonDown == MouseButton.Left)
4427
                            {
4428
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4429
                                {
4430
                                    if (currentControl is SymControl)
4431
                                    {
4432
                                        CreateControl();
4433
                                        //(currentControl as SymControlN).ApplyOverViewData();
4434
                                        //controlType = ControlType.None;
4435
                                        currentControl = null;
4436
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
4437
                                        this.cursor = Cursors.Arrow;
4438
                                    }
4439
                                    else
4440
                                    {
4441
                                        currentControl = new SymControl
4442
                                        {
4443
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4444
                                            Background = new SolidColorBrush(Colors.Black),
4445
                                            ControlType = ControlType.Symbol
4446
                                        };
4447

    
4448
                                        currentControl.IsNew = true;
4449
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4450
                                        currentControl.CommentID = Save.shortGuid();
4451
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4452
                                    }
4453
                                }
4454
                            }
4455
                        }
4456
                        break;
4457
                    case ControlType.Stamp:
4458
                        {
4459
                            if (mouseButtonDown == MouseButton.Left)
4460
                            {
4461
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4462
                                {
4463
                                    if (currentControl is SymControlN)
4464
                                    {
4465
                                        CreateControl();
4466
                                        currentControl = null;
4467
                                        this.cursor = Cursors.Arrow;
4468
                                    }
4469
                                    else
4470
                                    {
4471
                                        currentControl = new SymControlN
4472
                                        {
4473
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4474
                                            Background = new SolidColorBrush(Colors.Black),
4475
                                            ControlType = ControlType.Stamp
4476
                                        };
4477

    
4478
                                        currentControl.IsNew = true;
4479
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4480
                                        currentControl.CommentID = Save.shortGuid();
4481
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4482
                                    }
4483
                                }
4484
                            }
4485
                        }
4486
                        break;
4487
                    case ControlType.PenControl:
4488
                        {
4489
                            //this.inkBoard.CaptureMouse();
4490

    
4491
                            if (inkBoard.Tag.ToString() == "Ink")
4492
                            {
4493
                                inkBoard.IsEnabled = true;
4494
                                StartNewStroke(canvasDrawingMouseDownPoint);
4495
                            }
4496
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4497
                            {
4498
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4499
                            }
4500
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4501
                            {
4502
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4503
                            }
4504
                            IsDrawing = true;
4505
                            return;
4506
                        }
4507
                        break;
4508
                    default:
4509
                        if (currentControl != null)
4510
                        {
4511
                            currentControl.CommentID = null;
4512
                            currentControl.IsNew = false;
4513
                        }
4514
                        break;
4515
                }
4516

    
4517
            }
4518

    
4519
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4520
            {
4521
                //bool Flag = true;
4522
                //ControlList = new List<object>();
4523
                //if (selected_item == null)
4524
                //{
4525
                //    selected_item = new Dictionary<Geometry, string>();
4526
                //}
4527
                //if (selected_item.Count > 0)
4528
                //{
4529
                //    mouseHandlingMode = MouseHandlingMode.Drawing;
4530

    
4531
                //    foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
4532
                //    {
4533
                //        ControlList.Add(item);
4534
                //    }
4535
                //    controlType = move.control_Move_R(ControlList, canvasDrawingMouseDownPoint);
4536
                //    currentControl = move.CurrentControl;
4537
                //}
4538
                //else
4539
                //{
4540
                //    isLeftMouseButtonDownOnWindow = true;
4541
                //}
4542
                if (controlType == ControlType.None)
4543
                {
4544
                    //init();
4545
                    //cursor = Cursors.Cross;
4546
                    //SetCursor();
4547
                    mouseHandlingMode = MouseHandlingMode.Selecting;
4548
                    this.cursor = Cursors.Arrow;
4549
                    inkDrawingCanvas.IsEnabled = false;
4550
                    isLeftMouseButtonDownOnWindow = true;
4551
                }
4552
            }
4553

    
4554
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4555
            {
4556
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4557
                {
4558
                    bool mouseOff = false;
4559
                    foreach (var item in SelectLayer.Children)
4560
                    {
4561
                        if (item is AdornerFinal)
4562
                        {
4563

    
4564
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4565
                            if (over != null)
4566
                            {
4567
                                mouseOff = true;
4568
                            }
4569
                        }
4570
                    }
4571

    
4572
                    if (!mouseOff)
4573
                    {
4574
                        ReleaseAdorner();
4575
                    }
4576
                }
4577
                //if (mouseHandlingMode == MouseHandlingMode.Adorner && ViewerDataModel.Instance.MarkupControls.Where(data => data.IsMouseOver).FirstOrDefault() == null && SelectLayer.Children.Count >0)
4578
                //{
4579

    
4580
                //}
4581
                zoomAndPanControl.CaptureMouse();
4582
                e.Handled = true;
4583
            }
4584

    
4585
            //txtDrawingCanvasDownPoint_X.Text = string.Format("{0:f2}", canvasDrawingMouseDownPoint.X);
4586
            //txtDrawingCanvasDownPoint_Y.Text = string.Format("{0:f2}", canvasDrawingMouseDownPoint.Y);
4587

    
4588
            //txtZoomCanvasDownPoint_X.Text = string.Format("{0:f2}", canvasZoomPanningMouseDownPoint.X);
4589
            //txtZoomCanvasDownPoint_Y.Text = string.Format("{0:f2}", canvasZoomPanningMouseDownPoint.Y);
4590
        }
4591
        //int maxViewerWidth;
4592
        //int maxViewerHeight;
4593
        //int minViewerTop;
4594
        //int minViewerLeft;
4595

    
4596
        private void RemoveLineStroke(Point P)
4597
        {
4598
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4599
            if (control != null)
4600
            {
4601
                UndoData = new Undo_data()
4602
                {
4603
                    IsUndo = false,
4604
                    Event = Event_Type.Delete,
4605
                    EventTime = DateTime.Now,
4606
                    Markup_List = new List<Multi_Undo_data>()
4607
                };
4608

    
4609

    
4610
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4611
                UndoData.Markup_List.Add(multi_Undo_Data);
4612
                multi_Undo_Data = new Multi_Undo_data();
4613

    
4614
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4615
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4616
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4617

    
4618

    
4619
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4620
                {
4621
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4622
                });
4623
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4624

    
4625
                //if (control as PolygonControl != null)
4626
                //{
4627
                //    if ((control as PolygonControl).ControlType == ControlType.Ink)
4628
                //    {
4629
                //        ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4630
                //        var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4631
                //        ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4632
                //    }
4633
                //}
4634
            }
4635

    
4636
            //StrokeCollection hits = inkBoard.Strokes.HitTest(P);
4637
            //inkBoard.Strokes.Remove(hits);
4638
        }
4639

    
4640
        private void RemovePointStroke(Point P)
4641
        {
4642
            //StrokeCollection hits = inkBoard.Strokes.HitTest(P);
4643
            foreach (Stroke hits in inkBoard.Strokes)
4644
            {
4645
                foreach (StylusPoint sty in hits.StylusPoints)
4646
                {
4647

    
4648
                }
4649
                if (hits.HitTest(P))
4650
                {
4651
                    inkBoard.Strokes.Remove(hits);
4652
                    return;
4653
                }
4654
            }
4655
        }
4656

    
4657
        private void StartNewStroke(Point P)
4658
        {
4659
            strokePoints = new StylusPointCollection();
4660
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4661
            strokePoints.Add(segment1Start);
4662
            stroke = new Stroke(strokePoints);
4663

    
4664
            stroke.DrawingAttributes.Color = Colors.Red;
4665
            stroke.DrawingAttributes.Width = 4;
4666
            stroke.DrawingAttributes.Height = 4;
4667

    
4668
            inkBoard.Strokes.Add(stroke);
4669

    
4670
            //inkBoard.Strokes.Add(stroke);
4671
        }
4672

    
4673
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4674
        {
4675
            ConsolidationMethod();
4676
        }
4677

    
4678
        public void ConsolidationMethod()
4679
        {
4680
            ChangeCommentReact();
4681

    
4682
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4683
            {
4684
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4685
            }
4686
            else
4687
            {
4688

    
4689
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4690
                {
4691
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4692
                }
4693
                //if (ViewerDataModel.Instance.MarkupControls_USER.Count() > 0 || this.gridViewMarkup.SelectedItems.Count > 0)
4694
                //{
4695
                //    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4696
                //}
4697

    
4698
                //if (ViewerDataModel.Instance.MarkupControls_USER.Count() > 0)
4699
                //{
4700
                //    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4701
                //}
4702

    
4703
                ViewerDataModel.Instance.IsConsolidate = true;
4704
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4705
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4706
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4707
                {
4708
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4709
                    if (markupInfo.CONSOLIDATE == 1)
4710
                    {
4711
                        markupInfo.AVOID_CONSOLIDATE = 1;
4712
                    }
4713

    
4714
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4715
                    {
4716
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4717
                          {
4718
                              instanceDataSet.Add(d);
4719
                          });
4720
                    }
4721

    
4722
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4723
                    info.ID = Save.shortGuid();
4724
                    info.CONSOLIDATE = 1;
4725
                    info.CREATE_TIME = DateTime.Now;
4726
                    info.DOCINFO_ID = _DocInfo.ID;
4727
                    info.UPDATE_TIME = DateTime.Now;
4728
                    info.USER_ID = App.ViewInfo.UserID;
4729
                    info.AVOID_CONSOLIDATE = 0;
4730

    
4731
                    Entity.MARKUP_INFO.AddObject(info);
4732
                    Entity.SaveChanges();
4733

    
4734

    
4735
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4736
                    {
4737
                        ID = Save.shortGuid(),
4738
                        CREATE_DATE = DateTime.Now,
4739
                        MARKUP_INFO = info,
4740
                    };
4741
                    Entity.SaveChanges();
4742

    
4743
                    foreach (var item in instanceDataSet)
4744
                    {
4745
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4746
                        {
4747
                            ID = Save.shortGuid(),
4748
                            DATA = item.DATA,
4749
                            DATA_TYPE = item.DATA_TYPE,
4750
                            PAGENUMBER = item.PAGENUMBER,
4751
                            MARKUP_INFO_VERSION = info2
4752
                        });
4753
                    }
4754
                    Entity.SaveChanges();
4755
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4756
                }
4757
            }
4758
        }
4759

    
4760
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4761
        {
4762
            if (App.ViewInfo != null)
4763
            {
4764
                btnConsolidate = (sender as RadRibbonButton);
4765
                if (!App.ViewInfo.NewCommentPermission)
4766
                {
4767
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4768
                    //instanceTop = this.ParentOfType<MainWindow>().dzTopMenu;
4769
                    //instanceTop.btnSwing.Visibility = Visibility.Collapsed;
4770
                    //instanceTop.cbSwingMode.Visibility = Visibility.Collapsed;
4771

    
4772
                    //instanceTop.btnExportPDF.Visibility = Visibility.Visible;
4773
                    //instanceTop.btnExportPrint.Visibility = Visibility.Visible;
4774
                }
4775
            }
4776
        }
4777

    
4778
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4779
        {
4780

    
4781
        }
4782

    
4783
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4784
        {
4785
            btnTeamConsolidate = sender as RadRibbonButton;
4786
            if (App.ViewInfo != null)
4787
            {
4788
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4789
                {
4790
                    if (btnConsolidate != null)
4791
                    {
4792
                        btnConsolidate.Visibility = Visibility.Collapsed;
4793
                    }
4794

    
4795
                    if (!App.ViewInfo.NewCommentPermission)
4796
                    {
4797
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4798
                    }
4799
                }
4800
                else
4801
                {
4802
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4803
                }
4804
            }
4805
        }
4806

    
4807
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4808
        {
4809
            //this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4810

    
4811
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4812
            if (item != null)
4813
            {
4814
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4815
            }
4816
            else
4817
            {
4818
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4819
            }
4820
        }
4821

    
4822
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4823
        {
4824
            btnFinalPDF = sender as RadRibbonButton;
4825
            if (App.ViewInfo != null)
4826
            {
4827
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4828
                {
4829
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4830
                    if (btnConsolidate != null)
4831
                    {
4832
                        btnConsolidate.Visibility = Visibility.Collapsed;
4833
                    }
4834
                }
4835
            }
4836
        }
4837

    
4838
        private void Button_Click(object sender, RoutedEventArgs e)
4839
        {
4840

    
4841
            //bool isGO = false;
4842
            //imageViewer.MouseLeftButtonDown += (sen, ea) =>
4843
            //  {
4844
            //      isGO = true;
4845
            //  };
4846
            //imageViewer.MouseLeftButtonUp += (sen, ea) =>
4847
            //{
4848
            //    isGO = false;
4849
            //};
4850
            //imageViewer.SizeMode = SizeMode.Fit;
4851
            //imageViewer.InteractiveMode = InteractiveMode.UserRectangle;
4852
            //imageViewer.InteractiveUserRectangle += (sen, ea) =>
4853
            //{
4854
            //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
4855
            //    if (ea.Status == InteractiveModeStatus.End)
4856
            //    {
4857
            //        //zoomAndPanControl.ZoomTo(ea.Bounds);
4858
            //        zoomAndPanControl.ZoomTo(ea.Bounds);
4859
            //    }
4860

    
4861
            //};
4862

    
4863
            //Canvas.SetZIndex(imageViewer, 10);
4864
            //gather information on the viewer
4865

    
4866

    
4867
            //System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
4868
            //var result = dialog.ShowDialog();
4869
            //if (result == System.Windows.Forms.DialogResult.OK)
4870
            //{
4871
            //    using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4872
            //    {
4873
            //        imageViewer.Image = codecs.Load(dialog.FileName, 0, Leadtools.Codecs.CodecsLoadByteOrder.Gray, 1, 1);
4874
            //        //imageViewer.Image = codecs.Load(dialog.FileName, 24, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4875
            //        //imageViewer.Image.AnimationBackground = Leadtools.RasterColor.White;
4876

    
4877
            //        //var d = imageViewer.Image.CreateThumbnail(100, 100, 24, Leadtools.RasterViewPerspective.TopLeft, Leadtools.RasterSizeFlags.None);
4878
            //        //RasterImageViewer vvv = new RasterImageViewer();
4879
            //        //vvv.Image = d;
4880
            //        //zoomAndPanCanvas.Children.Add(vvv);
4881

    
4882
            //        zoomAndPanCanvas.Width = Convert.ToDouble(imageViewer.Image.ImageWidth);
4883
            //        zoomAndPanCanvas.Height = Convert.ToDouble(imageViewer.Image.ImageHeight);
4884

    
4885
            //        Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
4886
            //        Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
4887
            //        //zoomAndPanControl.AnimatedScaleToFit();
4888
            //        zoomAndPanControl.ScaleToFit();
4889
            //    }
4890
            //}
4891

    
4892
        }//괄호 다시 확인 필요
4893

    
4894
        //강인구 추가
4895
        //가로 세로 동일한 컨트롤 그리기(계산 다시 필요)
4896
        private Point ShiftDrawing(Point StartP, Point EndP)
4897
        {
4898
            Point Return_Point = EndP;
4899
            //Shift key를 눌렀을때만 발동
4900
            if (ViewerDataModel.Instance.IsPressShift)
4901
            {
4902
                Square square = new Square();
4903
                double pt_X = 0;
4904
                double pt_Y = 0;
4905
                double result = 0;
4906

    
4907
                //pt_X = Math.Max(StartP.X, EndP.X) - Math.Min(StartP.X, EndP.X);
4908
                //pt_Y = Math.Max(StartP.Y, EndP.Y) - Math.Min(StartP.Y, EndP.Y);
4909
                if (EndP.X > StartP.X && EndP.Y > StartP.Y)
4910
                {
4911
                    pt_X = EndP.X - StartP.X;
4912
                    pt_Y = EndP.Y - StartP.Y;
4913
                }
4914
                else if (EndP.X < StartP.X && EndP.Y > StartP.Y)
4915
                {
4916
                    pt_X = StartP.X - EndP.X;
4917
                    pt_Y = EndP.Y - StartP.Y;
4918
                }
4919
                else if (EndP.X > StartP.X && EndP.Y < StartP.Y)
4920
                {
4921
                    pt_X = EndP.X - StartP.X;
4922
                    pt_Y = StartP.Y - EndP.Y
4923
;
4924
                }
4925
                result = Math.Max(pt_X, pt_Y) - Math.Min(pt_X, pt_Y);
4926
                if (pt_X < pt_Y)
4927
                {
4928
                    Return_Point = new Point(EndP.X + result, EndP.Y);
4929
                }
4930
                else
4931
                {
4932
                    Return_Point = new Point(EndP.X, EndP.Y + result);
4933
                }
4934
            }
4935

    
4936
            return Return_Point;
4937
        }
4938

    
4939
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4940
        {
4941
            if (CompareMode.IsChecked)
4942
            {
4943
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4944
                {
4945
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4946
                }
4947
                if (ViewerDataModel.Instance.PageNumber == 0)
4948
                {
4949
                    ViewerDataModel.Instance.PageNumber = 1;
4950
                }
4951

    
4952
                //BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageBalanceMode ? ViewerDataModel.Instance.PageBalanceNumber.ToString() : pageNavigator.CurrentPage.PageNumber.ToString());
4953
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4954

    
4955
                //string originFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, pageNavigator.CurrentPage.PageNumber);
4956
                //string targetFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4957

    
4958
                //MARKUS.CompareLib compareLib = new MARKUS.CompareLib();
4959
                //System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile);
4960
                //System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile);
4961

    
4962
                //var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
4963
                //var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
4964

    
4965
                //string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
4966
                //var result = compareLib.GetBoundBoxInImage(outPutFile);
4967

    
4968
                //SolidColorBrush mySolidColorBrush = new SolidColorBrush();
4969
                //mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
4970

    
4971
                //result.ForEach(d =>
4972
                //{
4973
                //    d.Width = d.Width * 3;
4974
                //    d.Height = d.Height * 3;
4975
                //    var point = MathSet.getRectMiddlePoint(d);
4976
                //    Ellipse myEllipse = new Ellipse();
4977
                //    myEllipse.Fill = new SolidColorBrush(Colors.Red);
4978
                //    myEllipse.Opacity = 1;
4979
                //        //myEllipse.StrokeThickness = 2;
4980
                //        //myEllipse.Stroke = Brushes.Black;
4981
                //        myEllipse.Width = d.Width;
4982
                //    myEllipse.Height = d.Height;
4983
                //    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
4984
                //    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
4985
                //    myEllipse.RenderTransformOrigin = point;
4986
                //    canvas_compareBorder.Children.Add(myEllipse);
4987
                //});
4988

    
4989
                //da.From = 0.8;
4990
                //da.To = 0;
4991
                //da.Duration = new Duration(TimeSpan.FromSeconds(1));
4992
                //da.AutoReverse = true;
4993
                //canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4994
            }
4995
            else
4996
            {
4997
                da.From = 1;
4998
                da.To = 1;
4999
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5000
                da.AutoReverse = false;
5001
                canvas_compareBorder.Children.Clear();
5002
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5003
            }
5004
        }
5005

    
5006
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5007
        {
5008
            if (UserList.IsChecked)
5009
            {
5010
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5011
            }
5012
            else
5013
            {
5014
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5015
            }
5016
            //if ((sender as RadToggleButton).IsChecked == true)
5017
            //{
5018
            //    this.gridViewRevMarkup.Visibility = Visibility.Visible;
5019
            //}
5020
            //else
5021
            //{
5022
            //    this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5023
            //}
5024
        }
5025

    
5026
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5027
        {
5028
            //ViewerDataModel.Instance.PageBalanceNumber = ViewerDataModel.Instance.PageBalanceNumber <= 0 ? Convert.ToInt32((sender as System.Windows.Controls.Control).Tag) : ViewerDataModel.Instance.PageBalanceNumber;
5029
            //ViewerDataModel.Instance.PageBalanceNumber = 0;
5030

    
5031

    
5032
            if (BalanceMode.IsChecked)
5033
            {
5034
                ViewerDataModel.Instance.PageBalanceMode = true;
5035
            }
5036
            else
5037
            {
5038
                ViewerDataModel.Instance.PageBalanceMode = false;
5039
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5040
            }
5041
            //if ((sender as RadToggleButton).IsChecked == true)
5042
            //{
5043
            //    ViewerDataModel.Instance.PageBalanceMode = true;
5044
            //}
5045
            //else
5046
            //{
5047
            //    ViewerDataModel.Instance.PageBalanceMode = false;
5048
            //    ViewerDataModel.Instance.PageBalanceNumber = 0;
5049
            //}
5050
        }
5051

    
5052
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5053
        {
5054
            //초기화
5055
            testPanel2.IsHidden = true;
5056
            ViewerDataModel.Instance.PageBalanceMode = false;
5057
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5058
            ViewerDataModel.Instance.PageNumber = 0;
5059
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5060
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5061
            UserList.IsChecked = false;
5062
            BalanceMode.IsChecked = false;
5063
        }
5064

    
5065
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5066
        {
5067
            if ((sender as System.Windows.Controls.Control).Tag != null)
5068
            {
5069
                //Compare 초기화
5070
                CompareMode.IsChecked = false;
5071
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5072

    
5073
                //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
5074
                //{
5075
                //    ViewerDataModel.Instance.PageBalanceNumber = 1;
5076
                //}
5077

    
5078
                if (ViewerDataModel.Instance.PageNumber == 0)
5079
                {
5080
                    ViewerDataModel.Instance.PageNumber = 1;
5081
                }
5082

    
5083
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5084
                {
5085
                }
5086
                else
5087
                {
5088
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5089
                }
5090
                //else if ((ViewerDataModel.Instance.PageBalanceNumber + balancePoint) >= 1)
5091
                //{
5092
                //    //ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5093
                //    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5094
                //}
5095

    
5096
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5097
                {
5098

    
5099
                }
5100
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5101
                {
5102
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5103
                }
5104

    
5105
                if (!testPanel2.IsHidden)
5106
                {
5107
                    //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5108
                    //{
5109
                    if (IsSyncPDFMode)
5110
                    {
5111
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5112
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5113

    
5114
                        if (pdfpath.IsDownloading)
5115
                        {
5116
                            pdfpath.DownloadCompleted += (ex, arg) =>
5117
                            {
5118
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5119
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5120
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5121
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5122
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5123
                            };
5124
                        }
5125
                        else
5126
                        {
5127
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5128
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5129
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5130

    
5131
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5132
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5133
                        }
5134

    
5135

    
5136
                        //PDF Mode 잠시대기
5137
                        //Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(CurrentRev.TO_VENDOR));
5138
                        //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageNumber);
5139
                        //Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
5140
                        //size.Run(image);
5141
                        //image.XResolution = 150;
5142
                        //image.YResolution = 150;
5143
                        //imageViewer_Compare.Image = image;
5144
                    }
5145
                    else
5146
                    {
5147
                        //var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageBalanceNumber);
5148
                        //var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5149
                        var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5150
                        //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
5151

    
5152
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5153

    
5154
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5155
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5156
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5157

    
5158
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5159
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5160

    
5161
                        if (defaultBitmapImage_Compare.IsDownloading)
5162
                        {
5163
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5164
                            {
5165
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5166
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5167
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5168

    
5169
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5170
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5171
                            };
5172
                        }
5173
                    }
5174

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

    
5179
                    foreach (var item in gridSelectionRevItem)
5180
                    {
5181
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5182
                        {
5183
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5184
                        });
5185
                    }
5186

    
5187

    
5188
                    //zoomAndPanCanvas2.Width = imageViewer_Compare.Image.Width;
5189
                    //zoomAndPanCanvas2.Height = imageViewer_Compare.Image.Height;
5190
                    //강인구 추가
5191
                    zoomAndPanControl2.ZoomTo(new Rect
5192
                    {
5193
                        X = 0,
5194
                        Y = 0,
5195
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5196
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5197
                    });
5198
                    //}
5199
                    //tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5200
                    //tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageBalanceNumber);
5201
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
5202

    
5203
                }
5204
            }
5205
        }
5206

    
5207
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5208
        {
5209
            //if ((sender as RadToggleButton).IsChecked)
5210
            if (MarkupMode.IsChecked)
5211
            {
5212
                //(sender as RadToggleButton).Content = "PDF Mode";
5213
                IsSyncPDFMode = true;
5214

    
5215
                var uri = CurrentRev.TO_VENDOR;
5216
                //Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(uri));
5217
                //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5218
                //{
5219
                //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
5220
                //{
5221
                //    ViewerDataModel.Instance.PageBalanceNumber = 1;
5222
                //}
5223
                if (ViewerDataModel.Instance.PageNumber == 0)
5224
                {
5225
                    ViewerDataModel.Instance.PageNumber = 1;
5226
                }
5227

    
5228
                //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageBalanceNumber);
5229

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

    
5234
                //System.Net.WebClient client = new System.Net.WebClient();
5235
                //byte[] imageBytes = client.DownloadData(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5236
                //System.Drawing.Image img;
5237
                //System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
5238
                //ms.Write(imageBytes, 0, imageBytes.Length);
5239
                //img = System.Drawing.Image.FromStream(ms, true);//Exception occurs here
5240

    
5241
                if (pdfpath.IsDownloading)
5242
                {
5243
                    pdfpath.DownloadCompleted += (ex, arg) =>
5244
                    {
5245
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5246
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5247
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5248
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5249
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5250
                    };
5251
                }
5252
                else
5253
                {
5254
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5255
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5256
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5257

    
5258
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5259
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5260
                }
5261

    
5262
                //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageNumber);
5263
                //Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
5264
                //size.Run(image);
5265
                //image.XResolution = 150;
5266
                //image.YResolution = 150;
5267
                //imageViewer_Compare.Image = image;
5268
                //}
5269
            }
5270
            else
5271
            {
5272
                //(sender as RadToggleButton).Content = "Markup Mode";
5273
                IsSyncPDFMode = false;
5274

    
5275
                //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5276
                //{
5277
                //var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5278
                var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5279

    
5280
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5281

    
5282
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5283
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5284
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5285

    
5286
                if (defaultBitmapImage_Compare.IsDownloading)
5287
                {
5288
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5289
                    {
5290
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5291
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5292
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5293
                    };
5294
                }
5295

    
5296
                //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
5297
                zoomAndPanControl2.ApplyTemplate();
5298
                zoomAndPanControl2.UpdateLayout();
5299
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5300
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5301
                //}
5302
            }
5303

    
5304
            //var options = new Leadtools.Documents.LoadDocumentAsyncOptions();
5305
            //options.FirstPageNumber = pageNavigator.CurrentPage.PageNumber;
5306
            //options.LastPageNumber = pageNavigator.CurrentPage.PageNumber;
5307
            ////options.LoadEmbeddedAnnotations = true;
5308
            ////options.UseCache = true;
5309
            //options.Completed += (sen, ea) =>
5310
            //{
5311
            //    //ea.Document.Pages[0].GetAnnotations(true);
5312
            //    //SetAnnotations
5313
            //    imageViewer_Compare.Image = ea.Document.Pages[0].GetImage();
5314

    
5315
            //    zoomAndPanCanvas2.Width = Convert.ToDouble(imageViewer_Compare.Image.Width);
5316
            //    zoomAndPanCanvas2.Height = Convert.ToDouble(imageViewer_Compare.Image.Height);
5317
            //};
5318
            //var uri = new Uri("http://cloud.devdoftech.co.kr:5977/FinalPDF/000000_app/VPCS_DOCLIB/111111/11111111/ToVendor/TEST_C_A.pdf");
5319
            //Leadtools.Documents.DocumentFactory.LoadFromUriAsync(uri, options);
5320

    
5321

    
5322
        }
5323

    
5324
        private void RadButton_Click(object sender, RoutedEventArgs e)
5325
        {
5326
            gridViewHistory_Busy.IsBusy = true;
5327

    
5328
            RadButton instance = sender as RadButton;
5329
            if (instance.CommandParameter != null)
5330
            {
5331
                CurrentRev = instance.CommandParameter as VPRevision;
5332
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5333
                {
5334
                    if (ea.Error == null && ea.Result != null)
5335
                    {
5336
                        testPanel2.IsHidden = false;
5337
                        //testList.ItemsSource = ea.Result;
5338

    
5339
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5340
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5341

    
5342
                        //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5343
                        //{
5344
                        //var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5345
                        var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5346

    
5347
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5348

    
5349
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5350

    
5351
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5352
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5353
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5354

    
5355
                        if (defaultBitmapImage_Compare.IsDownloading)
5356
                        {
5357
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5358
                            {
5359
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5360
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5361
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5362
                            };
5363
                        }
5364

    
5365
                        //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
5366

    
5367
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5368
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5369
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5370
                        //대기(강인구)
5371
                        //imageViewer_Compare.RotateAngle = imageViewer.RotateAngle;
5372
                        zoomAndPanControl2.ApplyTemplate();
5373
                        zoomAndPanControl2.UpdateLayout();
5374

    
5375
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5376
                        {
5377
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5378
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5379
                        }
5380
                        //}
5381

    
5382
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5383
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5384
                        gridViewHistory_Busy.IsBusy = false;
5385
                    }
5386
                };
5387
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5388
            }
5389
        }
5390

    
5391
        public void Sync_Event(VPRevision Currnet_Rev)
5392
        {
5393
            CurrentRev = Currnet_Rev;
5394

    
5395
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5396
            {
5397
                if (ea.Error == null && ea.Result != null)
5398
                {
5399
                    testPanel2.IsHidden = false;
5400
                    //testList.ItemsSource = ea.Result;
5401

    
5402
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5403
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5404

    
5405
                    //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5406
                    //{
5407
                    //var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5408
                    var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.png", _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5409

    
5410
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5411

    
5412
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5413

    
5414
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5415
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5416
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5417

    
5418
                    if (defaultBitmapImage_Compare.IsDownloading)
5419
                    {
5420
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5421
                        {
5422
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5423
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5424
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5425
                        };
5426
                    }
5427

    
5428
                    //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
5429

    
5430
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5431
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5432
                    zoomAndPanControl2.ApplyTemplate();
5433
                    zoomAndPanControl2.UpdateLayout();
5434

    
5435
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5436
                    {
5437
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5438
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5439
                    }
5440
                    //}
5441

    
5442
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5443
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5444
                    gridViewHistory_Busy.IsBusy = false;
5445
                }
5446
            };
5447
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5448

    
5449

    
5450
        }
5451

    
5452
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5453
        {
5454
            if (sender is Image)
5455
            {
5456
                if ((sender as Image).Tag != null)
5457
                {
5458
                    var pdfUrl = (sender as Image).Tag.ToString();
5459
                    System.Diagnostics.Process.Start(pdfUrl);
5460
                }
5461
                else
5462
                {
5463
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5464
                }
5465
            }
5466
        }
5467

    
5468
        private void Create_Symbol(object sender, RoutedEventArgs e)
5469
        {
5470
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5471
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5472

    
5473
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5474
            {
5475
                DialogMessage_Alert("Please Select Controls", "Alert");
5476
            }
5477
            else //선택된 것이 있으면
5478
            {
5479
                string MarkupData = "";
5480
                adorner_ = new AdornerFinal();
5481

    
5482
                foreach (var item in SelectLayer.Children)
5483
                {
5484
                    if (item.GetType().Name == "AdornerFinal")
5485
                    {
5486
                        adorner_ = (item as Controls.AdornerFinal);
5487
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5488
                        {
5489
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5490
                            {
5491
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5492
                                MarkupData += markupReturn.ConvertData;
5493
                            }
5494
                        }
5495
                    }
5496
                }
5497
                DialogParameters parameters = new DialogParameters()
5498
                {
5499
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5500
                    DefaultPromptResultValue = "Custom State",
5501
                    Content = "Name :",
5502
                    Header = "Insert Custom Symbol Name",
5503
                    Theme = new VisualStudio2013Theme(),
5504
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5505
                };
5506
                RadWindow.Prompt(parameters);
5507
            }
5508

    
5509
        }
5510

    
5511
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5512
        {
5513
            Save save = new Save();
5514

    
5515
            if (args.DialogResult.Value)
5516
            {
5517
                PngBitmapEncoder _Encoder = symImage(data);
5518

    
5519
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5520
                _Encoder.Save(fs);
5521
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5522

    
5523
                byte[] Img_byte = fs.ToArray();
5524

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

    
5528
                save.SymbolSave(args.PromptResult, filename, data);
5529
            }
5530
        }
5531

    
5532
        public PngBitmapEncoder symImage(string data)
5533
        {
5534

    
5535
            Canvas _canvas = new Canvas();
5536
            _canvas.Background = Brushes.White;
5537
            _canvas.Width = adorner_.BorderSize.Width;
5538
            _canvas.Height = adorner_.BorderSize.Height;
5539
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5540

    
5541
            BitmapEncoder encoder = new PngBitmapEncoder();
5542

    
5543

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

    
5546
            DrawingVisual dv = new DrawingVisual();
5547

    
5548
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5549
            //_canvas.Arrange(new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X - 50, Y = -adorner_.BorderSize.Y - 50 }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
5550
            _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)));
5551

    
5552
            using (DrawingContext ctx = dv.RenderOpen())
5553
            {
5554
                VisualBrush vb = new VisualBrush(_canvas);
5555
                //ctx.DrawRectangle(vb, null, 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)));
5556
                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)));
5557
            }
5558

    
5559
            try
5560
            {
5561
                renderBitmap.Render(dv);
5562

    
5563
                GC.Collect();
5564
                GC.WaitForPendingFinalizers();
5565
                GC.Collect();
5566
                //bitmap.Render(controlToConvert);
5567
                // encode png data
5568
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5569
                // puch rendered bitmap into it
5570
                pngEncoder.Interlace = PngInterlaceOption.Off;
5571
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5572
                return pngEncoder;
5573

    
5574
            }
5575
            catch (Exception ex)
5576
            {
5577
                return null;
5578
            }
5579

    
5580
        }
5581

    
5582
        public void DialogMessage_Alert(string content, string header)
5583
        {
5584
            var box = new TextBlock();
5585
            box.MinWidth = 400;
5586
            box.FontSize = 11;
5587
            //box.FontSize = 12;
5588
            box.Text = content;
5589
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5590

    
5591
            DialogParameters parameters = new DialogParameters()
5592
            {
5593
                Content = box,
5594
                Header = header,
5595
                Theme = new VisualStudio2013Theme(),
5596
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5597
            };
5598
            RadWindow.Alert(parameters);
5599
        }
5600

    
5601
        #region 캡쳐 기능
5602

    
5603
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5604
        {
5605
            if (x < 0)
5606
            {
5607
                width += x;
5608
                x = 0;
5609
            }
5610
            if (y < 0)
5611
            {
5612
                height += y;
5613
                y = 0;
5614

    
5615
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5616
            }
5617
            if (x + width > zoomAndPanCanvas.ActualWidth)
5618
            {
5619
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5620
            }
5621
            if (y + height > zoomAndPanCanvas.ActualHeight)
5622
            {
5623
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5624
            }
5625

    
5626
            byte[] pixels = CopyPixels(x, y, width, height);
5627

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

    
5630
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5631
        }
5632

    
5633
        public byte[] CopyPixels(int x, int y, int width, int height)
5634
        {
5635
            byte[] pixels = new byte[width * height * 4];
5636
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5637

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

    
5641
            return pixels;
5642
        }
5643

    
5644
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5645
        {
5646
            DrawingVisual drawingVisual = new DrawingVisual();
5647
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5648

    
5649
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5650
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5651
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5652
            drawingContext.Close();
5653

    
5654
            // 비트맵으로 변환합니다.
5655
            RenderTargetBitmap target =
5656
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5657
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5658

    
5659
            target.Render(drawingVisual);
5660
            return target;
5661
        }
5662

    
5663
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5664
        {
5665
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5666
            KCOMDataModel.DataModel.CHECK_LIST check_;
5667
            string Result = streamToBase64.ImageToBase64(source);
5668
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5669

    
5670
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
5671
            {
5672
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
5673

    
5674
                //새로운 데이터 추가
5675
                if (Item == null)
5676
                {
5677
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
5678
                    {
5679
                        ID = Save.shortGuid(),
5680
                        USER_ID = App.ViewInfo.UserID,
5681
                        IMAGE_URL = Result,
5682
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5683
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5684
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5685
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5686
                        PROJECT_NO = App.ViewInfo.ProjectNO,
5687
                        STATUS = "False",
5688
                        CREATE_TIME = DateTime.Now,
5689
                        UPDATE_TIME = DateTime.Now,
5690
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5691
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
5692
                    };
5693

    
5694
                    Entity.CHECK_LIST.AddObject(check_);
5695
                }
5696
                //기존에 있던 데이터 업데이트
5697
                else
5698
                {
5699
                    Item.IMAGE_URL = Result;
5700
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5701
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5702
                }
5703

    
5704
                //Item.REV_0 = "Test";
5705

    
5706
                try
5707
                {
5708
                    Entity.SaveChanges();
5709
                }
5710
                catch (Exception ex)
5711
                {
5712

    
5713
                }
5714
                //Entity.SaveChanges();
5715
            }
5716
        }
5717

    
5718
        public void Set_Capture()
5719
        {
5720
            //double x = Canvas.GetLeft(dragCaptureBorder);
5721
            //double y = Canvas.GetTop(dragCaptureBorder);
5722
            double x = canvasDrawingMouseDownPoint.X;
5723
            double y = canvasDrawingMouseDownPoint.Y;
5724
            double width = dragCaptureBorder.Width;
5725
            double height = dragCaptureBorder.Height;
5726

    
5727
            if (width > 5 || height > 5)
5728
            {
5729
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5730
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5731
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5732
            }
5733
        }
5734
        #endregion
5735

    
5736
        public void CreateControl()
5737
        {
5738
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5739
            {
5740
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5741
            });
5742
            multi_Undo_Data.Markup = currentControl;
5743
            UndoData.Markup_List.Add(multi_Undo_Data);
5744
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5745
        }
5746

    
5747
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5748
        {
5749
            multi_Undo_Data = new Multi_Undo_data();
5750

    
5751
            multi_Undo_Data.Markup = control;
5752

    
5753
            if ((control as IShapeControl) != null)
5754
            {
5755
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5756
            }
5757
            if ((control as IDashControl) != null)
5758
            {
5759
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5760
            }
5761
            if ((control as IPath) != null)
5762
            {
5763
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5764
            }
5765
            if ((control as UIElement) != null)
5766
            {
5767
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5768
            }
5769

    
5770
            return multi_Undo_Data;
5771
        }
5772

    
5773
        public void Undo()
5774
        {
5775
            Undo_data undo = new Undo_data();
5776
            AdornerFinal final;
5777
            ReleaseAdorner();
5778

    
5779
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5780
            if (undo == null)
5781
                return;
5782

    
5783
            switch (undo.Event)
5784
            {
5785
                case (Event_Type.Create):
5786
                    {
5787
                        foreach (var item in undo.Markup_List)
5788
                        {
5789
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5790
                        }
5791
                    }
5792
                    break;
5793
                case (Event_Type.Delete):
5794
                    {
5795
                        foreach (var item in undo.Markup_List)
5796
                        {
5797
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5798

    
5799
                            //final = new AdornerFinal(item.Markup);
5800
                            //SelectLayer.Children.Add(final);
5801
                        }
5802
                    }
5803
                    break;
5804
                case (Event_Type.Thumb):
5805
                    {
5806
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5807

    
5808
                        foreach (var item in undo.Markup_List)
5809
                        {
5810
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5811

    
5812
                            if ((item.Markup as IViewBox) != null)
5813
                            {
5814
                                (item.Markup as IViewBox).Angle = item.Angle;
5815
                            }
5816
                            if ((item.Markup as TextControl) != null)
5817
                            {
5818
                                (item.Markup as TextControl).Angle = item.Angle;
5819
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5820
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5821
                            }
5822
                            else
5823
                            {
5824
                                (item.Markup as IPath).PointSet = item.PointSet;
5825
                                (item.Markup as IPath).updateControl();
5826
                            }
5827

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

    
5840
                        foreach (var item in undo.Markup_List)
5841
                        {
5842
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5843

    
5844
                            if ((item.Markup as IPath) != null)
5845
                            {
5846
                                (item.Markup as IPath).LineSize = item.LineSize;
5847
                            }
5848
                            if ((item.Markup as UIElement) != null)
5849
                            {
5850
                                (item.Markup as UIElement).Opacity = item.Opacity;
5851
                            }
5852
                            if ((item.Markup as IDashControl) != null)
5853
                            {
5854
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5855
                            }
5856
                            if ((item.Markup as IShapeControl) != null)
5857
                            {
5858
                                (item.Markup as IShapeControl).Paint = item.paint;
5859
                            }
5860

    
5861
                            comment.Add(item.Markup);
5862
                        }
5863

    
5864
                        final = new AdornerFinal(comment);
5865
                        SelectLayer.Children.Add(final);
5866
                    }
5867
                    break;
5868
                case (Event_Type.Option):
5869
                    {
5870
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5871

    
5872
                        foreach (var item in undo.Markup_List)
5873
                        {
5874
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5875

    
5876
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5877
                            {
5878
                                (item.Markup as IPath).LineSize = undo.LineSize;
5879
                            }
5880
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5881
                            {
5882
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5883
                            }
5884
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5885
                            {
5886
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5887
                            }
5888
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
5889
                            {
5890
                                (item.Markup as LineControl).Interval = undo.Interval;
5891
                            }
5892
                            else if (item.Markup as IShapeControl != null)
5893
                            {
5894
                                (item.Markup as IShapeControl).Paint = undo.paint;
5895
                            }
5896
                            comment.Add(item.Markup);
5897
                        }
5898
                        final = new AdornerFinal(comment);
5899
                        SelectLayer.Children.Add(final);
5900
                    }
5901
                    break;
5902
            }
5903
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5904
           {
5905
               i.IsUndo = true;
5906
           });
5907
        }
5908

    
5909
        public void Redo()
5910
        {
5911
            AdornerFinal final;
5912
            Undo_data redo = new Undo_data();
5913
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5914
            ReleaseAdorner();
5915
            if (redo == null)
5916
                return;
5917

    
5918
            switch (redo.Event)
5919
            {
5920
                case (Event_Type.Create):
5921
                    {
5922
                        foreach (var item in redo.Markup_List)
5923
                        {
5924
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5925
                        }
5926
                    }
5927
                    break;
5928
                case (Event_Type.Delete):
5929
                    {
5930
                        foreach (var item in redo.Markup_List)
5931
                        {
5932
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5933
                        }
5934
                    }
5935
                    break;
5936
                case (Event_Type.Thumb):
5937
                    {
5938
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5939

    
5940
                        foreach (var item in redo.Markup_List)
5941
                        {
5942
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5943

    
5944
                            if ((item.Markup as IViewBox) != null)
5945
                            {
5946
                                (item.Markup as IViewBox).Angle = item.Angle;
5947
                            }
5948
                            if ((item.Markup as TextControl) != null)
5949
                            {
5950
                                //(item.Markup as TextControl).CanvasX = item.PointSet[0].X;
5951
                                //(item.Markup as TextControl).CanvasY = item.PointSet[0].Y;
5952

    
5953
                                (item.Markup as TextControl).Angle = item.Angle;
5954

    
5955
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5956
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5957
                            }
5958
                            else
5959
                            {
5960
                                (item.Markup as IPath).PointSet = item.PointSet;
5961
                                (item.Markup as IPath).updateControl();
5962
                            }
5963
                            comment.Add(item.Markup);
5964
                        }
5965
                        final = new AdornerFinal(comment);
5966
                        SelectLayer.Children.Add(final);
5967
                        ReleaseAdorner();
5968
                    }
5969
                    break;
5970
                case (Event_Type.Select):
5971
                    {
5972
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5973

    
5974
                        foreach (var item in redo.Markup_List)
5975
                        {
5976
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5977

    
5978
                            if ((item.Markup as IPath) != null)
5979
                            {
5980
                                (item.Markup as IPath).LineSize = item.LineSize;
5981
                            }
5982
                            if ((item.Markup as UIElement) != null)
5983
                            {
5984
                                (item.Markup as UIElement).Opacity = item.Opacity;
5985
                            }
5986
                            if ((item.Markup as IDashControl) != null)
5987
                            {
5988
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5989
                            }
5990
                            if ((item.Markup as IShapeControl) != null)
5991
                            {
5992
                                (item.Markup as IShapeControl).Paint = item.paint;
5993
                            }
5994

    
5995
                            comment.Add(item.Markup);
5996
                        }
5997
                        final = new AdornerFinal(comment);
5998
                        SelectLayer.Children.Add(final);
5999
                    }
6000
                    break;
6001
                case (Event_Type.Option):
6002
                    {
6003
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6004

    
6005
                        foreach (var item in redo.Markup_List)
6006
                        {
6007
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6008
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6009
                            {
6010
                                (item.Markup as IPath).LineSize = redo.LineSize;
6011
                            }
6012
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6013
                            {
6014
                                (item.Markup as UIElement).Opacity = redo.Opacity;
6015
                            }
6016
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
6017
                            {
6018
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
6019
                            }
6020
                            else if(redo.Interval != 0 && item.Markup as LineControl != null)
6021
                            {
6022
                                (item.Markup as LineControl).Interval = redo.Interval;
6023
                            }
6024
                            else if (item.Markup as IShapeControl != null)
6025
                            {
6026
                                (item.Markup as IShapeControl).Paint = redo.paint;
6027
                            }
6028
                            comment.Add(item.Markup);
6029
                        }
6030
                        final = new AdornerFinal(comment);
6031
                        SelectLayer.Children.Add(final);
6032
                    }
6033
                    break;
6034
            }
6035

    
6036
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6037
            {
6038
                i.IsUndo = false;
6039
            });
6040
        }
6041

    
6042
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6043
        {
6044
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6045
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6046
            {
6047
                if (items.UserID == Select_ID)
6048
                {
6049
                    foreach (var item in items.MarkupList)
6050
                    {
6051
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6052
                        {
6053
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
6054
                        }
6055
                    }
6056
                }
6057
            }
6058
        }
6059

    
6060
        public void InkControl_Convert()
6061
        {
6062
            if (inkBoard.Strokes.Count > 0)
6063
            {
6064
                inkBoard.Strokes.ToList().ForEach(stroke =>
6065
                {
6066
                    List<Stroke> removingStroke = new List<Stroke>();
6067
                    StrokeCollection stC = new StrokeCollection();
6068
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
6069
                    //{
6070
                    //    removingStroke.Add(inkBoard.Strokes[i]);
6071
                    //}
6072

    
6073
                    removingStroke.Add(stroke);
6074

    
6075
                    InkToPath ip = new InkToPath();
6076
                    List<Point> inkPointSet = new List<Point>();
6077
                    PolygonControl pc = null;
6078
                    //InkControl pc = null;
6079
                    //pc = new InkControl()
6080
                    pc = new PolygonControl()
6081
                    {
6082
                        //PointC = new List<StylusPointSet>(),
6083
                        Angle = 0,
6084
                        PointSet = new List<Point>(),
6085
                        ControlType = ControlType.Ink
6086
                    };
6087
                    foreach (var item in removingStroke)
6088
                    {
6089
                        //pc.PointC.Add(new StylusPointSet() { pointSet = ip.StrokeGetPointsPlus(item) });
6090
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6091
                        inkBoard.Strokes.Remove(item);
6092
                    }
6093
                    if (inkPointSet.Count != 0)
6094
                    {
6095

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

    
6105
                        pc.StartPoint = inkPointSet[0];
6106
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6107
                        pc.PointSet = inkPointSet;
6108
                        pc.LineSize = 3;
6109
                        pc.CommentID = Save.shortGuid();
6110
                        //pc.StrokeColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("ff18b7fc"));
6111
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6112
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6113
                        pc.SetPolyPath();
6114

    
6115
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6116
                        {
6117
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6118
                        });
6119
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6120
                        UndoData.Markup_List.Add(multi_Undo_Data);
6121
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6122
                    }
6123
                });
6124

    
6125
            }
6126
        }
6127
    }
6128
}
클립보드 이미지 추가 (최대 크기: 500 MB)