프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs.bak @ e907328e

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

1
using Leadtools.Windows.Controls;
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

    
54
            return instance;
55
        }
56
    }
57

    
58
    /// <summary>
59
    /// MainMenu.xaml에 대한 상호 작용 논리
60
    /// </summary>
61
    public partial class MainMenu : UserControl
62
    {
63

    
64
        //public List<Undo_data> UndoDataList { get; set; }
65
        public Undo_data UndoData { get; set; }
66

    
67
        public CommentUserInfo currentControl { get; set; }
68
        public ControlType controlType { get; set; }
69
        private Move move;
70
        private double[] rotateValue = { 0, 90, 180, 270 };
71
        //private OverView overview = new OverView();
72
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
73
        public MouseButton mouseButtonDown { get; set; }
74
        private static readonly double DragThreshold = 5;
75
        private Cursor cursor { get; set; }
76
        private Point canvasDrawingMouseDownPoint;
77
        public string filename { get; set; }
78
        private Point canvasZoomPanningMouseDownPoint;
79
        public Point getCurrentPoint;
80
        private Point canvasZoommovingMouseDownPoint;
81
        private int rotateOffSet = 0;
82
        List<object> ControlList = new List<object>();
83
        private ListBox listBox = new ListBox();
84
        //public ObservableCollection<MarkupInfoItem> _markupInfoList = new ObservableCollection<MarkupInfoItem>();
85
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
86
        private bool isDraggingSelectionRect = false;
87
        DrawingAttributes inkDA = new DrawingAttributes();
88
        private VPRevision CurrentRev { get; set; }
89
        public RadRibbonButton btnConsolidate { get; set; }
90
        public RadRibbonButton btnFinalPDF { get; set; }
91
        public RadRibbonButton btnTeamConsolidate { get; set; }
92
        public string Filename_ { get; set; }
93
        public double L_Size = 0;
94
        public AdornerFinal adorner_;
95
        public Multi_Undo_data multi_Undo_Data;
96
        /// <summary>
97
        /// Set to 'true' when the left mouse-button is down.
98
        /// </summary>
99
        private bool isLeftMouseButtonDownOnWindow = false;
100
        //public int currnetNo = 1;
101

    
102
        public InkPresenter _InkBoard = null;
103
        Stroke stroke;
104
        Boolean IsDrawing = false;
105
        StylusPointCollection strokePoints;
106
        StylusPointCollection erasePoints;
107
        RenderTargetBitmap canvasImage;
108
        Point Sync_Offset_Point;
109

    
110
        //강인구 테스트
111
        private Path _SelectionPath { get; set; }
112
        public Path SelectionPath
113
        {
114
            get
115
            {
116
                return _SelectionPath;
117
            }
118
            set
119
            {
120
                if (_SelectionPath != value)
121
                {
122
                    _SelectionPath = value;
123
                    RaisePropertyChanged("SelectionPath");
124

    
125
                }
126
            }
127
        }
128

    
129
        private RasterImageViewer _imageViewer { get; set; }
130
        public RasterImageViewer imageViewer
131
        {
132
            get
133
            {
134
                if (_imageViewer == null)
135
                {
136
                    _imageViewer = new RasterImageViewer();
137
                    return _imageViewer;
138
                }
139
                else
140
                {
141
                    return _imageViewer;
142
                }
143
            }
144
            set
145
            {
146
                if (_imageViewer != value)
147
                {
148
                    _imageViewer = value;
149
                }
150
            }
151
        }
152

    
153
        public bool IsSyncPDFMode { get; set; }
154

    
155

    
156
        private RasterImageViewer _imageViewer_Compare { get; set; }
157
        public RasterImageViewer imageViewer_Compare
158
        {
159
            get
160
            {
161
                if (_imageViewer_Compare == null)
162
                {
163
                    _imageViewer_Compare = new RasterImageViewer();
164
                    return _imageViewer_Compare;
165
                }
166
                else
167
                {
168
                    return _imageViewer_Compare;
169
                }
170
            }
171
            set
172
            {
173
                if (_imageViewer_Compare != value)
174
                {
175
                    _imageViewer_Compare = value;
176
                }
177
            }
178
        }
179

    
180
        public MainMenu()
181
        {
182
            InitializeComponent();
183
            this.Loaded += MainMenu_Loaded;
184
            //UndoDataList = new List<Undo_data>();
185
        }
186
        private void SetCursor()
187
        {
188
            this.Cursor = cursor;
189
        }
190

    
191
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
192
        {
193
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
194
                             zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
195
                             (_canvasZoomPanningMouseDownPoint.Y > 0 &&
196
                             zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
197
            {
198
                return true;
199
            }
200

    
201
            return false;
202
        }
203

    
204
        public void DeleteItem(MarkupInfoItem item)
205
        {
206
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
207
            {
208
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
209
            }
210

    
211
            ViewerDataModel.Instance._markupInfoList.Remove(item);
212

    
213
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
214
            {
215
                ViewerDataModel.Instance.MarkupControls.Remove(a);
216
            });
217

    
218
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
219
            {
220
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
221
            });
222

    
223
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
224
            {
225
                ComingNewBieEnd = false;
226
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
227
            });
228

    
229
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
230
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
231
            {
232
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
233
                {
234
                    var infoId = Events.Save.shortGuid();
235
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
236
                    {
237
                        CreateTime = DateTime.Now,
238
                        Depatment = userData.DEPARTMENT,
239
                        DisplayColor = "#FFFF0000",
240
                        UserID = userData.ID,
241
                        UserName = userData.NAME,
242
                        PageCount = 1,
243
                        Description = "",
244
                        MarkupInfoID = infoId,
245
                        MarkupList = null,
246
                        MarkupVersionID = Events.Save.shortGuid(),
247
                        Consolidate = 0,
248
                        PartConsolidate = 0,
249
                        userDelete = true,
250
                        AvoidConsolidate = 0,
251
                        IsPreviewUser = true
252
                    };
253
                    App.Custom_ViewInfoId = infoId;
254
                }
255
            }
256
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
257
        }
258

    
259
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
260
        {
261
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
262
            this.ReleaseAdorner();
263

    
264
            Button content = (sender as Button);
265
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
266

    
267
            DeleteItem(item);
268
        }
269
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
270
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
271
        {
272
            if (App.ParameterMode)
273
            {
274
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
275
                imageViewer_Compare = new RasterImageViewer();
276
                zoomAndPanCanvas.Children.Add(imageViewer);
277
                zoomAndPanCanvas2.Children.Add(imageViewer_Compare);
278

    
279
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
280
                ViewerDataModel.Instance.Capture_Opacity = 0;
281
                //ViewerDataModel.Instance.Capture_Opacity = 0.5;
282

    
283
                //testPanel.Visibility = Visibility.Collapsed;
284
                //testPanel2.IsHidden = false;
285
                //testPanel2.Visibility = Visibility.Visible;
286
                //testPanel3.Visibility = Visibility.Collapsed;
287

    
288

    
289
                da.From = 0.8;
290
                da.To = 0;
291
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
292
                da.AutoReverse = true;
293
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
294
            }
295

    
296

    
297
        }
298

    
299
        public void ReleaseAdorner()
300
        {
301
            if (SelectLayer.Children.Count > 0)
302
            {
303
                foreach (var item in SelectLayer.Children)
304
                {
305
                    if (item.GetType().Name == "AdornerFinal")
306
                    {
307
                        (item as AdornerFinal).unRegister();
308

    
309
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
310
                        {
311
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
312
                            {
313
                                //if (InnerItem.DrawingData.GetType().Name == "InkControl")
314
                                if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
315
                                {
316
                                    if((InnerItem.DrawingData as PolygonControl).CommentID == null)
317
                                    {
318
                                        (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
319
                                    }
320

    
321
                                    //(InnerItem.DrawingData as InkControl).CommentID = KCOM.Events.Save.shortGuid();
322

    
323
                                    //List<Stroke> removingStroke = new List<Stroke>();
324
                                    //StrokeCollection stC = new StrokeCollection();
325

    
326

    
327
                                    ////foreach (var P in (InnerItem.DrawingData as InkControl).PointC)
328
                                    ////{
329
                                    ////    StylusPoint segment10End = new StylusPoint();
330
                                    ////    strokePoints.Add(segment10End);
331
                                    ////    inkBoard.Strokes.Add(P);
332
                                    ////}
333

    
334
                                    //stroke = new Stroke(strokePoints);
335
                                    //stroke.DrawingAttributes.Color = Colors.Red;
336
                                    //stroke.DrawingAttributes.Width = 4;
337
                                    //stroke.DrawingAttributes.Height = 4;
338

    
339
                                    //inkBoard.Strokes.Add(stroke);
340

    
341
                                }
342

    
343
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
344
                            }
345
                        }
346
                    }
347
                }
348
                SelectLayer.Children.Clear();
349
            }
350
        }
351

    
352
        public List<CommentUserInfo> AddAdorner()
353
        {
354
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
355

    
356
            if (SelectLayer.Children.Count > 0)
357
            {
358
                foreach (var item in SelectLayer.Children)
359
                {
360
                    if (item.GetType().Name == "AdornerFinal")
361
                    {
362
                        (item as AdornerFinal).unRegister();
363

    
364
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
365
                        {
366
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
367
                            {
368
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
369
                            }
370

    
371
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
372

    
373
                            UndoData.Markup_List.Add(multi_Undo_Data);
374
                            multi_Undo_Data = new Multi_Undo_data();
375
                        }
376
                    }
377
                }
378
                SelectLayer.Children.Clear();
379
            }
380
            return adornerSet;
381
        }
382

    
383
        public void ChangeCommentReact()
384
        {
385
            bool isComingNewBie = false;
386
            //if (PreviewUserMarkupInfoItem != null) // 신규 임시 저장인 경우
387
            //{
388

    
389
            //}
390
            //else //기존 게시물에 추가하는 경우
391
            //{
392

    
393
            //}
394

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

    
439

    
440
            //if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
441
            //{
442
            //    foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
443
            //    {
444
            //        var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
445
            //        var existItem = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.ID == root.CommentID).FirstOrDefault();
446
            //        if (existItem != null) //신규 추가 된 코멘트
447
            //        {
448
            //            if (existItem.Data != root.ConvertData) //코멘트가 같은지
449
            //            {
450
            //                existItem.Data = root.ConvertData;
451
            //                existItem.IsUpdate = true;
452
            //            }
453
            //        }
454
            //        else //신규 코멘트
455
            //        {
456
            //            if (root.CommentID != null)
457
            //            {
458
            //                isComingNewBie = true;
459
            //                var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
460
            //                if (currentCommentCheck!=null)
461
            //                {
462
            //                    currentCommentCheck.Data = root.ConvertData;
463
            //                }
464
            //                else
465
            //                {
466
            //                    ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
467
            //                    {
468
            //                        ID = control.CommentID,
469
            //                        Data = root.ConvertData,
470
            //                        Data_Type = root.DATA_TYPE,
471
            //                        MarkupInfoID = App.Custom_ViewInfoId,
472
            //                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
473
            //                    });
474
            //                }
475
            //            }
476

    
477
            //        }
478
            //    }
479

    
480
            //}
481

    
482
            //if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
483
            if (PreviewUserMarkupInfoItem != null && isComingNewBie)
484
            {
485
                if (PreviewUserMarkupInfoItem.MarkupList == null)
486
                {
487
                    PreviewUserMarkupInfoItem.MarkupList = new List<MarkupItem>();
488
                }
489
                foreach (var item in ViewerDataModel.Instance.MarkupList_USER)
490
                {
491
                    PreviewUserMarkupInfoItem.MarkupList.Add(item);
492
                }
493
                if(!ComingNewBieEnd)
494
                {
495
                    ComingNewBieEnd = true;
496
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
497
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
498
                    gridViewMarkup.ItemsSource = null;
499
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
500
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
501
                }
502
            }
503
        }
504

    
505
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
506
        bool ComingNewBieEnd = false;
507

    
508
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
509
        {
510
            ViewerDataModel.Instance.UndoDataList.Clear();
511

    
512
            InkControl_Convert();
513

    
514
            ReleaseAdorner();
515
            ChangeCommentReact();
516
            CompareMode.IsChecked = false;
517
            //if (ViewerDataModel.Instance.PageBalanceMode)
518
            //{
519
            //    //ViewerDataModel.Instance.PageBalanceNumber = e.PageNumber + (ViewerDataModel.Instance.PageBalanceNumber - e.PageNumber);
520
            //    //ViewerDataModel.Instance.PageBalanceNumber = e.CurrentPage.PAGE_NUMBER;
521
            //}
522
            //else
523
            //{
524
            //    //ViewerDataModel.Instance.PageBalanceNumber = e.PageNumber + (ViewerDataModel.Instance.PageBalanceNumber - e.PageNumber);
525
            //    ViewerDataModel.Instance.PageBalanceNumber = e.CurrentPage.PAGE_NUMBER;
526
            //}
527

    
528

    
529

    
530
            using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
531
            {
532

    
533
                //var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber - 1 : e.PageNumber;
534
                var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
535

    
536

    
537
                #region 페이지가 벗어난 경우
538

    
539
                if (BalancePoint < 1)
540
                {
541
                    BalancePoint = 1;
542
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
543
                }
544

    
545
                if (pageNavigator.PageCount < BalancePoint)
546
                {
547
                    BalancePoint = pageNavigator.PageCount;
548
                    ViewerDataModel.Instance.PageBalanceNumber = 0;
549
                }
550

    
551
                #endregion
552

    
553
                ViewerDataModel.Instance.PageNumber = BalancePoint;
554

    
555

    
556

    
557
                //if(!ViewerDataModel.Instance.PageBalanceMode)
558
                //{ 
559
                //    ViewerDataModel.Instance.PageNumber = e.PageNumber;
560
                //}
561

    
562
                //zoomAndPanControl.ScaleToFit();
563
                //var uri = String.Format(@"http://www.honeyhead.net/Pages/{0}/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
564
                //imageViewer.Image = codecs.Load(uri, 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
565

    
566
                var uri = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
567
                imageViewer.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
568

    
569
                zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
570
                zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
571

    
572

    
573
                Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
574
                Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
575
                //inkDrawingCanvas.Width = zoomAndPanCanvas.Width;
576
                //inkDrawingCanvas.Height = zoomAndPanCanvas.Height;
577
                inkBoard.Width = zoomAndPanCanvas.Width;
578
                inkBoard.Height = zoomAndPanCanvas.Height;
579

    
580

    
581
                if (!testPanel2.IsHidden)
582
                {
583
                    //ViewerDataModel.Instance.PageBalanceNumber = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + (ViewerDataModel.Instance.PageBalanceNumber - e.PageNumber) : e.PageNumber;
584

    
585
                    if (IsSyncPDFMode)
586
                    {
587
                        Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(CurrentRev.TO_VENDOR));
588

    
589
                        var image = dpc.GetPageImage(codecs, BalancePoint);
590
                        Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
591
                        size.Run(image);
592
                        image.XResolution = 150;
593
                        image.YResolution = 150;
594
                        imageViewer_Compare.Image = image;
595
                    }
596
                    else
597
                    {
598
                        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);
599
                        imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri2), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
600

    
601
                        zoomAndPanCanvas2.Width = imageViewer_Compare.Image.Width;
602
                        zoomAndPanCanvas2.Height = imageViewer_Compare.Image.Height;
603
                    }
604
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
605
                }
606

    
607
                this.pageNavigator.SetNextPage();
608

    
609
                //강인구 수정
610
                if (!zoomAndPanCanvas2.Width.IsNaN())
611
                {
612
                    zoomAndPanControl2.ZoomTo(new Rect
613
                    {
614
                        X = 0,
615
                        Y = 0,
616
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
617
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
618
                    });
619
                }
620
                else
621
                {
622
                    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
623
                }
624

    
625
                Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
626
                Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
627

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

    
647

    
648
                if (!testPanel2.IsHidden)
649
                {
650
                    Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
651
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
652

    
653

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

    
662
                }
663

    
664

    
665

    
666
                var instanceMain = this.ParentOfType<MainWindow>();
667
                instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
668

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

    
674
            }
675
            SetCommentPages(true);
676
        }
677

    
678
        private void SetCommentPages(bool onlyMe = false)
679
        {
680

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

    
704
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
705
        {
706
            if (e.MiddleButton == MouseButtonState.Pressed)
707
            {
708

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

    
723
        #region ZoomIn & ZoomOut
724

    
725
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
726
        {
727
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
728
                zoomAndPanControl.ContentZoomFocusY));
729
        }
730

    
731
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
732
        {
733
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
734
                zoomAndPanControl.ContentZoomFocusY));
735
        }
736

    
737

    
738
        //강인구 추가 (줌 인아웃 수치 변경)
739
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
740
        private void ZoomOut(Point contentZoomCenter)
741
        {
742
            if (zoomAndPanControl.ContentScale > 0.39)
743
            {
744
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
745
            }
746
            else
747
            {
748
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
749
            }
750

    
751
            if (zoomAndPanControl2 != null)
752
            {
753
                if (zoomAndPanControl2.ContentScale > 0.39)
754
                {
755
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
756
                }
757
                else
758
                {
759
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
760
                }
761
            }
762
        }
763

    
764
        private void ZoomIn(Point contentZoomCenter)
765
        {
766
            if (zoomAndPanControl.ContentScale > 0.19)
767
            {
768
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
769
            }
770
            else
771
            {
772
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
773
            }
774

    
775
            if (zoomAndPanControl2 != null)
776
            {
777
                if (zoomAndPanControl2.ContentScale > 0.19)
778
                {
779
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
780
                }
781
                else
782
                {
783
                    zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
784
                }
785
            }
786
        }
787

    
788
        private void ZoomOut()
789
        {
790
            zoomAndPanControl.ContentScale -= 0.1;
791
            //if (zoomAndPanControl2 != null)
792
            //{
793
            //    zoomAndPanControl2.ContentScale -= 0.1;
794
            //}
795
        }
796

    
797
        private void ZoomIn()
798
        {
799
            zoomAndPanControl.ContentScale += 0.1;
800
            //if (zoomAndPanControl2 != null)
801
            //{
802
            //    zoomAndPanControl2.ContentScale += 0.1;
803
            //}
804
        }
805

    
806
        #endregion
807

    
808

    
809
        private void init()
810
        {
811
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
812
            {
813

    
814
                ControlList.Clear();
815
                listBox.Items.Clear();
816
                selected_item.Clear();
817

    
818
                (item as IMarkupCommonData).IsSelected = false;
819
            }
820

    
821
        }
822

    
823
        private HitTestResultBehavior MyCallback(HitTestResult result)
824
        {
825
            //this.cursor = Cursors.UpArrow;
826
            var element = result.VisualHit;
827
            while (element != null && !(element is CommentUserInfo))
828
                element = VisualTreeHelper.GetParent(element);
829

    
830
            if (element == null)
831
            {
832
                return HitTestResultBehavior.Stop;
833
            }
834
            else
835
            {
836
                if (element is CommentUserInfo)
837
                {
838
                    if (!hitList.Contains(element))
839
                    {
840
                        hitList.Add((CommentUserInfo)element);
841
                    }
842
                    else
843
                    {
844
                        return HitTestResultBehavior.Stop;
845
                    }
846
                    //IntersectionDetail intersectionDetail =
847
                    //((GeometryHitTestResult)result).IntersectionDetail;
848
                    //switch (intersectionDetail)
849
                    //{
850
                    //    case IntersectionDetail.FullyContains:
851
                    //        // Add the hit test result to the list:
852
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
853
                    //        return HitTestResultBehavior.Continue;
854
                    //    case IntersectionDetail.Intersects:
855
                    //        // Set the behavior to return visuals at all z-order levels:
856
                    //        return HitTestResultBehavior.Continue;
857
                    //    case IntersectionDetail.FullyInside:
858
                    //        // Set the behavior to return visuals at all z-order levels:
859
                    //        return HitTestResultBehavior.Continue;
860
                    //    default:
861
                    //        return HitTestResultBehavior.Stop;
862
                    //}
863
                }
864
            }
865
            return HitTestResultBehavior.Continue;
866
        }
867

    
868
        public void ReleaseSelectPath()
869
        {
870
            if (SelectionPath == null)
871
            {
872
                SelectionPath = new Path();
873
                SelectionPath.Name = "";
874
            }
875
            if (SelectionPath.Name != "")
876
            {
877
                SelectionPath.Name = "None";
878
            }
879
            SelectionPath.Opacity = 0.01;
880
            SelectionPath.RenderTransform = null;
881
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
882
        }
883

    
884
        #region 컨트롤 초기화 
885
        public void Control_Init(object control)
886
        {
887
            if (L_Size != 0 && (control as IPath) != null)
888
            {
889
                (control as IPath).LineSize = L_Size;
890
                L_Size = 0;
891
            }
892

    
893
            switch (control.GetType().Name)
894
            {
895
                case "RectangleControl":
896
                    {
897
                        (control as RectangleControl).StrokeColor = Brushes.Red;
898
                    }
899
                    break;
900
                case "CircleControl":
901
                    {
902
                        (control as CircleControl).StrokeColor = Brushes.Red;
903
                    }
904
                    break;
905
                case "TriControl":
906
                    {
907
                        (control as TriControl).StrokeColor = Brushes.Red;
908
                    }
909
                    break;
910
                case "RectCloudControl":
911
                    {
912
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
913
                    }
914
                    break;
915
                case "CloudControl":
916
                    {
917
                        (control as CloudControl).StrokeColor = Brushes.Red;
918
                    }
919
                    break;
920
                case "PolygonControl":
921
                    {
922
                        (control as PolygonControl).StrokeColor = Brushes.Red;
923
                    }
924
                    break;
925
                case "ArcControl":
926
                    {
927
                        (control as ArcControl).StrokeColor = Brushes.Red;
928
                    }
929
                    break;
930
                case "LineControl":
931
                    {
932
                        (control as LineControl).StrokeColor = Brushes.Red;
933
                    }
934
                    break;
935
                case "ArrowControl_Multi":
936
                    {
937
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
938
                    }
939
                    break;
940
                case "TextControl":
941
                    {
942
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
943
                    }
944
                    break;
945
                case "ArrowTextControl":
946
                    {
947
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
948
                    }
949
                    break;
950
            }
951
        }
952
        #endregion
953

    
954
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
955
        {
956
            //Control_Init(e.Source);
957
        }
958

    
959
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
960
        {
961
            if(Common.ViewerDataModel.Instance.SelectedControl == "Batch")
962
            {
963
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
964

    
965
                Point currentPos = e.GetPosition(rect);
966

    
967
                floatingTip.HorizontalOffset = currentPos.X + 20;
968
                floatingTip.VerticalOffset = currentPos.Y;
969

    
970

    
971
                //ToolTip tool = new System.Windows.Controls.ToolTip();
972
                //tool.Content = "ToolTip";
973
                //panel.ToolTip = tool;
974
            }
975

    
976
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
977
            {
978
                #region 마우스 오버 시 색상 변경
979
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
980
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
981

    
982
                //if (firstCondition != null)
983
                //{
984
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
985

    
986
                //    if (firstCondition.GetType().Name == "TextControl")
987
                //    {
988
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
989
                //        return;
990
                //    }
991
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
992
                //    {
993
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
994
                //        return;
995
                //    }
996

    
997
                //    if (L_Size == 0)
998
                //    {
999
                //        L_Size = (firstCondition as IPath).LineSize;
1000
                //        (firstCondition as IPath).LineSize *= 4;
1001
                //    }
1002
                //    switch (firstCondition.GetType().Name)
1003
                //    {
1004
                //        case "RectangleControl":
1005
                //            {
1006
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1007
                //            }
1008
                //            break;
1009
                //        case "CircleControl":
1010
                //            {
1011
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1012
                //            }
1013
                //            break;
1014
                //        case "TriControl":
1015
                //            {
1016
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1017
                //            }
1018
                //            break;
1019
                //        case "RectCloudControl":
1020
                //            {
1021
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1022
                //            }
1023
                //            break;
1024
                //        case "CloudControl":
1025
                //            {
1026
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1027
                //            }
1028
                //            break;
1029
                //        case "PolygonControl":
1030
                //            {
1031
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1032
                //            }
1033
                //            break;
1034
                //        case "ArcControl":
1035
                //            {
1036
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1037
                //            }
1038
                //            break;
1039
                //        case "LineControl":
1040
                //            {
1041
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1042
                //            }
1043
                //            break;
1044
                //        case "ArrowControl_Multi":
1045
                //            {
1046
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1047
                //            }
1048
                //            break;
1049

    
1050
                //        default:
1051
                //            {
1052

    
1053
                //            }
1054
                //            break;
1055
                //    }
1056
                //} 
1057
                #endregion
1058
            }
1059

    
1060
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1061

    
1062
            if (mouseButtonDown == MouseButton.Middle)
1063
            {
1064
                SetCursor();
1065
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1066
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1067

    
1068
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1069

    
1070
                zoomAndPanControl.ContentOffsetX += 1;
1071
                zoomAndPanControl.ContentOffsetY += 1;
1072

    
1073
                //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1074
                //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1075
            }
1076

    
1077
            if (mouseButtonDown == MouseButton.Right)
1078
            {
1079
                SetCursor();
1080
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1081
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1082

    
1083
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1084
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1085
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1086

    
1087
            }
1088
            //else if (currentControl != null && mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1089
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1090
            {
1091
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1092
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1093
                SetCursor();
1094

    
1095
                if (IsDrawing)
1096
                {
1097
                    if (currentControl == null)
1098
                    {
1099
                        switch (controlType)
1100
                        {
1101
                            case ControlType.PenControl:
1102
                                {
1103
                                    if (inkBoard.Tag.ToString() == "Ink")
1104
                                    {
1105
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1106
                                    }
1107
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1108
                                    {
1109
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1110
                                    }
1111
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1112
                                    {
1113
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1114
                                    }
1115

    
1116
                                    //inkBoard.Strokes.Add(stroke);
1117
                                }
1118
                                break;
1119
                        }
1120
                        return;
1121
                    }
1122
                }
1123

    
1124
                if (currentControl != null)
1125
                {
1126
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1127
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1128
                    //강인구 추가
1129
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1130

    
1131
                    if ((currentControl as IPath) != null)
1132
                    {
1133
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1134
                    }
1135
                    if ((currentControl as IShapeControl) != null)
1136
                    {
1137
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1138
                    }
1139
                    if ((currentControl as TextControl) != null)
1140
                    {
1141
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1142
                        {
1143
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1144
                        }
1145
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1146
                        {
1147
                            (currentControl as TextControl).TextWeight = FontWeights.Heavy;
1148
                        }
1149
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1150
                        {
1151
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1152
                        }
1153
                    }
1154
                    else if ((currentControl as ArrowTextControl) != null)
1155
                    {
1156
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1157
                        {
1158
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1159
                        }
1160
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1161
                        {
1162
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Heavy;
1163
                        }
1164
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1165
                        {
1166
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1167
                        }
1168
                    }
1169

    
1170
                    switch (controlType)
1171
                    {
1172
                        case ControlType.Rectangle:
1173
                            {
1174
                                var control = currentControl as RectangleControl;
1175

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

    
1189

    
1190
                                        //control.PointSet = new List<Point>
1191
                                        //{
1192
                                        //    control.StartPoint,
1193
                                        //    control.LeftBottomPoint,
1194
                                        //    control.EndPoint,
1195
                                        //    control.TopRightPoint,
1196
                                        //};
1197
                                        control.PointSet = new List<Point>
1198
                                        {
1199
                                            new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
1200
                                            new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y),
1201
                                            new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y),
1202
                                            new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y),
1203
                                        };
1204
                                        control.updateControl();
1205
                                    }
1206

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

    
1215
                        case ControlType.RectCloud:
1216
                            {
1217
                                var control = currentControl as RectCloudControl;
1218

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

    
1232
                                        control.PointSet = new List<Point>
1233
                                        {
1234
                                            control.StartPoint,
1235
                                            control.LeftBottomPoint,
1236
                                            control.EndPoint,
1237
                                            control.TopRightPoint,
1238
                                        };
1239
                                    }
1240
                                    //강인구 추가
1241
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1242
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1243
                                }
1244
                            }
1245
                            break;
1246

    
1247
                        case ControlType.SingleLine:
1248
                            {
1249
                                if (currentControl != null)
1250
                                {
1251
                                    var control = currentControl as LineControl;
1252
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1253
                                    control.ControlType = controlType;
1254
                                    if (control != null)
1255
                                    {
1256
                                        if (move.mousemode == MouseMode.Drawing)
1257
                                        {
1258
                                            //move.control_Move(ControlList, true, moveX, moveY);
1259
                                        }
1260
                                        else
1261
                                        {
1262
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1263
                                            {
1264
                                                control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1265
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1266

    
1267
                                                Point tempPoint = control.EndPoint;
1268
                                                var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1269
                                                control.EndPoint = tempPoint;
1270
                                            }
1271
                                            else
1272
                                            {
1273
                                                control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1274
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1275
                                            }
1276

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

    
1288
                            }
1289
                            break;
1290

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

    
1304
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1305
                                        {
1306
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1307
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1308

    
1309
                                            Point tempPoint = control.EndPoint;
1310
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1311
                                            control.EndPoint = tempPoint;
1312
                                        }
1313
                                        else
1314
                                        {
1315
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1316
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1317
                                        }
1318

    
1319

    
1320
                                        control.PointSet = new List<Point>
1321
                                            {
1322
                                                control.StartPoint,
1323
                                                control.EndPoint,
1324
                                            };
1325
                                    }
1326
                                    //강인구 추가
1327
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1328
                                }
1329
                            }
1330
                            break;
1331

    
1332
                        case ControlType.ArrowLine:
1333
                            {
1334
                                if (currentControl != null)
1335
                                {
1336
                                    var control = currentControl as LineControl;
1337
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1338
                                    control.ControlType = controlType;
1339
                                    if (control != null)
1340
                                    {
1341
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1342

    
1343
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1344

    
1345
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1346
                                        {
1347
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1348
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1349

    
1350
                                            Point tempPoint = control.EndPoint;
1351
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1352
                                            control.EndPoint = tempPoint;
1353
                                        }
1354
                                        else
1355
                                        {
1356
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1357
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1358
                                        }
1359

    
1360

    
1361
                                        control.PointSet = new List<Point>
1362
                                            {
1363
                                                control.StartPoint,
1364
                                                control.EndPoint,
1365
                                            };
1366
                                    }
1367
                                    //강인구 추가
1368
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1369
                                }
1370

    
1371
                            }
1372
                            break;
1373

    
1374
                        case ControlType.TwinLine:
1375
                            {
1376
                                if (currentControl != null)
1377
                                {
1378
                                    var control = currentControl as LineControl;
1379
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1380
                                    control.ControlType = controlType;
1381
                                    if (control != null)
1382
                                    {
1383
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1384

    
1385
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1386

    
1387
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1388
                                        {
1389
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1390
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1391

    
1392
                                            Point tempPoint = control.EndPoint;
1393
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1394
                                            control.EndPoint = tempPoint;
1395
                                        }
1396
                                        else
1397
                                        {
1398
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1399
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1400
                                        }
1401

    
1402

    
1403
                                        control.PointSet = new List<Point>
1404
                                            {
1405
                                                control.StartPoint,
1406
                                                control.EndPoint,
1407
                                            };
1408
                                    }
1409
                                    //강인구 추가
1410
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1411
                                }
1412

    
1413
                            }
1414
                            break;
1415

    
1416
                        case ControlType.DimLine:
1417
                            {
1418
                                if (currentControl != null)
1419
                                {
1420
                                    var control = currentControl as LineControl;
1421
                                    control.LineStyleSet = LineStyleSet.DimLine;
1422
                                    control.ControlType = controlType;
1423
                                    if (control != null)
1424
                                    {
1425
                                        //control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1426

    
1427
                                        //control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1428

    
1429
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1430
                                        {
1431
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1432
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1433

    
1434
                                            Point tempPoint = control.EndPoint;
1435
                                            var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1436
                                            control.EndPoint = tempPoint;
1437
                                        }
1438
                                        else
1439
                                        {
1440
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1441
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1442
                                        }
1443

    
1444

    
1445
                                        control.PointSet = new List<Point>
1446
                                            {
1447
                                                control.StartPoint,
1448
                                                control.EndPoint,
1449
                                            };
1450
                                    }
1451
                                    //강인구 추가
1452
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1453
                                }
1454

    
1455
                            }
1456
                            break;
1457

    
1458
                        case ControlType.ChainLine:
1459
                            {
1460
                                var control = currentControl as PolygonControl;
1461

    
1462
                                if (control != null)
1463
                                {
1464
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1465
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1466
                                    control.SetPolyPath();
1467
                                    //movePoint.X = currentCanvasDrawingMouseMovePoint.X;
1468
                                    //movePoint.Y = currentCanvasDrawingMouseMovePoint.Y;
1469
                                    //control.PointC.pointSet.Add(new Point(currentCanvasDrawingMouseMovePoint.X,currentCanvasDrawingMouseMovePoint.Y));
1470

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

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

    
1485
                                    if (control != null)
1486
                                    {
1487
                                        if (move.mousemode == MouseMode.Drawing)
1488
                                        {
1489
                                            //move.control_Move(ControlList, false, moveX, moveY);
1490
                                        }
1491
                                        else
1492
                                        {
1493
                                            control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1494
                                            control.MidPoint = new Point(0, 0);
1495
                                            control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1496
                                        }
1497

    
1498

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

    
1510
                            }
1511
                            break;
1512

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

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

    
1534

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

    
1546
                            }
1547
                            break;
1548

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

    
1555
                                    if (control != null)
1556
                                    {
1557
                                        if (control.MiddlePoint == new Point(0, 0))
1558
                                        {
1559
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1560
                                            {
1561
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1562
                                                Point tempPoint = control.EndPoint;
1563
                                                var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1564
                                                control.EndPoint = tempPoint;
1565
                                            }
1566
                                            else
1567
                                            {
1568
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1569
                                            }
1570

    
1571

    
1572
                                        }
1573
                                        else
1574
                                        {
1575
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1576
                                            {
1577
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1578
                                                Point tempPoint = control.EndPoint;
1579
                                                var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1580
                                                control.EndPoint = tempPoint;
1581
                                            }
1582
                                            else
1583
                                            {
1584
                                                control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1585
                                            }
1586

    
1587
                                        }
1588

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

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

    
1601
                            }
1602
                            break;
1603

    
1604
                        case ControlType.Circle:
1605
                            {
1606
                                var control = currentControl as CircleControl;
1607

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

    
1621
                                        control.PointSet = new List<Point>
1622
                                        {
1623
                                            control.StartPoint,
1624
                                            control.LeftBottomPoint,
1625
                                            control.EndPoint,
1626
                                            control.TopRightPoint,
1627
                                        };
1628
                                    }
1629
                                    //강인구 추가
1630
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1631
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1632

    
1633
                                }
1634
                            }
1635
                            break;
1636

    
1637
                        case ControlType.PolygonCloud:
1638
                            {
1639
                                var control = currentControl as CloudControl;
1640

    
1641
                                if (control != null)
1642
                                {
1643
                                    control.isTransOn = true;
1644
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1645

    
1646
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1647

    
1648
                                    control.SetCloud();
1649
                                    //강인구 추가
1650
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1651
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1652
                                }
1653
                            }
1654
                            break;
1655

    
1656
                        case ControlType.Triangle:
1657
                            {
1658
                                var control = currentControl as TriControl;
1659

    
1660
                                if (control != null)
1661
                                {
1662
                                    if (move.mousemode == MouseMode.Drawing)
1663
                                    {
1664
                                        //move.control_Move(ControlList, true, moveX, moveY);
1665
                                    }
1666
                                    else
1667
                                    {
1668
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1669
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1670

    
1671
                                        control.PointSet = new List<Point>
1672
                                            {
1673
                                                control.StartPoint,
1674
                                                control.MidPoint,
1675
                                                control.EndPoint,
1676
                                            };
1677
                                    }
1678
                                    //강인구 추가
1679
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1680
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1681
                                }
1682
                            }
1683
                            break;
1684

    
1685
                        case ControlType.ImgControl:
1686
                            {
1687
                                var control = currentControl as ImgControl;
1688

    
1689
                                if (control != null)
1690
                                {
1691
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1692
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1693
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1694
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1695

    
1696
                                    control.PointSet = new List<Point>
1697
                                        {
1698
                                            control.StartPoint,
1699
                                            control.LeftBottomPoint,
1700
                                            control.EndPoint,
1701
                                            control.TopRightPoint,
1702
                                        };
1703
                                }
1704
                            }
1705
                            break;
1706

    
1707
                        case ControlType.Date:
1708
                            {
1709
                                var control = currentControl as DateControl;
1710

    
1711
                                if (control != null)
1712
                                {
1713
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1714
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1715
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1716
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1717
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1718

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

    
1730
                        case ControlType.ArrowTextControl:
1731
                            {
1732
                                var control = currentControl as ArrowTextControl;
1733

    
1734
                                if (control != null)
1735
                                {
1736
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1737

    
1738
                                    control.PointSet = new List<Point>
1739
                                            {
1740
                                                control.StartPoint,
1741
                                                control.MidPoint,
1742
                                                control.EndPoint,
1743
                                            };
1744
                                }
1745

    
1746
                            }
1747
                            break;
1748

    
1749
                        case ControlType.ArrowTransTextControl:
1750
                            {
1751
                                var control = currentControl as ArrowTextControl;
1752

    
1753
                                if (control != null)
1754
                                {
1755
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1756
                                    control.isFixed = true;
1757

    
1758
                                    control.PointSet = new List<Point>
1759
                                            {
1760
                                                control.StartPoint,
1761
                                                control.MidPoint,
1762
                                                control.EndPoint,
1763
                                            };
1764
                                }
1765
                            }
1766
                            break;
1767

    
1768
                        case ControlType.ArrowTextBorderControl:
1769
                            {
1770
                                var control = currentControl as ArrowTextControl;
1771

    
1772
                                if (control != null)
1773
                                {
1774
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1775
                                    control.PointSet = new List<Point>
1776
                                            {
1777
                                                control.StartPoint,
1778
                                                control.MidPoint,
1779
                                                control.EndPoint,
1780
                                            };
1781
                                }
1782

    
1783
                            }
1784
                            break;
1785
                        case ControlType.ArrowTransTextBorderControl:
1786
                            {
1787
                                var control = currentControl as ArrowTextControl;
1788

    
1789
                                if (control != null)
1790
                                {
1791
                                    control.isFixed = true;
1792
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1793
                                    control.PointSet = new List<Point>
1794
                                            {
1795
                                                control.StartPoint,
1796
                                                control.MidPoint,
1797
                                                control.EndPoint,
1798
                                            };
1799
                                }
1800

    
1801
                            }
1802
                            break;
1803
                        case ControlType.ArrowTextCloudControl:
1804
                            {
1805
                                var control = currentControl as ArrowTextControl;
1806

    
1807
                                if (control != null)
1808
                                {
1809
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1810
                                    control.PointSet = new List<Point>
1811
                                            {
1812
                                                control.StartPoint,
1813
                                                control.MidPoint,
1814
                                                control.EndPoint,
1815
                                            };
1816
                                }
1817

    
1818
                            }
1819
                            break;
1820
                        case ControlType.ArrowTransTextCloudControl:
1821
                            {
1822
                                var control = currentControl as ArrowTextControl;
1823

    
1824
                                if (control != null)
1825
                                {
1826
                                    control.isFixed = true;
1827
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1828
                                    control.PointSet = new List<Point>
1829
                                            {
1830
                                                control.StartPoint,
1831
                                                control.MidPoint,
1832
                                                control.EndPoint,
1833
                                            };
1834
                                }
1835

    
1836
                            }
1837
                            break;
1838
                        case ControlType.PolygonControl:
1839
                            {
1840
                                var control = currentControl as PolygonControl;
1841

    
1842
                                if (control != null)
1843
                                {
1844
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1845
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1846
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1847
                                    control.SetPolyPath();
1848
                                    //강인구 추가
1849
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1850
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1851
                                }
1852
                            }
1853
                            break;
1854
                        //강인구 추가
1855
                        case ControlType.Sign:
1856
                            {
1857
                                var control = currentControl as SignControl;
1858

    
1859
                                if (control != null)
1860
                                {
1861
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1862
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1863
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1864
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1865

    
1866
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
1867
                                    {
1868
                                        GetUserSign getUser = new GetUserSign();
1869
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
1870
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
1871
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
1872
                                        stream.Write(imageBytes, 0, imageBytes.Length);
1873
                                        stream.Position = 0;
1874
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
1875
                                        BitmapImage returnImage = new BitmapImage();
1876
                                        returnImage.BeginInit();
1877
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
1878
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
1879
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
1880
                                        returnImage.StreamSource = ms;
1881
                                        returnImage.EndInit();
1882
                                        stream.Close();
1883

    
1884
                                        control.SignImage = returnImage;
1885
                                    }
1886
                                    control.PointSet = new List<Point>
1887
                                        {
1888
                                            control.StartPoint,
1889
                                            control.LeftBottomPoint,
1890
                                            control.EndPoint,
1891
                                            control.TopRightPoint,
1892
                                        };
1893
                                }
1894
                            }
1895
                            break;
1896
                        //강인구 추가
1897
                        case ControlType.Symbol:
1898
                            {
1899
                                var control = currentControl as SymControl;
1900

    
1901
                                if (control != null)
1902
                                {
1903
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1904
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1905
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1906
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1907
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1908
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
1909

    
1910
                                    if (control.StartPoint != control.EndPoint)
1911
                                    {
1912
                                        if (control.PathData == null)
1913
                                        {
1914
                                            using (StringToPathConverter Convert = new StringToPathConverter())
1915
                                            {
1916
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
1917
                                            }
1918
                                        }
1919
                                    }
1920

    
1921
                                    control.PointSet = new List<Point>
1922
                                        {
1923
                                            control.StartPoint,
1924
                                            control.LeftBottomPoint,
1925
                                            control.EndPoint,
1926
                                            control.TopRightPoint,
1927
                                        };
1928
                                }
1929
                            }
1930
                            break;
1931
                        case ControlType.Stamp:
1932
                            {
1933
                                var control = currentControl as SymControlN;
1934

    
1935
                                if (control != null)
1936
                                {
1937

    
1938
                                    if (control.StartPoint == control.EndPoint)
1939
                                    {
1940
                                        string appovalData = "eJyycS/KTFHwS8xNtVVKBAMlhYrcnLxiW6WMkpICK3394uSM1NzEYr3czOSi/OL8tBK95Pxc/fLMvLQKfSMDAzP9isTcHP2CotTi1LySxJLM/DwlOxuQqXpOicnZ6UX5pXkpdjbB+TmZKc75OflFTkWlxRkKYKatkrIbFCgp+BckJmeWVNoqGegZKino29noYxgSlJpckpiXnpOqEFxSlFqSnGGr5JaZk6ME4uZnp0KNMwACmFBIRmZydl5qMdA7pjAxn8y8VK/8zDxbpSCQsUpQ38MNV1IIz0wpAZptZADU45GamZ5RYqtkYamk4JyYVwYMCZ/UNKCArpGeKVwoJL8AJqIP8T00DILyy11S0zLzMkEBUwz0AjIfbrgWWBt2OWM9U3zSBviljfBJaiGFM7pDQ1IrSpxy8pOzFUAsWyXHgIAg/zBXFyUFt/y8knCoCa4VJUWJTvk5KRDh4MwqYEgaG4B4RamQaEOJFY/8oswqoMLEHMeczPS8XGCSsVVyBpKpRUoKYalFJZnJWKVgTrRVgqQNdNc5VSqkJKbmZOYS4TwjWjrPGBGkMAoAAAD//w==";
1941

    
1942
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(appovalData);
1943
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
1944
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
1945

    
1946
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
1947
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
1948
                                        writer.Write(xamlData);
1949
                                        writer.Flush();
1950
                                        stream.Position = 0;
1951

    
1952
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
1953
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
1954
                                        UIElement ob = obj as UIElement;
1955

    
1956
                                        //control.ApplyTemplate();
1957

    
1958
                                        control.SetViewBox();
1959
                                        control.PathXathData = appovalData;
1960
                                        control.Base_ViewBox.Child = ob;
1961
                                    }
1962

    
1963
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1964
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1965
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1966
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1967
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
1968

    
1969

    
1970
                                    control.PointSet = new List<Point>
1971
                                    {
1972
                                        control.StartPoint,
1973
                                        control.LeftBottomPoint,
1974
                                        control.EndPoint,
1975
                                        control.TopRightPoint,
1976
                                    };
1977
                                }
1978
                            }
1979
                            break;
1980
                        case ControlType.Mark:
1981
                            {
1982
                                var control = currentControl as RectangleControl;
1983

    
1984
                                if (control != null)
1985
                                {
1986
                                    if (move.mousemode == MouseMode.Drawing)
1987
                                    {
1988
                                        //move.control_Move(ControlList, true, moveX, moveY);
1989
                                    }
1990
                                    else
1991
                                    {
1992
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1993
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1994
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1995
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1996

    
1997

    
1998
                                        control.PointSet = new List<Point>
1999
                                    {
2000
                                        control.StartPoint,
2001
                                        control.LeftBottomPoint,
2002
                                        control.EndPoint,
2003
                                        control.TopRightPoint,
2004
                                    };
2005
                                    }
2006

    
2007
                                    //강인구 추가
2008
                                    control.Paint = PaintSet.Fill;
2009
                                }
2010
                            }
2011
                            break;
2012
                        case ControlType.PenControl:
2013
                            {
2014
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2015
                                //inkBoard.Strokes.Add(stroke);
2016
                            }
2017
                            break;
2018
                        default:
2019
                            break;
2020
                    }
2021
                }
2022
            }
2023
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture)
2024
            {
2025
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2026

    
2027
                if (isDraggingSelectionRect)
2028
                {
2029
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2030

    
2031
                    e.Handled = true;
2032
                }
2033
                else if (isLeftMouseButtonDownOnWindow)
2034
                {
2035
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2036
                    double dragDistance = Math.Abs(dragDelta.Length);
2037

    
2038
                    if (dragDistance > DragThreshold)
2039
                    {
2040
                        isDraggingSelectionRect = true;
2041

    
2042
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2043
                    }
2044

    
2045
                    e.Handled = true;
2046
                }
2047

    
2048

    
2049
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2050
                {
2051
                    //SelectionPath = new Path();
2052
                    //PathFigure pathFigure = new PathFigure();
2053
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2054
                    //SelectionPath.Opacity = 0.5;
2055
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2056
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2057
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2058
                }
2059
                else
2060
                {
2061
                    //List<Stroke> removingStroke = new List<Stroke>();
2062
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2063
                    //StrokeCollection stC = new StrokeCollection();
2064
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2065
                    //{
2066
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2067
                    //    p1.Intersect(p2);
2068
                    //    if (p1.IsEmpty)
2069
                    //    {
2070

    
2071

    
2072
                    //        p1 = SelectionPath.Data.Bounds;
2073
                    //        bool intersectCheck = false;
2074
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2075
                    //        {
2076
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2077
                    //            p1.Intersect(p3);
2078
                    //            if (!p1.IsEmpty)
2079
                    //            {
2080
                    //                intersectCheck = true;
2081
                    //            }
2082
                    //        }
2083
                    //        if (intersectCheck)
2084
                    //        {
2085
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2086
                    //        }
2087

    
2088
                    //    }
2089
                    //    else
2090
                    //    {
2091
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2092
                    //    }
2093
                    //}
2094

    
2095
                    e.Handled = true;
2096
                }
2097
            }
2098
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2099
            {
2100
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2101
                if (control != null)
2102
                {
2103
                    this.cursor = Cursors.Hand;
2104
                    SetCursor();
2105
                }
2106
                else
2107
                {
2108
                    this.cursor = Cursors.Arrow;
2109
                    SetCursor();
2110
                }
2111
            }
2112
            else
2113
            {
2114
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2115

    
2116
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2117
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2118

    
2119
                //if (hitList.Count > 0)
2120
                //{
2121

    
2122
                //}
2123

    
2124
                #region 조건 설정 : firstCondition
2125
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2126
                //pnts = generalTransform.Transform(pnts);
2127
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2128
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2129
                //                               this.DeepLayer._BaseLayer).ToObservable()
2130
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2131
                //                      select kkk).FirstOrDefault();
2132

    
2133
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2134
                //if (canvas !=null)
2135
                //{
2136
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2137
                //    {
2138
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2139
                //        if (uiElement!=null)
2140
                //        {
2141
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2142
                //        }
2143
                //    }
2144
                //}
2145

    
2146
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2147
                //hitResultsList.Clear();
2148

    
2149
                #endregion
2150
            }
2151
        }
2152

    
2153
        //private void Point_StateChanged(object sender, MyEventArgs e)
2154
        //{
2155
        //    //if (e.isMouseOver)
2156
        //    //{
2157
        //    //    this.cursor = Cursors.Hand;
2158
        //    //}
2159
        //    //else
2160
        //    //{
2161
        //    //    this.cursor = Cursors.Arrow;
2162
        //    //    (sender as CommentUserInfo).StateChanged -= Point_StateChanged;
2163
        //    //}
2164
        //}
2165
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2166
        private EllipseGeometry hitArea = new EllipseGeometry();
2167

    
2168
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2169
        {
2170
            IsDrawing = false;
2171

    
2172
            if (mouseHandlingMode != MouseHandlingMode.None)
2173
            {
2174
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2175
                {
2176
                    this.cursor = Cursors.Arrow;
2177

    
2178
                    SetCursor();
2179

    
2180
                    switch (controlType)
2181
                    {
2182
                        case ControlType.None:
2183
                            break;
2184
                        case ControlType.Rectangle:
2185
                            {
2186

    
2187
                            }
2188
                            break;
2189
                        case ControlType.PenControl:
2190
                            {
2191

    
2192
                            }
2193
                            break;
2194
                        default:
2195
                            break;
2196
                    }
2197
                }
2198
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left)
2199
                {
2200
                    if (isLeftMouseButtonDownOnWindow)
2201
                    {
2202
                        bool wasDragSelectionApplied = false;
2203

    
2204
                        if (isDraggingSelectionRect)
2205
                        {
2206
                            if (mouseHandlingMode == MouseHandlingMode.Capture)
2207
                            {
2208
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2209
                                mouseHandlingMode = MouseHandlingMode.None;
2210
                                Set_Capture();
2211

    
2212
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2213
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2214
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2215
                            }
2216

    
2217
                            isDraggingSelectionRect = false;
2218
                            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2219
                            {
2220
                                ApplyDragSelectionRect();
2221
                            }
2222

    
2223
                            e.Handled = true;
2224
                            wasDragSelectionApplied = true;
2225
                        }
2226

    
2227
                        if (isLeftMouseButtonDownOnWindow)
2228
                        {
2229
                            isLeftMouseButtonDownOnWindow = false;
2230
                            this.ReleaseMouseCapture();
2231
                            e.Handled = true;
2232
                        }
2233

    
2234
                        if (!wasDragSelectionApplied)
2235
                        {
2236
                            init();
2237
                        }
2238
                    }
2239
                }
2240
                else if (mouseButtonDown == MouseButton.Right)
2241
                {
2242
                    this.cursor = Cursors.Arrow;
2243
                    SetCursor();
2244
                }
2245

    
2246
                zoomAndPanControl.ReleaseMouseCapture();
2247

    
2248

    
2249
                e.Handled = true;
2250
            }
2251
            else
2252
            {
2253
                this.cursor = Cursors.Arrow;
2254
                SetCursor();
2255
            }
2256
            mouseButtonDown = MouseButton.Left;
2257

    
2258
            //controlType = ControlType.SingleLine;
2259
        }
2260

    
2261

    
2262
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2263
        {
2264
            this.Cursor = Cursors.Arrow;
2265
        }
2266

    
2267
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2268
        {
2269

    
2270
        }
2271

    
2272
        private void ApplyDragSelectionRect()
2273
        {
2274
            multi_Undo_Data = new Multi_Undo_data();
2275

    
2276
            UndoData = new Undo_data()
2277
            {
2278
                IsUndo = false,
2279
                Event = Event_Type.Select,
2280
                EventTime = DateTime.Now,
2281
                Markup_List = new List<Multi_Undo_data>()
2282
            };
2283

    
2284

    
2285
            InkControl_Convert();
2286
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2287

    
2288
            double x = Canvas.GetLeft(dragSelectionBorder);
2289
            double y = Canvas.GetTop(dragSelectionBorder);
2290
            double width = dragSelectionBorder.Width;
2291
            double height = dragSelectionBorder.Height;
2292
            Rect dragRect = new Rect(x, y, width, height);
2293
            Boolean Flag = false;
2294
            dragRect.Inflate(width / 10, height / 10);
2295
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2296
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
2297

    
2298
      
2299

    
2300

    
2301
            //#region 잉크 불필요
2302

    
2303
            ////#region Ink Canvas Select
2304
            //List<Stroke> removingStroke = new List<Stroke>();
2305
            //StrokeCollection stC = new StrokeCollection();
2306

    
2307

    
2308
            //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2309
            //{
2310
            //    dragRect = new Rect(x, y, width, height);
2311
            //    dragRect.Inflate(width / 10, height / 10);
2312

    
2313
            //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2314
            //    dragRect.Intersect(p2);
2315
            //    if (dragRect.IsEmpty)
2316
            //    {
2317
            //        //dragRect = SelectionPath.Data.Bounds;
2318
            //        bool intersectCheck = false;
2319
            //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2320
            //        {
2321
            //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2322
            //            dragRect.Intersect(p3);
2323
            //            if (!dragRect.IsEmpty)
2324
            //            {
2325
            //                intersectCheck = true;
2326
            //            }
2327
            //        }
2328
            //        if (intersectCheck)
2329
            //        {
2330
            //            removingStroke.Add(inkBoard.Strokes[i]);
2331
            //        }
2332
            //    }
2333
            //    else
2334
            //    {
2335
            //        removingStroke.Add(inkBoard.Strokes[i]);
2336
            //    }
2337
            //}
2338

    
2339
            //InkToPath ip = new InkToPath();
2340
            //List<Point> inkPointSet = new List<Point>();
2341
            //PolygonControl pc = null;
2342
            ////InkControl pc = null;
2343
            ////pc = new InkControl()
2344
            //pc = new PolygonControl()
2345
            //{
2346
            //    //PointC = new List<StylusPointSet>(),
2347
            //    Angle = 0,
2348
            //    StartPoint = dragRect.TopLeft,
2349
            //    EndPoint = dragRect.BottomRight,
2350
            //    PointSet = new List<Point>(),
2351
            //    CommentID = Save.shortGuid(),
2352
            //    ControlType = ControlType.Ink,
2353
            //};
2354
            //foreach (var item in removingStroke)
2355
            //{
2356
            //    //pc.PointC.Add(new StylusPointSet() { pointSet = ip.StrokeGetPointsPlus(item) });
2357
            //    inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
2358
            //    inkBoard.Strokes.Remove(item);
2359
            //}
2360
            //if (inkPointSet.Count != 0)
2361
            //{
2362
            //    pc.StartPoint = inkPointSet[0];
2363
            //    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
2364
            //    pc.PointSet = inkPointSet;
2365
            //    pc.LineSize = 3;
2366
            //    //pc.StrokeColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("ff18b7fc"));
2367
            //    pc.StrokeColor = new SolidColorBrush(Colors.Red);
2368
            //    ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
2369
            //    pc.SetPolyPath();
2370

    
2371
            //    adornerSet.Add(pc);
2372
            //    ViewerDataModel.Instance.MarkupControls_USER.Remove(pc);
2373

    
2374
            //    //Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2375
            //    //SelectLayer.Children.Add(final);
2376
            //}
2377
            ////#endregion 
2378
            //#endregion
2379

    
2380

    
2381
            dragRect = new Rect(x, y, width, height);
2382
            dragRect.Inflate(width / 10, height / 10);
2383

    
2384
            foreach (var item in Items)
2385
            {
2386
                //switch ((item as IMarkupCommonData).ControlType)
2387
                //{
2388
                //case ControlType.Rectangle:
2389
                //    {
2390
                //var rectangleControl = (item as RectangleControl);
2391
                //Flag = move.control_Select(rectangleControl,  dragRect);
2392
                Flag = move.control_Select(item, dragRect);
2393

    
2394
                if (Flag)
2395
                {
2396
                    adornerSet.Add(item);
2397
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2398

    
2399
                    Control_Style(item);
2400
                    UndoData.Markup_List.Add(multi_Undo_Data);
2401
                    multi_Undo_Data = new Multi_Undo_data();
2402

    
2403
                    //SelectLayer.Children.Add(final);
2404
                }
2405
                //}
2406
                //break;
2407
                //}
2408
            }
2409
            if (adornerSet.Count > 0)
2410
            {
2411
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2412
                {
2413
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2414
                });
2415
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2416

    
2417
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2418
                SelectLayer.Children.Add(final);
2419
                //mouseHandlingMode = MouseHandlingMode.Adorner;
2420
            }
2421
        }
2422

    
2423

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

    
2439
        /// <summary>
2440
        /// Update the position and size of the rectangle used for drag selection.
2441
        /// </summary>
2442
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2443
        {
2444
            double x, y, width, height;
2445

    
2446
            //
2447
            // Determine x,y,width and height of the rect inverting the points if necessary.
2448
            // 
2449

    
2450
            if (pt2.X < pt1.X)
2451
            {
2452
                x = pt2.X;
2453
                width = pt1.X - pt2.X;
2454
            }
2455
            else
2456
            {
2457
                x = pt1.X;
2458
                width = pt2.X - pt1.X;
2459
            }
2460

    
2461
            if (pt2.Y < pt1.Y)
2462
            {
2463
                y = pt2.Y;
2464
                height = pt1.Y - pt2.Y;
2465
            }
2466
            else
2467
            {
2468
                y = pt1.Y;
2469
                height = pt2.Y - pt1.Y;
2470
            }
2471

    
2472

    
2473
            //
2474
            // Update the coordinates of the rectangle used for drag selection.
2475
            //
2476
            //선택 중
2477
            if (mouseHandlingMode == MouseHandlingMode.Selecting)
2478
            {
2479
                Canvas.SetLeft(dragSelectionBorder, x);
2480
                Canvas.SetTop(dragSelectionBorder, y);
2481
                dragSelectionBorder.Width = width;
2482
                dragSelectionBorder.Height = height;
2483
            }
2484
            //캡쳐 중
2485
            else
2486
            {
2487
                Canvas.SetLeft(dragCaptureBorder, x);
2488
                Canvas.SetTop(dragCaptureBorder, y);
2489
                dragCaptureBorder.Width = width;
2490
                dragCaptureBorder.Height = height;
2491
            }
2492

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

    
2496

    
2497
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
2498
        {
2499
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
2500

    
2501
            bool result = false;
2502
            if (dragRect.Contains(controlRect))
2503
            {
2504
                result = true;
2505
                //잡은 객체들을 담은 리스트
2506
                //selected_item.Add(OverViewPathData, type);
2507
                try
2508
                {
2509
                    //controlType = type;
2510
                    selected_item.Add(OverViewPathData, type.ToString());
2511
                }
2512
                catch (Exception)
2513
                {
2514

    
2515
                }
2516
                //listBox.Items.Add(OverViewPathData, commonData.ControlType.ToString());
2517
                //listBox.SelectedItems.Add(rectangleViewModel);
2518
            }
2519
            return result;
2520
        }
2521

    
2522
        private void drawingPannelRotate(double angle)
2523
        {
2524
            rotate.Angle = angle;
2525
            var rotationNum = Math.Abs((rotate.Angle / 90));
2526

    
2527
            if (angle == 90 || angle == 270)
2528
            {
2529
                double emptySize = zoomAndPanCanvas.Width;
2530
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2531
                zoomAndPanCanvas.Height = emptySize;
2532
            }
2533
            if (angle == 0)
2534
            {
2535
                translate.X = 0;
2536
                translate.Y = 0;
2537
            }
2538
            else if (angle == 90)
2539
            {
2540
                translate.X = zoomAndPanCanvas.Width;
2541
                translate.Y = 0;
2542
            }
2543
            else if (angle == 180)
2544
            {
2545
                translate.X = zoomAndPanCanvas.Width;
2546
                translate.Y = zoomAndPanCanvas.Height;
2547
            }
2548
            else
2549
            {
2550
                translate.X = 0;
2551
                translate.Y = zoomAndPanCanvas.Height;
2552
            }
2553

    
2554
            zoomAndPanControl.RotationAngle = rotate.Angle;
2555
            _imageViewer.RotateAngle = rotate.Angle;
2556

    
2557
            if (!testPanel2.IsHidden)
2558
            {
2559
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2560
                _imageViewer_Compare.RotateAngle = rotate.Angle;
2561

    
2562
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2563
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2564
            }
2565

    
2566
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2567
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2568
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2569
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2570
            ViewerDataModel.Instance.Angle = rotate.Angle;
2571

    
2572

    
2573
        }
2574

    
2575
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2576
        {
2577
            if (currentControl != null && currentControl.GetType().Name == "TextControl")
2578
            {
2579
                (currentControl as TextControl).Base_TextBlock.Visibility = System.Windows.Visibility.Visible;
2580
                (currentControl as TextControl).Base_TextBox.Visibility = System.Windows.Visibility.Collapsed;
2581
                (currentControl as TextControl).IsEditing = false;
2582
                (currentControl as TextControl).EnableEditing = false;
2583
                currentControl = null;
2584
            }
2585

    
2586
            double Ang = 0;
2587
            if (rotate.Angle != 0)
2588
            {
2589
                Ang = 360 - rotate.Angle;
2590
            }
2591

    
2592
            move = new Move();
2593

    
2594
            if (e.OriginalSource is Canvas)
2595
            {
2596
                (e.OriginalSource as Canvas).Focus();
2597
            }
2598
            mouseButtonDown = e.ChangedButton;
2599
            if (mouseButtonDown == MouseButton.Left)
2600
            {
2601
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2602
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2603

    
2604
                this.cursor = Cursors.Arrow;
2605
                SetCursor();
2606

    
2607
                if (!ViewerDataModel.Instance.IsPressCtrl)
2608
                {
2609
                    ReleaseAdorner();
2610
                }
2611
            }
2612
            if (mouseButtonDown == MouseButton.Middle)
2613
            {
2614
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2615
                cursor = Cursors.SizeAll;
2616
                SetCursor();
2617
            }
2618
            if (mouseButtonDown == MouseButton.Right)
2619
            {
2620
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2621
                cursor = Cursors.SizeAll;
2622
                SetCursor();
2623
            }
2624
            else if (mouseButtonDown == MouseButton.XButton1)
2625
            {
2626
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2627
                {
2628
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
2629
                }
2630

    
2631
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2632

    
2633
            }
2634
            else if (mouseButtonDown == MouseButton.XButton2)
2635
            {
2636
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2637
                {
2638
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2639
                }
2640
            }
2641

    
2642
            //캡쳐 모드 설정
2643
            if (mouseHandlingMode == MouseHandlingMode.Capture && mouseButtonDown == MouseButton.Left)
2644
            {
2645
                dragCaptureBorder.Visibility = Visibility.Visible;
2646
                isLeftMouseButtonDownOnWindow = true;
2647
            }
2648

    
2649
            if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2650
            {
2651

    
2652
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2653
                {
2654
                    if (SelectLayer.Children.Count == 0)
2655
                    {
2656
                        isLeftMouseButtonDownOnWindow = true;
2657
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2658
                    }
2659

    
2660
                    if (controlType == ControlType.None)
2661
                    {
2662
                        isLeftMouseButtonDownOnWindow = true;
2663
                    }
2664
                }
2665

    
2666

    
2667
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2668
                if (control != null)
2669
                {
2670

    
2671
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
2672
                    AdornerFinal final;
2673
                    List<Point> p_set = new List<Point>();
2674
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
2675
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
2676
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
2677
                    multi_Undo_Data = new Multi_Undo_data();
2678

    
2679
                    //강인구 Undo/Redo 보류
2680
                    UndoData = new Undo_data()
2681
                    {
2682
                        IsUndo = false,
2683
                        Event = Event_Type.Select,
2684
                        EventTime = DateTime.Now,
2685
                        Markup_List = new List<Multi_Undo_data>()
2686
                    };
2687

    
2688
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2689
                    {
2690
                        ReleaseAdorner();
2691
                        final = new AdornerFinal(control);
2692
                        //단일 컨트롤 언두 저장
2693

    
2694
                        Control_Style(control);
2695
                        UndoData.Markup_List.Add(multi_Undo_Data);
2696

    
2697
                        if ((control as IPath) != null)
2698
                        {
2699
                            if ((control as IPath).LineSize != 0)
2700
                            {
2701
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2702
                            }
2703
                        }
2704
                        if ((control as IShapeControl) != null)
2705
                        {
2706
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2707
                            {
2708
                                ViewerDataModel.Instance.checkHatchShape = true;
2709
                            }
2710
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2711
                            {
2712
                                ViewerDataModel.Instance.checkFillShape = true;
2713
                            }
2714
                            else
2715
                            {
2716
                                ViewerDataModel.Instance.checkHatchShape = false;
2717
                                ViewerDataModel.Instance.checkFillShape = false;
2718
                            }
2719
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2720
                        }
2721
                        //SelectLayer.Children.Add(final);
2722
                        if ((control as IPath) != null)
2723
                        {
2724
                            if ((control as IPath).LineSize != 0)
2725
                            {
2726
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2727
                            }
2728
                        }
2729
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2730
                    }
2731
                    else
2732
                    {
2733
                        comment = AddAdorner();
2734
                        comment.Add(control);
2735

    
2736
                        Control_Style(control);
2737
                        UndoData.Markup_List.Add(multi_Undo_Data);
2738

    
2739
                        final = new AdornerFinal(comment);
2740
                        //다중 컨트롤 언두 저장
2741
                    }
2742

    
2743
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2744
                    {
2745
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2746
                    });
2747

    
2748
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2749

    
2750
                    SelectLayer.Children.Add(final);
2751

    
2752
                    //Control_Init(control);
2753

    
2754
                   
2755

    
2756
                    //강인구 폰트 변경 보류
2757

    
2758
                    //if ((currentControl as TextControl) != null)
2759
                    //{
2760
                    //    if ((control as TextControl).TextStyle == FontStyles.Italic)
2761
                    //    {
2762
                    //        ViewerDataModel.Instance.checkTextStyle = true;
2763
                    //    }
2764
                    //    else
2765
                    //    {
2766
                    //        ViewerDataModel.Instance.checkTextStyle = false;
2767
                    //    }
2768

    
2769
                    //    if((currentControl as TextControl).TextStyle == FontStyles.Italic)
2770
                    //    {
2771

    
2772
                    //    }
2773
                    //    if((currentControl as TextControl).TextWeight == FontWeights.Heavy)
2774
                    //    {
2775

    
2776
                    //    }
2777
                    //    if((currentControl as TextControl).UnderLine == TextDecorations.Underline)
2778
                    //    {
2779

    
2780
                    //    }
2781
                    //}
2782
                    //else if ((currentControl as ArrowTextControl) != null)
2783
                    //{
2784
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
2785
                    //    {
2786
                    //        (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
2787
                    //    }
2788
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
2789
                    //    {
2790
                    //        (currentControl as ArrowTextControl).TextWeight = FontWeights.Heavy;
2791
                    //    }
2792
                    //    if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
2793
                    //    {
2794
                    //        (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
2795
                    //    }
2796
                    //}
2797

    
2798
                    mouseHandlingMode = MouseHandlingMode.Adorner;
2799

    
2800
                }
2801
            }
2802
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2803
            {
2804
                init();
2805
                cursor = Cursors.Cross;
2806
                SetCursor();
2807
                //currentControl.IsNew = true;
2808
                bool init_user = false;
2809
                foreach(var user in gridViewMarkup.Items)
2810
                {
2811
                    if((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2812
                    {
2813
                        init_user = true;
2814
                    }
2815
                }
2816
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2817
                //if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2818
                //if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
2819
                {
2820
                    RadWindow.Alert(new DialogParameters
2821
                    {
2822
                        Theme = new VisualStudio2013Theme(),
2823
                        Header = "안내",
2824
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2825
                    });
2826
                    return;
2827
                }
2828
                else
2829
                {
2830
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2831
                    if (item != null)
2832
                    {
2833
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2834
                    }
2835
                }
2836

    
2837
                multi_Undo_Data = new Multi_Undo_data();
2838
                //강인구 Undo/Redo 보류
2839
                UndoData = new Undo_data()
2840
                {
2841
                    IsUndo = false,
2842
                    Event = Event_Type.Create,
2843
                    EventTime = DateTime.Now,
2844
                    Markup_List = new List<Multi_Undo_data>()
2845
                };
2846

    
2847
                switch (controlType)
2848
                {
2849
                    case ControlType.Rectangle:
2850
                        {
2851
                            if (mouseButtonDown == MouseButton.Left)
2852
                            {
2853
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2854
                                {
2855
                                    if (currentControl is RectangleControl)
2856
                                    {
2857
                                        CreateControl();
2858

    
2859
                                        (currentControl as RectangleControl).ApplyOverViewData();
2860
                                        currentControl = null;
2861
                                        this.cursor = Cursors.Arrow;
2862
                                    }
2863
                                    else
2864
                                    {
2865
                                        currentControl = new RectangleControl
2866
                                        {
2867
                                            Background = new SolidColorBrush(Colors.Black),
2868
                                            ControlType = ControlType.Rectangle
2869
                                        };
2870

    
2871
                                        currentControl.CommentID = Save.shortGuid();
2872
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2873
                                        currentControl.IsNew = true;
2874
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2875

    
2876
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2877
                                    }
2878
                                }
2879
                            }
2880
                        }
2881
                        break;
2882
                    case ControlType.RectCloud:
2883
                        {
2884
                            if (mouseButtonDown == MouseButton.Left)
2885
                            {
2886
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2887
                                {
2888
                                    if (currentControl is RectCloudControl)
2889
                                    {
2890
                                        CreateControl();
2891

    
2892
                                        (currentControl as RectCloudControl).ApplyOverViewData();
2893
                                        //controlType = ControlType.None;
2894
                                        currentControl = null;
2895
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
2896
                                        this.cursor = Cursors.Arrow;
2897
                                    }
2898
                                    else
2899
                                    {
2900
                                        currentControl = new RectCloudControl
2901
                                        {
2902
                                            Background = new SolidColorBrush(Colors.Black)
2903
                                        };
2904

    
2905
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2906
                                        currentControl.CommentID = Save.shortGuid();
2907
                                        currentControl.IsNew = true;
2908
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2909
                                    }
2910
                                }
2911
                            }
2912
                        }
2913
                        break;
2914
                    case ControlType.Circle:
2915
                        {
2916
                            if (mouseButtonDown == MouseButton.Left)
2917
                            {
2918
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2919
                                {
2920
                                    if (currentControl is CircleControl)
2921
                                    {
2922
                                        CreateControl();
2923

    
2924
                                        (currentControl as CircleControl).ApplyOverViewData();
2925
                                        //controlType = ControlType.None;
2926
                                        currentControl = null;
2927
                                    }
2928
                                    else
2929
                                    {
2930
                                        currentControl = new CircleControl
2931
                                        {
2932
                                            Background = new SolidColorBrush(Colors.Black)
2933
                                        };
2934

    
2935
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2936
                                        currentControl.CommentID = Save.shortGuid();
2937
                                        currentControl.IsNew = true;
2938
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2939
                                    }
2940
                                }
2941
                            }
2942
                        }
2943
                        break;
2944
                    case ControlType.Triangle:
2945
                        {
2946
                            if (mouseButtonDown == MouseButton.Left)
2947
                            {
2948
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2949
                                {
2950
                                    if (currentControl is TriControl)
2951
                                    {
2952
                                        var content = currentControl as TriControl;
2953
                                        if (content.MidPoint == new Point(0, 0))
2954
                                        {
2955
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2956
                                        }
2957
                                        else
2958
                                        {
2959
                                            CreateControl();
2960

    
2961
                                            (currentControl as TriControl).ApplyOverViewData();
2962
                                            //controlType = ControlType.None;
2963
                                            currentControl = null;
2964
                                        }
2965
                                    }
2966
                                    else
2967
                                    {
2968
                                        currentControl = new TriControl
2969
                                        {
2970
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2971
                                            Background = new SolidColorBrush(Colors.Black),
2972
                                        };
2973

    
2974
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2975
                                        currentControl.CommentID = Save.shortGuid();
2976
                                        currentControl.IsNew = true;
2977
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2978
                                    }
2979
                                }
2980
                            }
2981
                        }
2982
                        break;
2983
                    case ControlType.SingleLine:
2984
                        {
2985
                            if (mouseButtonDown == MouseButton.Left)
2986
                            {
2987
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2988
                                {
2989
                                    if (currentControl is LineControl)
2990
                                    {
2991
                                        CreateControl();
2992

    
2993
                                        (currentControl as LineControl).ApplyOverViewData();
2994
                                        //controlType = ControlType.None;
2995
                                        currentControl = null;
2996
                                    }
2997
                                    else
2998
                                    {
2999
                                        currentControl = new LineControl
3000
                                        {
3001
                                            Background = new SolidColorBrush(Colors.Black)
3002
                                        };
3003

    
3004
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3005
                                        currentControl.CommentID = Save.shortGuid();
3006
                                        currentControl.IsNew = true;
3007
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3008
                                    }
3009
                                }
3010
                            }
3011
                        }
3012
                        break;
3013
                    case ControlType.CancelLine:
3014
                        {
3015
                            if (mouseButtonDown == MouseButton.Left)
3016
                            {
3017
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3018
                                {
3019
                                    if (currentControl is LineControl)
3020
                                    {
3021
                                        CreateControl();
3022

    
3023
                                        (currentControl as LineControl).ApplyOverViewData();
3024
                                        //controlType = ControlType.None;
3025
                                        currentControl = null;
3026
                                    }
3027
                                    else
3028
                                    {
3029
                                        currentControl = new LineControl
3030
                                        {
3031
                                            Background = new SolidColorBrush(Colors.Black)
3032
                                        };
3033

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

    
3053
                                        (currentControl as LineControl).ApplyOverViewData();
3054
                                        //controlType = ControlType.None;
3055
                                        currentControl = null;
3056
                                    }
3057
                                    else
3058
                                    {
3059
                                        currentControl = new LineControl
3060
                                        {
3061
                                            Background = new SolidColorBrush(Colors.Black)
3062
                                        };
3063

    
3064
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3065
                                        currentControl.CommentID = Save.shortGuid();
3066
                                        currentControl.IsNew = true;
3067
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3068
                                    }
3069
                                }
3070
                            }
3071
                        }
3072
                        break;
3073
                    case ControlType.TwinLine:
3074
                        {
3075
                            if (mouseButtonDown == MouseButton.Left)
3076
                            {
3077
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3078
                                {
3079
                                    if (currentControl is LineControl)
3080
                                    {
3081
                                        CreateControl();
3082

    
3083
                                        (currentControl as LineControl).ApplyOverViewData();
3084
                                        //controlType = ControlType.None;
3085
                                        currentControl = null;
3086
                                    }
3087
                                    else
3088
                                    {
3089
                                        currentControl = new LineControl
3090
                                        {
3091
                                            Background = new SolidColorBrush(Colors.Black)
3092
                                        };
3093
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3094
                                        currentControl.CommentID = Save.shortGuid();
3095
                                        currentControl.IsNew = true;
3096
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3097
                                    }
3098
                                }
3099
                            }
3100
                        }
3101
                        break;
3102
                    case ControlType.DimLine:
3103
                        {
3104
                            if (mouseButtonDown == MouseButton.Left)
3105
                            {
3106
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3107
                                {
3108
                                    if (currentControl is LineControl)
3109
                                    {
3110
                                        CreateControl();
3111

    
3112
                                        (currentControl as LineControl).ApplyOverViewData();
3113
                                        //controlType = ControlType.None;
3114
                                        currentControl = null;
3115
                                    }
3116
                                    else
3117
                                    {
3118
                                        currentControl = new LineControl
3119
                                        {
3120
                                            Background = new SolidColorBrush(Colors.Black)
3121
                                        };
3122
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3123
                                        currentControl.CommentID = Save.shortGuid();
3124
                                        currentControl.IsNew = true;
3125
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3126
                                    }
3127
                                }
3128
                            }
3129
                        }
3130
                        break;
3131
                    case ControlType.ChainLine:
3132
                        {
3133
                            if (currentControl is PolygonControl)
3134
                            {
3135
                                var control = currentControl as PolygonControl;
3136

    
3137
                                if (mouseButtonDown == MouseButton.Right)
3138
                                {
3139
                                    CreateControl();
3140

    
3141
                                    (currentControl as PolygonControl).ApplyOverViewData();
3142
                                    //controlType = ControlType.None;
3143
                                    currentControl = null;
3144
                                    return;
3145
                                }
3146

    
3147
                                if (!control.IsCompleted)
3148
                                {
3149
                                    //control.PointC.pointSet.Add(control.EndPoint);
3150
                                    control.PointSet.Add(control.EndPoint);
3151
                                }
3152
                                //else
3153
                                //{
3154
                                //    var firstPoint = control.PointC.pointSet.First();
3155

    
3156
                                //    //control.PointC.pointSet.Add(new Point(firstPoint.X, firstPoint.Y));
3157
                                //    control.PointC.pointSet.Add(firstPoint);
3158

    
3159
                                //    control.SetPolyPath();
3160

    
3161
                                //    controlType = ControlType.None;
3162

    
3163
                                //    currentControl = null;
3164
                                //}
3165
                            }
3166
                            else
3167
                            {
3168
                                if (mouseButtonDown == MouseButton.Left)
3169
                                {
3170
                                    currentControl = new PolygonControl
3171
                                    {
3172
                                        PointSet = new List<Point>(),
3173
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3174
                                        ControlType = ControlType.ChainLine,
3175
                                        DashSize = ViewerDataModel.Instance.DashSize,
3176
                                        LineSize = ViewerDataModel.Instance.LineSize,
3177
                                        //PointC = new StylusPointSet()
3178
                                    };
3179

    
3180
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3181
                                    {
3182
                                        var polygonControl = (currentControl as PolygonControl);
3183
                                        currentControl.CommentID = Save.shortGuid();
3184
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3185
                                        currentControl.IsNew = true;
3186
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3187
                                        //currentControl.OnApplyTemplate();
3188
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3189
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3190
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3191
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3192
                                    }
3193
                                }
3194
                            }
3195
                        }
3196
                        break;
3197
                    case ControlType.ArcLine:
3198
                        {
3199
                            if (mouseButtonDown == MouseButton.Left)
3200
                            {
3201
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3202
                                {
3203
                                    if (currentControl is ArcControl)
3204
                                    {
3205
                                        CreateControl();
3206

    
3207
                                        (currentControl as ArcControl).ApplyOverViewData();
3208
                                        //controlType = ControlType.None;
3209
                                        currentControl = null;
3210
                                    }
3211
                                    else
3212
                                    {
3213
                                        currentControl = new ArcControl
3214
                                        {
3215
                                            Background = new SolidColorBrush(Colors.Black)
3216
                                        };
3217
                                        currentControl.CommentID = Save.shortGuid();
3218
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3219
                                        currentControl.IsNew = true;
3220
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3221
                                    }
3222
                                }
3223
                            }
3224
                            else if (mouseButtonDown == MouseButton.Right)
3225
                            {
3226
                                if (currentControl != null)
3227
                                {
3228
                                    (currentControl as ArcControl).setClock();
3229
                                }
3230

    
3231
                            }
3232

    
3233
                        }
3234
                        break;
3235
                    case ControlType.ArcArrow:
3236
                        {
3237
                            if (mouseButtonDown == MouseButton.Left)
3238
                            {
3239
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3240
                                {
3241
                                    if (currentControl is ArcControl)
3242
                                    {
3243
                                        CreateControl();
3244

    
3245
                                        (currentControl as ArcControl).ApplyOverViewData();
3246
                                        //controlType = ControlType.None;
3247
                                        currentControl = null;
3248
                                    }
3249
                                    else
3250
                                    {
3251
                                        currentControl = new ArcControl
3252
                                        {
3253
                                            Background = new SolidColorBrush(Colors.Red),
3254
                                        };
3255
                                        currentControl.CommentID = Save.shortGuid();
3256
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3257
                                        currentControl.IsNew = true;
3258
                                        (currentControl as IMarkupCommonData).ControlType = ControlType.ArcArrow;
3259
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3260
                                    }
3261
                                }
3262
                            }
3263
                            else if (mouseButtonDown == MouseButton.Right)
3264
                            {
3265
                                (currentControl as ArcControl).setClock();
3266
                            }
3267
                        }
3268
                        break;
3269
                    case ControlType.ArrowMultiLine:
3270
                        {
3271
                            if (mouseButtonDown == MouseButton.Left)
3272
                            {
3273
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3274
                                {
3275

    
3276
                                    if (currentControl is ArrowControl_Multi)
3277
                                    {
3278
                                        var content = currentControl as ArrowControl_Multi;
3279
                                        if (content.MiddlePoint == new Point(0, 0))
3280
                                        {
3281
                                            content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3282
                                        }
3283
                                        else
3284
                                        {
3285
                                            CreateControl();
3286

    
3287
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
3288
                                            //controlType = ControlType.None;
3289
                                            currentControl = null;
3290
                                        }
3291
                                    }
3292
                                    else
3293
                                    {
3294
                                        currentControl = new ArrowControl_Multi
3295
                                        {
3296
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3297
                                            Background = new SolidColorBrush(Colors.Black)
3298
                                        };
3299
                                        currentControl.CommentID = Save.shortGuid();
3300
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3301
                                        currentControl.IsNew = true;
3302
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3303
                                    }
3304

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

    
3318
                                    //    DataModel.Instance.MarkupControls.Add(currentControl);
3319
                                    //}
3320

    
3321

    
3322

    
3323
                                }
3324
                            }
3325
                        }
3326
                        break;
3327
                    case ControlType.PolygonCloud:
3328
                        {
3329
                            if (currentControl is CloudControl)
3330
                            {
3331
                                var control = currentControl as CloudControl;
3332
                                //control.Paint = PaintSet.Cloud;
3333
                                if (mouseButtonDown == MouseButton.Right)
3334
                                {
3335
                                    control.IsCompleted = true;
3336
                                }
3337

    
3338
                                if (!control.IsCompleted)
3339
                                {
3340
                                    //control.PointC.pointSet.Add(control.EndPoint);
3341
                                    control.PointSet.Add(control.EndPoint);
3342
                                }
3343
                                else
3344
                                {
3345
                                    CreateControl();
3346

    
3347
                                    control.isTransOn = true;
3348
                                    //var firstPoint = control.PointC.pointSet.First();
3349
                                    var firstPoint = control.PointSet.First();
3350

    
3351
                                    //control.PointC.pointSet.Add(firstPoint);
3352
                                    control.PointSet.Add(firstPoint);
3353
                                    control.DrawingCloud();
3354
                                    control.ApplyOverViewData();
3355

    
3356
                                    //controlType = ControlType.None;
3357

    
3358
                                    currentControl = null;
3359
                                }
3360
                            }
3361
                            else
3362
                            {
3363
                                if (mouseButtonDown == MouseButton.Left)
3364
                                {
3365
                                    currentControl = new CloudControl
3366
                                    {
3367
                                        PointSet = new List<Point>(),
3368
                                        PointC = new StylusPointSet()
3369
                                    };
3370

    
3371
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3372
                                    {
3373
                                        var polygonControl = (currentControl as CloudControl);
3374
                                        currentControl.CommentID = Save.shortGuid();
3375
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3376
                                        currentControl.IsNew = true;
3377
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3378
                                        //currentControl.OnApplyTemplate();
3379

    
3380
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3381
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3382
                                        //polygonControl.PointC.pointSet.Add(canvasZoomPanningMouseDownPoint);
3383
                                        //polygonControl.PointC.pointSet.Add(canvasZoomPanningMouseDownPoint);
3384

    
3385
                                    }
3386
                                }
3387
                            }
3388
                        }
3389
                        break;
3390
                    case ControlType.ImgControl:
3391
                        {
3392
                            if (mouseButtonDown == MouseButton.Left)
3393
                            {
3394
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3395
                                {
3396
                                    if (currentControl is ImgControl)
3397
                                    {
3398
                                        CreateControl();
3399
                                        (currentControl as ImgControl).ApplyOverViewData();
3400

    
3401
                                        //controlType = ControlType.None;
3402
                                        currentControl = null;
3403
                                    }
3404
                                    else
3405
                                    {
3406
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3407
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG")
3408
                                        {
3409
                                            Image img = new Image();
3410
                                            img.Source = new BitmapImage(new Uri(filename));
3411

    
3412
                                            currentControl = new ImgControl
3413
                                            {
3414
                                                Background = new SolidColorBrush(Colors.Black),
3415
                                                PointSet = new List<Point>(),
3416
                                                FilePath = filename,
3417
                                                ImageData = img.Source,
3418
                                                StartPoint = canvasDrawingMouseDownPoint,
3419
                                                EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3420
                                                TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3421
                                                LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y)
3422
                                            };
3423

    
3424
                                            currentControl.CommentID = Save.shortGuid();
3425
                                            currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3426
                                            currentControl.IsNew = true;
3427
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3428
                                        }
3429
                                    }
3430
                                }
3431
                            }
3432
                        }
3433
                        break;
3434
                    case ControlType.Date:
3435
                        {
3436
                            if (mouseButtonDown == MouseButton.Left)
3437
                            {
3438
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3439
                                {
3440
                                    if (currentControl is DateControl)
3441
                                    {
3442
                                        CreateControl();
3443
                                        (currentControl as DateControl).ApplyOverViewData();
3444
                                        //controlType = ControlType.None;
3445
                                        currentControl = null;
3446

    
3447
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3448
                                        {
3449
                                            controlType = ControlType.None;
3450
                                            IsSwingMode = false;
3451
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3452
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3453
                                            mouseHandlingMode = MouseHandlingMode.None;
3454
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3455
                                            txtBatch.Visibility = Visibility.Collapsed;
3456
                                            
3457
                                        }
3458
                                    }
3459
                                    else
3460
                                    {
3461
                                        currentControl = new DateControl
3462
                                        {
3463
                                            Background = new SolidColorBrush(Colors.Black)
3464
                                        };
3465
                                        //inkDrawingCanvas.Children.Add(currentControl);
3466
                                        //InkCanvas.SetLeft(currentControl, canvasDrawingMouseDownPoint.X);
3467
                                        //InkCanvas.SetTop(currentControl, canvasDrawingMouseDownPoint.Y);
3468
                                        currentControl.CommentID = Save.shortGuid();
3469
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3470
                                        currentControl.IsNew = true;
3471
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3472
                                        //DataModel.Instance.MarkupControls.Add(currentControl);
3473
                                    }
3474
                                }
3475
                            }
3476
                        }
3477
                        break;
3478
                    case ControlType.TextControl:
3479
                        {
3480
                            if (mouseButtonDown == MouseButton.Left)
3481
                            {
3482
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3483
                                {
3484
                                    if (currentControl is TextControl)
3485
                                    {
3486
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3487
                                        (currentControl as TextControl).Base_TextBox.Text = (currentControl as TextControl).Text;
3488
                                        //(currentControl as TextControl).Base_TextBlock.Text = "";
3489
                                        (currentControl as TextControl).Base_TextBox.Visibility = System.Windows.Visibility.Visible;
3490
                                        (currentControl as TextControl).Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed;
3491
                                        (currentControl as TextControl).Angle = Ang;
3492
                                        //(currentControl as TextControl).Base_TextBox.Focus();
3493
                                        currentControl.Focus();
3494
                                    }
3495
                                    else
3496
                                    {
3497
                                        currentControl = new TextControl();
3498
                                        currentControl.CommentID = Save.shortGuid();
3499
                                        currentControl.IsNew = true;
3500
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3501
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3502
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3503
                                        //(currentControl as TextControl).StartPoint = canvasDrawingMouseDownPoint;
3504
                                        //(currentControl as TextControl).EndPoint = canvasDrawingMouseDownPoint;
3505
                                        currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3506
                                        currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3507
                                        currentControl.Focus();
3508
                                        (currentControl as TextControl).ApplyOverViewData();
3509
                                        (currentControl as TextControl).ControlType_No = 0;
3510
                                        (currentControl as TextControl).Angle -= rotate.Angle;
3511
                                        (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3512

    
3513
                                        CreateControl();
3514
                                    }
3515

    
3516
                                    //controlType = ControlType.None;
3517
                                    //currentControl = null;
3518

    
3519
                                }
3520
                            }
3521
                        }
3522
                        break;
3523
                    case ControlType.TextBorder:
3524
                        {
3525
                            if (mouseButtonDown == MouseButton.Left)
3526
                            {
3527
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3528
                                {
3529
                                    currentControl = new TextControl
3530
                                    {
3531
                                        //ControlType = PaintSet.Rect
3532
                                        ControlType = controlType
3533
                                    };
3534

    
3535

    
3536
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3537
                                    currentControl.CommentID = Save.shortGuid();
3538
                                    currentControl.IsNew = true;
3539
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3540
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3541
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3542
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3543
                                    currentControl.Focus();
3544
                                    (currentControl as TextControl).ControlType_No = 1;
3545
                                    (currentControl as TextControl).Angle = Ang;
3546
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3547
                                    //controlType = ControlType.None;
3548
                                    CreateControl();
3549

    
3550
                                    currentControl = null;
3551
                                }
3552
                            }
3553
                        }
3554
                        break;
3555
                    case ControlType.TextCloud:
3556
                        {
3557
                            if (mouseButtonDown == MouseButton.Left)
3558
                            {
3559
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3560
                                {
3561
                                    currentControl = new TextControl
3562
                                    {
3563
                                        //Paint = PaintSet.Cloud
3564
                                        ControlType = controlType
3565
                                    };
3566
                                    currentControl.CommentID = Save.shortGuid();
3567
                                    currentControl.IsNew = true;
3568
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3569
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3570

    
3571
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3572
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3573
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3574
                                    currentControl.Focus();
3575

    
3576
                                    (currentControl as TextControl).Angle = Ang;
3577
                                    (currentControl as TextControl).ControlType_No = 2;
3578
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3579

    
3580
                                    CreateControl();
3581
                                    //controlType = ControlType.None;
3582
                                    currentControl = null;
3583
                                }
3584
                            }
3585
                        }
3586
                        break;
3587
                    case ControlType.ArrowTextControl:
3588
                        {
3589
                            if (mouseButtonDown == MouseButton.Left)
3590
                            {
3591
                                if (currentControl is ArrowTextControl)
3592
                                {
3593
                                    CreateControl();
3594
                                    //controlType = ControlType.None;
3595
                                    currentControl = null;
3596
                                }
3597
                                else
3598
                                {
3599
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3600
                                    {
3601
                                        currentControl = new ArrowTextControl();
3602
                                        currentControl.CommentID = Save.shortGuid();
3603
                                        currentControl.IsNew = true;
3604
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3605
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3606

    
3607
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3608

    
3609
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3610

    
3611
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3612

    
3613
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3614

    
3615
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3616

    
3617
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3618
                                        //currentControl.Focus();
3619
                                    }
3620
                                }
3621
                            }
3622
                        }
3623
                        break;
3624
                    case ControlType.ArrowTransTextControl:
3625
                        {
3626
                            if (mouseButtonDown == MouseButton.Left)
3627
                            {
3628
                                if (currentControl is ArrowTextControl)
3629
                                {
3630
                                    CreateControl();
3631
                                    //controlType = ControlType.None;
3632
                                    currentControl = null;
3633
                                }
3634
                                else
3635
                                {
3636
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3637
                                    {
3638
                                        currentControl = new ArrowTextControl();
3639
                                        currentControl.CommentID = Save.shortGuid();
3640
                                        currentControl.IsNew = true;
3641
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3642
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3643

    
3644
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3645

    
3646
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3647

    
3648
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3649

    
3650
                                        (currentControl as ArrowTextControl).isFixed = true;
3651
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3652

    
3653
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3654

    
3655
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3656
                                        //currentControl.Focus();
3657
                                    }
3658
                                }
3659
                            }
3660
                        }
3661
                        break;
3662
                    case ControlType.ArrowTextBorderControl:
3663
                        {
3664
                            if (mouseButtonDown == MouseButton.Left)
3665
                            {
3666
                                if (currentControl is ArrowTextControl)
3667
                                {
3668
                                    CreateControl();
3669
                                    //controlType = ControlType.None;
3670
                                    currentControl = null;
3671
                                }
3672
                                else
3673
                                {
3674
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3675
                                    {
3676
                                        currentControl = new ArrowTextControl()
3677
                                        {
3678
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3679
                                        };
3680
                                        currentControl.CommentID = Save.shortGuid();
3681
                                        currentControl.IsNew = true;
3682
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3683
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3684

    
3685
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3686

    
3687
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3688

    
3689
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3690
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3691

    
3692
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3693

    
3694
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3695

    
3696
                                        //currentControl.Focus();
3697
                                    }
3698
                                }
3699
                            }
3700
                        }
3701
                        break;
3702
                    case ControlType.ArrowTransTextBorderControl:
3703
                        {
3704
                            if (mouseButtonDown == MouseButton.Left)
3705
                            {
3706
                                if (currentControl is ArrowTextControl)
3707
                                {
3708
                                    CreateControl();
3709
                                    //controlType = ControlType.None;
3710
                                    currentControl = null;
3711
                                }
3712
                                else
3713
                                {
3714
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3715
                                    {
3716
                                        currentControl = new ArrowTextControl()
3717
                                        {
3718
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3719
                                        };
3720
                                        currentControl.CommentID = Save.shortGuid();
3721
                                        currentControl.IsNew = true;
3722
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3723
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3724

    
3725
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3726

    
3727
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3728

    
3729
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3730

    
3731
                                        (currentControl as ArrowTextControl).isFixed = true;
3732
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3733

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

    
3736
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3737
                                        //currentControl.Focus();
3738
                                    }
3739
                                }
3740
                            }
3741
                        }
3742
                        break;
3743
                    case ControlType.ArrowTextCloudControl:
3744
                        {
3745
                            if (mouseButtonDown == MouseButton.Left)
3746
                            {
3747
                                if (currentControl is ArrowTextControl)
3748
                                {
3749
                                    CreateControl();
3750
                                    //controlType = ControlType.None;
3751
                                    currentControl = null;
3752
                                }
3753
                                else
3754
                                {
3755
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3756
                                    {
3757
                                        currentControl = new ArrowTextControl()
3758
                                        {
3759
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3760
                                        };
3761
                                        currentControl.CommentID = Save.shortGuid();
3762
                                        currentControl.IsNew = true;
3763
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3764
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3765

    
3766
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3767

    
3768
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3769

    
3770
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3771
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3772
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3773

    
3774
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3775

    
3776
                                        //currentControl.Focus();
3777
                                    }
3778
                                }
3779
                            }
3780
                        }
3781
                        break;
3782
                    case ControlType.ArrowTransTextCloudControl:
3783
                        {
3784
                            if (mouseButtonDown == MouseButton.Left)
3785
                            {
3786
                                if (currentControl is ArrowTextControl)
3787
                                {
3788
                                    CreateControl();
3789
                                    //controlType = ControlType.None;
3790
                                    currentControl = null;
3791
                                }
3792
                                else
3793
                                {
3794
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3795
                                    {
3796
                                        currentControl = new ArrowTextControl()
3797
                                        {
3798
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3799
                                        };
3800
                                        currentControl.CommentID = Save.shortGuid();
3801
                                        currentControl.IsNew = true;
3802
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3803
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3804

    
3805
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3806

    
3807
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3808

    
3809
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3810

    
3811
                                        (currentControl as ArrowTextControl).isFixed = true;
3812
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3813

    
3814
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3815

    
3816
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3817
                                        //currentControl.Focus();
3818
                                    }
3819
                                }
3820
                            }
3821
                        }
3822
                        break;
3823
                    case ControlType.PolygonControl:
3824
                        {
3825
                            if (currentControl is PolygonControl)
3826
                            {
3827
                                var control = currentControl as PolygonControl;
3828

    
3829
                                if (mouseButtonDown == MouseButton.Right)
3830
                                {
3831
                                    control.IsCompleted = true;
3832
                                }
3833

    
3834
                                if (!control.IsCompleted)
3835
                                {
3836
                                    //control.PointC.pointSet.Add(control.EndPoint);
3837
                                    control.PointSet.Add(control.EndPoint);
3838
                                }
3839
                                else
3840
                                {
3841
                                    //control.IsSelected = true;
3842
                                    var firstPoint = control.PointSet.First();
3843
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3844
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3845
                                    control.PointSet.Add(firstPoint);
3846

    
3847
                                    control.SetPolyPath();
3848

    
3849
                                    control.ApplyOverViewData();
3850

    
3851
                                    CreateControl();
3852

    
3853
                                    //controlType = ControlType.None;
3854

    
3855
                                    currentControl = null;
3856
                                }
3857
                            }
3858
                            else
3859
                            {
3860
                                if (mouseButtonDown == MouseButton.Left)
3861
                                {
3862
                                    currentControl = new PolygonControl
3863
                                    {
3864
                                        PointSet = new List<Point>(),
3865
                                        //PointC = new StylusPointSet()
3866
                                    };
3867

    
3868
                                    if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3869
                                    {
3870
                                        var polygonControl = (currentControl as PolygonControl);
3871
                                        currentControl.CommentID = Save.shortGuid();
3872
                                        currentControl.IsNew = true;
3873
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3874
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3875
                                        //currentControl.OnApplyTemplate();
3876
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3877
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3878
                                    }
3879
                                }
3880
                            }
3881
                        }
3882
                        break;
3883
                    //강인구 추가
3884
                    case ControlType.Sign:
3885
                        {
3886
                            if (mouseButtonDown == MouseButton.Left)
3887
                            {
3888
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3889
                                {
3890
                                    if (currentControl is SignControl)
3891
                                    {
3892
                                        CreateControl();
3893
                                        currentControl = null;
3894
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3895
                                        {
3896
                                            txtBatch.Text = "Date Control을 그립니다.";
3897
                                            controlType = ControlType.Date;
3898
                                        }
3899
                                    }
3900
                                    else
3901
                                    {
3902
                                        currentControl = new SignControl
3903
                                        {
3904
                                            Background = new SolidColorBrush(Colors.Black),
3905
                                            //UserNumber = "H2011357",
3906
                                            UserNumber = App.ViewInfo.UserID,
3907
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3908
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3909
                                            ControlType = ControlType.Sign
3910
                                        };
3911

    
3912
                                        currentControl.CommentID = Save.shortGuid();
3913
                                        currentControl.IsNew = true;
3914
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3915
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3916
                                        //currentControl.ApplyTemplate();
3917
                                    }
3918
                                }
3919
                            }
3920
                        }
3921
                        break;
3922
                    case ControlType.Mark:
3923
                        {
3924
                            if (mouseButtonDown == MouseButton.Left)
3925
                            {
3926
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3927
                                {
3928
                                    if (currentControl is RectangleControl)
3929
                                    {
3930
                                        CreateControl();
3931
                                        (currentControl as RectangleControl).ApplyOverViewData();
3932
                                        //controlType = ControlType.None;
3933
                                        currentControl = null;
3934
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
3935
                                        this.cursor = Cursors.Arrow;
3936

    
3937
                                        if(Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3938
                                        {
3939
                                            txtBatch.Text = "Sign Control을 그립니다.";
3940
                                            controlType = ControlType.Sign;
3941
                                        }
3942
                                    }
3943
                                    else
3944
                                    {
3945
                                        currentControl = new RectangleControl
3946
                                        {
3947
                                            Background = new SolidColorBrush(Colors.Black),
3948
                                            Paint = PaintSet.Fill
3949
                                        };
3950

    
3951
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3952
                                        currentControl.CommentID = Save.shortGuid();
3953
                                        currentControl.IsNew = true;
3954
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3955
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3956
                                    }
3957
                                }
3958
                            }
3959
                        }
3960
                        break;
3961
                    case ControlType.Symbol:
3962
                        {
3963
                            if (mouseButtonDown == MouseButton.Left)
3964
                            {
3965
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3966
                                {
3967
                                    if (currentControl is SymControl)
3968
                                    {
3969
                                        CreateControl();
3970
                                        //(currentControl as SymControlN).ApplyOverViewData();
3971
                                        //controlType = ControlType.None;
3972
                                        currentControl = null;
3973
                                        //mouseHandlingMode = MouseHandlingMode.Selecting;
3974
                                        this.cursor = Cursors.Arrow;
3975
                                    }
3976
                                    else
3977
                                    {
3978
                                        currentControl = new SymControl
3979
                                        {
3980
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3981
                                            Background = new SolidColorBrush(Colors.Black),
3982
                                            ControlType = ControlType.Symbol
3983
                                        };
3984

    
3985
                                        currentControl.IsNew = true;
3986
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3987
                                        currentControl.CommentID = Save.shortGuid();
3988
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3989
                                    }
3990
                                }
3991
                            }
3992
                        }
3993
                        break;
3994
                    case ControlType.Stamp:
3995
                        {
3996
                            if (mouseButtonDown == MouseButton.Left)
3997
                            {
3998
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3999
                                {
4000
                                    if (currentControl is SymControlN)
4001
                                    {
4002
                                        CreateControl();
4003
                                        currentControl = null;
4004
                                        this.cursor = Cursors.Arrow;
4005
                                    }
4006
                                    else
4007
                                    {
4008
                                        currentControl = new SymControlN
4009
                                        {
4010
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4011
                                            Background = new SolidColorBrush(Colors.Black),
4012
                                            ControlType = ControlType.Stamp
4013
                                        };
4014

    
4015
                                        currentControl.IsNew = true;
4016
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4017
                                        currentControl.CommentID = Save.shortGuid();
4018
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4019
                                    }
4020
                                }
4021
                            }
4022
                        }
4023
                        break;
4024
                    case ControlType.PenControl:
4025
                        {
4026
                            //this.inkBoard.CaptureMouse();
4027

    
4028
                            if (inkBoard.Tag.ToString() == "Ink")
4029
                            {
4030
                                inkBoard.IsEnabled = true;
4031
                                StartNewStroke(canvasDrawingMouseDownPoint);
4032
                            }
4033
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4034
                            {
4035
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4036
                            }
4037
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4038
                            {
4039
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4040
                            }
4041
                            IsDrawing = true;
4042
                        }
4043
                        break;
4044
                    default:
4045
                        if (currentControl != null)
4046
                        {
4047
                            currentControl.CommentID = null;
4048
                            currentControl.IsNew = false;
4049
                        }
4050
                        break;
4051
                }
4052

    
4053
            }
4054
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting)
4055
            {
4056
                //bool Flag = true;
4057
                //ControlList = new List<object>();
4058
                //if (selected_item == null)
4059
                //{
4060
                //    selected_item = new Dictionary<Geometry, string>();
4061
                //}
4062
                //if (selected_item.Count > 0)
4063
                //{
4064
                //    mouseHandlingMode = MouseHandlingMode.Drawing;
4065

    
4066
                //    foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
4067
                //    {
4068
                //        ControlList.Add(item);
4069
                //    }
4070
                //    controlType = move.control_Move_R(ControlList, canvasDrawingMouseDownPoint);
4071
                //    currentControl = move.CurrentControl;
4072
                //}
4073
                //else
4074
                //{
4075
                //    isLeftMouseButtonDownOnWindow = true;
4076
                //}
4077
                if (controlType == ControlType.None)
4078
                {
4079
                    //init();
4080
                    //cursor = Cursors.Cross;
4081
                    //SetCursor();
4082
                    mouseHandlingMode = MouseHandlingMode.Selecting;
4083
                    this.cursor = Cursors.Arrow;
4084
                    inkDrawingCanvas.IsEnabled = false;
4085
                    isLeftMouseButtonDownOnWindow = true;
4086
                }
4087
            }
4088
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4089
            {
4090
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4091
                {
4092
                    bool mouseOff = false;
4093
                    foreach (var item in SelectLayer.Children)
4094
                    {
4095
                        if (item is AdornerFinal)
4096
                        {
4097

    
4098
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4099
                            if (over != null)
4100
                            {
4101
                                mouseOff = true;
4102
                            }
4103
                        }
4104
                    }
4105

    
4106
                    if (!mouseOff)
4107
                    {
4108
                        ReleaseAdorner();
4109
                    }
4110
                }
4111
                //if (mouseHandlingMode == MouseHandlingMode.Adorner && ViewerDataModel.Instance.MarkupControls.Where(data => data.IsMouseOver).FirstOrDefault() == null && SelectLayer.Children.Count >0)
4112
                //{
4113

    
4114
                //}
4115
                zoomAndPanControl.CaptureMouse();
4116
                e.Handled = true;
4117
            }
4118
            //txtDrawingCanvasDownPoint_X.Text = string.Format("{0:f2}", canvasDrawingMouseDownPoint.X);
4119
            //txtDrawingCanvasDownPoint_Y.Text = string.Format("{0:f2}", canvasDrawingMouseDownPoint.Y);
4120

    
4121
            //txtZoomCanvasDownPoint_X.Text = string.Format("{0:f2}", canvasZoomPanningMouseDownPoint.X);
4122
            //txtZoomCanvasDownPoint_Y.Text = string.Format("{0:f2}", canvasZoomPanningMouseDownPoint.Y);
4123
        }
4124
        int maxViewerWidth;
4125
        int maxViewerHeight;
4126
        int minViewerTop;
4127
        int minViewerLeft;
4128

    
4129
        private void RemoveLineStroke(Point P)
4130
        {
4131
            StrokeCollection hits = inkBoard.Strokes.HitTest(P);
4132
            inkBoard.Strokes.Remove(hits);
4133
        }
4134

    
4135
        private void RemovePointStroke(Point P)
4136
        {
4137
            //StrokeCollection hits = inkBoard.Strokes.HitTest(P);
4138
            foreach (Stroke hits in inkBoard.Strokes)
4139
            {
4140
                foreach (StylusPoint sty in hits.StylusPoints)
4141
                {
4142

    
4143
                }
4144
                if (hits.HitTest(P))
4145
                {
4146
                    inkBoard.Strokes.Remove(hits);
4147
                    return;
4148
                }
4149
            }
4150
        }
4151

    
4152
        private void StartNewStroke(Point P)
4153
        {
4154
            strokePoints = new StylusPointCollection();
4155
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4156
            strokePoints.Add(segment1Start);
4157
            stroke = new Stroke(strokePoints);
4158

    
4159
            stroke.DrawingAttributes.Color = Colors.Red;
4160
            stroke.DrawingAttributes.Width = 4;
4161
            stroke.DrawingAttributes.Height = 4;
4162

    
4163
            inkBoard.Strokes.Add(stroke);
4164

    
4165
            //inkBoard.Strokes.Add(stroke);
4166
        }
4167

    
4168
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4169
        {
4170
            ConsolidationMethod();
4171
        }
4172

    
4173
        public void ConsolidationMethod()
4174
        {
4175
            ChangeCommentReact();
4176

    
4177
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4178
            {
4179
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4180
            }
4181
            else
4182
            {
4183

    
4184
                if (ViewerDataModel.Instance.MarkupList_USER.Count > 0)
4185
                {
4186
                    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4187
                }
4188
                //if (ViewerDataModel.Instance.MarkupControls_USER.Count() > 0 || this.gridViewMarkup.SelectedItems.Count > 0)
4189
                //{
4190
                //    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4191
                //}
4192

    
4193
                //if (ViewerDataModel.Instance.MarkupControls_USER.Count() > 0)
4194
                //{
4195
                //    this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4196
                //}
4197

    
4198
                ViewerDataModel.Instance.IsConsolidate = true;
4199
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4200
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4201
                using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
4202
                {
4203
                    var markupInfo = Entity.MARKUP_INFO.Where(entity => entity.DOCINFO_ID == _DocInfo.ID).OrderByDescending(i => i.CONSOLIDATE).OrderByDescending(j => j.CREATE_TIME).FirstOrDefault();
4204
                    if (markupInfo.CONSOLIDATE == 1)
4205
                    {
4206
                        markupInfo.AVOID_CONSOLIDATE = 1;
4207
                    }
4208

    
4209
                    foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4210
                    {
4211

    
4212
                        Entity.MARKUP_DATA.Where(data => data.MARKUPINFO_VERSION_ID == item.MarkupVersionID).ToList().ForEach(d =>
4213
                          {
4214
                              instanceDataSet.Add(d);
4215
                          });
4216
                    }
4217

    
4218
                    KCOMDataModel.DataModel.MARKUP_INFO info = new KCOMDataModel.DataModel.MARKUP_INFO();
4219
                    info.ID = Save.shortGuid();
4220
                    info.CONSOLIDATE = 1;
4221
                    info.CREATE_TIME = DateTime.Now;
4222
                    info.DOCINFO_ID = _DocInfo.ID;
4223
                    info.UPDATE_TIME = DateTime.Now;
4224
                    info.USER_ID = App.ViewInfo.UserID;
4225
                    info.AVOID_CONSOLIDATE = 0;
4226

    
4227
                    Entity.MARKUP_INFO.AddObject(info);
4228
                    Entity.SaveChanges();
4229

    
4230

    
4231
                    KCOMDataModel.DataModel.MARKUP_INFO_VERSION info2 = new KCOMDataModel.DataModel.MARKUP_INFO_VERSION
4232
                    {
4233
                        ID = Save.shortGuid(),
4234
                        CREATE_DATE = DateTime.Now,
4235
                        MARKUP_INFO = info,
4236
                    };
4237
                    Entity.SaveChanges();
4238

    
4239
                    foreach (var item in instanceDataSet)
4240
                    {
4241
                        Entity.MARKUP_DATA.AddObject(new KCOMDataModel.DataModel.MARKUP_DATA
4242
                        {
4243
                            ID = Save.shortGuid(),
4244
                            DATA = item.DATA,
4245
                            DATA_TYPE = item.DATA_TYPE,
4246
                            PAGENUMBER = item.PAGENUMBER,
4247
                            MARKUP_INFO_VERSION = info2
4248
                        });
4249
                    }
4250
                    Entity.SaveChanges();
4251
                    this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4252
                }
4253
            }
4254
        }
4255

    
4256
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4257
        {
4258
            if (App.ViewInfo != null)
4259
            {
4260
                btnConsolidate = (sender as RadRibbonButton);
4261
                if (!App.ViewInfo.NewCommentPermission)
4262
                {
4263
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4264
                    //instanceTop = this.ParentOfType<MainWindow>().dzTopMenu;
4265
                    //instanceTop.btnSwing.Visibility = Visibility.Collapsed;
4266
                    //instanceTop.cbSwingMode.Visibility = Visibility.Collapsed;
4267

    
4268
                    //instanceTop.btnExportPDF.Visibility = Visibility.Visible;
4269
                    //instanceTop.btnExportPrint.Visibility = Visibility.Visible;
4270
                }
4271
            }
4272
        }
4273

    
4274
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4275
        {
4276

    
4277
        }
4278

    
4279
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4280
        {
4281
            btnTeamConsolidate = sender as RadRibbonButton;
4282
            if (App.ViewInfo != null)
4283
            {
4284
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4285
                {
4286
                    if (btnConsolidate != null)
4287
                    {
4288
                        btnConsolidate.Visibility = Visibility.Collapsed;
4289
                    }
4290

    
4291
                    if (!App.ViewInfo.NewCommentPermission)
4292
                    {
4293
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4294
                    }
4295
                }
4296
                else
4297
                {
4298
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4299
                }
4300
            }
4301
        }
4302

    
4303
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4304
        {
4305
            //this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
4306

    
4307
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4308
            if (item != null)
4309
            {
4310
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4311
            }
4312
            else
4313
            {
4314
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4315
            }
4316
        }
4317

    
4318
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4319
        {
4320
            btnFinalPDF = sender as RadRibbonButton;
4321
            if (App.ViewInfo != null)
4322
            {
4323
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4324
                {
4325
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4326
                    if (btnConsolidate != null)
4327
                    {
4328
                        btnConsolidate.Visibility = Visibility.Collapsed;
4329
                    }
4330
                }
4331
            }
4332
        }
4333

    
4334
        private void Button_Click(object sender, RoutedEventArgs e)
4335
        {
4336

    
4337
            //bool isGO = false;
4338
            //imageViewer.MouseLeftButtonDown += (sen, ea) =>
4339
            //  {
4340
            //      isGO = true;
4341
            //  };
4342
            //imageViewer.MouseLeftButtonUp += (sen, ea) =>
4343
            //{
4344
            //    isGO = false;
4345
            //};
4346
            //imageViewer.SizeMode = SizeMode.Fit;
4347
            //imageViewer.InteractiveMode = InteractiveMode.UserRectangle;
4348
            //imageViewer.InteractiveUserRectangle += (sen, ea) =>
4349
            //{
4350
            //    System.Diagnostics.Debug.WriteLine(ea.Bounds);
4351
            //    if (ea.Status == InteractiveModeStatus.End)
4352
            //    {
4353
            //        //zoomAndPanControl.ZoomTo(ea.Bounds);
4354
            //        zoomAndPanControl.ZoomTo(ea.Bounds);
4355
            //    }
4356

    
4357
            //};
4358

    
4359
            //Canvas.SetZIndex(imageViewer, 10);
4360
            //gather information on the viewer
4361

    
4362

    
4363
            //System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
4364
            //var result = dialog.ShowDialog();
4365
            //if (result == System.Windows.Forms.DialogResult.OK)
4366
            //{
4367
            //    using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4368
            //    {
4369
            //        imageViewer.Image = codecs.Load(dialog.FileName, 0, Leadtools.Codecs.CodecsLoadByteOrder.Gray, 1, 1);
4370
            //        //imageViewer.Image = codecs.Load(dialog.FileName, 24, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4371
            //        //imageViewer.Image.AnimationBackground = Leadtools.RasterColor.White;
4372

    
4373
            //        //var d = imageViewer.Image.CreateThumbnail(100, 100, 24, Leadtools.RasterViewPerspective.TopLeft, Leadtools.RasterSizeFlags.None);
4374
            //        //RasterImageViewer vvv = new RasterImageViewer();
4375
            //        //vvv.Image = d;
4376
            //        //zoomAndPanCanvas.Children.Add(vvv);
4377

    
4378
            //        zoomAndPanCanvas.Width = Convert.ToDouble(imageViewer.Image.ImageWidth);
4379
            //        zoomAndPanCanvas.Height = Convert.ToDouble(imageViewer.Image.ImageHeight);
4380

    
4381
            //        Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
4382
            //        Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
4383
            //        //zoomAndPanControl.AnimatedScaleToFit();
4384
            //        zoomAndPanControl.ScaleToFit();
4385
            //    }
4386
            //}
4387

    
4388
        }//괄호 다시 확인 필요
4389

    
4390
        //강인구 추가
4391
        //가로 세로 동일한 컨트롤 그리기(계산 다시 필요)
4392
        private Point ShiftDrawing(Point StartP, Point EndP)
4393
        {
4394
            Point Return_Point = EndP;
4395
            //Shift key를 눌렀을때만 발동
4396
            if (ViewerDataModel.Instance.IsPressShift)
4397
            {
4398
                Square square = new Square();
4399
                double pt_X = 0;
4400
                double pt_Y = 0;
4401
                double result = 0;
4402

    
4403
                //pt_X = Math.Max(StartP.X, EndP.X) - Math.Min(StartP.X, EndP.X);
4404
                //pt_Y = Math.Max(StartP.Y, EndP.Y) - Math.Min(StartP.Y, EndP.Y);
4405
                if (EndP.X > StartP.X && EndP.Y > StartP.Y)
4406
                {
4407
                    pt_X = EndP.X - StartP.X;
4408
                    pt_Y = EndP.Y - StartP.Y;
4409
                }
4410
                else if (EndP.X < StartP.X && EndP.Y > StartP.Y)
4411
                {
4412
                    pt_X = StartP.X - EndP.X;
4413
                    pt_Y = EndP.Y - StartP.Y;
4414
                }
4415
                else if (EndP.X > StartP.X && EndP.Y < StartP.Y)
4416
                {
4417
                    pt_X = EndP.X - StartP.X;
4418
                    pt_Y = StartP.Y - EndP.Y
4419
;
4420
                }
4421
                result = Math.Max(pt_X, pt_Y) - Math.Min(pt_X, pt_Y);
4422
                if (pt_X < pt_Y)
4423
                {
4424
                    Return_Point = new Point(EndP.X + result, EndP.Y);
4425
                }
4426
                else
4427
                {
4428
                    Return_Point = new Point(EndP.X, EndP.Y + result);
4429
                }
4430
            }
4431

    
4432
            return Return_Point;
4433
        }
4434

    
4435
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4436
        {
4437
            if (CompareMode.IsChecked)
4438
            {
4439
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0 )
4440
                {
4441
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4442
                }
4443
 
4444
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageBalanceMode ? ViewerDataModel.Instance.PageBalanceNumber.ToString() : pageNavigator.CurrentPage.PageNumber.ToString());
4445

    
4446
                //    string originFile = String.Format(@"http://cloud.devdoftech.co.kr:5977/TileSource/{0}_Tile/{1}/{2}/{3}.cmp", _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, pageNavigator.CurrentPage.PageNumber);
4447
                //    string targetFile = 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);
4448

    
4449
                //    CompareLib compareLib = new CompareLib();
4450
                //    //System.IO.Stream resultOrigin = compareLib.ChangeCmpUrlToPng(originFile);
4451
                //    //System.IO.Stream resultTarget = compareLib.ChangeCmpUrlToPng(targetFile);
4452

    
4453
                //    var resultOrigin = compareLib.ChangeCmpUrlToPng_File(originFile);
4454
                //    var resultTarget = compareLib.ChangeCmpUrlToPng_File(targetFile);
4455

    
4456
                //    string outPutFile = compareLib.ImageCompare_File(resultOrigin, resultTarget);
4457
                //    var result = compareLib.GetBoundBoxInImage(outPutFile);
4458

    
4459
                //    SolidColorBrush mySolidColorBrush = new SolidColorBrush();
4460
                //    mySolidColorBrush.Color = Color.FromArgb(255, 255, 255, 0);
4461

    
4462
                //    result.ForEach(d =>
4463
                //    {
4464
                //        d.Width = d.Width * 3;
4465
                //        d.Height = d.Height * 3;
4466
                //        var point = MathSet.getRectMiddlePoint(d);
4467
                //        Ellipse myEllipse = new Ellipse();
4468
                //        myEllipse.Fill = new SolidColorBrush(Colors.Red);
4469
                //        myEllipse.Opacity = 1;
4470
                //        //myEllipse.StrokeThickness = 2;
4471
                //        //myEllipse.Stroke = Brushes.Black;
4472
                //        myEllipse.Width = d.Width;
4473
                //        myEllipse.Height = d.Height;
4474
                //        Canvas.SetLeft(myEllipse, d.X - ((point.X - d.X) / 2.0));
4475
                //        Canvas.SetTop(myEllipse, d.Y - ((point.Y - d.Y) / 2.0));
4476
                //        myEllipse.RenderTransformOrigin = point;
4477
                //        canvas_compareBorder.Children.Add(myEllipse);
4478
                //    });
4479

    
4480
                //    da.From = 0.8;
4481
                //    da.To = 0;
4482
                //    da.Duration = new Duration(TimeSpan.FromSeconds(1));
4483
                //    da.AutoReverse = true;
4484
                //    canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4485
                //}
4486
                //else
4487
                //{
4488
                //    da.From = 1;
4489
                //    da.To = 1;
4490
                //    da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4491
                //    da.AutoReverse = false;
4492
                //    canvas_compareBorder.Children.Clear();
4493
                //    canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4494
            }
4495
            else
4496
            {
4497
                da.From = 1;
4498
                da.To = 1;
4499
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4500
                da.AutoReverse = false;
4501
                canvas_compareBorder.Children.Clear();
4502
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4503
            }
4504
        }
4505

    
4506
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4507
        {
4508
            if (UserList.IsChecked)
4509
            {
4510
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4511
            }
4512
            else
4513
            {
4514
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4515
            }
4516
            //if ((sender as RadToggleButton).IsChecked == true)
4517
            //{
4518
            //    this.gridViewRevMarkup.Visibility = Visibility.Visible;
4519
            //}
4520
            //else
4521
            //{
4522
            //    this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4523
            //}
4524
        }
4525
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4526
        {
4527
            //ViewerDataModel.Instance.PageBalanceNumber = ViewerDataModel.Instance.PageBalanceNumber <= 0 ? Convert.ToInt32((sender as System.Windows.Controls.Control).Tag) : ViewerDataModel.Instance.PageBalanceNumber;
4528
            //ViewerDataModel.Instance.PageBalanceNumber = 0;
4529

    
4530

    
4531
            if (BalanceMode.IsChecked)
4532
            {
4533
                ViewerDataModel.Instance.PageBalanceMode = true;
4534
            }
4535
            else
4536
            {
4537
                ViewerDataModel.Instance.PageBalanceMode = false;
4538
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4539
            }
4540
            //if ((sender as RadToggleButton).IsChecked == true)
4541
            //{
4542
            //    ViewerDataModel.Instance.PageBalanceMode = true;
4543
            //}
4544
            //else
4545
            //{
4546
            //    ViewerDataModel.Instance.PageBalanceMode = false;
4547
            //    ViewerDataModel.Instance.PageBalanceNumber = 0;
4548
            //}
4549
        }
4550

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

    
4564
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4565
        {
4566
            if ((sender as System.Windows.Controls.Control).Tag != null)
4567
            {
4568
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4569

    
4570
                //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
4571
                //{
4572
                //    ViewerDataModel.Instance.PageBalanceNumber = 1;
4573
                //}
4574

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

    
4580
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4581
                {
4582
                }
4583
                else
4584
                {
4585
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4586
                }
4587
                //else if ((ViewerDataModel.Instance.PageBalanceNumber + balancePoint) >= 1)
4588
                //{
4589
                //    //ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4590
                //    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4591
                //}
4592

    
4593
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4594
                {
4595

    
4596
                }
4597
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4598
                {
4599
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4600
                }
4601

    
4602
                if (!testPanel2.IsHidden)
4603
                {
4604
                    using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4605
                    {
4606
                        if (IsSyncPDFMode)
4607
                        {
4608
                            Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(CurrentRev.TO_VENDOR));
4609
                            //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageBalanceNumber);
4610
                            var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageNumber);
4611
                            Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
4612
                            size.Run(image);
4613
                            image.XResolution = 150;
4614
                            image.YResolution = 150;
4615
                            imageViewer_Compare.Image = image;
4616
                        }
4617
                        else
4618
                        {
4619
                            //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);
4620
                            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);
4621
                            imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4622
                        }
4623

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

    
4628
                        foreach (var item in gridSelectionRevItem)
4629
                        {
4630
                            item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4631
                            {
4632
                                layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4633
                            });
4634
                        }
4635

    
4636

    
4637
                        zoomAndPanCanvas2.Width = imageViewer_Compare.Image.Width;
4638
                        zoomAndPanCanvas2.Height = imageViewer_Compare.Image.Height;
4639
                        //강인구 추가
4640
                        zoomAndPanControl2.ZoomTo(new Rect
4641
                        {
4642
                            X = 0,
4643
                            Y = 0,
4644
                            Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4645
                            Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4646
                        });
4647
                    }
4648
                    //tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4649
                    //tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageBalanceNumber);
4650
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4651

    
4652
                }
4653
            }
4654
        }
4655

    
4656
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4657
        {
4658
            //if ((sender as RadToggleButton).IsChecked)
4659
            if (MarkupMode.IsChecked)                
4660
            {
4661
                //(sender as RadToggleButton).Content = "PDF Mode";
4662
                IsSyncPDFMode = true;
4663

    
4664
                var uri = CurrentRev.TO_VENDOR;
4665
                Leadtools.Pdf.PDFDocument dpc = new Leadtools.Pdf.PDFDocument(ViewerDataModel.Instance.GetStreamFromUrl(uri));
4666
                using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4667
                {
4668
                    //if (ViewerDataModel.Instance.PageBalanceNumber == 0)
4669
                    //{
4670
                    //    ViewerDataModel.Instance.PageBalanceNumber = 1;
4671
                    //}
4672
                    if (ViewerDataModel.Instance.PageNumber == 0)
4673
                    {
4674
                        ViewerDataModel.Instance.PageNumber = 1;
4675
                    }
4676

    
4677
                    //var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageBalanceNumber);
4678
                    var image = dpc.GetPageImage(codecs, ViewerDataModel.Instance.PageNumber);
4679
                    Leadtools.ImageProcessing.SizeCommand size = new Leadtools.ImageProcessing.SizeCommand((int)imageViewer.Image.Width, (int)imageViewer.Image.Height, Leadtools.RasterSizeFlags.Resample);
4680
                    size.Run(image);
4681
                    image.XResolution = 150;
4682
                    image.YResolution = 150;
4683
                    imageViewer_Compare.Image = image;
4684
                }
4685
            }
4686
            else
4687
            {
4688
                //(sender as RadToggleButton).Content = "Markup Mode";
4689
                IsSyncPDFMode = false;
4690

    
4691
                using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4692
                {
4693
                    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);
4694

    
4695
                    imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4696
                    zoomAndPanControl2.ApplyTemplate();
4697
                    zoomAndPanControl2.UpdateLayout();
4698
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4699
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4700
                }
4701
            }
4702

    
4703
            //var options = new Leadtools.Documents.LoadDocumentAsyncOptions();
4704
            //options.FirstPageNumber = pageNavigator.CurrentPage.PageNumber;
4705
            //options.LastPageNumber = pageNavigator.CurrentPage.PageNumber;
4706
            ////options.LoadEmbeddedAnnotations = true;
4707
            ////options.UseCache = true;
4708
            //options.Completed += (sen, ea) =>
4709
            //{
4710
            //    //ea.Document.Pages[0].GetAnnotations(true);
4711
            //    //SetAnnotations
4712
            //    imageViewer_Compare.Image = ea.Document.Pages[0].GetImage();
4713

    
4714
            //    zoomAndPanCanvas2.Width = Convert.ToDouble(imageViewer_Compare.Image.Width);
4715
            //    zoomAndPanCanvas2.Height = Convert.ToDouble(imageViewer_Compare.Image.Height);
4716
            //};
4717
            //var uri = new Uri("http://cloud.devdoftech.co.kr:5977/FinalPDF/000000_app/VPCS_DOCLIB/111111/11111111/ToVendor/TEST_C_A.pdf");
4718
            //Leadtools.Documents.DocumentFactory.LoadFromUriAsync(uri, options);
4719

    
4720

    
4721
        }
4722

    
4723
        private void RadButton_Click(object sender, RoutedEventArgs e)
4724
        {
4725
            gridViewHistory_Busy.IsBusy = true;
4726

    
4727
            RadButton instance = sender as RadButton;
4728
            if (instance.CommandParameter != null)
4729
            {
4730
                CurrentRev = instance.CommandParameter as VPRevision;
4731
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4732
                {
4733
                    if (ea.Error == null && ea.Result != null)
4734
                    {
4735
                        testPanel2.IsHidden = false;
4736
                        //testList.ItemsSource = ea.Result;
4737

    
4738
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4739
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4740

    
4741
                        using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4742
                        {
4743
                            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);
4744

    
4745
                            Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4746

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

    
4749
                            zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4750
                            zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4751
                            zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
4752
                            imageViewer_Compare.RotateAngle = imageViewer.RotateAngle;
4753
                            zoomAndPanControl2.ApplyTemplate();
4754
                            zoomAndPanControl2.UpdateLayout();
4755

    
4756
                            if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4757
                            {
4758
                                zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4759
                                zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4760
                            }
4761
                        }
4762

    
4763
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4764
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4765
                        gridViewHistory_Busy.IsBusy = false;
4766
                    }
4767
                };
4768
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4769
            }
4770
        }
4771

    
4772
        public void Sync_Event(VPRevision Currnet_Rev)
4773
        {
4774
            CurrentRev = Currnet_Rev;
4775

    
4776
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4777
            {
4778
                if (ea.Error == null && ea.Result != null)
4779
                {
4780
                    testPanel2.IsHidden = false;
4781
                    //testList.ItemsSource = ea.Result;
4782

    
4783
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
4784
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4785

    
4786
                    using (Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs())
4787
                    {
4788
                        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);
4789

    
4790
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4791

    
4792
                        imageViewer_Compare.Image = codecs.Load(ViewerDataModel.Instance.GetStreamFromUrl(uri), 0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, 1);
4793
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4794
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4795
                        zoomAndPanControl2.ApplyTemplate();
4796
                        zoomAndPanControl2.UpdateLayout();
4797

    
4798
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4799
                        {
4800
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4801
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4802
                        }
4803
                    }
4804

    
4805
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4806
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4807
                    gridViewHistory_Busy.IsBusy = false;
4808
                }
4809
            };
4810
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4811

    
4812

    
4813
        }
4814

    
4815
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4816
        {
4817
            if (sender is Image)
4818
            {
4819
                if ((sender as Image).Tag != null)
4820
                {
4821
                    var pdfUrl = (sender as Image).Tag.ToString();
4822
                    System.Diagnostics.Process.Start(pdfUrl);
4823
                }
4824
                else
4825
                {
4826
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4827
                }
4828
            }
4829
        }
4830

    
4831
        private void Create_Symbol(object sender, RoutedEventArgs e)
4832
        {
4833
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
4834
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
4835

    
4836
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4837
            {
4838
                DialogMessage_Alert("Please Select Controls", "Alert");
4839
            }
4840
            else //선택된 것이 있으면
4841
            {
4842
                string MarkupData = "";
4843
                adorner_ = new AdornerFinal();
4844

    
4845
                foreach (var item in SelectLayer.Children)
4846
                {
4847
                    if (item.GetType().Name == "AdornerFinal")
4848
                    {
4849
                        adorner_ = (item as Controls.AdornerFinal);
4850
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
4851
                        {
4852
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4853
                            {
4854
                                markupReturn = layer.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4855
                                MarkupData += markupReturn.ConvertData;
4856
                            }
4857
                        }
4858
                    }
4859
                }
4860
                DialogParameters parameters = new DialogParameters()
4861
                {
4862
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4863
                    DefaultPromptResultValue = "Custom State",
4864
                    Content = "Name :",
4865
                    Header = "Insert Custom Symbol Name",
4866
                    Theme = new VisualStudio2013Theme(),
4867
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4868
                };
4869
                RadWindow.Prompt(parameters);
4870

    
4871

    
4872

    
4873
            }
4874
        }
4875

    
4876
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4877
        {
4878
            //Save save = new Save();
4879
            //string urlAddress = "";
4880
            //System.IO.Stream stf = System.IO.File.Create(@"D:\Temp\3.png");
4881

    
4882

    
4883
            //if (args.DialogResult.Value)
4884
            //{
4885
            //    urlAddress = "http://172.20.100.71:9094/UserSymbol/";
4886
            //}
4887
            //PngBitmapEncoder _Encoder = symImage(data);
4888

    
4889
            //if (_Encoder != null)
4890
            //{
4891
            //    _Encoder.Save(stf);
4892
            //}
4893

    
4894
            //save.SymbolSave(args.PromptResult, urlAddress, data);
4895
        }
4896

    
4897
        public PngBitmapEncoder symImage(string data)
4898
        {
4899

    
4900

    
4901
            Canvas _canvas = new Canvas();
4902
            _canvas.Background = Brushes.White;
4903
            _canvas.Width = adorner_.BorderSize.Width;
4904
            _canvas.Height = adorner_.BorderSize.Height;
4905
            //_canvas.CacheMode = new BitmapCache { RenderAtScale = 8, SnapsToDevicePixels = true, EnableClearType = false };
4906
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
4907

    
4908
            BitmapEncoder encoder = new PngBitmapEncoder();
4909

    
4910

    
4911
            RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)_canvas.Width, (int)_canvas.Height, 96d, 96d, PixelFormats.Pbgra32);
4912

    
4913
            DrawingVisual dv = new DrawingVisual();
4914

    
4915
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width, adorner_.BorderSize.Height));
4916
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width, adorner_.BorderSize.Height)));
4917

    
4918
            using (DrawingContext ctx = dv.RenderOpen())
4919
            {
4920
                VisualBrush vb = new VisualBrush(_canvas);
4921
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width, adorner_.BorderSize.Height)));
4922
            }
4923

    
4924
            try
4925
            {
4926
                renderBitmap.Render(dv);
4927

    
4928
                GC.Collect();
4929
                GC.WaitForPendingFinalizers();
4930
                GC.Collect();
4931
                //bitmap.Render(controlToConvert);
4932
                // encode png data
4933
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4934
                // puch rendered bitmap into it
4935
                pngEncoder.Interlace = PngInterlaceOption.Off;
4936
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4937
                return pngEncoder;
4938

    
4939
            }
4940
            catch (Exception ex)
4941
            {
4942
                return null;
4943
            }
4944
        }
4945

    
4946
        public void DialogMessage_Alert(string content, string header)
4947
        {
4948
            var box = new TextBlock();
4949
            box.MinWidth = 400;
4950
            box.FontSize = 11;
4951
            //box.FontSize = 12;
4952
            box.Text = content;
4953
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4954

    
4955
            DialogParameters parameters = new DialogParameters()
4956
            {
4957
                Content = box,
4958
                Header = header,
4959
                Theme = new VisualStudio2013Theme(),
4960
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4961
            };
4962
            RadWindow.Alert(parameters);
4963
        }
4964

    
4965
        #region 캡쳐 기능
4966

    
4967
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4968
        {
4969
            if (x < 0)
4970
            {
4971
                width += x;
4972
                x = 0;
4973
            }
4974
            if (y < 0)
4975
            {
4976
                height += y;
4977
                y = 0;
4978

    
4979
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4980
            }
4981
            if (x + width > zoomAndPanCanvas.ActualWidth)
4982
            {
4983
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4984
            }
4985
            if (y + height > zoomAndPanCanvas.ActualHeight)
4986
            {
4987
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4988
            }
4989

    
4990
            byte[] pixels = CopyPixels(x, y, width, height);
4991

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

    
4994
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4995
        }
4996

    
4997
        public byte[] CopyPixels(int x, int y, int width, int height)
4998
        {
4999
            byte[] pixels = new byte[width * height * 4];
5000
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5001

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

    
5005
            return pixels;
5006
        }
5007

    
5008
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5009
        {
5010
            DrawingVisual drawingVisual = new DrawingVisual();
5011
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5012

    
5013
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5014
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5015
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5016
            drawingContext.Close();
5017

    
5018
            // 비트맵으로 변환합니다.
5019
            RenderTargetBitmap target =
5020
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5021
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5022

    
5023
            target.Render(drawingVisual);
5024
            return target;
5025
        }
5026

    
5027
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5028
        {
5029
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5030
            KCOMDataModel.DataModel.CHECK_LIST check_;
5031
            string Result = streamToBase64.ImageToBase64(source);
5032
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5033

    
5034
            using (KCOMDataModel.DataModel.CIEntities Entity = new KCOMDataModel.DataModel.CIEntities(KCOMDataModel.Common.ConnectStringBuilder.ProjectCIConnectString(App.ViewInfo.ProjectNO).ToString()))
5035
            {
5036
                Item = Entity.CHECK_LIST.Where(i => i.ID == ViewerDataModel.Instance.CheckList_ID).FirstOrDefault();
5037

    
5038
                //새로운 데이터 추가
5039
                if (Item == null)
5040
                {
5041
                    check_ = new KCOMDataModel.DataModel.CHECK_LIST
5042
                    {
5043
                        ID = Save.shortGuid(),
5044
                        USER_ID = App.ViewInfo.UserID,
5045
                        IMAGE_URL = Result,
5046
                        IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5047
                        PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5048
                        REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5049
                        DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5050
                        PROJECT_NO = App.ViewInfo.ProjectNO,
5051
                        STATUS = "False",
5052
                        CREATE_TIME = DateTime.Now,
5053
                        UPDATE_TIME = DateTime.Now,
5054
                        DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5055
                        STATUS_DESC_OPEN = "Vendor 반영 필요",
5056
                    };
5057

    
5058
                    Entity.CHECK_LIST.AddObject(check_);
5059
                }
5060
                //기존에 있던 데이터 업데이트
5061
                else
5062
                {
5063
                    Item.IMAGE_URL = Result;
5064
                    Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5065
                    Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5066
                }
5067

    
5068
                //Item.REV_0 = "Test";
5069

    
5070
                try
5071
                {
5072
                    Entity.SaveChanges();
5073
                }
5074
                catch (Exception ex)
5075
                {
5076

    
5077
                }
5078
                //Entity.SaveChanges();
5079
            }
5080
        }
5081

    
5082
        public void Set_Capture()
5083
        {
5084
            //double x = Canvas.GetLeft(dragCaptureBorder);
5085
            //double y = Canvas.GetTop(dragCaptureBorder);
5086
            double x = canvasDrawingMouseDownPoint.X;
5087
            double y = canvasDrawingMouseDownPoint.Y;
5088
            double width = dragCaptureBorder.Width;
5089
            double height = dragCaptureBorder.Height;
5090

    
5091
            if (width > 5 || height > 5)
5092
            {
5093
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5094
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5095
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5096
            }
5097
        }
5098
        #endregion
5099

    
5100
        public void CreateControl()
5101
        {
5102
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5103
            {
5104
                ViewerDataModel.Instance.UndoDataList.Remove(i);
5105
            });
5106
            multi_Undo_Data.Markup = currentControl;
5107
            UndoData.Markup_List.Add(multi_Undo_Data);
5108
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5109
        }
5110

    
5111
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5112
        {
5113
            multi_Undo_Data = new Multi_Undo_data();
5114

    
5115
            multi_Undo_Data.Markup = control;
5116

    
5117
            if ((control as IShapeControl) != null)
5118
            {
5119
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5120
            }
5121
            if ((control as IDashControl) != null)
5122
            {
5123
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5124
            }
5125
            if ((control as IPath) != null)
5126
            {
5127
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5128
            }
5129
            if ((control as UIElement) != null)
5130
            {
5131
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5132
            }
5133

    
5134
            return multi_Undo_Data;
5135
        }
5136

    
5137
        public void Undo()
5138
        {
5139
            Undo_data undo = new Undo_data();
5140
            AdornerFinal final;
5141
            ReleaseAdorner();
5142

    
5143
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
5144
            if (undo == null)
5145
                return;
5146

    
5147
            switch (undo.Event)
5148
            {
5149
                case (Event_Type.Create):
5150
                    {
5151
                        foreach (var item in undo.Markup_List)
5152
                        {
5153
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5154
                        }
5155
                    }
5156
                    break;
5157
                case (Event_Type.Delete):
5158
                    {
5159
                        foreach (var item in undo.Markup_List)
5160
                        {
5161
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5162

    
5163
                            //final = new AdornerFinal(item.Markup);
5164
                            //SelectLayer.Children.Add(final);
5165
                        }
5166
                    }
5167
                    break;
5168
                case (Event_Type.Thumb):
5169
                    {
5170
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5171

    
5172
                        foreach (var item in undo.Markup_List)
5173
                        {
5174
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5175

    
5176
                            if ((item.Markup as IViewBox) != null)
5177
                            {
5178
                                (item.Markup as IViewBox).Angle = item.Angle;
5179
                            }
5180
                            if((item.Markup as TextControl) != null)
5181
                            {
5182
                                (item.Markup as TextControl).Angle = item.Angle;
5183
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5184
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5185
                            }
5186
                            else
5187
                            {
5188
                                (item.Markup as IPath).PointSet = item.PointSet;
5189
                                (item.Markup as IPath).updateControl();
5190
                            }
5191

    
5192
                            comment.Add(item.Markup);
5193
                        }
5194
                        final = new AdornerFinal(comment);
5195
                        SelectLayer.Children.Add(final);
5196
                        ReleaseAdorner();
5197
                    }
5198
                    break;
5199
                case (Event_Type.Select):
5200
                    {
5201
                        ReleaseAdorner();
5202
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5203

    
5204
                        foreach (var item in undo.Markup_List)
5205
                        {
5206
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
5207

    
5208
                            if((item.Markup as IPath) != null)
5209
                            {
5210
                                (item.Markup as IPath).LineSize = item.LineSize;
5211
                            }
5212
                            if ((item.Markup as UIElement) != null)
5213
                            {
5214
                                (item.Markup as UIElement).Opacity = item.Opacity;
5215
                            }
5216
                            if ((item.Markup as IDashControl) != null)
5217
                            {
5218
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5219
                            }
5220
                            if((item.Markup as IShapeControl) != null)
5221
                            {
5222
                                (item.Markup as IShapeControl).Paint = item.paint;
5223
                            }
5224

    
5225
                            comment.Add(item.Markup);
5226
                        }
5227

    
5228
                        final = new AdornerFinal(comment);
5229
                        SelectLayer.Children.Add(final);
5230
                    }
5231
                    break;
5232
                case (Event_Type.Option):
5233
                    {
5234
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5235

    
5236
                        foreach (var item in undo.Markup_List)
5237
                        {
5238
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5239

    
5240
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
5241
                            {
5242
                                (item.Markup as IPath).LineSize = undo.LineSize;
5243
                            }
5244
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
5245
                            {
5246
                                (item.Markup as UIElement).Opacity = undo.Opacity;
5247
                            }
5248
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
5249
                            {
5250
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
5251
                            }
5252
                            else if(item.Markup as IShapeControl != null)
5253
                            {
5254
                                (item.Markup as IShapeControl).Paint = undo.paint;
5255
                            }
5256
                            comment.Add(item.Markup);
5257
                        }
5258
                        final = new AdornerFinal(comment);
5259
                        SelectLayer.Children.Add(final);
5260
                    }
5261
                    break;
5262
            }
5263

    
5264
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5265
           {
5266
               i.IsUndo = true;
5267
           });
5268
        }
5269

    
5270
        public void Redo()
5271
        {
5272
            AdornerFinal final;
5273
            Undo_data redo = new Undo_data();
5274
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
5275
            ReleaseAdorner();
5276
            if (redo == null)
5277
                return;
5278

    
5279
            switch (redo.Event)
5280
            {
5281
                case (Event_Type.Create):
5282
                    {
5283
                        foreach (var item in redo.Markup_List)
5284
                        {
5285
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
5286
                        }
5287
                    }
5288
                    break;
5289
                case (Event_Type.Delete):
5290
                    {
5291
                        foreach (var item in redo.Markup_List)
5292
                        {
5293
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5294
                        }
5295
                    }
5296
                    break;
5297
                case (Event_Type.Thumb):
5298
                    {
5299
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5300

    
5301
                        foreach (var item in redo.Markup_List)
5302
                        {
5303
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
5304

    
5305
                            if ((item.Markup as IViewBox) != null)
5306
                            {
5307
                                (item.Markup as IViewBox).Angle = item.Angle;
5308
                            }
5309
                            if ((item.Markup as TextControl) != null)
5310
                            {
5311
                                //(item.Markup as TextControl).CanvasX = item.PointSet[0].X;
5312
                                //(item.Markup as TextControl).CanvasY = item.PointSet[0].Y;
5313

    
5314
                                (item.Markup as TextControl).Angle = item.Angle;
5315

    
5316
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
5317
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
5318
                            }
5319
                            else
5320
                            {
5321
                                (item.Markup as IPath).PointSet = item.PointSet;
5322
                                (item.Markup as IPath).updateControl();
5323
                            }
5324
                            comment.Add(item.Markup);
5325
                        }
5326
                        final = new AdornerFinal(comment);
5327
                        SelectLayer.Children.Add(final);
5328
                        ReleaseAdorner();
5329
                    }
5330
                    break;
5331
                case (Event_Type.Select):
5332
                    {
5333
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5334

    
5335
                        foreach (var item in redo.Markup_List)
5336
                        {
5337
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5338

    
5339
                            if ((item.Markup as IPath) != null)
5340
                            {
5341
                                (item.Markup as IPath).LineSize = item.LineSize;
5342
                            }
5343
                            if ((item.Markup as UIElement) != null)
5344
                            {
5345
                                (item.Markup as UIElement).Opacity = item.Opacity;
5346
                            }
5347
                            if ((item.Markup as IDashControl) != null)
5348
                            {
5349
                                (item.Markup as IDashControl).DashSize = item.DashSize;
5350
                            }
5351
                            if ((item.Markup as IShapeControl) != null)
5352
                            {
5353
                                (item.Markup as IShapeControl).Paint = item.paint;
5354
                            }
5355

    
5356
                            comment.Add(item.Markup);
5357
                        }
5358
                        final = new AdornerFinal(comment);
5359
                        SelectLayer.Children.Add(final);
5360
                    }
5361
                    break;
5362
                case (Event_Type.Option):
5363
                    {
5364
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
5365

    
5366
                        foreach (var item in redo.Markup_List)
5367
                        {
5368
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
5369
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
5370
                            {
5371
                                (item.Markup as IPath).LineSize = redo.LineSize;
5372
                            }
5373
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
5374
                            {
5375
                                (item.Markup as UIElement).Opacity = redo.Opacity;
5376
                            }
5377
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
5378
                            {
5379
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
5380
                            }
5381
                            else if (item.Markup as IShapeControl != null)
5382
                            {
5383
                                (item.Markup as IShapeControl).Paint = redo.paint;
5384
                            }
5385
                            comment.Add(item.Markup);
5386
                        }
5387
                        final = new AdornerFinal(comment);
5388
                        SelectLayer.Children.Add(final);
5389
                    }
5390
                    break;
5391
            }
5392

    
5393
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
5394
            {
5395
                i.IsUndo = false;
5396
            });
5397
        }
5398

    
5399
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5400
        {
5401
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5402
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5403
            {
5404
                if (items.UserID == Select_ID)
5405
                {
5406
                    foreach (var item in items.MarkupList)
5407
                    {
5408
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5409
                        {
5410
                            layerControl.markupParseEx(item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", items.MarkupInfoID, Save.shortGuid());
5411
                        }
5412
                    }
5413
                }
5414
            }
5415
        }
5416

    
5417
        public void InkControl_Convert()
5418
        {
5419
            if (inkBoard.Strokes.Count > 0)
5420
            {
5421
                inkBoard.Strokes.ToList().ForEach(stroke =>
5422
                {
5423
                    List<Stroke> removingStroke = new List<Stroke>();
5424
                    StrokeCollection stC = new StrokeCollection();
5425
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
5426
                    //{
5427
                    //    removingStroke.Add(inkBoard.Strokes[i]);
5428
                    //}
5429

    
5430
                    removingStroke.Add(stroke);
5431

    
5432
                    InkToPath ip = new InkToPath();
5433
                    List<Point> inkPointSet = new List<Point>();
5434
                    PolygonControl pc = null;
5435
                    //InkControl pc = null;
5436
                    //pc = new InkControl()
5437
                    pc = new PolygonControl()
5438
                    {
5439
                        //PointC = new List<StylusPointSet>(),
5440
                        Angle = 0,
5441
                        PointSet = new List<Point>(),
5442
                        ControlType = ControlType.Ink
5443
                    };
5444
                    foreach (var item in removingStroke)
5445
                    {
5446
                        //pc.PointC.Add(new StylusPointSet() { pointSet = ip.StrokeGetPointsPlus(item) });
5447
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
5448
                        inkBoard.Strokes.Remove(item);
5449
                    }
5450
                    if (inkPointSet.Count != 0)
5451
                    {
5452
                        pc.StartPoint = inkPointSet[0];
5453
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5454
                        pc.PointSet = inkPointSet;
5455
                        pc.LineSize = 3;
5456
                        pc.CommentID = Save.shortGuid();
5457
                        //pc.StrokeColor = new SolidColorBrush(MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("ff18b7fc"));
5458
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
5459
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5460
                        pc.SetPolyPath();
5461
                    }
5462
                });
5463

    
5464
            }
5465
        }
5466
    }
5467
}
클립보드 이미지 추가 (최대 크기: 500 MB)