프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (280 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
        /// <summary>
147
        /// Set to 'true' when the left mouse-button is down.
148
        /// </summary>
149
        private bool isLeftMouseButtonDownOnWindow = false;
150
        //public int currnetNo = 1;
151

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

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

    
175
                }
176
            }
177
        }
178

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

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

    
227
        public bool IsSyncPDFMode { get; set; }
228

    
229

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

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

    
278
        #endregion
279

    
280

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

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

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

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

    
308
            return false;
309
        }
310

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

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

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

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

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

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

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

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

    
374
            DeleteItem(item);
375
        }
376

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

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

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

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

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

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

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

    
403

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

    
411

    
412
        }
413

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

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

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

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

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

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

    
465
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
466

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

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

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

    
487
            //}
488

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

    
533

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

    
571
            //        }
572
            //    }
573

    
574
            //}
575

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

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

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

    
611
        }
612

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

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

    
620
            InkControl_Convert();
621

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

    
636

    
637

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

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

    
644

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

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

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

    
659
            #endregion
660

    
661
            ViewerDataModel.Instance.PageNumber = BalancePoint;
662

    
663
            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);
664

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

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

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

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

    
684

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

    
692

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

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

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

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

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

    
726
                    //var image = dpc.GetPageImage(codecs, BalancePoint);
727
                    //Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
728
                    //size.Run(image);
729
                    //image.XResolution = 150;
730
                    //image.YResolution = 150;
731
                    //imageViewer_Compare.Image = image;
732
                }
733
                else
734
                {
735
                    //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);
736
                    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);
737

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

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

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

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

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

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

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

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

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

    
784
            this.pageNavigator.SetNextPage();
785

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

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

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

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

    
829

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

    
835

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

    
844
            }
845

    
846

    
847

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

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

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

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

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

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

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

    
905
        #region ZoomIn & ZoomOut
906

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

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

    
919

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

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

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

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

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

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

    
988
        #endregion
989

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

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

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

    
1002
        }
1003

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

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

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

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

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

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

    
1140
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1141
        {
1142
            //var ct = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1143
            //if (ct != null)
1144
            //{
1145
            //    this.cursor = Cursors.Hand;
1146
            //    SetCursor();
1147
            //}
1148
            //else
1149
            //{
1150
            //    this.cursor = Cursors.Arrow;
1151
            //    SetCursor();
1152
            //}
1153

    
1154
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1155
            {
1156
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1157

    
1158
                Point currentPos = e.GetPosition(rect);
1159

    
1160
                floatingTip.HorizontalOffset = currentPos.X + 20;
1161
                floatingTip.VerticalOffset = currentPos.Y;
1162

    
1163

    
1164
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1165
                //tool.Content = "ToolTip";
1166
                //panel.ToolTip = tool;
1167
            }
1168

    
1169
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1170
            {
1171
                #region 마우스 오버 시 색상 변경
1172
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1173
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1174

    
1175
                //if (firstCondition != null)
1176
                //{
1177
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1178

    
1179
                //    if (firstCondition.GetType().Name == "TextControl")
1180
                //    {
1181
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1182
                //        return;
1183
                //    }
1184
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1185
                //    {
1186
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1187
                //        return;
1188
                //    }
1189

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

    
1243
                //        default:
1244
                //            {
1245

    
1246
                //            }
1247
                //            break;
1248
                //    }
1249
                //} 
1250
                #endregion
1251
            }
1252

    
1253
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1254

    
1255
            if (mouseButtonDown == MouseButton.Middle)
1256
            {
1257
                SetCursor();
1258
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1259
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1260

    
1261
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1262

    
1263
                zoomAndPanControl.ContentOffsetX += 1;
1264
                zoomAndPanControl.ContentOffsetY += 1;
1265

    
1266
                //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1267
                //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1268
            }
1269

    
1270
            if (mouseButtonDown == MouseButton.Right)
1271
            {
1272
                SetCursor();
1273
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1274
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1275

    
1276
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1277
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1278
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1279
            }
1280
            //else if (currentControl != null && mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1281
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1282
            {
1283
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1284
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1285
                SetCursor();
1286

    
1287
                if (IsDrawing)
1288
                {
1289
                    if (currentControl == null)
1290
                    {
1291
                        switch (controlType)
1292
                        {
1293
                            case ControlType.PenControl:
1294
                                {
1295
                                    if (inkBoard.Tag.ToString() == "Ink")
1296
                                    {
1297
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1298
                                    }
1299
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1300
                                    {
1301
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1302
                                    }
1303
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1304
                                    {
1305
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1306
                                    }
1307

    
1308
                                    //inkBoard.Strokes.Add(stroke);
1309
                                }
1310
                                break;
1311
                        }
1312
                        return;
1313
                    }
1314
                }
1315

    
1316
                if (currentControl != null)
1317
                {
1318
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1319
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1320
                    //강인구 추가
1321
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1322

    
1323
                    if ((currentControl as IPath) != null)
1324
                    {
1325
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1326
                    }
1327
                    if ((currentControl as IShapeControl) != null)
1328
                    {
1329
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1330
                    }
1331
                    if ((currentControl as TextControl) != null)
1332
                    {
1333
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1334
                        {
1335
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1336
                        }
1337
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1338
                        {
1339
                            (currentControl as TextControl).TextWeight = FontWeights.Heavy;
1340
                        }
1341
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1342
                        {
1343
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1344
                        }
1345
                    }
1346
                    else if ((currentControl as ArrowTextControl) != null)
1347
                    {
1348
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1349
                        {
1350
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1351
                        }
1352
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1353
                        {
1354
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Heavy;
1355
                        }
1356
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1357
                        {
1358
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1359
                        }
1360
                    }
1361

    
1362
                    switch (controlType)
1363
                    {
1364
                        case ControlType.Rectangle:
1365
                            {
1366
                                var control = currentControl as RectangleControl;
1367

    
1368
                                if (control != null)
1369
                                {
1370
                                    if (move.mousemode == MouseMode.Drawing)
1371
                                    {
1372
                                        //move.control_Move(ControlList, true, moveX, moveY);
1373
                                    }
1374
                                    else
1375
                                    {
1376
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1377
                                        //control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1378
                                        //control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1379
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1380

    
1381

    
1382
                                        //control.PointSet = new List<Point>
1383
                                        //{
1384
                                        //    control.StartPoint,
1385
                                        //    control.LeftBottomPoint,
1386
                                        //    control.EndPoint,
1387
                                        //    control.TopRightPoint,
1388
                                        //};
1389
                                        control.PointSet = new List<Point>
1390
                                        {
1391
                                            new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
1392
                                            new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y),
1393
                                            new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y),
1394
                                            new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y),
1395
                                        };
1396
                                        control.updateControl();
1397
                                    }
1398

    
1399
                                    //강인구 추가
1400
                                    control.ControlType = controlType;
1401
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1402
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1403
                                }
1404
                            }
1405
                            break;
1406

    
1407
                        case ControlType.RectCloud:
1408
                            {
1409
                                var control = currentControl as RectCloudControl;
1410

    
1411
                                if (control != null)
1412
                                {
1413
                                    if (move.mousemode == MouseMode.Drawing)
1414
                                    {
1415
                                        //move.control_Move(ControlList, true, moveX, moveY);
1416
                                    }
1417
                                    else
1418
                                    {
1419
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1420
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1421
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1422
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1423

    
1424
                                        control.PointSet = new List<Point>
1425
                                        {
1426
                                            control.StartPoint,
1427
                                            control.LeftBottomPoint,
1428
                                            control.EndPoint,
1429
                                            control.TopRightPoint,
1430
                                        };
1431
                                    }
1432
                                    //강인구 추가
1433
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1434
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1435
                                }
1436
                            }
1437
                            break;
1438

    
1439
                        case ControlType.SingleLine:
1440
                            {
1441
                                if (currentControl != null)
1442
                                {
1443
                                    var control = currentControl as LineControl;
1444
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1445
                                    control.ControlType = controlType;
1446
                                    if (control != null)
1447
                                    {
1448
                                        if (move.mousemode == MouseMode.Drawing)
1449
                                        {
1450
                                            //move.control_Move(ControlList, true, moveX, moveY);
1451
                                        }
1452
                                        else
1453
                                        {
1454
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1455
                                            {
1456
                                                control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1457
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1458

    
1459
                                                Point tempPoint = control.EndPoint;
1460
                                                var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1461
                                                control.EndPoint = tempPoint;
1462
                                            }
1463
                                            else
1464
                                            {
1465
                                                control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1466
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1467
                                            }
1468

    
1469
                                            control.PointSet = new List<Point>
1470
                                            {
1471
                                                control.StartPoint,
1472
                                                control.EndPoint,
1473
                                            };
1474
                                        }
1475
                                        //강인구 추가
1476
                                        control.DashSize = ViewerDataModel.Instance.DashSize;
1477
                                    }
1478
                                }
1479

    
1480
                            }
1481
                            break;
1482

    
1483
                        case ControlType.CancelLine:
1484
                            {
1485
                                if (currentControl != null)
1486
                                {
1487
                                    var control = currentControl as LineControl;
1488
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1489
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1490
                                    control.ControlType = controlType;
1491
                                    if (control != null)
1492
                                    {
1493
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1494
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1495

    
1496
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1497
                                        {
1498
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1499
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1500

    
1501
                                            Point tempPoint = control.EndPoint;
1502
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1503
                                            control.EndPoint = tempPoint;
1504
                                        }
1505
                                        else
1506
                                        {
1507
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1508
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1509
                                        }
1510

    
1511

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

    
1524
                        case ControlType.ArrowLine:
1525
                            {
1526
                                if (currentControl != null)
1527
                                {
1528
                                    var control = currentControl as LineControl;
1529
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1530
                                    control.ControlType = controlType;
1531
                                    if (control != null)
1532
                                    {
1533
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1534

    
1535
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1536

    
1537
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1538
                                        {
1539
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1540
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1541

    
1542
                                            Point tempPoint = control.EndPoint;
1543
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1544
                                            control.EndPoint = tempPoint;
1545
                                        }
1546
                                        else
1547
                                        {
1548
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1549
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
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

    
1577
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1578

    
1579
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1580
                                        {
1581
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1582
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1583

    
1584
                                            Point tempPoint = control.EndPoint;
1585
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1586
                                            control.EndPoint = tempPoint;
1587
                                        }
1588
                                        else
1589
                                        {
1590
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1591
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1592
                                        }
1593

    
1594

    
1595
                                        control.PointSet = new List<Point>
1596
                                            {
1597
                                                control.StartPoint,
1598
                                                control.EndPoint,
1599
                                            };
1600
                                    }
1601
                                    //강인구 추가
1602
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1603
                                }
1604

    
1605
                            }
1606
                            break;
1607

    
1608
                        case ControlType.DimLine:
1609
                            {
1610
                                if (currentControl != null)
1611
                                {
1612
                                    var control = currentControl as LineControl;
1613
                                    control.LineStyleSet = LineStyleSet.DimLine;
1614
                                    control.ControlType = controlType;
1615
                                    if (control != null)
1616
                                    {
1617
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1618

    
1619
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1620

    
1621
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1622
                                        {
1623
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1624
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1625

    
1626
                                            Point tempPoint = control.EndPoint;
1627
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1628
                                            control.EndPoint = tempPoint;
1629
                                        }
1630
                                        else
1631
                                        {
1632
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1633
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1634
                                        }
1635

    
1636

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

    
1647
                            }
1648
                            break;
1649

    
1650
                        case ControlType.ChainLine:
1651
                            {
1652
                                var control = currentControl as PolygonControl;
1653

    
1654
                                if (control != null)
1655
                                {
1656
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1657
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1658
                                    control.SetPolyPath();
1659
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1660
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1661
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1662

    
1663
                                    //강인구 추가
1664
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1665
                                }
1666
                            }
1667
                            break;
1668

    
1669
                        case ControlType.ArcLine:
1670
                            {
1671
                                if (currentControl != null)
1672
                                {
1673
                                    var control = currentControl as ArcControl;
1674
                                    control.isTransOn = false;
1675
                                    control.ControlType = controlType;
1676

    
1677
                                    if (control != null)
1678
                                    {
1679
                                        if (move.mousemode == MouseMode.Drawing)
1680
                                        {
1681
                                            //move.control_Move(ControlList, false, moveX, moveY);
1682
                                        }
1683
                                        else
1684
                                        {
1685
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1686
                                            control.MidPoint = new Point(0, 0);
1687
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1688
                                        }
1689

    
1690

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

    
1702
                            }
1703
                            break;
1704

    
1705
                        case ControlType.ArcArrow:
1706
                            {
1707
                                if (currentControl != null)
1708
                                {
1709
                                    var control = currentControl as ArcControl;
1710
                                    control.isTransOn = true;
1711
                                    control.ControlType = controlType;
1712

    
1713
                                    if (control != null)
1714
                                    {
1715
                                        if (move.mousemode == MouseMode.Drawing)
1716
                                        {
1717
                                            //move.control_Move(ControlList, true, moveX, moveY);
1718
                                        }
1719
                                        else
1720
                                        {
1721
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1722
                                            control.MidPoint = new Point(0, 0);
1723
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1724
                                        }
1725

    
1726

    
1727
                                        control.PointSet = new List<Point>
1728
                                            {
1729
                                                control.StartPoint,
1730
                                                control.MidPoint,
1731
                                                control.EndPoint,
1732
                                            };
1733
                                    }
1734
                                    //강인구 추가
1735
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1736
                                }
1737

    
1738
                            }
1739
                            break;
1740

    
1741
                        case ControlType.ArrowMultiLine:
1742
                            {
1743
                                if (currentControl != null)
1744
                                {
1745
                                    var control = currentControl as ArrowControl_Multi;
1746

    
1747
                                    if (control != null)
1748
                                    {
1749
                                        if (control.MiddlePoint == new Point(0, 0))
1750
                                        {
1751
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1752
                                            {
1753
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1754
                                                Point tempPoint = control.EndPoint;
1755
                                                var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1756
                                                control.EndPoint = tempPoint;
1757
                                            }
1758
                                            else
1759
                                            {
1760
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1761
                                            }
1762

    
1763

    
1764
                                        }
1765
                                        else
1766
                                        {
1767
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1768
                                            {
1769
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1770
                                                Point tempPoint = control.EndPoint;
1771
                                                var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1772
                                                control.EndPoint = tempPoint;
1773
                                            }
1774
                                            else
1775
                                            {
1776
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1777
                                            }
1778

    
1779
                                        }
1780

    
1781
                                        control.PointSet = new List<Point>
1782
                                            {
1783
                                                control.StartPoint,
1784
                                                control.MiddlePoint,
1785
                                                control.EndPoint,
1786
                                            };
1787

    
1788
                                    }
1789
                                    //강인구 추가
1790
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1791
                                }
1792

    
1793
                            }
1794
                            break;
1795

    
1796
                        case ControlType.Circle:
1797
                            {
1798
                                var control = currentControl as CircleControl;
1799

    
1800
                                if (control != null)
1801
                                {
1802
                                    if (move.mousemode == MouseMode.Drawing)
1803
                                    {
1804
                                        //move.control_Move(ControlList, true, moveX, moveY);
1805
                                    }
1806
                                    else
1807
                                    {
1808
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1809
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1810
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1811
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1812

    
1813
                                        control.PointSet = new List<Point>
1814
                                        {
1815
                                            control.StartPoint,
1816
                                            control.LeftBottomPoint,
1817
                                            control.EndPoint,
1818
                                            control.TopRightPoint,
1819
                                        };
1820
                                    }
1821
                                    //강인구 추가
1822
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1823
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1824

    
1825
                                }
1826
                            }
1827
                            break;
1828

    
1829
                        case ControlType.PolygonCloud:
1830
                            {
1831
                                var control = currentControl as CloudControl;
1832

    
1833
                                if (control != null)
1834
                                {
1835
                                    control.isTransOn = true;
1836
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1837

    
1838
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1839

    
1840
                                    control.SetCloud();
1841
                                    //강인구 추가
1842
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1843
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1844
                                }
1845
                            }
1846
                            break;
1847

    
1848
                        case ControlType.Triangle:
1849
                            {
1850
                                var control = currentControl as TriControl;
1851

    
1852
                                if (control != null)
1853
                                {
1854
                                    if (move.mousemode == MouseMode.Drawing)
1855
                                    {
1856
                                        //move.control_Move(ControlList, true, moveX, moveY);
1857
                                    }
1858
                                    else
1859
                                    {
1860
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1861
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1862

    
1863
                                        control.PointSet = new List<Point>
1864
                                            {
1865
                                                control.StartPoint,
1866
                                                control.MidPoint,
1867
                                                control.EndPoint,
1868
                                            };
1869
                                    }
1870
                                    //강인구 추가
1871
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1872
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1873
                                }
1874
                            }
1875
                            break;
1876

    
1877
                        case ControlType.ImgControl:
1878
                            {
1879
                                var control = currentControl as ImgControl;
1880

    
1881
                                if (control != null)
1882
                                {
1883
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1884
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1885
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1886
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1887

    
1888
                                    control.PointSet = new List<Point>
1889
                                        {
1890
                                            control.StartPoint,
1891
                                            control.LeftBottomPoint,
1892
                                            control.EndPoint,
1893
                                            control.TopRightPoint,
1894
                                        };
1895
                                }
1896
                            }
1897
                            break;
1898

    
1899
                        case ControlType.Date:
1900
                            {
1901
                                var control = currentControl as DateControl;
1902

    
1903
                                if (control != null)
1904
                                {
1905
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1906
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1907
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1908
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1909
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1910

    
1911
                                    control.PointSet = new List<Point>
1912
                                        {
1913
                                            control.StartPoint,
1914
                                            control.LeftBottomPoint,
1915
                                            control.EndPoint,
1916
                                            control.TopRightPoint,
1917
                                        };
1918
                                }
1919
                            }
1920
                            break;
1921

    
1922
                        case ControlType.ArrowTextControl:
1923
                            {
1924
                                var control = currentControl as ArrowTextControl;
1925

    
1926
                                if (control != null)
1927
                                {
1928
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1929

    
1930
                                    control.PointSet = new List<Point>
1931
                                            {
1932
                                                control.StartPoint,
1933
                                                control.MidPoint,
1934
                                                control.EndPoint,
1935
                                            };
1936
                                }
1937

    
1938
                            }
1939
                            break;
1940

    
1941
                        case ControlType.ArrowTransTextControl:
1942
                            {
1943
                                var control = currentControl as ArrowTextControl;
1944

    
1945
                                if (control != null)
1946
                                {
1947
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1948
                                    control.isFixed = true;
1949

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

    
1960
                        case ControlType.ArrowTextBorderControl:
1961
                            {
1962
                                var control = currentControl as ArrowTextControl;
1963

    
1964
                                if (control != null)
1965
                                {
1966
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1967
                                    control.PointSet = new List<Point>
1968
                                            {
1969
                                                control.StartPoint,
1970
                                                control.MidPoint,
1971
                                                control.EndPoint,
1972
                                            };
1973
                                }
1974

    
1975
                            }
1976
                            break;
1977
                        case ControlType.ArrowTransTextBorderControl:
1978
                            {
1979
                                var control = currentControl as ArrowTextControl;
1980

    
1981
                                if (control != null)
1982
                                {
1983
                                    control.isFixed = true;
1984
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1985
                                    control.PointSet = new List<Point>
1986
                                            {
1987
                                                control.StartPoint,
1988
                                                control.MidPoint,
1989
                                                control.EndPoint,
1990
                                            };
1991
                                }
1992

    
1993
                            }
1994
                            break;
1995
                        case ControlType.ArrowTextCloudControl:
1996
                            {
1997
                                var control = currentControl as ArrowTextControl;
1998

    
1999
                                if (control != null)
2000
                                {
2001
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2002
                                    control.PointSet = new List<Point>
2003
                                            {
2004
                                                control.StartPoint,
2005
                                                control.MidPoint,
2006
                                                control.EndPoint,
2007
                                            };
2008
                                }
2009

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

    
2016
                                if (control != null)
2017
                                {
2018
                                    control.isFixed = true;
2019
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2020
                                    control.PointSet = new List<Point>
2021
                                            {
2022
                                                control.StartPoint,
2023
                                                control.MidPoint,
2024
                                                control.EndPoint,
2025
                                            };
2026
                                }
2027

    
2028
                            }
2029
                            break;
2030
                        case ControlType.PolygonControl:
2031
                            {
2032
                                var control = currentControl as PolygonControl;
2033

    
2034
                                if (control != null)
2035
                                {
2036
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2037
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2038
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2039
                                    control.SetPolyPath();
2040
                                    //강인구 추가
2041
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2042
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2043
                                }
2044
                            }
2045
                            break;
2046
                        //강인구 추가
2047
                        case ControlType.Sign:
2048
                            {
2049
                                var control = currentControl as SignControl;
2050

    
2051
                                if (control != null)
2052
                                {
2053
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2054
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2055
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2056
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2057

    
2058
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2059
                                    {
2060
                                        GetUserSign getUser = new GetUserSign();
2061
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2062
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2063
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2064
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2065
                                        stream.Position = 0;
2066
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2067
                                        BitmapImage returnImage = new BitmapImage();
2068
                                        returnImage.BeginInit();
2069
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2070
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2071
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2072
                                        returnImage.StreamSource = ms;
2073
                                        returnImage.EndInit();
2074
                                        stream.Close();
2075

    
2076
                                        control.SignImage = returnImage;
2077
                                    }
2078
                                    control.PointSet = new List<Point>
2079
                                        {
2080
                                            control.StartPoint,
2081
                                            control.LeftBottomPoint,
2082
                                            control.EndPoint,
2083
                                            control.TopRightPoint,
2084
                                        };
2085
                                }
2086
                            }
2087
                            break;
2088
                        //강인구 추가
2089
                        case ControlType.Symbol:
2090
                            {
2091
                                var control = currentControl as SymControl;
2092

    
2093
                                if (control != null)
2094
                                {
2095
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2096
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2097
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2098
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2099
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2100
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2101

    
2102
                                    if (control.StartPoint != control.EndPoint)
2103
                                    {
2104
                                        if (control.PathData == null)
2105
                                        {
2106
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2107
                                            {
2108
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2109
                                            }
2110
                                        }
2111
                                    }
2112

    
2113
                                    control.PointSet = new List<Point>
2114
                                        {
2115
                                            control.StartPoint,
2116
                                            control.LeftBottomPoint,
2117
                                            control.EndPoint,
2118
                                            control.TopRightPoint,
2119
                                        };
2120
                                }
2121
                            }
2122
                            break;
2123
                        case ControlType.Stamp:
2124
                            {
2125
                                var control = currentControl as SymControlN;
2126

    
2127
                                if (control != null)
2128
                                {
2129

    
2130
                                    if (control.StartPoint == control.EndPoint)
2131
                                    {
2132
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
2133

    
2134
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
2135
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2136

    
2137

    
2138
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2139

    
2140
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2141
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2142
                                        writer.Write(xamlData);
2143
                                        writer.Flush();
2144
                                        stream.Position = 0;
2145

    
2146
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2147
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2148
                                        UIElement ob = obj as UIElement;
2149

    
2150
                                        //control.ApplyTemplate();
2151

    
2152
                                        control.SetViewBox();
2153
                                        control.PathXathData = appovalData;
2154
                                        control.Base_ViewBox.Child = ob;
2155
                                    }
2156

    
2157
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2158
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2159
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2160
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2161
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2162

    
2163

    
2164
                                    control.PointSet = new List<Point>
2165
                                    {
2166
                                        control.StartPoint,
2167
                                        control.LeftBottomPoint,
2168
                                        control.EndPoint,
2169
                                        control.TopRightPoint,
2170
                                    };
2171
                                }
2172
                            }
2173
                            break;
2174
                        case ControlType.Mark:
2175
                            {
2176
                                var control = currentControl as RectangleControl;
2177

    
2178
                                if (control != null)
2179
                                {
2180
                                    if (move.mousemode == MouseMode.Drawing)
2181
                                    {
2182
                                        //move.control_Move(ControlList, true, moveX, moveY);
2183
                                    }
2184
                                    else
2185
                                    {
2186
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2187
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2188
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2189
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2190

    
2191

    
2192
                                        control.PointSet = new List<Point>
2193
                                    {
2194
                                        control.StartPoint,
2195
                                        control.LeftBottomPoint,
2196
                                        control.EndPoint,
2197
                                        control.TopRightPoint,
2198
                                    };
2199
                                    }
2200

    
2201
                                    //강인구 추가
2202
                                    control.Paint = PaintSet.Fill;
2203
                                }
2204
                            }
2205
                            break;
2206
                        case ControlType.PenControl:
2207
                            {
2208
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2209
                                //inkBoard.Strokes.Add(stroke);
2210
                            }
2211
                            break;
2212
                        default:
2213
                            break;
2214
                    }
2215
                }
2216
            }
2217
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture)
2218
            {
2219
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2220

    
2221
                if (isDraggingSelectionRect)
2222
                {
2223
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2224

    
2225
                    e.Handled = true;
2226
                }
2227
                else if (isLeftMouseButtonDownOnWindow)
2228
                {
2229
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2230
                    double dragDistance = Math.Abs(dragDelta.Length);
2231

    
2232
                    if (dragDistance > DragThreshold)
2233
                    {
2234
                        isDraggingSelectionRect = true;
2235

    
2236
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2237
                    }
2238

    
2239
                    e.Handled = true;
2240
                }
2241

    
2242

    
2243
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2244
                {
2245
                    //SelectionPath = new Path();
2246
                    //PathFigure pathFigure = new PathFigure();
2247
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2248
                    //SelectionPath.Opacity = 0.5;
2249
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2250
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2251
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2252
                }
2253
                else
2254
                {
2255
                    //List<Stroke> removingStroke = new List<Stroke>();
2256
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2257
                    //StrokeCollection stC = new StrokeCollection();
2258
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2259
                    //{
2260
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2261
                    //    p1.Intersect(p2);
2262
                    //    if (p1.IsEmpty)
2263
                    //    {
2264

    
2265

    
2266
                    //        p1 = SelectionPath.Data.Bounds;
2267
                    //        bool intersectCheck = false;
2268
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2269
                    //        {
2270
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2271
                    //            p1.Intersect(p3);
2272
                    //            if (!p1.IsEmpty)
2273
                    //            {
2274
                    //                intersectCheck = true;
2275
                    //            }
2276
                    //        }
2277
                    //        if (intersectCheck)
2278
                    //        {
2279
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2280
                    //        }
2281

    
2282
                    //    }
2283
                    //    else
2284
                    //    {
2285
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2286
                    //    }
2287
                    //}
2288

    
2289
                    e.Handled = true;
2290
                }
2291
            }
2292
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2293
            {
2294
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2295
                if (control != null)
2296
                {
2297
                    this.cursor = Cursors.Hand;
2298
                    SetCursor();
2299
                }
2300
                else
2301
                {
2302
                    this.cursor = Cursors.Arrow;
2303
                    SetCursor();
2304
                }
2305
            }
2306
            else
2307
            {
2308
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2309

    
2310
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2311
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2312

    
2313
                //if (hitList.Count > 0)
2314
                //{
2315

    
2316
                //}
2317

    
2318
                #region 조건 설정 : firstCondition
2319
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2320
                //pnts = generalTransform.Transform(pnts);
2321
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2322
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2323
                //                               this.DeepLayer._BaseLayer).ToObservable()
2324
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2325
                //                      select kkk).FirstOrDefault();
2326

    
2327
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2328
                //if (canvas !=null)
2329
                //{
2330
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2331
                //    {
2332
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2333
                //        if (uiElement!=null)
2334
                //        {
2335
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2336
                //        }
2337
                //    }
2338
                //}
2339

    
2340
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2341
                //hitResultsList.Clear();
2342

    
2343
                #endregion
2344
            }
2345
        }
2346

    
2347
        //private void Point_StateChanged(object sender, MyEventArgs e)
2348
        //{
2349
        //    //if (e.isMouseOver)
2350
        //    //{
2351
        //    //    this.cursor = Cursors.Hand;
2352
        //    //}
2353
        //    //else
2354
        //    //{
2355
        //    //    this.cursor = Cursors.Arrow;
2356
        //    //    (sender as CommentUserInfo).StateChanged -= Point_StateChanged;
2357
        //    //}
2358
        //}
2359
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2360

    
2361
        private EllipseGeometry hitArea = new EllipseGeometry();
2362

    
2363
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2364
        {
2365
            IsDrawing = false;
2366

    
2367
            if (mouseHandlingMode != MouseHandlingMode.None)
2368
            {
2369
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2370
                {
2371
                    this.cursor = Cursors.Arrow;
2372

    
2373
                    SetCursor();
2374

    
2375
                    switch (controlType)
2376
                    {
2377
                        case ControlType.None:
2378
                            break;
2379
                        case ControlType.Rectangle:
2380
                            {
2381

    
2382
                            }
2383
                            break;
2384
                        case ControlType.PenControl:
2385
                            {
2386

    
2387
                            }
2388
                            break;
2389
                        default:
2390
                            break;
2391
                    }
2392
                }
2393
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left)
2394
                {
2395
                    if (isLeftMouseButtonDownOnWindow)
2396
                    {
2397
                        bool wasDragSelectionApplied = false;
2398

    
2399
                        if (isDraggingSelectionRect)
2400
                        {
2401
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2402
                            {
2403
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2404
                                mouseHandlingMode = MouseHandlingMode.None;
2405
                                Set_Capture();
2406

    
2407
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2408
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2409
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2410
                            }
2411

    
2412
                            isDraggingSelectionRect = false;
2413
                            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2414
                            {
2415
                                ApplyDragSelectionRect();
2416
                            }
2417

    
2418
                            e.Handled = true;
2419
                            wasDragSelectionApplied = true;
2420
                        }
2421

    
2422
                        if (isLeftMouseButtonDownOnWindow)
2423
                        {
2424
                            isLeftMouseButtonDownOnWindow = false;
2425
                            this.ReleaseMouseCapture();
2426
                            e.Handled = true;
2427
                        }
2428

    
2429
                        if (!wasDragSelectionApplied)
2430
                        {
2431
                            init();
2432
                        }
2433
                    }
2434
                }
2435
                else if (mouseButtonDown == MouseButton.Right)
2436
                {
2437
                    this.cursor = Cursors.Arrow;
2438
                    SetCursor();
2439
                }
2440

    
2441
                zoomAndPanControl.ReleaseMouseCapture();
2442

    
2443

    
2444
                e.Handled = true;
2445
            }
2446
            else
2447
            {
2448
                this.cursor = Cursors.Arrow;
2449
                SetCursor();
2450
            }
2451
            mouseButtonDown = MouseButton.Left;
2452

    
2453
            //controlType = ControlType.SingleLine;
2454
        }
2455

    
2456
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2457
        {
2458
            mouseButtonDown = MouseButton.Left;
2459
            this.Cursor = Cursors.Arrow;
2460
        }
2461

    
2462
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2463
        {
2464

    
2465
        }
2466

    
2467
        private void ApplyDragSelectionRect()
2468
        {
2469
            multi_Undo_Data = new Multi_Undo_data();
2470

    
2471
            UndoData = new Undo_data()
2472
            {
2473
                IsUndo = false,
2474
                Event = Event_Type.Select,
2475
                EventTime = DateTime.Now,
2476
                Markup_List = new List<Multi_Undo_data>()
2477
            };
2478

    
2479
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2480

    
2481
            double x = Canvas.GetLeft(dragSelectionBorder);
2482
            double y = Canvas.GetTop(dragSelectionBorder);
2483
            double width = dragSelectionBorder.Width;
2484
            double height = dragSelectionBorder.Height;
2485
            Rect dragRect = new Rect(x, y, width, height);
2486
            Boolean Flag = false;
2487
            dragRect.Inflate(width / 10, height / 10);
2488
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2489
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2490

    
2491

    
2492

    
2493

    
2494
            //#region 잉크 불필요
2495

    
2496
            ////#region Ink Canvas Select
2497
            //List<Stroke> removingStroke = new List<Stroke>();
2498
            //StrokeCollection stC = new StrokeCollection();
2499

    
2500

    
2501
            //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2502
            //{
2503
            //    dragRect = new Rect(x, y, width, height);
2504
            //    dragRect.Inflate(width / 10, height / 10);
2505

    
2506
            //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2507
            //    dragRect.Intersect(p2);
2508
            //    if (dragRect.IsEmpty)
2509
            //    {
2510
            //        //dragRect = SelectionPath.Data.Bounds;
2511
            //        bool intersectCheck = false;
2512
            //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2513
            //        {
2514
            //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2515
            //            dragRect.Intersect(p3);
2516
            //            if (!dragRect.IsEmpty)
2517
            //            {
2518
            //                intersectCheck = true;
2519
            //            }
2520
            //        }
2521
            //        if (intersectCheck)
2522
            //        {
2523
            //            removingStroke.Add(inkBoard.Strokes[i]);
2524
            //        }
2525
            //    }
2526
            //    else
2527
            //    {
2528
            //        removingStroke.Add(inkBoard.Strokes[i]);
2529
            //    }
2530
            //}
2531

    
2532
            //InkToPath ip = new InkToPath();
2533
            //List<Point> inkPointSet = new List<Point>();
2534
            //PolygonControl pc = null;
2535
            ////InkControl pc = null;
2536
            ////pc = new InkControl()
2537
            //pc = new PolygonControl()
2538
            //{
2539
            //    //PointC = new List<StylusPointSet>(),
2540
            //    Angle = 0,
2541
            //    StartPoint = dragRect.TopLeft,
2542
            //    EndPoint = dragRect.BottomRight,
2543
            //    PointSet = new List<Point>(),
2544
            //    CommentID = Save.shortGuid(),
2545
            //    ControlType = ControlType.Ink,
2546
            //};
2547
            //foreach (var item in removingStroke)
2548
            //{
2549
            //    //pc.PointC.Add(new StylusPointSet() { pointSet = ip.StrokeGetPointsPlus(item) });
2550
            //    inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
2551
            //    inkBoard.Strokes.Remove(item);
2552
            //}
2553
            //if (inkPointSet.Count != 0)
2554
            //{
2555
            //    pc.StartPoint = inkPointSet[0];
2556
            //    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
2557
            //    pc.PointSet = inkPointSet;
2558
            //    pc.LineSize = 3;
2559
            //    //pc.StrokeColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("ff18b7fc"));
2560
            //    pc.StrokeColor = new SolidColorBrush(Colors.Red);
2561
            //    ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
2562
            //    pc.SetPolyPath();
2563

    
2564
            //    adornerSet.Add(pc);
2565
            //    ViewerDataModel.Instance.MarkupControls_USER.Remove(pc);
2566

    
2567
            //    //Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2568
            //    //SelectLayer.Children.Add(final);
2569
            //}
2570
            ////#endregion 
2571
            //#endregion
2572

    
2573

    
2574
            dragRect = new Rect(x, y, width, height);
2575
            dragRect.Inflate(width / 10, height / 10);
2576

    
2577
            foreach (var item in Items)
2578
            {
2579
                //switch ((item as IMarkupCommonData).ControlType)
2580
                //{
2581
                //case ControlType.Rectangle:
2582
                //    {
2583
                //var rectangleControl = (item as RectangleControl);
2584
                //Flag = move.control_Select(rectangleControl,  dragRect);
2585
                Flag = move.control_Select(item, dragRect);
2586

    
2587
                if (Flag)
2588
                {
2589
                    adornerSet.Add(item);
2590
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2591

    
2592
                    Control_Style(item);
2593
                    UndoData.Markup_List.Add(multi_Undo_Data);
2594
                    multi_Undo_Data = new Multi_Undo_data();
2595

    
2596
                    //SelectLayer.Children.Add(final);
2597
                }
2598
                //}
2599
                //break;
2600
                //}
2601
            }
2602
            if (adornerSet.Count > 0)
2603
            {
2604
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2605
                {
2606
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2607
                });
2608
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2609

    
2610
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2611
                SelectLayer.Children.Add(final);
2612
                //mouseHandlingMode = MouseHandlingMode.Adorner;
2613
            }
2614
        }
2615

    
2616
        private void InitDragSelectionRect(Point pt1, Point pt2)
2617
        {
2618
            //선택 중
2619
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2620
            {
2621
                dragSelectionBorder.Visibility = Visibility.Visible;
2622
            }
2623
            //캡쳐 중
2624
            else
2625
            {
2626
                dragCaptureBorder.Visibility = Visibility.Visible;
2627
            }
2628
            UpdateDragSelectionRect(pt1, pt2);
2629
        }
2630

    
2631
        /// <summary>
2632
        /// Update the position and size of the rectangle used for drag selection.
2633
        /// </summary>
2634
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2635
        {
2636
            double x, y, width, height;
2637

    
2638
            //
2639
            // Determine x,y,width and height of the rect inverting the points if necessary.
2640
            // 
2641

    
2642
            if (pt2.X < pt1.X)
2643
            {
2644
                x = pt2.X;
2645
                width = pt1.X - pt2.X;
2646
            }
2647
            else
2648
            {
2649
                x = pt1.X;
2650
                width = pt2.X - pt1.X;
2651
            }
2652

    
2653
            if (pt2.Y < pt1.Y)
2654
            {
2655
                y = pt2.Y;
2656
                height = pt1.Y - pt2.Y;
2657
            }
2658
            else
2659
            {
2660
                y = pt1.Y;
2661
                height = pt2.Y - pt1.Y;
2662
            }
2663

    
2664

    
2665
            //
2666
            // Update the coordinates of the rectangle used for drag selection.
2667
            //
2668
            //선택 중
2669
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2670
            {
2671
                Canvas.SetLeft(dragSelectionBorder, x);
2672
                Canvas.SetTop(dragSelectionBorder, y);
2673
                dragSelectionBorder.Width = width;
2674
                dragSelectionBorder.Height = height;
2675
            }
2676
            //캡쳐 중
2677
            else
2678
            {
2679
                Canvas.SetLeft(dragCaptureBorder, x);
2680
                Canvas.SetTop(dragCaptureBorder, y);
2681
                dragCaptureBorder.Width = width;
2682
                dragCaptureBorder.Height = height;
2683
            }
2684

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

    
2688
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2689
        {
2690
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2691

    
2692
            bool result = false;
2693
            if (dragRect.Contains(controlRect))
2694
            {
2695
                result = true;
2696
                //잡은 객체들을 담은 리스트
2697
                //selected_item.Add(OverViewPathData, type);
2698
                try
2699
                {
2700
                    //controlType = type;
2701
                    selected_item.Add(OverViewPathData, type.ToString());
2702
                }
2703
                catch (Exception)
2704
                {
2705

    
2706
                }
2707
                //listBox.Items.Add(OverViewPathData, commonData.ControlType.ToString());
2708
                //listBox.SelectedItems.Add(rectangleViewModel);
2709
            }
2710
            return result;
2711
        }
2712

    
2713
        private void drawingPannelRotate(double angle)
2714
        {
2715
            rotate.Angle = angle;
2716
            var rotationNum = Math.Abs((rotate.Angle / 90));
2717

    
2718
            if (angle == 90 || angle == 270)
2719
            {
2720
                double emptySize = zoomAndPanCanvas.Width;
2721
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2722
                zoomAndPanCanvas.Height = emptySize;
2723
            }
2724
            if (angle == 0)
2725
            {
2726
                translate.X = 0;
2727
                translate.Y = 0;
2728
            }
2729
            else if (angle == 90)
2730
            {
2731
                translate.X = zoomAndPanCanvas.Width;
2732
                translate.Y = 0;
2733
            }
2734
            else if (angle == 180)
2735
            {
2736
                translate.X = zoomAndPanCanvas.Width;
2737
                translate.Y = zoomAndPanCanvas.Height;
2738
            }
2739
            else
2740
            {
2741
                translate.X = 0;
2742
                translate.Y = zoomAndPanCanvas.Height;
2743
            }
2744

    
2745
            zoomAndPanControl.RotationAngle = rotate.Angle;
2746
            //회전 잠시 대기(강인구)
2747
            //_imageViewer.RotateAngle = rotate.Angle;
2748

    
2749
            //RotateTransform rotateTransform = new RotateTransform(rotate.Angle);
2750
            //_imageViewer1.RenderTransform = rotateTransform;
2751

    
2752
            if (!testPanel2.IsHidden)
2753
            {
2754
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2755
                //회전 잠시 대기(강인구)
2756
                //_imageViewer_Compare.RotateAngle = rotate.Angle;
2757

    
2758
                //_imageViewer_Compare.RenderTransform = rotateTransform;
2759

    
2760
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2761
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2762
            }
2763

    
2764
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2765
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2766
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2767
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2768
            ViewerDataModel.Instance.Angle = rotate.Angle;
2769

    
2770

    
2771
        }
2772

    
2773
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2774
        {
2775
            InkControl_Convert();
2776

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

    
2780
            if(text_item != null && (currentControl as ArrowTextControl) == null)
2781
            {
2782
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2783
            }
2784

    
2785
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2786
            {
2787
                if (arrow_text as ArrowTextControl != null)
2788
                {
2789
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2790
                    //(arrow_text as ArrowTextControl).Base_TextBox.Focusable = true;
2791
                }
2792
            }
2793

    
2794
            if(currentControl == null)
2795
            {
2796
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2797
                if (text_item_ != null)
2798
                {
2799
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2800
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2801
                    (text_item_ as TextControl).IsEditing = false;
2802
                    (text_item_ as TextControl).EnableEditing = false;
2803
                }
2804

    
2805
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2806
                if (Arrowtext_item_ != null)
2807
                {
2808
                    //(text_item_ as ArrowTextControl).Base_TextBlock.Visibility = Visibility.Visible;
2809
                    //(text_item_ as ArrowTextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2810
                    //(Arrowtext_item_ as ArrowTextControl).IsEditing = false;
2811
                    //(Arrowtext_item_ as ArrowTextControl).EnableEditing = false;
2812
                    //(Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2813

    
2814
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2815
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2816
                }
2817
            }
2818

    
2819

    
2820
            if (currentControl != null && currentControl.GetType().Name == "TextControl")
2821
            {
2822
                //(currentControl as TextControl).Base_TextBlock.Visibility = System.Windows.Visibility.Visible;
2823
                //(currentControl as TextControl).Base_TextBox.Visibility = System.Windows.Visibility.Collapsed;
2824
                //(currentControl as TextControl).IsEditing = false;
2825
                //(currentControl as TextControl).EnableEditing = false;
2826
                //currentControl = null;
2827
            }
2828

    
2829
            double Ang = 0;
2830
            if (rotate.Angle != 0)
2831
            {
2832
                Ang = 360 - rotate.Angle;
2833
            }
2834

    
2835
            move = new Move();
2836

    
2837
            //if (e.OriginalSource is Canvas)
2838
            //{
2839
            //    (e.OriginalSource as Canvas).Focus();
2840
            //}
2841

    
2842
            if (e.OriginalSource is System.Windows.Controls.Image)
2843
            {
2844
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2845
            }
2846

    
2847
            mouseButtonDown = e.ChangedButton;
2848
            if (mouseButtonDown == MouseButton.Left)
2849
            {
2850
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2851
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2852

    
2853
                this.cursor = Cursors.Arrow;
2854
                SetCursor();
2855

    
2856
                if (!ViewerDataModel.Instance.IsPressCtrl)
2857
                {
2858
                    ReleaseAdorner();
2859
                }
2860
            }
2861
            if (mouseButtonDown == MouseButton.Middle)
2862
            {
2863
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2864
                cursor = Cursors.SizeAll;
2865
                SetCursor();
2866
            }
2867
            if (mouseButtonDown == MouseButton.Right)
2868
            {
2869
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2870
                cursor = Cursors.SizeAll;
2871
                SetCursor();
2872
            }
2873
            else if (mouseButtonDown == MouseButton.XButton1)
2874
            {
2875
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2876
                {
2877
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2878
                }
2879

    
2880
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2881

    
2882
            }
2883
            else if (mouseButtonDown == MouseButton.XButton2)
2884
            {
2885
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2886
                {
2887
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2888
                }
2889
            }
2890

    
2891
            //캡쳐 모드 설정
2892
            if (mouseHandlingMode == MouseHandlingMode.Capture && mouseButtonDown == MouseButton.Left)
2893
            {
2894
                dragCaptureBorder.Visibility = Visibility.Visible;
2895
                isLeftMouseButtonDownOnWindow = true;
2896
            }
2897

    
2898
            if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2899
            {
2900

    
2901
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2902
                {
2903
                    if (SelectLayer.Children.Count == 0)
2904
                    {
2905
                        isLeftMouseButtonDownOnWindow = true;
2906
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2907
                    }
2908

    
2909
                    if (controlType == ControlType.None)
2910
                    {
2911
                        isLeftMouseButtonDownOnWindow = true;
2912
                    }
2913
                }
2914

    
2915

    
2916
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2917
                if (control != null)
2918
                {
2919
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2920
                    AdornerFinal final;
2921
                    List<Point> p_set = new List<Point>();
2922
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2923
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2924
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2925
                    multi_Undo_Data = new Multi_Undo_data();
2926

    
2927
                    //강인구 Undo/Redo 보류
2928
                    UndoData = new Undo_data()
2929
                    {
2930
                        IsUndo = false,
2931
                        Event = Event_Type.Select,
2932
                        EventTime = DateTime.Now,
2933
                        Markup_List = new List<Multi_Undo_data>()
2934
                    };
2935

    
2936
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2937
                    {
2938
                        ReleaseAdorner();
2939
                        final = new AdornerFinal(control);
2940
                        //단일 컨트롤 언두 저장
2941

    
2942
                        Control_Style(control);
2943
                        UndoData.Markup_List.Add(multi_Undo_Data);
2944

    
2945
                        if ((control as IPath) != null)
2946
                        {
2947
                            if ((control as IPath).LineSize != 0)
2948
                            {
2949
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2950
                            }
2951
                        }
2952
                        if ((control as IShapeControl) != null)
2953
                        {
2954
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2955
                            {
2956
                                ViewerDataModel.Instance.checkHatchShape = true;
2957
                            }
2958
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2959
                            {
2960
                                ViewerDataModel.Instance.checkFillShape = true;
2961
                            }
2962
                            else
2963
                            {
2964
                                ViewerDataModel.Instance.checkHatchShape = false;
2965
                                ViewerDataModel.Instance.checkFillShape = false;
2966
                            }
2967
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2968
                        }
2969
                        //SelectLayer.Children.Add(final);
2970
                        if ((control as IPath) != null)
2971
                        {
2972
                            if ((control as IPath).LineSize != 0)
2973
                            {
2974
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2975
                            }
2976
                        }
2977
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2978
                    }
2979
                    else
2980
                    {
2981
                        comment = AddAdorner();
2982
                        comment.Add(control);
2983

    
2984
                        Control_Style(control);
2985
                        UndoData.Markup_List.Add(multi_Undo_Data);
2986

    
2987
                        final = new AdornerFinal(comment);
2988
                        //다중 컨트롤 언두 저장
2989
                    }
2990

    
2991
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2992
                    {
2993
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2994
                    });
2995

    
2996
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2997

    
2998
                    SelectLayer.Children.Add(final);
2999

    
3000
                    //Control_Init(control);
3001

    
3002

    
3003

    
3004
                    //강인구 폰트 변경 보류
3005

    
3006
                    //if ((currentControl as TextControl) != null)
3007
                    //{
3008
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
3009
                    //    {
3010
                    //        ViewerDataModel.Instance.checkTextStyle = true;
3011
                    //    }
3012
                    //    else
3013
                    //    {
3014
                    //        ViewerDataModel.Instance.checkTextStyle = false;
3015
                    //    }
3016

    
3017
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
3018
                    //    {
3019

    
3020
                    //    }
3021
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Heavy)
3022
                    //    {
3023

    
3024
                    //    }
3025
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
3026
                    //    {
3027

    
3028
                    //    }
3029
                    //}
3030
                    //else if ((currentControl as ArrowTextControl) != null)
3031
                    //{
3032
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
3033
                    //    {
3034
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
3035
                    //    }
3036
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
3037
                    //    {
3038
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Heavy;
3039
                    //    }
3040
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
3041
                    //    {
3042
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
3043
                    //    }
3044
                    //}
3045

    
3046
                    mouseHandlingMode = MouseHandlingMode.Adorner;
3047
                }
3048
            }
3049

    
3050
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3051
            {
3052
                init();
3053
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3054
                if (cursor != Cursors.SizeAll)
3055
                {
3056
                    cursor = Cursors.Cross;
3057
                    SetCursor();
3058
                }
3059
                //currentControl.IsNew = true;
3060
                bool init_user = false;
3061
                foreach (var user in gridViewMarkup.Items)
3062
                {
3063
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3064
                    {
3065
                        init_user = true;
3066
                    }
3067
                }
3068
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3069
                //if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3070
                //if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
3071
                {
3072
                    RadWindow.Alert(new DialogParameters
3073
                    {
3074
                        Theme = new VisualStudio2013Theme(),
3075
                        Header = "안내",
3076
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3077
                    });
3078
                    return;
3079
                }
3080
                else
3081
                {
3082
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3083
                    if (item != null)
3084
                    {
3085
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3086
                    }
3087
                }
3088

    
3089
                multi_Undo_Data = new Multi_Undo_data();
3090
                //강인구 Undo/Redo 보류
3091
                UndoData = new Undo_data()
3092
                {
3093
                    IsUndo = false,
3094
                    Event = Event_Type.Create,
3095
                    EventTime = DateTime.Now,
3096
                    Markup_List = new List<Multi_Undo_data>()
3097
                };
3098

    
3099
                switch (controlType)
3100
                {
3101
                    case ControlType.Rectangle:
3102
                        {
3103
                            if (mouseButtonDown == MouseButton.Left)
3104
                            {
3105
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3106
                                {
3107
                                    if (currentControl is RectangleControl)
3108
                                    {
3109
                                        CreateControl();
3110

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

    
3123
                                        currentControl.CommentID = Save.shortGuid();
3124
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3125
                                        currentControl.IsNew = true;
3126
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3127

    
3128
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3129
                                    }
3130
                                }
3131
                            }
3132
                        }
3133
                        break;
3134
                    case ControlType.RectCloud:
3135
                        {
3136
                            if (mouseButtonDown == MouseButton.Left)
3137
                            {
3138
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3139
                                {
3140
                                    if (currentControl is RectCloudControl)
3141
                                    {
3142
                                        CreateControl();
3143

    
3144
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3145
                                        //controlType = ControlType.None;
3146
                                        currentControl = null;
3147
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
3148
                                        this.cursor = Cursors.Arrow;
3149
                                    }
3150
                                    else
3151
                                    {
3152
                                        currentControl = new RectCloudControl
3153
                                        {
3154
                                            Background = new SolidColorBrush(Colors.Black)
3155
                                        };
3156

    
3157
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3158
                                        currentControl.CommentID = Save.shortGuid();
3159
                                        currentControl.IsNew = true;
3160
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3161
                                    }
3162
                                }
3163
                            }
3164
                        }
3165
                        break;
3166
                    case ControlType.Circle:
3167
                        {
3168
                            if (mouseButtonDown == MouseButton.Left)
3169
                            {
3170
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3171
                                {
3172
                                    if (currentControl is CircleControl)
3173
                                    {
3174
                                        CreateControl();
3175

    
3176
                                        (currentControl as CircleControl).ApplyOverViewData();
3177
                                        //controlType = ControlType.None;
3178
                                        currentControl = null;
3179
                                    }
3180
                                    else
3181
                                    {
3182
                                        currentControl = new CircleControl
3183
                                        {
3184
                                            Background = new SolidColorBrush(Colors.Black)
3185
                                        };
3186

    
3187
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3188
                                        currentControl.CommentID = Save.shortGuid();
3189
                                        currentControl.IsNew = true;
3190
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3191
                                    }
3192
                                }
3193
                            }
3194
                        }
3195
                        break;
3196
                    case ControlType.Triangle:
3197
                        {
3198
                            if (mouseButtonDown == MouseButton.Left)
3199
                            {
3200
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3201
                                {
3202
                                    if (currentControl is TriControl)
3203
                                    {
3204
                                        var content = currentControl as TriControl;
3205
                                        if (content.MidPoint == new Point(0, 0))
3206
                                        {
3207
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3208
                                        }
3209
                                        else
3210
                                        {
3211
                                            CreateControl();
3212

    
3213
                                            (currentControl as TriControl).ApplyOverViewData();
3214
                                            //controlType = ControlType.None;
3215
                                            currentControl = null;
3216
                                        }
3217
                                    }
3218
                                    else
3219
                                    {
3220
                                        currentControl = new TriControl
3221
                                        {
3222
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3223
                                            Background = new SolidColorBrush(Colors.Black),
3224
                                        };
3225

    
3226
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3227
                                        currentControl.CommentID = Save.shortGuid();
3228
                                        currentControl.IsNew = true;
3229
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3230
                                    }
3231
                                }
3232
                            }
3233
                        }
3234
                        break;
3235
                    case ControlType.SingleLine:
3236
                        {
3237
                            if (mouseButtonDown == MouseButton.Left)
3238
                            {
3239
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3240
                                {
3241
                                    if (currentControl is LineControl)
3242
                                    {
3243
                                        CreateControl();
3244

    
3245
                                        (currentControl as LineControl).ApplyOverViewData();
3246
                                        //controlType = ControlType.None;
3247
                                        currentControl = null;
3248
                                    }
3249
                                    else
3250
                                    {
3251
                                        currentControl = new LineControl
3252
                                        {
3253
                                            Background = new SolidColorBrush(Colors.Black)
3254
                                        };
3255

    
3256
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3257
                                        currentControl.CommentID = Save.shortGuid();
3258
                                        currentControl.IsNew = true;
3259
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3260
                                    }
3261
                                }
3262
                            }
3263
                        }
3264
                        break;
3265
                    case ControlType.CancelLine:
3266
                        {
3267
                            if (mouseButtonDown == MouseButton.Left)
3268
                            {
3269
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3270
                                {
3271
                                    if (currentControl is LineControl)
3272
                                    {
3273
                                        CreateControl();
3274

    
3275
                                        (currentControl as LineControl).ApplyOverViewData();
3276
                                        //controlType = ControlType.None;
3277
                                        currentControl = null;
3278
                                    }
3279
                                    else
3280
                                    {
3281
                                        currentControl = new LineControl
3282
                                        {
3283
                                            Background = new SolidColorBrush(Colors.Black)
3284
                                        };
3285

    
3286
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3287
                                        currentControl.CommentID = Save.shortGuid();
3288
                                        currentControl.IsNew = true;
3289
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3290
                                    }
3291
                                }
3292
                            }
3293
                        }
3294
                        break;
3295
                    case ControlType.ArrowLine:
3296
                        {
3297
                            if (mouseButtonDown == MouseButton.Left)
3298
                            {
3299
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3300
                                {
3301
                                    if (currentControl is LineControl)
3302
                                    {
3303
                                        CreateControl();
3304

    
3305
                                        (currentControl as LineControl).ApplyOverViewData();
3306
                                        //controlType = ControlType.None;
3307
                                        currentControl = null;
3308
                                    }
3309
                                    else
3310
                                    {
3311
                                        currentControl = new LineControl
3312
                                        {
3313
                                            Background = new SolidColorBrush(Colors.Black)
3314
                                        };
3315

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

    
3335
                                        (currentControl as LineControl).ApplyOverViewData();
3336
                                        //controlType = ControlType.None;
3337
                                        currentControl = null;
3338
                                    }
3339
                                    else
3340
                                    {
3341
                                        currentControl = new LineControl
3342
                                        {
3343
                                            Background = new SolidColorBrush(Colors.Black)
3344
                                        };
3345
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3346
                                        currentControl.CommentID = Save.shortGuid();
3347
                                        currentControl.IsNew = true;
3348
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3349
                                    }
3350
                                }
3351
                            }
3352
                        }
3353
                        break;
3354
                    case ControlType.DimLine:
3355
                        {
3356
                            if (mouseButtonDown == MouseButton.Left)
3357
                            {
3358
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3359
                                {
3360
                                    if (currentControl is LineControl)
3361
                                    {
3362
                                        CreateControl();
3363

    
3364
                                        (currentControl as LineControl).ApplyOverViewData();
3365
                                        //controlType = ControlType.None;
3366
                                        currentControl = null;
3367
                                    }
3368
                                    else
3369
                                    {
3370
                                        currentControl = new LineControl
3371
                                        {
3372
                                            Background = new SolidColorBrush(Colors.Black)
3373
                                        };
3374
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3375
                                        currentControl.CommentID = Save.shortGuid();
3376
                                        currentControl.IsNew = true;
3377
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3378
                                    }
3379
                                }
3380
                            }
3381
                        }
3382
                        break;
3383
                    case ControlType.ChainLine:
3384
                        {
3385
                            if (currentControl is PolygonControl)
3386
                            {
3387
                                var control = currentControl as PolygonControl;
3388

    
3389
                                if (mouseButtonDown == MouseButton.Right)
3390
                                {
3391
                                    CreateControl();
3392

    
3393
                                    (currentControl as PolygonControl).ApplyOverViewData();
3394
                                    //controlType = ControlType.None;
3395
                                    currentControl = null;
3396
                                    return;
3397
                                }
3398

    
3399
                                if (!control.IsCompleted)
3400
                                {
3401
                                    //control.PointC.pointSet.Add(control.EndPoint);
3402
                                    control.PointSet.Add(control.EndPoint);
3403
                                }
3404
                                //else
3405
                                //{
3406
                                //    var firstPoint = control.PointC.pointSet.First();
3407

    
3408
                                //    //control.PointC.pointSet.Add(new Point(firstPoint.X, firstPoint.Y));
3409
                                //    control.PointC.pointSet.Add(firstPoint);
3410

    
3411
                                //    control.SetPolyPath();
3412

    
3413
                                //    controlType = ControlType.None;
3414

    
3415
                                //    currentControl = null;
3416
                                //}
3417
                            }
3418
                            else
3419
                            {
3420
                                if (mouseButtonDown == MouseButton.Left)
3421
                                {
3422
                                    currentControl = new PolygonControl
3423
                                    {
3424
                                        PointSet = new List<Point>(),
3425
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3426
                                        ControlType = ControlType.ChainLine,
3427
                                        DashSize = ViewerDataModel.Instance.DashSize,
3428
                                        LineSize = ViewerDataModel.Instance.LineSize,
3429
                                        //PointC = new StylusPointSet()
3430
                                    };
3431

    
3432
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3433
                                    {
3434
                                        var polygonControl = (currentControl as PolygonControl);
3435
                                        currentControl.CommentID = Save.shortGuid();
3436
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3437
                                        currentControl.IsNew = true;
3438
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3439
                                        //currentControl.OnApplyTemplate();
3440
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3441
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3442
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3443
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3444
                                    }
3445
                                }
3446
                            }
3447
                        }
3448
                        break;
3449
                    case ControlType.ArcLine:
3450
                        {
3451
                            if (mouseButtonDown == MouseButton.Left)
3452
                            {
3453
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3454
                                {
3455
                                    if (currentControl is ArcControl)
3456
                                    {
3457
                                        CreateControl();
3458

    
3459
                                        (currentControl as ArcControl).ApplyOverViewData();
3460
                                        //controlType = ControlType.None;
3461
                                        currentControl = null;
3462
                                    }
3463
                                    else
3464
                                    {
3465
                                        currentControl = new ArcControl
3466
                                        {
3467
                                            Background = new SolidColorBrush(Colors.Black)
3468
                                        };
3469
                                        currentControl.CommentID = Save.shortGuid();
3470
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3471
                                        currentControl.IsNew = true;
3472
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3473
                                    }
3474
                                }
3475
                            }
3476
                            else if (mouseButtonDown == MouseButton.Right)
3477
                            {
3478
                                if (currentControl != null)
3479
                                {
3480
                                    (currentControl as ArcControl).setClock();
3481
                                }
3482

    
3483
                            }
3484

    
3485
                        }
3486
                        break;
3487
                    case ControlType.ArcArrow:
3488
                        {
3489
                            if (mouseButtonDown == MouseButton.Left)
3490
                            {
3491
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3492
                                {
3493
                                    if (currentControl is ArcControl)
3494
                                    {
3495
                                        CreateControl();
3496

    
3497
                                        (currentControl as ArcControl).ApplyOverViewData();
3498
                                        //controlType = ControlType.None;
3499
                                        currentControl = null;
3500
                                    }
3501
                                    else
3502
                                    {
3503
                                        currentControl = new ArcControl
3504
                                        {
3505
                                            Background = new SolidColorBrush(Colors.Red),
3506
                                        };
3507
                                        currentControl.CommentID = Save.shortGuid();
3508
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3509
                                        currentControl.IsNew = true;
3510
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3511
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3512
                                    }
3513
                                }
3514
                            }
3515
                            else if (mouseButtonDown == MouseButton.Right)
3516
                            {
3517
                                (currentControl as ArcControl).setClock();
3518
                            }
3519
                        }
3520
                        break;
3521
                    case ControlType.ArrowMultiLine:
3522
                        {
3523
                            if (mouseButtonDown == MouseButton.Left)
3524
                            {
3525
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3526
                                {
3527

    
3528
                                    if (currentControl is ArrowControl_Multi)
3529
                                    {
3530
                                        var content = currentControl as ArrowControl_Multi;
3531
                                        if (content.MiddlePoint == new Point(0, 0))
3532
                                        {
3533
                                            content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3534
                                        }
3535
                                        else
3536
                                        {
3537
                                            CreateControl();
3538

    
3539
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3540
                                            //controlType = ControlType.None;
3541
                                            currentControl = null;
3542
                                        }
3543
                                    }
3544
                                    else
3545
                                    {
3546
                                        currentControl = new ArrowControl_Multi
3547
                                        {
3548
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3549
                                            Background = new SolidColorBrush(Colors.Black)
3550
                                        };
3551
                                        currentControl.CommentID = Save.shortGuid();
3552
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3553
                                        currentControl.IsNew = true;
3554
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3555
                                    }
3556

    
3557
                                    //if (currentControl is ArrowControl_Multi)
3558
                                    //{
3559
                                    //    (currentControl as ArrowControl_Multi).ApplyOverViewData();
3560
                                    //    controlType = ControlType.None;
3561
                                    //    currentControl = null;
3562
                                    //}
3563
                                    //else
3564
                                    //{
3565
                                    //    currentControl = new ArrowControl_Multi
3566
                                    //    {
3567
                                    //        Background = new SolidColorBrush(Colors.Black)
3568
                                    //    };
3569

    
3570
                                    //    DataModel.Instance.MarkupControls.Add(currentControl);
3571
                                    //}
3572

    
3573

    
3574

    
3575
                                }
3576
                            }
3577
                        }
3578
                        break;
3579
                    case ControlType.PolygonCloud:
3580
                        {
3581
                            if (currentControl is CloudControl)
3582
                            {
3583
                                var control = currentControl as CloudControl;
3584
                                //control.Paint = PaintSet.Cloud;
3585
                                if (mouseButtonDown == MouseButton.Right)
3586
                                {
3587
                                    control.IsCompleted = true;
3588
                                }
3589

    
3590
                                if (!control.IsCompleted)
3591
                                {
3592
                                    //control.PointC.pointSet.Add(control.EndPoint);
3593
                                    control.PointSet.Add(control.EndPoint);
3594
                                }
3595
                                else
3596
                                {
3597
                                    CreateControl();
3598

    
3599
                                    control.isTransOn = true;
3600
                                    //var firstPoint = control.PointC.pointSet.First();
3601
                                    var firstPoint = control.PointSet.First();
3602

    
3603
                                    //control.PointC.pointSet.Add(firstPoint);
3604
                                    control.PointSet.Add(firstPoint);
3605
                                    control.DrawingCloud();
3606
                                    control.ApplyOverViewData();
3607

    
3608
                                    //controlType = ControlType.None;
3609

    
3610
                                    currentControl = null;
3611
                                }
3612
                            }
3613
                            else
3614
                            {
3615
                                if (mouseButtonDown == MouseButton.Left)
3616
                                {
3617
                                    currentControl = new CloudControl
3618
                                    {
3619
                                        PointSet = new List<Point>(),
3620
                                        PointC = new StylusPointSet()
3621
                                    };
3622

    
3623
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3624
                                    {
3625
                                        var polygonControl = (currentControl as CloudControl);
3626
                                        currentControl.CommentID = Save.shortGuid();
3627
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3628
                                        currentControl.IsNew = true;
3629
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3630
                                        //currentControl.OnApplyTemplate();
3631

    
3632
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3633
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3634
                                        //polygonControl.PointC.pointSet.Add(canvasZoomPanningMouseDownPoint);
3635
                                        //polygonControl.PointC.pointSet.Add(canvasZoomPanningMouseDownPoint);
3636

    
3637
                                    }
3638
                                }
3639
                            }
3640
                        }
3641
                        break;
3642
                    case ControlType.ImgControl:
3643
                        {
3644
                            if (mouseButtonDown == MouseButton.Left)
3645
                            {
3646
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3647
                                {
3648
                                    if (currentControl is ImgControl)
3649
                                    {
3650
                                        CreateControl();
3651
                                        (currentControl as ImgControl).ApplyOverViewData();
3652

    
3653
                                        //controlType = ControlType.None;
3654
                                        currentControl = null;
3655
                                    }
3656
                                    else
3657
                                    {
3658
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3659
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3660
                                        {
3661
                                            Image img = new Image();
3662
                                            img.Source = new BitmapImage(new Uri(filename));
3663

    
3664
                                            currentControl = new ImgControl
3665
                                            {
3666
                                                Background = new SolidColorBrush(Colors.Black),
3667
                                                PointSet = new List<Point>(),
3668
                                                FilePath = filename,
3669
                                                ImageData = img.Source,
3670
                                                StartPoint = canvasDrawingMouseDownPoint,
3671
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3672
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3673
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3674
                                            };
3675

    
3676
                                            currentControl.CommentID = Save.shortGuid();
3677
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3678
                                            currentControl.IsNew = true;
3679
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3680
                                        }
3681
                                    }
3682
                                }
3683
                            }
3684
                        }
3685
                        break;
3686
                    case ControlType.Date:
3687
                        {
3688
                            if (mouseButtonDown == MouseButton.Left)
3689
                            {
3690
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3691
                                {
3692
                                    if (currentControl is DateControl)
3693
                                    {
3694
                                        CreateControl();
3695
                                        (currentControl as DateControl).ApplyOverViewData();
3696
                                        //controlType = ControlType.None;
3697
                                        currentControl = null;
3698

    
3699
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3700
                                        {
3701
                                            controlType = ControlType.None;
3702
                                            IsSwingMode = false;
3703
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3704
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3705
                                            mouseHandlingMode = MouseHandlingMode.None;
3706
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3707
                                            txtBatch.Visibility = Visibility.Collapsed;
3708

    
3709
                                        }
3710
                                    }
3711
                                    else
3712
                                    {
3713
                                        currentControl = new DateControl
3714
                                        {
3715
                                            Background = new SolidColorBrush(Colors.Black)
3716
                                        };
3717
                                        //inkDrawingCanvas.Children.Add(currentControl);
3718
                                        //InkCanvas.SetLeft(currentControl, canvasDrawingMouseDownPoint.X);
3719
                                        //InkCanvas.SetTop(currentControl, canvasDrawingMouseDownPoint.Y);
3720
                                        currentControl.CommentID = Save.shortGuid();
3721
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3722
                                        currentControl.IsNew = true;
3723
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3724
                                        //DataModel.Instance.MarkupControls.Add(currentControl);
3725
                                    }
3726
                                }
3727
                            }
3728
                        }
3729
                        break;
3730
                    case ControlType.TextControl:
3731
                        {
3732
                            if (mouseButtonDown == MouseButton.Left)
3733
                            {
3734
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3735
                                {
3736

    
3737
                                    currentControl = new TextControl
3738
                                    {
3739
                                        //ControlType = PaintSet.Rect
3740
                                        ControlType = controlType
3741
                                    };
3742

    
3743
                                    //if (currentControl is TextControl)
3744
                                    //{
3745
                                    //    //currentControl.SetValue(Canvas.ZIndexProperty, 2);
3746
                                    //    //(currentControl as TextControl).Base_TextBox.Text = (currentControl as TextControl).Text;
3747
                                    //    //(currentControl as TextControl).Base_TextBox.Visibility = System.Windows.Visibility.Visible;
3748
                                    //    //(currentControl as TextControl).Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed;
3749
                                    //    //(currentControl as TextControl).Angle = Ang;
3750
                                    //    //currentControl.Focus();
3751
                                    //}
3752
                                    //else
3753
                                    //{
3754
                                    //currentControl = new TextControl();
3755
                                        currentControl.CommentID = Save.shortGuid();
3756
                                        currentControl.IsNew = true;
3757
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3758
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3759
                                        currentControl.SetValue(Canvas.ZIndexProperty, 2);
3760
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3761
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3762
                                        currentControl.Focus();
3763
                                        (currentControl as TextControl).ApplyOverViewData();
3764
                                        (currentControl as TextControl).ControlType_No = 0;
3765
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3766
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3767

    
3768
                                        CreateControl();
3769

    
3770
                                        currentControl = null;
3771
                                    //}
3772

    
3773
                                    //controlType = ControlType.None;
3774
                                    //currentControl = null;
3775

    
3776
                                }
3777
                            }
3778
                        }
3779
                        break;
3780
                    case ControlType.TextBorder:
3781
                        {
3782
                            if (mouseButtonDown == MouseButton.Left)
3783
                            {
3784
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3785
                                {
3786
                                    currentControl = new TextControl
3787
                                    {
3788
                                        //ControlType = PaintSet.Rect
3789
                                        ControlType = controlType
3790
                                    };
3791

    
3792

    
3793
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3794
                                    currentControl.CommentID = Save.shortGuid();
3795
                                    currentControl.IsNew = true;
3796
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3797
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3798
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3799
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3800
                                    currentControl.Focus();
3801
                                    (currentControl as TextControl).ControlType_No = 1;
3802
                                    (currentControl as TextControl).Angle = Ang;
3803
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3804
                                    //controlType = ControlType.None;
3805
                                    CreateControl();
3806

    
3807
                                    currentControl = null;
3808
                                }
3809
                            }
3810
                        }
3811
                        break;
3812
                    case ControlType.TextCloud:
3813
                        {
3814
                            if (mouseButtonDown == MouseButton.Left)
3815
                            {
3816
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3817
                                {
3818
                                    currentControl = new TextControl
3819
                                    {
3820
                                        //Paint = PaintSet.Cloud
3821
                                        ControlType = controlType
3822
                                    };
3823
                                    currentControl.CommentID = Save.shortGuid();
3824
                                    currentControl.IsNew = true;
3825
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3826
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3827

    
3828
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3829
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3830
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3831
                                    currentControl.Focus();
3832

    
3833
                                    (currentControl as TextControl).Angle = Ang;
3834
                                    (currentControl as TextControl).ControlType_No = 2;
3835
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3836

    
3837
                                    CreateControl();
3838
                                    //controlType = ControlType.None;
3839
                                    currentControl = null;
3840
                                }
3841
                            }
3842
                        }
3843
                        break;
3844
                    case ControlType.ArrowTextControl:
3845
                        {
3846
                            if (mouseButtonDown == MouseButton.Left)
3847
                            {
3848
                                if (currentControl is ArrowTextControl)
3849
                                {
3850
                                    CreateControl();
3851
                                    //controlType = ControlType.None;
3852

    
3853
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3854
                                    (currentControl as ArrowTextControl).IsEditing = false;
3855
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3856
                                    currentControl = null;
3857

    
3858
                                }
3859
                                else
3860
                                {
3861
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3862
                                    {
3863
                                        currentControl = new ArrowTextControl();
3864
                                        currentControl.CommentID = Save.shortGuid();
3865
                                        currentControl.IsNew = true;
3866
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3867
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3868

    
3869
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3870

    
3871
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3872

    
3873
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3874

    
3875
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3876

    
3877
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3878

    
3879
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3880
                                        //currentControl.Focus();
3881
                                    }
3882
                                }
3883
                            }
3884
                        }
3885
                        break;
3886
                    case ControlType.ArrowTransTextControl:
3887
                        {
3888
                            if (mouseButtonDown == MouseButton.Left)
3889
                            {
3890
                                if (currentControl is ArrowTextControl)
3891
                                {
3892
                                    CreateControl();
3893
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3894
                                    //controlType = ControlType.None;
3895
                                    currentControl = null;
3896
                                }
3897
                                else
3898
                                {
3899
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3900
                                    {
3901
                                        currentControl = new ArrowTextControl();
3902
                                        currentControl.CommentID = Save.shortGuid();
3903
                                        currentControl.IsNew = true;
3904
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3905
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3906

    
3907
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3908

    
3909
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3910

    
3911
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3912

    
3913
                                        (currentControl as ArrowTextControl).isFixed = true;
3914
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3915

    
3916
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3917

    
3918
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3919
                                        //currentControl.Focus();
3920
                                    }
3921
                                }
3922
                            }
3923
                        }
3924
                        break;
3925
                    case ControlType.ArrowTextBorderControl:
3926
                        {
3927
                            if (mouseButtonDown == MouseButton.Left)
3928
                            {
3929
                                if (currentControl is ArrowTextControl)
3930
                                {
3931
                                    CreateControl();
3932
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3933
                                    //controlType = ControlType.None;
3934
                                    currentControl = null;
3935
                                }
3936
                                else
3937
                                {
3938
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3939
                                    {
3940
                                        currentControl = new ArrowTextControl()
3941
                                        {
3942
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3943
                                        };
3944
                                        currentControl.CommentID = Save.shortGuid();
3945
                                        currentControl.IsNew = true;
3946
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3947
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3948

    
3949
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3950

    
3951
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3952

    
3953
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3954
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3955

    
3956
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3957

    
3958
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3959

    
3960
                                        //currentControl.Focus();
3961
                                    }
3962
                                }
3963
                            }
3964
                        }
3965
                        break;
3966
                    case ControlType.ArrowTransTextBorderControl:
3967
                        {
3968
                            if (mouseButtonDown == MouseButton.Left)
3969
                            {
3970
                                if (currentControl is ArrowTextControl)
3971
                                {
3972
                                    CreateControl();
3973
                                    //controlType = ControlType.None;
3974
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3975
                                    currentControl = null;
3976
                                }
3977
                                else
3978
                                {
3979
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3980
                                    {
3981
                                        currentControl = new ArrowTextControl()
3982
                                        {
3983
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3984
                                        };
3985
                                        currentControl.CommentID = Save.shortGuid();
3986
                                        currentControl.IsNew = true;
3987
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3988
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3989

    
3990
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3991

    
3992
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3993

    
3994
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3995

    
3996
                                        (currentControl as ArrowTextControl).isFixed = true;
3997
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3998

    
3999
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4000

    
4001
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4002
                                        //currentControl.Focus();
4003
                                    }
4004
                                }
4005
                            }
4006
                        }
4007
                        break;
4008
                    case ControlType.ArrowTextCloudControl:
4009
                        {
4010
                            if (mouseButtonDown == MouseButton.Left)
4011
                            {
4012
                                if (currentControl is ArrowTextControl)
4013
                                {
4014
                                    CreateControl();
4015
                                    //controlType = ControlType.None;
4016
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4017
                                    currentControl = null;
4018
                                }
4019
                                else
4020
                                {
4021
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4022
                                    {
4023
                                        currentControl = new ArrowTextControl()
4024
                                        {
4025
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4026
                                        };
4027
                                        currentControl.CommentID = Save.shortGuid();
4028
                                        currentControl.IsNew = true;
4029
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4030
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4031

    
4032
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4033

    
4034
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4035

    
4036
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4037
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4038
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4039

    
4040
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4041

    
4042
                                        //currentControl.Focus();
4043
                                    }
4044
                                }
4045
                            }
4046
                        }
4047
                        break;
4048
                    case ControlType.ArrowTransTextCloudControl:
4049
                        {
4050
                            if (mouseButtonDown == MouseButton.Left)
4051
                            {
4052
                                if (currentControl is ArrowTextControl)
4053
                                {
4054
                                    CreateControl();
4055
                                    //controlType = ControlType.None;
4056
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4057
                                    currentControl = null;
4058
                                }
4059
                                else
4060
                                {
4061
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4062
                                    {
4063
                                        currentControl = new ArrowTextControl()
4064
                                        {
4065
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4066
                                        };
4067
                                        currentControl.CommentID = Save.shortGuid();
4068
                                        currentControl.IsNew = true;
4069
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4070
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4071

    
4072
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4073

    
4074
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4075

    
4076
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4077

    
4078
                                        (currentControl as ArrowTextControl).isFixed = true;
4079
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4080

    
4081
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4082

    
4083
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4084
                                        //currentControl.Focus();
4085
                                    }
4086
                                }
4087
                            }
4088
                        }
4089
                        break;
4090
                    case ControlType.PolygonControl:
4091
                        {
4092
                            if (currentControl is PolygonControl)
4093
                            {
4094
                                var control = currentControl as PolygonControl;
4095

    
4096
                                if (mouseButtonDown == MouseButton.Right)
4097
                                {
4098
                                    control.IsCompleted = true;
4099
                                }
4100

    
4101
                                if (!control.IsCompleted)
4102
                                {
4103
                                    //control.PointC.pointSet.Add(control.EndPoint);
4104
                                    control.PointSet.Add(control.EndPoint);
4105
                                }
4106
                                else
4107
                                {
4108
                                    //control.IsSelected = true;
4109
                                    var firstPoint = control.PointSet.First();
4110
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4111
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4112
                                    control.PointSet.Add(firstPoint);
4113

    
4114
                                    control.SetPolyPath();
4115

    
4116
                                    control.ApplyOverViewData();
4117

    
4118
                                    CreateControl();
4119

    
4120
                                    //controlType = ControlType.None;
4121

    
4122
                                    currentControl = null;
4123
                                }
4124
                            }
4125
                            else
4126
                            {
4127
                                if (mouseButtonDown == MouseButton.Left)
4128
                                {
4129
                                    currentControl = new PolygonControl
4130
                                    {
4131
                                        PointSet = new List<Point>(),
4132
                                        //PointC = new StylusPointSet()
4133
                                    };
4134

    
4135
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4136
                                    {
4137
                                        var polygonControl = (currentControl as PolygonControl);
4138
                                        currentControl.CommentID = Save.shortGuid();
4139
                                        currentControl.IsNew = true;
4140
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4141
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4142
                                        //currentControl.OnApplyTemplate();
4143
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4144
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4145
                                    }
4146
                                }
4147
                            }
4148
                        }
4149
                        break;
4150
                    //강인구 추가
4151
                    case ControlType.Sign:
4152
                        {
4153
                            if (mouseButtonDown == MouseButton.Left)
4154
                            {
4155
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4156
                                {
4157
                                    if (currentControl is SignControl)
4158
                                    {
4159
                                        CreateControl();
4160
                                        currentControl = null;
4161
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4162
                                        {
4163
                                            txtBatch.Text = "Date Control을 그립니다.";
4164
                                            controlType = ControlType.Date;
4165
                                        }
4166
                                    }
4167
                                    else
4168
                                    {
4169
                                        currentControl = new SignControl
4170
                                        {
4171
                                            Background = new SolidColorBrush(Colors.Black),
4172
                                            //UserNumber = "H2011357",
4173
                                            UserNumber = App.ViewInfo.UserID,
4174
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4175
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4176
                                            ControlType = ControlType.Sign
4177
                                        };
4178

    
4179
                                        currentControl.CommentID = Save.shortGuid();
4180
                                        currentControl.IsNew = true;
4181
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4182
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4183
                                        //currentControl.ApplyTemplate();
4184
                                    }
4185
                                }
4186
                            }
4187
                        }
4188
                        break;
4189
                    case ControlType.Mark:
4190
                        {
4191
                            if (mouseButtonDown == MouseButton.Left)
4192
                            {
4193
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4194
                                {
4195
                                    if (currentControl is RectangleControl)
4196
                                    {
4197
                                        CreateControl();
4198
                                        (currentControl as RectangleControl).ApplyOverViewData();
4199
                                        //controlType = ControlType.None;
4200
                                        currentControl = null;
4201
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
4202
                                        this.cursor = Cursors.Arrow;
4203

    
4204
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4205
                                        {
4206
                                            txtBatch.Text = "Sign Control을 그립니다.";
4207
                                            controlType = ControlType.Sign;
4208
                                        }
4209
                                    }
4210
                                    else
4211
                                    {
4212
                                        currentControl = new RectangleControl
4213
                                        {
4214
                                            Background = new SolidColorBrush(Colors.Black),
4215
                                            Paint = PaintSet.Fill
4216
                                        };
4217

    
4218
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4219
                                        currentControl.CommentID = Save.shortGuid();
4220
                                        currentControl.IsNew = true;
4221
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4222
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4223
                                    }
4224
                                }
4225
                            }
4226
                        }
4227
                        break;
4228
                    case ControlType.Symbol:
4229
                        {
4230
                            if (mouseButtonDown == MouseButton.Left)
4231
                            {
4232
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4233
                                {
4234
                                    if (currentControl is SymControl)
4235
                                    {
4236
                                        CreateControl();
4237
                                        //(currentControl as SymControlN).ApplyOverViewData();
4238
                                        //controlType = ControlType.None;
4239
                                        currentControl = null;
4240
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
4241
                                        this.cursor = Cursors.Arrow;
4242
                                    }
4243
                                    else
4244
                                    {
4245
                                        currentControl = new SymControl
4246
                                        {
4247
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4248
                                            Background = new SolidColorBrush(Colors.Black),
4249
                                            ControlType = ControlType.Symbol
4250
                                        };
4251

    
4252
                                        currentControl.IsNew = true;
4253
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4254
                                        currentControl.CommentID = Save.shortGuid();
4255
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4256
                                    }
4257
                                }
4258
                            }
4259
                        }
4260
                        break;
4261
                    case ControlType.Stamp:
4262
                        {
4263
                            if (mouseButtonDown == MouseButton.Left)
4264
                            {
4265
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4266
                                {
4267
                                    if (currentControl is SymControlN)
4268
                                    {
4269
                                        CreateControl();
4270
                                        currentControl = null;
4271
                                        this.cursor = Cursors.Arrow;
4272
                                    }
4273
                                    else
4274
                                    {
4275
                                        currentControl = new SymControlN
4276
                                        {
4277
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4278
                                            Background = new SolidColorBrush(Colors.Black),
4279
                                            ControlType = ControlType.Stamp
4280
                                        };
4281

    
4282
                                        currentControl.IsNew = true;
4283
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4284
                                        currentControl.CommentID = Save.shortGuid();
4285
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4286
                                    }
4287
                                }
4288
                            }
4289
                        }
4290
                        break;
4291
                    case ControlType.PenControl:
4292
                        {
4293
                            //this.inkBoard.CaptureMouse();
4294

    
4295
                            if (inkBoard.Tag.ToString() == "Ink")
4296
                            {
4297
                                inkBoard.IsEnabled = true;
4298
                                StartNewStroke(canvasDrawingMouseDownPoint);
4299
                            }
4300
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4301
                            {
4302
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4303
                            }
4304
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4305
                            {
4306
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4307
                            }
4308
                            IsDrawing = true;
4309
                            return;
4310
                        }
4311
                        break;
4312
                    default:
4313
                        if (currentControl != null)
4314
                        {
4315
                            currentControl.CommentID = null;
4316
                            currentControl.IsNew = false;
4317
                        }
4318
                        break;
4319
                }
4320

    
4321
            }
4322

    
4323
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4324
            {
4325
                //bool Flag = true;
4326
                //ControlList = new List<object>();
4327
                //if (selected_item == null)
4328
                //{
4329
                //    selected_item = new Dictionary<Geometry, string>();
4330
                //}
4331
                //if (selected_item.Count > 0)
4332
                //{
4333
                //    mouseHandlingMode = MouseHandlingMode.Drawing;
4334

    
4335
                //    foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
4336
                //    {
4337
                //        ControlList.Add(item);
4338
                //    }
4339
                //    controlType = move.control_Move_R(ControlList, canvasDrawingMouseDownPoint);
4340
                //    currentControl = move.CurrentControl;
4341
                //}
4342
                //else
4343
                //{
4344
                //    isLeftMouseButtonDownOnWindow = true;
4345
                //}
4346
                if (controlType == ControlType.None)
4347
                {
4348
                    //init();
4349
                    //cursor = Cursors.Cross;
4350
                    //SetCursor();
4351
                    mouseHandlingMode = MouseHandlingMode.Selecting;
4352
                    this.cursor = Cursors.Arrow;
4353
                    inkDrawingCanvas.IsEnabled = false;
4354
                    isLeftMouseButtonDownOnWindow = true;
4355
                }
4356
            }
4357

    
4358
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4359
            {
4360
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4361
                {
4362
                    bool mouseOff = false;
4363
                    foreach (var item in SelectLayer.Children)
4364
                    {
4365
                        if (item is AdornerFinal)
4366
                        {
4367

    
4368
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4369
                            if (over != null)
4370
                            {
4371
                                mouseOff = true;
4372
                            }
4373
                        }
4374
                    }
4375

    
4376
                    if (!mouseOff)
4377
                    {
4378
                        ReleaseAdorner();
4379
                    }
4380
                }
4381
                //if (mouseHandlingMode == MouseHandlingMode.Adorner && ViewerDataModel.Instance.MarkupControls.Where(data => data.IsMouseOver).FirstOrDefault() == null && SelectLayer.Children.Count >0)
4382
                //{
4383

    
4384
                //}
4385
                zoomAndPanControl.CaptureMouse();
4386
                e.Handled = true;
4387
            }
4388

    
4389
            //txtDrawingCanvasDownPoint_X.Text = string.Format("{0:f2}", canvasDrawingMouseDownPoint.X);
4390
            //txtDrawingCanvasDownPoint_Y.Text = string.Format("{0:f2}", canvasDrawingMouseDownPoint.Y);
4391

    
4392
            //txtZoomCanvasDownPoint_X.Text = string.Format("{0:f2}", canvasZoomPanningMouseDownPoint.X);
4393
            //txtZoomCanvasDownPoint_Y.Text = string.Format("{0:f2}", canvasZoomPanningMouseDownPoint.Y);
4394
        }
4395
        //int maxViewerWidth;
4396
        //int maxViewerHeight;
4397
        //int minViewerTop;
4398
        //int minViewerLeft;
4399

    
4400
        private void RemoveLineStroke(Point P)
4401
        {
4402
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4403
            if (control != null)
4404
            {
4405
                UndoData = new Undo_data()
4406
                {
4407
                    IsUndo = false,
4408
                    Event = Event_Type.Delete,
4409
                    EventTime = DateTime.Now,
4410
                    Markup_List = new List<Multi_Undo_data>()
4411
                };
4412

    
4413

    
4414
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4415
                UndoData.Markup_List.Add(multi_Undo_Data);
4416
                multi_Undo_Data = new Multi_Undo_data();
4417

    
4418
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4419
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4420
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4421

    
4422

    
4423
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4424
                {
4425
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4426
                });
4427
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4428

    
4429
                //if (control as PolygonControl != null)
4430
                //{
4431
                //    if ((control as PolygonControl).ControlType == ControlType.Ink)
4432
                //    {
4433
                //        ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4434
                //        var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4435
                //        ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
4436
                //    }
4437
                //}
4438
            }
4439

    
4440
            //StrokeCollection hits = inkBoard.Strokes.HitTest(P);
4441
            //inkBoard.Strokes.Remove(hits);
4442
        }
4443

    
4444
        private void RemovePointStroke(Point P)
4445
        {
4446
            //StrokeCollection hits = inkBoard.Strokes.HitTest(P);
4447
            foreach (Stroke hits in inkBoard.Strokes)
4448
            {
4449
                foreach (StylusPoint sty in hits.StylusPoints)
4450
                {
4451

    
4452
                }
4453
                if (hits.HitTest(P))
4454
                {
4455
                    inkBoard.Strokes.Remove(hits);
4456
                    return;
4457
                }
4458
            }
4459
        }
4460

    
4461
        private void StartNewStroke(Point P)
4462
        {
4463
            strokePoints = new StylusPointCollection();
4464
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4465
            strokePoints.Add(segment1Start);
4466
            stroke = new Stroke(strokePoints);
4467

    
4468
            stroke.DrawingAttributes.Color = Colors.Red;
4469
            stroke.DrawingAttributes.Width = 4;
4470
            stroke.DrawingAttributes.Height = 4;
4471

    
4472
            inkBoard.Strokes.Add(stroke);
4473

    
4474
            //inkBoard.Strokes.Add(stroke);
4475
        }
4476

    
4477
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4478
        {
4479
            ConsolidationMethod();
4480
        }
4481

    
4482
        public void ConsolidationMethod()
4483
        {
4484
            ChangeCommentReact();
4485

    
4486
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4487
            {
4488
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4489
            }
4490
            else
4491
            {
4492

    
4493
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4494
                {
4495
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4496
                }
4497
                //if (ViewerDataModel.Instance.MarkupControls_USER.Count() > 0 || this.gridViewMarkup.SelectedItems.Count > 0)
4498
                //{
4499
                //    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4500
                //}
4501

    
4502
                //if (ViewerDataModel.Instance.MarkupControls_USER.Count() > 0)
4503
                //{
4504
                //    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4505
                //}
4506

    
4507
                ViewerDataModel.Instance.IsConsolidate = true;
4508
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4509
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4510
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4511
                {
4512
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4513
                    if (markupInfo.CONSOLIDATE == 1)
4514
                    {
4515
                        markupInfo.AVOID_CONSOLIDATE = 1;
4516
                    }
4517

    
4518
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4519
                    {
4520
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4521
                          {
4522
                              instanceDataSet.Add(d);
4523
                          });
4524
                    }
4525

    
4526
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4527
                    info.ID = Save.shortGuid();
4528
                    info.CONSOLIDATE = 1;
4529
                    info.CREATE_TIME = DateTime.Now;
4530
                    info.DOCINFO_ID = _DocInfo.ID;
4531
                    info.UPDATE_TIME = DateTime.Now;
4532
                    info.USER_ID = App.ViewInfo.UserID;
4533
                    info.AVOID_CONSOLIDATE = 0;
4534

    
4535
                    Entity.MARKUP_INFO.AddObject(info);
4536
                    Entity.SaveChanges();
4537

    
4538

    
4539
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4540
                    {
4541
                        ID = Save.shortGuid(),
4542
                        CREATE_DATE = DateTime.Now,
4543
                        MARKUP_INFO = info,
4544
                    };
4545
                    Entity.SaveChanges();
4546

    
4547
                    foreach (var item in instanceDataSet)
4548
                    {
4549
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4550
                        {
4551
                            ID = Save.shortGuid(),
4552
                            DATA = item.DATA,
4553
                            DATA_TYPE = item.DATA_TYPE,
4554
                            PAGENUMBER = item.PAGENUMBER,
4555
                            MARKUP_INFO_VERSION = info2
4556
                        });
4557
                    }
4558
                    Entity.SaveChanges();
4559
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4560
                }
4561
            }
4562
        }
4563

    
4564
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4565
        {
4566
            if (App.ViewInfo != null)
4567
            {
4568
                btnConsolidate = (sender as RadRibbonButton);
4569
                if (!App.ViewInfo.NewCommentPermission)
4570
                {
4571
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4572
                    //instanceTop = this.ParentOfType<MainWindow>().dzTopMenu;
4573
                    //instanceTop.btnSwing.Visibility = Visibility.Collapsed;
4574
                    //instanceTop.cbSwingMode.Visibility = Visibility.Collapsed;
4575

    
4576
                    //instanceTop.btnExportPDF.Visibility = Visibility.Visible;
4577
                    //instanceTop.btnExportPrint.Visibility = Visibility.Visible;
4578
                }
4579
            }
4580
        }
4581

    
4582
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4583
        {
4584

    
4585
        }
4586

    
4587
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4588
        {
4589
            btnTeamConsolidate = sender as RadRibbonButton;
4590
            if (App.ViewInfo != null)
4591
            {
4592
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4593
                {
4594
                    if (btnConsolidate != null)
4595
                    {
4596
                        btnConsolidate.Visibility = Visibility.Collapsed;
4597
                    }
4598

    
4599
                    if (!App.ViewInfo.NewCommentPermission)
4600
                    {
4601
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4602
                    }
4603
                }
4604
                else
4605
                {
4606
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4607
                }
4608
            }
4609
        }
4610

    
4611
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4612
        {
4613
            //this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4614

    
4615
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4616
            if (item != null)
4617
            {
4618
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4619
            }
4620
            else
4621
            {
4622
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4623
            }
4624
        }
4625

    
4626
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4627
        {
4628
            btnFinalPDF = sender as RadRibbonButton;
4629
            if (App.ViewInfo != null)
4630
            {
4631
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4632
                {
4633
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4634
                    if (btnConsolidate != null)
4635
                    {
4636
                        btnConsolidate.Visibility = Visibility.Collapsed;
4637
                    }
4638
                }
4639
            }
4640
        }
4641

    
4642
        private void Button_Click(object sender, RoutedEventArgs e)
4643
        {
4644

    
4645
            //bool isGO = false;
4646
            //imageViewer.MouseLeftButtonDown += (sen, ea) =>
4647
            //  {
4648
            //      isGO = true;
4649
            //  };
4650
            //imageViewer.MouseLeftButtonUp += (sen, ea) =>
4651
            //{
4652
            //    isGO = false;
4653
            //};
4654
            //imageViewer.SizeMode = SizeMode.Fit;
4655
            //imageViewer.InteractiveMode = InteractiveMode.UserRectangle;
4656
            //imageViewer.InteractiveUserRectangle += (sen, ea) =>
4657
            //{
4658
            //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
4659
            //    if (ea.Status == InteractiveModeStatus.End)
4660
            //    {
4661
            //        //zoomAndPanControl.ZoomTo(ea.Bounds);
4662
            //        zoomAndPanControl.ZoomTo(ea.Bounds);
4663
            //    }
4664

    
4665
            //};
4666

    
4667
            //Canvas.SetZIndex(imageViewer, 10);
4668
            //gather information on the viewer
4669

    
4670

    
4671
            //System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
4672
            //var result = dialog.ShowDialog();
4673
            //if (result == System.Windows.Forms.DialogResult.OK)
4674
            //{
4675
            //    using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4676
            //    {
4677
            //        imageViewer.Image = codecs.Load(dialog.FileName, 0, Leadtools.Codecs.CodecsLoadByteOrder.Gray, 1, 1);
4678
            //        //imageViewer.Image = codecs.Load(dialog.FileName, 24, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4679
            //        //imageViewer.Image.AnimationBackground = Leadtools.RasterColor.White;
4680

    
4681
            //        //var d = imageViewer.Image.CreateThumbnail(100, 100, 24, Leadtools.RasterViewPerspective.TopLeft, Leadtools.RasterSizeFlags.None);
4682
            //        //RasterImageViewer vvv = new RasterImageViewer();
4683
            //        //vvv.Image = d;
4684
            //        //zoomAndPanCanvas.Children.Add(vvv);
4685

    
4686
            //        zoomAndPanCanvas.Width = Convert.ToDouble(imageViewer.Image.ImageWidth);
4687
            //        zoomAndPanCanvas.Height = Convert.ToDouble(imageViewer.Image.ImageHeight);
4688

    
4689
            //        Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
4690
            //        Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
4691
            //        //zoomAndPanControl.AnimatedScaleToFit();
4692
            //        zoomAndPanControl.ScaleToFit();
4693
            //    }
4694
            //}
4695

    
4696
        }//괄호 다시 확인 필요
4697

    
4698
        //강인구 추가
4699
        //가로 세로 동일한 컨트롤 그리기(계산 다시 필요)
4700
        private Point ShiftDrawing(Point StartP, Point EndP)
4701
        {
4702
            Point Return_Point = EndP;
4703
            //Shift key를 눌렀을때만 발동
4704
            if (ViewerDataModel.Instance.IsPressShift)
4705
            {
4706
                Square square = new Square();
4707
                double pt_X = 0;
4708
                double pt_Y = 0;
4709
                double result = 0;
4710

    
4711
                //pt_X = Math.Max(StartP.X, EndP.X) - Math.Min(StartP.X, EndP.X);
4712
                //pt_Y = Math.Max(StartP.Y, EndP.Y) - Math.Min(StartP.Y, EndP.Y);
4713
                if (EndP.X > StartP.X && EndP.Y > StartP.Y)
4714
                {
4715
                    pt_X = EndP.X - StartP.X;
4716
                    pt_Y = EndP.Y - StartP.Y;
4717
                }
4718
                else if (EndP.X < StartP.X && EndP.Y > StartP.Y)
4719
                {
4720
                    pt_X = StartP.X - EndP.X;
4721
                    pt_Y = EndP.Y - StartP.Y;
4722
                }
4723
                else if (EndP.X > StartP.X && EndP.Y < StartP.Y)
4724
                {
4725
                    pt_X = EndP.X - StartP.X;
4726
                    pt_Y = StartP.Y - EndP.Y
4727
;
4728
                }
4729
                result = Math.Max(pt_X, pt_Y) - Math.Min(pt_X, pt_Y);
4730
                if (pt_X < pt_Y)
4731
                {
4732
                    Return_Point = new Point(EndP.X + result, EndP.Y);
4733
                }
4734
                else
4735
                {
4736
                    Return_Point = new Point(EndP.X, EndP.Y + result);
4737
                }
4738
            }
4739

    
4740
            return Return_Point;
4741
        }
4742

    
4743
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4744
        {
4745
            if (CompareMode.IsChecked)
4746
            {
4747
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4748
                {
4749
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4750
                }
4751
                if (ViewerDataModel.Instance.PageNumber == 0)
4752
                {
4753
                    ViewerDataModel.Instance.PageNumber = 1;
4754
                }
4755

    
4756
                //BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageBalanceMode ? ViewerDataModel.Instance.PageBalanceNumber.ToString() : pageNavigator.CurrentPage.PageNumber.ToString());
4757
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString());
4758

    
4759
                //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);
4760
                //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);
4761

    
4762
                //MARKUS.CompareLib compareLib = new MARKUS.CompareLib();
4763
                //System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile);
4764
                //System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile);
4765

    
4766
                //var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
4767
                //var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
4768

    
4769
                //string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
4770
                //var result = compareLib.GetBoundBoxInImage(outPutFile);
4771

    
4772
                //SolidColorBrush mySolidColorBrush = new SolidColorBrush();
4773
                //mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
4774

    
4775
                //result.ForEach(d =>
4776
                //{
4777
                //    d.Width = d.Width * 3;
4778
                //    d.Height = d.Height * 3;
4779
                //    var point = MathSet.getRectMiddlePoint(d);
4780
                //    Ellipse myEllipse = new Ellipse();
4781
                //    myEllipse.Fill = new SolidColorBrush(Colors.Red);
4782
                //    myEllipse.Opacity = 1;
4783
                //        //myEllipse.StrokeThickness = 2;
4784
                //        //myEllipse.Stroke = Brushes.Black;
4785
                //        myEllipse.Width = d.Width;
4786
                //    myEllipse.Height = d.Height;
4787
                //    Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
4788
                //    Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
4789
                //    myEllipse.RenderTransformOrigin = point;
4790
                //    canvas_compareBorder.Children.Add(myEllipse);
4791
                //});
4792

    
4793
                //da.From = 0.8;
4794
                //da.To = 0;
4795
                //da.Duration = new Duration(TimeSpan.FromSeconds(1));
4796
                //da.AutoReverse = true;
4797
                //canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4798
            }
4799
            else
4800
            {
4801
                da.From = 1;
4802
                da.To = 1;
4803
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4804
                da.AutoReverse = false;
4805
                canvas_compareBorder.Children.Clear();
4806
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4807
            }
4808
        }
4809

    
4810
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4811
        {
4812
            if (UserList.IsChecked)
4813
            {
4814
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4815
            }
4816
            else
4817
            {
4818
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4819
            }
4820
            //if ((sender as RadToggleButton).IsChecked == true)
4821
            //{
4822
            //    this.gridViewRevMarkup.Visibility = Visibility.Visible;
4823
            //}
4824
            //else
4825
            //{
4826
            //    this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4827
            //}
4828
        }
4829

    
4830
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4831
        {
4832
            //ViewerDataModel.Instance.PageBalanceNumber = ViewerDataModel.Instance.PageBalanceNumber <= 0 ? Convert.ToInt32((sender as System.Windows.Controls.Control).Tag) : ViewerDataModel.Instance.PageBalanceNumber;
4833
            //ViewerDataModel.Instance.PageBalanceNumber = 0;
4834

    
4835

    
4836
            if (BalanceMode.IsChecked)
4837
            {
4838
                ViewerDataModel.Instance.PageBalanceMode = true;
4839
            }
4840
            else
4841
            {
4842
                ViewerDataModel.Instance.PageBalanceMode = false;
4843
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4844
            }
4845
            //if ((sender as RadToggleButton).IsChecked == true)
4846
            //{
4847
            //    ViewerDataModel.Instance.PageBalanceMode = true;
4848
            //}
4849
            //else
4850
            //{
4851
            //    ViewerDataModel.Instance.PageBalanceMode = false;
4852
            //    ViewerDataModel.Instance.PageBalanceNumber = 0;
4853
            //}
4854
        }
4855

    
4856
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4857
        {
4858
            //초기화
4859
            testPanel2.IsHidden = true;
4860
            ViewerDataModel.Instance.PageBalanceMode = false;
4861
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4862
            ViewerDataModel.Instance.PageNumber = 0;
4863
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4864
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4865
            UserList.IsChecked = false;
4866
            BalanceMode.IsChecked = false;
4867
        }
4868

    
4869
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4870
        {
4871
            if ((sender as System.Windows.Controls.Control).Tag != null)
4872
            {
4873
                //Compare 초기화
4874
                CompareMode.IsChecked = false;
4875
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4876

    
4877
                //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
4878
                //{
4879
                //    ViewerDataModel.Instance.PageBalanceNumber = 1;
4880
                //}
4881

    
4882
                if (ViewerDataModel.Instance.PageNumber == 0)
4883
                {
4884
                    ViewerDataModel.Instance.PageNumber = 1;
4885
                }
4886

    
4887
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4888
                {
4889
                }
4890
                else
4891
                {
4892
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4893
                }
4894
                //else if ((ViewerDataModel.Instance.PageBalanceNumber + balancePoint) >= 1)
4895
                //{
4896
                //    //ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4897
                //    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4898
                //}
4899

    
4900
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4901
                {
4902

    
4903
                }
4904
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4905
                {
4906
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4907
                }
4908

    
4909
                if (!testPanel2.IsHidden)
4910
                {
4911
                    //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4912
                    //{
4913
                    if (IsSyncPDFMode)
4914
                    {
4915
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4916
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4917

    
4918
                        if (pdfpath.IsDownloading)
4919
                        {
4920
                            pdfpath.DownloadCompleted += (ex, arg) =>
4921
                            {
4922
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4923
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4924
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4925
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4926
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4927
                            };
4928
                        }
4929
                        else
4930
                        {
4931
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4932
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4933
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4934

    
4935
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4936
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4937
                        }
4938

    
4939

    
4940
                        //PDF Mode 잠시대기
4941
                        //Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(CurrentRev.TO_VENDOR));
4942
                        //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageNumber);
4943
                        //Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
4944
                        //size.Run(image);
4945
                        //image.XResolution = 150;
4946
                        //image.YResolution = 150;
4947
                        //imageViewer_Compare.Image = image;
4948
                    }
4949
                    else
4950
                    {
4951
                        //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);
4952
                        //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);
4953
                        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);
4954
                        //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4955

    
4956
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4957

    
4958
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4959
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4960
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4961

    
4962
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4963
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4964

    
4965
                        if (defaultBitmapImage_Compare.IsDownloading)
4966
                        {
4967
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4968
                            {
4969
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4970
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4971
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4972

    
4973
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4974
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4975
                            };
4976
                        }
4977
                    }
4978

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

    
4983
                    foreach (var item in gridSelectionRevItem)
4984
                    {
4985
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4986
                        {
4987
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4988
                        });
4989
                    }
4990

    
4991

    
4992
                    //zoomAndPanCanvas2.Width = imageViewer_Compare.Image.Width;
4993
                    //zoomAndPanCanvas2.Height = imageViewer_Compare.Image.Height;
4994
                    //강인구 추가
4995
                    zoomAndPanControl2.ZoomTo(new Rect
4996
                    {
4997
                        X = 0,
4998
                        Y = 0,
4999
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5000
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5001
                    });
5002
                    //}
5003
                    //tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5004
                    //tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageBalanceNumber);
5005
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
5006

    
5007
                }
5008
            }
5009
        }
5010

    
5011
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5012
        {
5013
            //if ((sender as RadToggleButton).IsChecked)
5014
            if (MarkupMode.IsChecked)
5015
            {
5016
                //(sender as RadToggleButton).Content = "PDF Mode";
5017
                IsSyncPDFMode = true;
5018

    
5019
                var uri = CurrentRev.TO_VENDOR;
5020
                //Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(uri));
5021
                //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5022
                //{
5023
                //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
5024
                //{
5025
                //    ViewerDataModel.Instance.PageBalanceNumber = 1;
5026
                //}
5027
                if (ViewerDataModel.Instance.PageNumber == 0)
5028
                {
5029
                    ViewerDataModel.Instance.PageNumber = 1;
5030
                }
5031

    
5032
                //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageBalanceNumber);
5033

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

    
5038
                //System.Net.WebClient client = new System.Net.WebClient();
5039
                //byte[] imageBytes = client.DownloadData(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5040
                //System.Drawing.Image img;
5041
                //System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes, 0, imageBytes.Length);
5042
                //ms.Write(imageBytes, 0, imageBytes.Length);
5043
                //img = System.Drawing.Image.FromStream(ms, true);//Exception occurs here
5044

    
5045
                if (pdfpath.IsDownloading)
5046
                {
5047
                    pdfpath.DownloadCompleted += (ex, arg) =>
5048
                    {
5049
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5050
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5051
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5052
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5053
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5054
                    };
5055
                }
5056
                else
5057
                {
5058
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5059
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5060
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5061

    
5062
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5063
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5064
                }
5065

    
5066
                //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageNumber);
5067
                //Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
5068
                //size.Run(image);
5069
                //image.XResolution = 150;
5070
                //image.YResolution = 150;
5071
                //imageViewer_Compare.Image = image;
5072
                //}
5073
            }
5074
            else
5075
            {
5076
                //(sender as RadToggleButton).Content = "Markup Mode";
5077
                IsSyncPDFMode = false;
5078

    
5079
                //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5080
                //{
5081
                //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);
5082
                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);
5083

    
5084
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5085

    
5086
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5087
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5088
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5089

    
5090
                if (defaultBitmapImage_Compare.IsDownloading)
5091
                {
5092
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5093
                    {
5094
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5095
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5096
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5097
                    };
5098
                }
5099

    
5100
                //imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
5101
                zoomAndPanControl2.ApplyTemplate();
5102
                zoomAndPanControl2.UpdateLayout();
5103
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5104
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5105
                //}
5106
            }
5107

    
5108
            //var options = new Leadtools.Documents.LoadDocumentAsyncOptions();
5109
            //options.FirstPageNumber = pageNavigator.CurrentPage.PageNumber;
5110
            //options.LastPageNumber = pageNavigator.CurrentPage.PageNumber;
5111
            ////options.LoadEmbeddedAnnotations = true;
5112
            ////options.UseCache = true;
5113
            //options.Completed += (sen, ea) =>
5114
            //{
5115
            //    //ea.Document.Pages[0].GetAnnotations(true);
5116
            //    //SetAnnotations
5117
            //    imageViewer_Compare.Image = ea.Document.Pages[0].GetImage();
5118

    
5119
            //    zoomAndPanCanvas2.Width = Convert.ToDouble(imageViewer_Compare.Image.Width);
5120
            //    zoomAndPanCanvas2.Height = Convert.ToDouble(imageViewer_Compare.Image.Height);
5121
            //};
5122
            //var uri = new Uri("http://cloud.devdoftech.co.kr:5977/FinalPDF/000000_app/VPCS_DOCLIB/111111/11111111/ToVendor/TEST_C_A.pdf");
5123
            //Leadtools.Documents.DocumentFactory.LoadFromUriAsync(uri, options);
5124

    
5125

    
5126
        }
5127

    
5128
        private void RadButton_Click(object sender, RoutedEventArgs e)
5129
        {
5130
            gridViewHistory_Busy.IsBusy = true;
5131

    
5132
            RadButton instance = sender as RadButton;
5133
            if (instance.CommandParameter != null)
5134
            {
5135
                CurrentRev = instance.CommandParameter as VPRevision;
5136
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5137
                {
5138
                    if (ea.Error == null && ea.Result != null)
5139
                    {
5140
                        testPanel2.IsHidden = false;
5141
                        //testList.ItemsSource = ea.Result;
5142

    
5143
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5144
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5145

    
5146
                        //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5147
                        //{
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, pageNavigator.CurrentPage.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, pageNavigator.CurrentPage.PageNumber);
5150

    
5151
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5152

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

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

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

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

    
5171
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5172
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5173
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5174
                        //대기(강인구)
5175
                        //imageViewer_Compare.RotateAngle = imageViewer.RotateAngle;
5176
                        zoomAndPanControl2.ApplyTemplate();
5177
                        zoomAndPanControl2.UpdateLayout();
5178

    
5179
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5180
                        {
5181
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5182
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5183
                        }
5184
                        //}
5185

    
5186
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5187
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5188
                        gridViewHistory_Busy.IsBusy = false;
5189
                    }
5190
                };
5191
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5192
            }
5193
        }
5194

    
5195
        public void Sync_Event(VPRevision Currnet_Rev)
5196
        {
5197
            CurrentRev = Currnet_Rev;
5198

    
5199
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5200
            {
5201
                if (ea.Error == null && ea.Result != null)
5202
                {
5203
                    testPanel2.IsHidden = false;
5204
                    //testList.ItemsSource = ea.Result;
5205

    
5206
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5207
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5208

    
5209
                    //using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
5210
                    //{
5211
                    //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);
5212
                    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);
5213

    
5214
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5215

    
5216
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5217

    
5218
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5219
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5220
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5221

    
5222
                    if (defaultBitmapImage_Compare.IsDownloading)
5223
                    {
5224
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5225
                        {
5226
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5227
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5228
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5229
                        };
5230
                    }
5231

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

    
5234
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5235
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5236
                    zoomAndPanControl2.ApplyTemplate();
5237
                    zoomAndPanControl2.UpdateLayout();
5238

    
5239
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5240
                    {
5241
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5242
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5243
                    }
5244
                    //}
5245

    
5246
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5247
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5248
                    gridViewHistory_Busy.IsBusy = false;
5249
                }
5250
            };
5251
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5252

    
5253

    
5254
        }
5255

    
5256
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5257
        {
5258
            if (sender is Image)
5259
            {
5260
                if ((sender as Image).Tag != null)
5261
                {
5262
                    var pdfUrl = (sender as Image).Tag.ToString();
5263
                    System.Diagnostics.Process.Start(pdfUrl);
5264
                }
5265
                else
5266
                {
5267
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5268
                }
5269
            }
5270
        }
5271

    
5272
        private void Create_Symbol(object sender, RoutedEventArgs e)
5273
        {
5274
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
5275
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
5276

    
5277
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5278
            {
5279
                DialogMessage_Alert("Please Select Controls", "Alert");
5280
            }
5281
            else //선택된 것이 있으면
5282
            {
5283
                string MarkupData = "";
5284
                adorner_ = new AdornerFinal();
5285

    
5286
                foreach (var item in SelectLayer.Children)
5287
                {
5288
                    if (item.GetType().Name == "AdornerFinal")
5289
                    {
5290
                        adorner_ = (item as Controls.AdornerFinal);
5291
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5292
                        {
5293
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5294
                            {
5295
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5296
                                MarkupData += markupReturn.ConvertData;
5297
                            }
5298
                        }
5299
                    }
5300
                }
5301
                DialogParameters parameters = new DialogParameters()
5302
                {
5303
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5304
                    DefaultPromptResultValue = "Custom State",
5305
                    Content = "Name :",
5306
                    Header = "Insert Custom Symbol Name",
5307
                    Theme = new VisualStudio2013Theme(),
5308
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5309
                };
5310
                RadWindow.Prompt(parameters);
5311
            }
5312

    
5313
        }
5314

    
5315
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5316
        {
5317
            Save save = new Save();
5318

    
5319
            if (args.DialogResult.Value)
5320
            {
5321
                PngBitmapEncoder _Encoder = symImage(data);
5322

    
5323
                System.IO.MemoryStream fs = new System.IO.MemoryStream();
5324
                _Encoder.Save(fs);
5325
                System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5326

    
5327
                byte[] Img_byte = fs.ToArray();
5328

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

    
5332
                save.SymbolSave(args.PromptResult, filename, data);
5333
            }
5334
        }
5335

    
5336
        public PngBitmapEncoder symImage(string data)
5337
        {
5338

    
5339
            Canvas _canvas = new Canvas();
5340
            _canvas.Background = Brushes.White;
5341
            _canvas.Width = adorner_.BorderSize.Width;
5342
            _canvas.Height = adorner_.BorderSize.Height;
5343
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
5344

    
5345
            BitmapEncoder encoder = new PngBitmapEncoder();
5346

    
5347

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

    
5350
            DrawingVisual dv = new DrawingVisual();
5351

    
5352
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
5353
            //_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)));
5354
            _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)));
5355

    
5356
            using (DrawingContext ctx = dv.RenderOpen())
5357
            {
5358
                VisualBrush vb = new VisualBrush(_canvas);
5359
                //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)));
5360
                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)));
5361
            }
5362

    
5363
            try
5364
            {
5365
                renderBitmap.Render(dv);
5366

    
5367
                GC.Collect();
5368
                GC.WaitForPendingFinalizers();
5369
                GC.Collect();
5370
                //bitmap.Render(controlToConvert);
5371
                // encode png data
5372
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5373
                // puch rendered bitmap into it
5374
                pngEncoder.Interlace = PngInterlaceOption.Off;
5375
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5376
                return pngEncoder;
5377

    
5378
            }
5379
            catch (Exception ex)
5380
            {
5381
                return null;
5382
            }
5383

    
5384
        }
5385

    
5386
        public void DialogMessage_Alert(string content, string header)
5387
        {
5388
            var box = new TextBlock();
5389
            box.MinWidth = 400;
5390
            box.FontSize = 11;
5391
            //box.FontSize = 12;
5392
            box.Text = content;
5393
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5394

    
5395
            DialogParameters parameters = new DialogParameters()
5396
            {
5397
                Content = box,
5398
                Header = header,
5399
                Theme = new VisualStudio2013Theme(),
5400
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5401
            };
5402
            RadWindow.Alert(parameters);
5403
        }
5404

    
5405
        #region 캡쳐 기능
5406

    
5407
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5408
        {
5409
            if (x < 0)
5410
            {
5411
                width += x;
5412
                x = 0;
5413
            }
5414
            if (y < 0)
5415
            {
5416
                height += y;
5417
                y = 0;
5418

    
5419
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5420
            }
5421
            if (x + width > zoomAndPanCanvas.ActualWidth)
5422
            {
5423
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5424
            }
5425
            if (y + height > zoomAndPanCanvas.ActualHeight)
5426
            {
5427
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5428
            }
5429

    
5430
            byte[] pixels = CopyPixels(x, y, width, height);
5431

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

    
5434
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5435
        }
5436

    
5437
        public byte[] CopyPixels(int x, int y, int width, int height)
5438
        {
5439
            byte[] pixels = new byte[width * height * 4];
5440
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5441

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

    
5445
            return pixels;
5446
        }
5447

    
5448
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5449
        {
5450
            DrawingVisual drawingVisual = new DrawingVisual();
5451
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5452

    
5453
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5454
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5455
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5456
            drawingContext.Close();
5457

    
5458
            // 비트맵으로 변환합니다.
5459
            RenderTargetBitmap target =
5460
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5461
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5462

    
5463
            target.Render(drawingVisual);
5464
            return target;
5465
        }
5466

    
5467
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5468
        {
5469
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5470
            KCOMDataModel.DataModel.CHECK_LIST check_;
5471
            string Result = streamToBase64.ImageToBase64(source);
5472
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5473

    
5474
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
5475
            {
5476
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
5477

    
5478
                //새로운 데이터 추가
5479
                if (Item == null)
5480
                {
5481
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
5482
                    {
5483
                        ID = Save.shortGuid(),
5484
                        USER_ID = App.ViewInfo.UserID,
5485
                        IMAGE_URL = Result,
5486
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5487
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5488
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5489
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5490
                        PROJECT_NO = App.ViewInfo.ProjectNO,
5491
                        STATUS = "False",
5492
                        CREATE_TIME = DateTime.Now,
5493
                        UPDATE_TIME = DateTime.Now,
5494
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5495
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
5496
                    };
5497

    
5498
                    Entity.CHECK_LIST.AddObject(check_);
5499
                }
5500
                //기존에 있던 데이터 업데이트
5501
                else
5502
                {
5503
                    Item.IMAGE_URL = Result;
5504
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5505
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5506
                }
5507

    
5508
                //Item.REV_0 = "Test";
5509

    
5510
                try
5511
                {
5512
                    Entity.SaveChanges();
5513
                }
5514
                catch (Exception ex)
5515
                {
5516

    
5517
                }
5518
                //Entity.SaveChanges();
5519
            }
5520
        }
5521

    
5522
        public void Set_Capture()
5523
        {
5524
            //double x = Canvas.GetLeft(dragCaptureBorder);
5525
            //double y = Canvas.GetTop(dragCaptureBorder);
5526
            double x = canvasDrawingMouseDownPoint.X;
5527
            double y = canvasDrawingMouseDownPoint.Y;
5528
            double width = dragCaptureBorder.Width;
5529
            double height = dragCaptureBorder.Height;
5530

    
5531
            if (width > 5 || height > 5)
5532
            {
5533
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5534
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5535
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5536
            }
5537
        }
5538
        #endregion
5539

    
5540
        public void CreateControl()
5541
        {
5542
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5543
            {
5544
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5545
            });
5546
            multi_Undo_Data.Markup = currentControl;
5547
            UndoData.Markup_List.Add(multi_Undo_Data);
5548
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5549
        }
5550

    
5551
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5552
        {
5553
            multi_Undo_Data = new Multi_Undo_data();
5554

    
5555
            multi_Undo_Data.Markup = control;
5556

    
5557
            if ((control as IShapeControl) != null)
5558
            {
5559
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5560
            }
5561
            if ((control as IDashControl) != null)
5562
            {
5563
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5564
            }
5565
            if ((control as IPath) != null)
5566
            {
5567
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5568
            }
5569
            if ((control as UIElement) != null)
5570
            {
5571
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5572
            }
5573

    
5574
            return multi_Undo_Data;
5575
        }
5576

    
5577
        public void Undo()
5578
        {
5579
            Undo_data undo = new Undo_data();
5580
            AdornerFinal final;
5581
            ReleaseAdorner();
5582

    
5583
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5584
            if (undo == null)
5585
                return;
5586

    
5587
            switch (undo.Event)
5588
            {
5589
                case (Event_Type.Create):
5590
                    {
5591
                        foreach (var item in undo.Markup_List)
5592
                        {
5593
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5594
                        }
5595
                    }
5596
                    break;
5597
                case (Event_Type.Delete):
5598
                    {
5599
                        foreach (var item in undo.Markup_List)
5600
                        {
5601
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5602

    
5603
                            //final = new AdornerFinal(item.Markup);
5604
                            //SelectLayer.Children.Add(final);
5605
                        }
5606
                    }
5607
                    break;
5608
                case (Event_Type.Thumb):
5609
                    {
5610
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5611

    
5612
                        foreach (var item in undo.Markup_List)
5613
                        {
5614
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5615

    
5616
                            if ((item.Markup as IViewBox) != null)
5617
                            {
5618
                                (item.Markup as IViewBox).Angle = item.Angle;
5619
                            }
5620
                            if ((item.Markup as TextControl) != null)
5621
                            {
5622
                                (item.Markup as TextControl).Angle = item.Angle;
5623
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5624
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5625
                            }
5626
                            else
5627
                            {
5628
                                (item.Markup as IPath).PointSet = item.PointSet;
5629
                                (item.Markup as IPath).updateControl();
5630
                            }
5631

    
5632
                            comment.Add(item.Markup);
5633
                        }
5634
                        final = new AdornerFinal(comment);
5635
                        SelectLayer.Children.Add(final);
5636
                        ReleaseAdorner();
5637
                    }
5638
                    break;
5639
                case (Event_Type.Select):
5640
                    {
5641
                        ReleaseAdorner();
5642
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5643

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

    
5648
                            if ((item.Markup as IPath) != null)
5649
                            {
5650
                                (item.Markup as IPath).LineSize = item.LineSize;
5651
                            }
5652
                            if ((item.Markup as UIElement) != null)
5653
                            {
5654
                                (item.Markup as UIElement).Opacity = item.Opacity;
5655
                            }
5656
                            if ((item.Markup as IDashControl) != null)
5657
                            {
5658
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5659
                            }
5660
                            if ((item.Markup as IShapeControl) != null)
5661
                            {
5662
                                (item.Markup as IShapeControl).Paint = item.paint;
5663
                            }
5664

    
5665
                            comment.Add(item.Markup);
5666
                        }
5667

    
5668
                        final = new AdornerFinal(comment);
5669
                        SelectLayer.Children.Add(final);
5670
                    }
5671
                    break;
5672
                case (Event_Type.Option):
5673
                    {
5674
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5675

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

    
5680
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5681
                            {
5682
                                (item.Markup as IPath).LineSize = undo.LineSize;
5683
                            }
5684
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5685
                            {
5686
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5687
                            }
5688
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5689
                            {
5690
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5691
                            }
5692
                            else if (item.Markup as IShapeControl != null)
5693
                            {
5694
                                (item.Markup as IShapeControl).Paint = undo.paint;
5695
                            }
5696
                            comment.Add(item.Markup);
5697
                        }
5698
                        final = new AdornerFinal(comment);
5699
                        SelectLayer.Children.Add(final);
5700
                    }
5701
                    break;
5702
            }
5703
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5704
           {
5705
               i.IsUndo = true;
5706
           });
5707
        }
5708

    
5709
        public void Redo()
5710
        {
5711
            AdornerFinal final;
5712
            Undo_data redo = new Undo_data();
5713
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5714
            ReleaseAdorner();
5715
            if (redo == null)
5716
                return;
5717

    
5718
            switch (redo.Event)
5719
            {
5720
                case (Event_Type.Create):
5721
                    {
5722
                        foreach (var item in redo.Markup_List)
5723
                        {
5724
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5725
                        }
5726
                    }
5727
                    break;
5728
                case (Event_Type.Delete):
5729
                    {
5730
                        foreach (var item in redo.Markup_List)
5731
                        {
5732
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5733
                        }
5734
                    }
5735
                    break;
5736
                case (Event_Type.Thumb):
5737
                    {
5738
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5739

    
5740
                        foreach (var item in redo.Markup_List)
5741
                        {
5742
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5743

    
5744
                            if ((item.Markup as IViewBox) != null)
5745
                            {
5746
                                (item.Markup as IViewBox).Angle = item.Angle;
5747
                            }
5748
                            if ((item.Markup as TextControl) != null)
5749
                            {
5750
                                //(item.Markup as TextControl).CanvasX = item.PointSet[0].X;
5751
                                //(item.Markup as TextControl).CanvasY = item.PointSet[0].Y;
5752

    
5753
                                (item.Markup as TextControl).Angle = item.Angle;
5754

    
5755
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5756
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5757
                            }
5758
                            else
5759
                            {
5760
                                (item.Markup as IPath).PointSet = item.PointSet;
5761
                                (item.Markup as IPath).updateControl();
5762
                            }
5763
                            comment.Add(item.Markup);
5764
                        }
5765
                        final = new AdornerFinal(comment);
5766
                        SelectLayer.Children.Add(final);
5767
                        ReleaseAdorner();
5768
                    }
5769
                    break;
5770
                case (Event_Type.Select):
5771
                    {
5772
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5773

    
5774
                        foreach (var item in redo.Markup_List)
5775
                        {
5776
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5777

    
5778
                            if ((item.Markup as IPath) != null)
5779
                            {
5780
                                (item.Markup as IPath).LineSize = item.LineSize;
5781
                            }
5782
                            if ((item.Markup as UIElement) != null)
5783
                            {
5784
                                (item.Markup as UIElement).Opacity = item.Opacity;
5785
                            }
5786
                            if ((item.Markup as IDashControl) != null)
5787
                            {
5788
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5789
                            }
5790
                            if ((item.Markup as IShapeControl) != null)
5791
                            {
5792
                                (item.Markup as IShapeControl).Paint = item.paint;
5793
                            }
5794

    
5795
                            comment.Add(item.Markup);
5796
                        }
5797
                        final = new AdornerFinal(comment);
5798
                        SelectLayer.Children.Add(final);
5799
                    }
5800
                    break;
5801
                case (Event_Type.Option):
5802
                    {
5803
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5804

    
5805
                        foreach (var item in redo.Markup_List)
5806
                        {
5807
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5808
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5809
                            {
5810
                                (item.Markup as IPath).LineSize = redo.LineSize;
5811
                            }
5812
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5813
                            {
5814
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5815
                            }
5816
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5817
                            {
5818
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5819
                            }
5820
                            else if (item.Markup as IShapeControl != null)
5821
                            {
5822
                                (item.Markup as IShapeControl).Paint = redo.paint;
5823
                            }
5824
                            comment.Add(item.Markup);
5825
                        }
5826
                        final = new AdornerFinal(comment);
5827
                        SelectLayer.Children.Add(final);
5828
                    }
5829
                    break;
5830
            }
5831

    
5832
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5833
            {
5834
                i.IsUndo = false;
5835
            });
5836
        }
5837

    
5838
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5839
        {
5840
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5841
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5842
            {
5843
                if (items.UserID == Select_ID)
5844
                {
5845
                    foreach (var item in items.MarkupList)
5846
                    {
5847
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5848
                        {
5849
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5850
                        }
5851
                    }
5852
                }
5853
            }
5854
        }
5855

    
5856
        public void InkControl_Convert()
5857
        {
5858
            if (inkBoard.Strokes.Count > 0)
5859
            {
5860
                inkBoard.Strokes.ToList().ForEach(stroke =>
5861
                {
5862
                    List<Stroke> removingStroke = new List<Stroke>();
5863
                    StrokeCollection stC = new StrokeCollection();
5864
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
5865
                    //{
5866
                    //    removingStroke.Add(inkBoard.Strokes[i]);
5867
                    //}
5868

    
5869
                    removingStroke.Add(stroke);
5870

    
5871
                    InkToPath ip = new InkToPath();
5872
                    List<Point> inkPointSet = new List<Point>();
5873
                    PolygonControl pc = null;
5874
                    //InkControl pc = null;
5875
                    //pc = new InkControl()
5876
                    pc = new PolygonControl()
5877
                    {
5878
                        //PointC = new List<StylusPointSet>(),
5879
                        Angle = 0,
5880
                        PointSet = new List<Point>(),
5881
                        ControlType = ControlType.Ink
5882
                    };
5883
                    foreach (var item in removingStroke)
5884
                    {
5885
                        //pc.PointC.Add(new StylusPointSet() { pointSet = ip.StrokeGetPointsPlus(item) });
5886
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5887
                        inkBoard.Strokes.Remove(item);
5888
                    }
5889
                    if (inkPointSet.Count != 0)
5890
                    {
5891

    
5892
                        //강인구 추가(PenControl Undo Redo 추가)
5893
                        UndoData = new Undo_data()
5894
                        {
5895
                            IsUndo = false,
5896
                            Event = Event_Type.Create,
5897
                            EventTime = DateTime.Now,
5898
                            Markup_List = new List<Multi_Undo_data>()
5899
                        };
5900

    
5901
                        pc.StartPoint = inkPointSet[0];
5902
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5903
                        pc.PointSet = inkPointSet;
5904
                        pc.LineSize = 3;
5905
                        pc.CommentID = Save.shortGuid();
5906
                        //pc.StrokeColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("ff18b7fc"));
5907
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5908
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5909
                        pc.SetPolyPath();
5910

    
5911
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5912
                        {
5913
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
5914
                        });
5915
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
5916
                        UndoData.Markup_List.Add(multi_Undo_Data);
5917
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5918
                    }
5919
                });
5920

    
5921
            }
5922
        }
5923
    }
5924
}
클립보드 이미지 추가 (최대 크기: 500 MB)