프로젝트

일반

사용자정보

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

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

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

1

2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Controls.Line;
4
using MarkupToPDF.Controls.Polygon;
5
using MarkupToPDF.Controls.Shape;
6
using MarkupToPDF.Controls.Text;
7
using MarkupToPDF.Controls.Etc;
8
using System;
9
using System.Collections.Generic;
10
using System.Linq;
11
using System.Text;
12
using System.Windows;
13
using System.Windows.Controls;
14
using System.Windows.Data;
15
using System.Windows.Documents;
16
using System.Windows.Input;
17
using System.Windows.Media;
18
using System.Windows.Media.Imaging;
19
using System.Windows.Navigation;
20
using System.Windows.Shapes;
21
using KCOM.Common;
22
using IKCOM;
23
using System.Windows.Ink;
24
using System.Collections.ObjectModel;
25
using Telerik.Windows.Controls;
26
using KCOM.Events;
27
using System.Reflection;
28
using MarkupToPDF.Common;
29
using KCOM.Controls;
30
using KCOMDataModel.DataModel;
31
using System.Xml;
32
using static KCOM.TempFile;
33
using System.Windows.Threading;
34
using System.Diagnostics;
35
using System.Threading;
36
using System.Windows.Resources;
37
using Svg2Xaml;
38
using System.Runtime.InteropServices;
39
using System.Windows.Media.Effects;
40
using MarkupToPDF.Controls.Cad;
41
using MarkupToPDF.Controls.Parsing;
42

    
43
namespace KCOM.Views
44
{
45
    public static class ControlExtensions
46
    {
47
        public static T Clone<T>(this T controlToClone)
48
            where T : System.Windows.Controls.Control
49
        {
50
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
51

    
52
            T instance = Activator.CreateInstance<T>();
53

    
54
            foreach (PropertyInfo propInfo in controlProperties)
55
            {
56
                if (propInfo.CanWrite)
57
                {
58
                    if (propInfo.Name != "WindowTarget")
59
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
60
                }
61
            }
62
            return instance;
63
        }
64
    }
65

    
66
    public class MyConsole
67
    {
68
        private readonly System.Threading.ManualResetEvent _readLineSignal;
69
        private string _lastLine;
70
        public MyConsole()
71
        {
72
            _readLineSignal = new System.Threading.ManualResetEvent(false);
73
            Gui = new TextBox();
74
            Gui.AcceptsReturn = true;
75
            Gui.KeyUp += OnKeyUp;
76
        }
77

    
78
        private void OnKeyUp(object sender, KeyEventArgs e)
79
        {
80
            // this is always fired on UI thread
81
            if (e.Key == Key.Enter)
82
            {
83
                // quick and dirty, but that is not relevant to your question
84
                _lastLine = Gui.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Last();
85
                // now, when you detected that user typed a line, set signal
86
                _readLineSignal.Set();
87
            }
88
        }
89

    
90
        public TextBox Gui { get; private set; }
91

    
92
        public string ReadLine()
93
        {
94
            // that should always be called from non-ui thread
95
            if (Gui.Dispatcher.CheckAccess())
96
                throw new Exception("Cannot be called on UI thread");
97
            // reset signal
98
            _readLineSignal.Reset();
99
            // wait until signal is set. This call is blocking, but since we are on non-ui thread - there is no problem with that
100
            _readLineSignal.WaitOne();
101
            // we got signalled - return line user typed.
102
            return _lastLine;
103
        }
104

    
105
        public void WriteLine(string line)
106
        {
107
            if (!Gui.Dispatcher.CheckAccess())
108
            {
109
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
110
                return;
111
            }
112

    
113
            Gui.Text += line + Environment.NewLine;
114
        }
115
    }
116

    
117
    /// <summary>
118
    /// MainMenu.xaml에 대한 상호 작용 논리
119
    /// </summary>
120
    public partial class MainMenu : UserControl
121
    {
122
        #region 프로퍼티
123
        public Undo_data UndoData { get; set; }
124
        public CommentUserInfo currentControl { get; set; }
125
        public ControlType controlType { get; set; }
126
        private Move move;
127
        private double[] rotateValue = { 0, 90, 180, 270 };
128
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
129
        public MouseButton mouseButtonDown { get; set; }
130
        private static readonly double DragThreshold = 5;
131
        private System.Windows.Input.Cursor cursor { get; set; }
132
        private Point canvasDrawingMouseDownPoint;
133
        public string filename { get; set; }
134
        private Point canvasZoomPanningMouseDownPoint;
135
        public Point getCurrentPoint;
136
        private Point canvasZoommovingMouseDownPoint;
137
        List<object> ControlList = new List<object>();
138
        private ListBox listBox = new ListBox();
139
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
140
        private bool isDraggingSelectionRect = false;
141
        DrawingAttributes inkDA = new DrawingAttributes();
142
        private VPRevision CurrentRev { get; set; }
143
        public RadRibbonButton btnConsolidate { get; set; }
144
        public RadRibbonButton btnFinalPDF { get; set; }
145
        public RadRibbonButton btnTeamConsolidate { get; set; }
146
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
147

    
148
        public string Filename_ { get; set; }
149
        public double L_Size = 0;
150
        public AdornerFinal adorner_;
151
        public Multi_Undo_data multi_Undo_Data;
152
        public string Symbol_ID = "";
153
        /// <summary>
154
        /// Set to 'true' when the left mouse-button is down.
155
        /// </summary>
156
        public bool isLeftMouseButtonDownOnWindow = false;
157

    
158
        public InkPresenter _InkBoard = null;
159
        Stroke stroke;
160
        Boolean IsDrawing = false;
161
        StylusPointCollection strokePoints;
162
        //StylusPointCollection erasePoints;
163
        RenderTargetBitmap canvasImage;
164
        Point Sync_Offset_Point;
165

    
166
        //강인구 테스트
167
        private Path _SelectionPath { get; set; }
168
        public Path SelectionPath
169
        {
170
            get
171
            {
172
                return _SelectionPath;
173
            }
174
            set
175
            {
176
                if (_SelectionPath != value)
177
                {
178
                    _SelectionPath = value;
179
                    RaisePropertyChanged("SelectionPath");
180

    
181
                }
182
            }
183
        }
184

    
185
        private System.Windows.Controls.Image _imageViewer { get; set; }
186
        public System.Windows.Controls.Image imageViewer
187
        {
188
            get
189
            {
190
                if (_imageViewer == null)
191
                {
192
                    _imageViewer = new System.Windows.Controls.Image();
193
                    return _imageViewer;
194
                }
195
                else
196
                {
197
                    return _imageViewer;
198
                }
199
            }
200
            set
201
            {
202
                if (_imageViewer != value)
203
                {
204
                    _imageViewer = value;
205
                }
206
            }
207
        }
208

    
209
        public bool IsSyncPDFMode { get; set; }
210

    
211
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
212
        public System.Windows.Controls.Image imageViewer_Compare
213
        {
214
            get
215
            {
216
                if (_imageViewer_Compare == null)
217
                {
218
                    _imageViewer_Compare = new System.Windows.Controls.Image();
219
                    return _imageViewer_Compare;
220
                }
221
                else
222
                {
223
                    return _imageViewer_Compare;
224
                }
225
            }
226
            set
227
            {
228
                if (_imageViewer_Compare != value)
229
                {
230
                    _imageViewer_Compare = value;
231
                }
232
            }
233
        }
234

    
235
        #endregion
236

    
237
        public MainMenu()
238
        {
239
            //InitializeComponent();    
240
            this.Loaded += MainMenu_Loaded;
241
        }
242

    
243
        public class TempDt
244
        {
245
            public int PageNumber { get; set; }
246
            public string CommentID { get; set; }
247
            public string ConvertData { get; set; }
248
            public int DATA_TYPE { get; set; }
249
            public string MarkupInfoID { get; set; }
250
            public int IsUpdate { get; set; }
251
        }
252

    
253
        List<TempDt> tempDtList = new List<TempDt>();
254

    
255
        private void SetCursor()
256
        {
257
            this.Cursor = cursor;
258
        }
259

    
260
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
261
        {
262
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
263
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
264
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
265
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
266
            {
267
                return true;
268
            }
269

    
270
            return false;
271
        }
272

    
273
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
274
        {
275
            if (rotate.Angle == 90 || rotate.Angle == 270)
276
            {
277
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
278
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
279
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
280
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
281
                {
282
                    return true;
283
                }
284
            }
285
            else
286
            {
287
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
288
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
289
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
290
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
291
                {
292
                    return true;
293
                }
294
            }
295

    
296
            return false;
297
        }
298

    
299

    
300
        public void DeleteItem(MarkupInfoItem item)
301
        {
302
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
303
            {
304
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
305
            }
306

    
307
            ViewerDataModel.Instance._markupInfoList.Remove(item);
308

    
309
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
310
            {
311
                ViewerDataModel.Instance.MarkupControls.Remove(a);
312
            });
313

    
314
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
315
            {
316
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
317
            });
318

    
319
            ViewerDataModel.Instance.MarkupList_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
320
            {
321
                ComingNewBieEnd = false;
322
                ViewerDataModel.Instance.MarkupList_USER.Remove(a);
323
                //임시파일에서도 삭제
324
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
325
            });
326

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

    
359
        /// <summary>
360
        /// delete selected comments
361
        /// </summary>
362
        /// <param name="sender"></param>
363
        /// <param name="e"></param>
364
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
365
        {
366
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
367
            this.ReleaseAdorner();
368

    
369
            Button content = (sender as Button);
370
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
371

    
372
            DeleteItem(item);
373
        }
374

    
375
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
376

    
377
        private static Timer timer;
378
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
379
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
380
        {
381
            InitializeComponent();
382
            
383
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
384

    
385
            if (App.ParameterMode)
386
            {
387
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
388
                imageViewer_Compare = new Image();
389
                ViewerDataModel.Instance.Capture_Opacity = 0;
390
                da.From = 0.8;
391
                da.To = 0;
392
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
393
                da.AutoReverse = true;
394
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
395

    
396
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
397
                {
398
                    this.SymbolPane.Visibility = Visibility.Collapsed;
399
                    this.FavoritePane.Visibility = Visibility.Collapsed;
400
                    this.drawingRotateCanvas.IsHitTestVisible = false;
401
                }
402
            }
403
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
404
        }
405

    
406
        private void timercallback(Object o)
407
        {
408
            Stopwatch sw = new Stopwatch();
409
            sw.Start();
410
            TempFileAdd();
411
            sw.Stop();
412

    
413
            Dispatcher.InvokeAsync(new Action(delegate
414
            {
415
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
416
                {
417
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
418
                }
419
            }));
420

    
421
            ////GC.Collect();
422
        }
423

    
424
        void TempFileAdd()
425
        {
426
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
427
            {
428
                if (ViewerDataModel.Instance.UndoDataList.Count > 0)
429
                {
430
                    DateTime undoTime = ViewerDataModel.Instance.UndoDataList.OrderByDescending(order => order.EventTime).FirstOrDefault().EventTime;
431
                    DateTime updatetime = DateTime.Now.AddDays(-1);
432
                    if (ViewerDataModel.Instance._markupInfoList.Count > 0)
433
                    {
434
                        updatetime = ViewerDataModel.Instance._markupInfoList.OrderByDescending(order => order.UpdateTime).FirstOrDefault().UpdateTime;
435
                    }
436

    
437
                    EmptyControlCheck();
438

    
439
                    if (undoTime > updatetime)
440
                    {
441
                        if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
442
                        {
443
                            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
444
                            {
445
                                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
446

    
447
                                var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
448
                                if (existItem != null)
449
                                {
450
                                    if (existItem.Data != root.ConvertData)
451
                                    {
452
                                        tempDtList.Add(new TempDt()
453
                                        {
454
                                            CommentID = control.CommentID,
455
                                            ConvertData = root.ConvertData,
456
                                            DATA_TYPE = root.DATA_TYPE,
457
                                            MarkupInfoID = App.Custom_ViewInfoId,
458
                                            PageNumber = this.pageNavigator.CurrentPage.PageNumber,
459
                                            IsUpdate = 1
460
                                        });
461
                                    }
462
                                }
463
                                else //신규 추가 된 코멘트
464
                                {
465
                                    if (root.CommentID != null)
466
                                    {
467
                                        var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
468
                                        if (currentCommentCheck != null)
469
                                        {
470
                                            tempDtList.Add(new TempDt()
471
                                            {
472
                                                CommentID = control.CommentID,
473
                                                ConvertData = root.ConvertData,
474
                                                DATA_TYPE = root.DATA_TYPE,
475
                                                MarkupInfoID = App.Custom_ViewInfoId,
476
                                                PageNumber = this.pageNavigator.CurrentPage.PageNumber,
477
                                                IsUpdate = 1
478
                                            });
479
                                        }
480
                                        else
481
                                        {
482
                                            tempDtList.Add(new TempDt()
483
                                            {
484
                                                CommentID = control.CommentID,
485
                                                ConvertData = root.ConvertData,
486
                                                DATA_TYPE = root.DATA_TYPE,
487
                                                MarkupInfoID = App.Custom_ViewInfoId,
488
                                                PageNumber = this.pageNavigator.CurrentPage.PageNumber,
489
                                                IsUpdate = 0
490
                                            });
491
                                        }
492
                                    }
493
                                }
494
                            }
495
                        }
496

    
497
                        TempFile.WriteTemp(tempDtList);
498
                        tempDtList.Clear();
499
                    }
500
                }
501
            }));
502

    
503
        }
504

    
505

    
506
        public class TempLoadData
507
        {
508
            public int PageNumber { get; set; }
509
            public string CommentID { get; set; }
510
            public string ConvertData { get; set; }
511
            public string DATA_TYPE { get; set; }
512
            public string MarkupInfoID { get; set; }
513
            public int IsUpdate { get; set; }
514
        }
515

    
516
        List<TempLoadData> tempLoadData = new List<TempLoadData>();
517
        //public string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" + ;
518
        public static string PathString = System.IO.Path.GetTempPath() + "\\MARKUS\\" + App.ViewInfo.DocumentItemID + ".tmp";
519

    
520
        public void TempLoad()
521
        {
522
            if ((System.IO.File.Exists(FilePath)) == true)
523
            {
524
                XmlDocument xdoc = new XmlDocument();
525
                xdoc.Load(FilePath);
526
                XmlNodeList nodes = xdoc.SelectNodes("/Root/CommentID");
527
                int PageNumber = 0;
528
                if (nodes.Count > 0)
529
                {
530
                    if (MessageBox.Show("저장하지 못한 데이터가 있습니다. 불러오시겠습니까?", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
531
                    {
532
                        foreach (XmlNode node in nodes)
533
                        {
534
                            string CommentID = node.Attributes["Value"].Value;
535
                            string ConvertData = node.SelectSingleNode("ConvertData").InnerText;
536
                            string DATA_TYPE = node.SelectSingleNode("DATA_TYPE").InnerText;
537
                            string MarkupInfoID = node.SelectSingleNode("MarkupInfoID").InnerText;
538
                            int IsUpdate = Convert.ToInt32(node.SelectSingleNode("IsUpdate").InnerText);
539
                            PageNumber = Convert.ToInt32(node.SelectSingleNode("PageNumber").InnerText);
540

    
541
                            tempLoadData.Add(new TempLoadData()
542
                            {
543
                                PageNumber = PageNumber,
544
                                CommentID = CommentID,
545
                                ConvertData = ConvertData,
546
                                DATA_TYPE = DATA_TYPE,
547
                                MarkupInfoID = MarkupInfoID,
548
                                IsUpdate = IsUpdate
549
                            });
550
                        }
551

    
552
                        if (PageNumber > 0)
553
                        {
554
                            this.pageNavigator.GotoPage(PageNumber);
555
                        }
556

    
557
                        // Temp Object add               
558
                        if (pageNavigator.CurrentPage.PageNumber == PageNumber)
559
                        {
560
                            TempControlLoad();
561
                        }
562
                        tempLoadData.Clear();
563
                    }
564
                }
565
                else //파일 삭제
566
                {
567
                    TempFile.Remove();
568
                }
569
            }            
570
        }
571

    
572

    
573
        public void ReleaseAdorner()
574
        {
575
            try
576
            {
577
                Logger.sendCheckLog("pageNavigator_PageChanging_ReleaseAdorner", 1);
578
                if (SelectLayer.Children.Count > 0)
579
                {
580
                    foreach (var item in SelectLayer.Children)
581
                    {
582
                        if (item.GetType().Name == "AdornerFinal")
583
                        {
584
                            (item as AdornerFinal).unRegister();
585

    
586
                            foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
587
                            {
588
                                if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
589
                                {
590
                                    if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
591
                                    {
592
                                        if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
593
                                        {
594
                                            (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.SaveCommand.shortGuid();
595
                                        }
596
                                    }
597

    
598
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
599
                                }
600
                            }
601
                        }
602
                    }
603
                    SelectLayer.Children.Clear();
604
                }
605
            }
606
            catch (Exception ex)
607
            {
608
                Logger.sendResLog("ReleaseAdorner", ex.ToString(), 0);
609
            }            
610
        }
611

    
612
        public List<CommentUserInfo> AddAdorner()
613
        {
614
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
615

    
616
            if (SelectLayer.Children.Count > 0)
617
            {
618
                foreach (var item in SelectLayer.Children)
619
                {
620
                    if (item.GetType().Name == "AdornerFinal")
621
                    {
622
                        (item as AdornerFinal).unRegister();
623

    
624
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
625
                        {
626
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
627
                            {
628
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
629
                            }
630

    
631
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
632

    
633
                            UndoData.Markup_List.Add(multi_Undo_Data);
634
                            multi_Undo_Data = new Multi_Undo_data();
635
                        }
636
                    }
637
                }
638
                SelectLayer.Children.Clear();
639
            }
640
            return adornerSet;
641
        }
642

    
643
        public void ChangeCommentReact()
644
        {
645
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
646
            bool isComingNewBie = false;
647

    
648
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
649
            {
650
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
651
                {
652
                    var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
653

    
654
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
655
                    if (existItem != null) //신규 추가 된 코멘트
656
                    {
657
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
658
                        {
659
                            existItem.Data = root.ConvertData;
660
                            existItem.IsUpdate = true;
661
                            ComingNewBieEnd = false;
662
                        }
663
                    }
664
                    else
665
                    {
666
                        if (root.CommentID != null)
667
                        {
668
                            isComingNewBie = true;
669
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
670
                            if (currentCommentCheck != null)
671
                            {
672
                                currentCommentCheck.Data = root.ConvertData;
673
                            }
674
                            else
675
                            {
676
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
677
                                {
678
                                    ID = control.CommentID,
679
                                    Data = root.ConvertData,
680
                                    Data_Type = root.DATA_TYPE,
681
                                    MarkupInfoID = App.Custom_ViewInfoId,
682
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
683
                                    Symbol_ID = control.SymbolID,
684
                                    Group_ID = control.GroupID,
685
                                });
686
                                ComingNewBieEnd = false;
687
                            }
688
                        }
689
                    }
690
                }
691
            }
692

    
693

    
694
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
695
            {
696
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
697
                {
698
                    ComingNewBieEnd = true;
699
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
700
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
701
                    gridViewMarkup.ItemsSource = null;
702
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
703
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
704
                }
705
            }
706

    
707
        }
708

    
709
        bool ComingNewBieEnd = false;
710

    
711
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
712
        {
713
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
714
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
715
            {
716
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
717
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
718
            }
719
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
720
            ViewerDataModel.Instance.UndoDataList.Clear();
721

    
722
            InkControl_Convert();
723

    
724
            ReleaseAdorner();
725
            ChangeCommentReact();
726

    
727
            Logger.sendCheckLog("pageNavigator_PageChanging_변수생성 및 값 설정", 1);
728
            CompareMode.IsChecked = false;
729
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
730

    
731

    
732
            #region 페이지가 벗어난 경우
733

    
734
            if (BalancePoint < 1)
735
            {
736
                BalancePoint = 1;
737
                ViewerDataModel.Instance.PageBalanceNumber = 0;
738
            }
739

    
740
            if (pageNavigator.PageCount < BalancePoint)
741
            {
742
                BalancePoint = pageNavigator.PageCount;
743
                ViewerDataModel.Instance.PageBalanceNumber = 0;
744
            }
745

    
746
            #endregion
747

    
748
            ViewerDataModel.Instance.PageNumber = BalancePoint;
749

    
750
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
751
            string uri = "";
752
            if (userData.COMPANY != "EXT")
753
            {
754
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
755
            }
756
            else
757
            {
758
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
759
            }
760

    
761
            var defaultBitmapImage = new BitmapImage();
762
            defaultBitmapImage.BeginInit();
763
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
764
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
765
            defaultBitmapImage.UriSource = new Uri(uri);
766
            defaultBitmapImage.EndInit();
767

    
768
            ViewerDataModel.Instance.ImageViewPath = null;
769
            GC.Collect();
770

    
771
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
772
            if (defaultBitmapImage.IsDownloading)
773
            {
774
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
775
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
776
                {
777
                    defaultBitmapImage.Freeze();
778
                    mainPanel.UpdateLayout();
779
                    GC.Collect();
780
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
781
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
782
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
783
                };
784
            }
785

    
786
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
787
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
788

    
789

    
790
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
791
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
792
            inkBoard.Width = zoomAndPanCanvas.Width;
793
            inkBoard.Height = zoomAndPanCanvas.Height;
794

    
795

    
796

    
797
            if (!testPanel2.IsHidden)
798
            {
799
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
800
                //PDF모드일때 잠시 대기(강인구)
801
                if (IsSyncPDFMode)
802
                {
803
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
804
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
805

    
806
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
807
                    if (pdfpath.IsDownloading)
808
                    {
809
                        pdfpath.DownloadCompleted += (ex, arg) =>
810
                        {
811
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
812
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
813
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
814
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
815
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
816
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
817
                        };
818
                    }
819
                    else
820
                    {
821
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
822
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
823
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
824
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
825

    
826
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
827
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
828
                    }
829
                }
830
                else
831
                {
832
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
833
                    string uri2 = "";
834
                    if (userData.COMPANY != "EXT")
835
                    {
836
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
837
                    }
838
                    else
839
                    {
840
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
841
                    }
842

    
843
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
844
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
845

    
846
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
847
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
848
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
849
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
850
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
851
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
852

    
853
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
854
                    zoomAndPanControl.ZoomTo(new Rect
855
                    {
856
                        X = 0,
857
                        Y = 0,
858
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
859
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
860
                    });
861

    
862
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
863
                    if (defaultBitmapImage_Compare.IsDownloading)
864
                    {
865
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
866
                        {
867
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
868
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
869
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
870
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
871

    
872
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
873
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
874

    
875
                            zoomAndPanControl.ZoomTo(new Rect
876
                            {
877
                                X = 0,
878
                                Y = 0,
879
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
880
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
881
                            });
882
                        };
883
                    }
884
                }
885
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
886
            }
887

    
888
            this.pageNavigator.SetNextPage();
889

    
890
            if (zoomAndPanCanvas2.Width.IsNaN())
891
            {
892
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
893
            }
894
            Logger.sendCheckLog("pageNavigator_PageChanging_ControlData Setting", 1);
895
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
896
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
897

    
898
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
899

    
900
            foreach (var item in gridSelectionItem)
901
            {
902
                if (item.UserID == App.ViewInfo.UserID)
903
                {
904
                    ViewerDataModel.Instance.current_page_commentcnt = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
905
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
906
                    {
907
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
908
                            item.MarkupInfoID, markupitem.ID);
909
                    });
910

    
911
                }
912
                else
913
                {
914
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
915
                    {
916
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
917
                    });
918
                }
919
            }
920

    
921
            if (!testPanel2.IsHidden)
922
            {
923
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
924
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
925
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
926

    
927
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
928
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
929

    
930

    
931
                foreach (var item in gridSelectionRevItem)
932
                {
933
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
934
                    {
935
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
936
                    });
937
                }
938
            }
939

    
940
            var instanceMain = this.ParentOfType<MainWindow>();
941
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
942
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
943

    
944
            instanceMain.dzTopMenu.rotateOffSet = 0;
945
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
946
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
947

    
948
            //}
949
            SetCommentPages(true);
950
        }
951

    
952

    
953
        //Temp Control Load
954
        public void TempControlLoad()
955
        {
956
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
957

    
958
            for (int k = 0; k < tempLoadData.Count; k++)
959
            {
960
                System.Windows.Controls.Control item = null;
961
                Multi_Undo_data multi_Undo_Data;
962

    
963

    
964
                switch (tempLoadData[k].IsUpdate)
965
                {
966
                    case 0://추가
967
                        var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
968
                        if (control != null)
969
                        {
970
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
971
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
972
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
973
                        }
974

    
975
                        //Control                   
976
                        item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
977

    
978
                        UndoData = new Undo_data()
979
                        {
980
                            IsUndo = false,
981
                            Event = Event_Type.Create,
982
                            EventTime = DateTime.Now,
983
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
984
                            Markup_List = new List<Multi_Undo_data>()
985
                        };
986

    
987
                        multi_Undo_Data = new Multi_Undo_data();
988
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
989
                        UndoData.Markup_List.Add(multi_Undo_Data);
990
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
991
                        break;
992
                    case 1://수정
993
                        control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
994
                        if (control != null)
995
                        {
996
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
997
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
998
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
999
                        }
1000

    
1001
                        //Control                   
1002
                        item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
1003

    
1004
                        UndoData = new Undo_data()
1005
                        {
1006
                            IsUndo = false,
1007
                            Event = Event_Type.Thumb,
1008
                            EventTime = DateTime.Now,
1009
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
1010
                            Markup_List = new List<Multi_Undo_data>()
1011
                        };
1012

    
1013
                        multi_Undo_Data = new Multi_Undo_data();
1014
                        multi_Undo_Data = this.ParentOfType<MainWindow>().dzMainMenu.Control_Style(item as MarkupToPDF.Common.CommentUserInfo);
1015
                        UndoData.Markup_List.Add(multi_Undo_Data);
1016
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
1017
                        break;
1018
                    case 2://삭제
1019

    
1020
                        control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.CommentID == tempLoadData[k].CommentID).FirstOrDefault();
1021
                        if (control != null)
1022
                        {
1023
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
1024
                            var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
1025
                            ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
1026
                        }
1027
                        break;
1028
                }
1029
            }
1030
        }
1031

    
1032
        private void SetCommentPages(bool onlyMe = false)
1033
        {
1034
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1035
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1036
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1037
            {
1038
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
1039
                instance.UserName = item.UserName;
1040
                instance.Depart = item.Depatment;
1041
                instance.MarkupInfoID = item.MarkupInfoID;
1042
                instance.IsSelected = true;
1043
                instance.isConSolidation = item.Consolidate;
1044
                instance.SetColor = item.DisplayColor;
1045
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1046
                {
1047
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
1048
                }
1049
                else
1050
                {
1051
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1052
                }
1053
                _pages.Add(instance);
1054
            }
1055
            this.pageNavigator.SetCommentList(_pages.ToList());
1056
        }
1057

    
1058
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1059
        {
1060
            if (e.MiddleButton == MouseButtonState.Pressed)
1061
            {
1062

    
1063
            }
1064
            e.Handled = true;
1065
            if (e.Delta > 0)
1066
            {
1067
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1068
                ZoomIn(currentContentMousePoint);
1069
            }
1070
            else
1071
            {
1072
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1073
                ZoomOut(currentContentMousePoint);
1074
            }
1075
        }
1076

    
1077
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1078
        {
1079
            e.Handled = true;
1080
            if (e.Delta > 0)
1081
            {
1082
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1083
                ZoomIn_Sync(currentContentMousePoint);
1084
            }
1085
            else
1086
            {
1087
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1088
                ZoomOut_Sync(currentContentMousePoint);
1089
            }
1090
        }
1091

    
1092
        #region ZoomIn & ZoomOut
1093

    
1094
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1095
        {
1096
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1097
                zoomAndPanControl.ContentZoomFocusY));
1098
        }
1099

    
1100
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1101
        {
1102
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1103
                zoomAndPanControl.ContentZoomFocusY));
1104
        }
1105

    
1106

    
1107
        //강인구 추가 (줌 인아웃 수치 변경)
1108
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1109
        private void ZoomOut(Point contentZoomCenter)
1110
        {
1111
            if (zoomAndPanControl.ContentScale > 0.39)
1112
            {
1113
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1114
            }
1115
            else
1116
            {
1117
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1118
            }
1119

    
1120
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1121
            {
1122
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1123
            }
1124
        }
1125

    
1126
        private void ZoomIn(Point contentZoomCenter)
1127
        {
1128
            if (zoomAndPanControl.ContentScale > 0.19)
1129
            {
1130
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1131
            }
1132
            else
1133
            {
1134
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1135
            }
1136

    
1137
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1138
            {
1139
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1140
            }
1141

    
1142
        }
1143

    
1144
        private void ZoomOut_Sync(Point contentZoomCenter)
1145
        {
1146
            if (zoomAndPanControl2.ContentScale > 0.39)
1147
            {
1148
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1149
            }
1150
            else
1151
            {
1152
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1153
            }
1154

    
1155
            if (Sync.IsChecked)
1156
            {
1157
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1158
            }
1159
        }
1160

    
1161
        private void ZoomIn_Sync(Point contentZoomCenter)
1162
        {
1163
            if (zoomAndPanControl2.ContentScale > 0.19)
1164
            {
1165
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1166
            }
1167
            else
1168
            {
1169
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1170
            }
1171

    
1172
            if (Sync.IsChecked)
1173
            {
1174
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1175
            }
1176
        }
1177

    
1178
        private void ZoomOut()
1179
        {
1180
            zoomAndPanControl.ContentScale -= 0.1;
1181
            //if (zoomAndPanControl2 != null)
1182
            //{
1183
            //    zoomAndPanControl2.ContentScale -= 0.1;
1184
            //}
1185
        }
1186

    
1187
        private void ZoomIn()
1188
        {
1189
            zoomAndPanControl.ContentScale += 0.1;
1190
            //if (zoomAndPanControl2 != null)
1191
            //{
1192
            //    zoomAndPanControl2.ContentScale += 0.1;
1193
            //}
1194
        }
1195

    
1196
        #endregion
1197

    
1198
        private void init()
1199
        {
1200
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1201
            {
1202

    
1203
                ControlList.Clear();
1204
                listBox.Items.Clear();
1205
                selected_item.Clear();
1206

    
1207
                (item as IMarkupCommonData).IsSelected = false;
1208
            }
1209

    
1210
        }
1211

    
1212
        private HitTestResultBehavior MyCallback(HitTestResult result)
1213
        {
1214
            //this.cursor = Cursors.UpArrow;
1215
            var element = result.VisualHit;
1216
            while (element != null && !(element is CommentUserInfo))
1217
                element = VisualTreeHelper.GetParent(element);
1218

    
1219
            if (element == null)
1220
            {
1221
                return HitTestResultBehavior.Stop;
1222
            }
1223
            else
1224
            {
1225
                if (element is CommentUserInfo)
1226
                {
1227
                    if (!hitList.Contains(element))
1228
                    {
1229
                        hitList.Add((CommentUserInfo)element);
1230
                    }
1231
                    else
1232
                    {
1233
                        return HitTestResultBehavior.Stop;
1234
                    }
1235
                    //IntersectionDetail intersectionDetail =
1236
                    //((GeometryHitTestResult)result).IntersectionDetail;
1237
                    //switch (intersectionDetail)
1238
                    //{
1239
                    //    case IntersectionDetail.FullyContains:
1240
                    //        // Add the hit test result to the list:
1241
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
1242
                    //        return HitTestResultBehavior.Continue;
1243
                    //    case IntersectionDetail.Intersects:
1244
                    //        // Set the behavior to return visuals at all z-order levels:
1245
                    //        return HitTestResultBehavior.Continue;
1246
                    //    case IntersectionDetail.FullyInside:
1247
                    //        // Set the behavior to return visuals at all z-order levels:
1248
                    //        return HitTestResultBehavior.Continue;
1249
                    //    default:
1250
                    //        return HitTestResultBehavior.Stop;
1251
                    //}
1252
                }
1253
            }
1254
            return HitTestResultBehavior.Continue;
1255
        }
1256

    
1257
        public void ReleaseSelectPath()
1258
        {
1259
            if (SelectionPath == null)
1260
            {
1261
                SelectionPath = new Path();
1262
                SelectionPath.Name = "";
1263
            }
1264
            if (SelectionPath.Name != "")
1265
            {
1266
                SelectionPath.Name = "None";
1267
            }
1268
            SelectionPath.Opacity = 0.01;
1269
            SelectionPath.RenderTransform = null;
1270
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1271
        }
1272

    
1273
        #region 컨트롤 초기화 
1274
        public void Control_Init(object control)
1275
        {
1276
            if (L_Size != 0 && (control as IPath) != null)
1277
            {
1278
                (control as IPath).LineSize = L_Size;
1279
                L_Size = 0;
1280
            }
1281

    
1282
            switch (control.GetType().Name)
1283
            {
1284
                case "RectangleControl":
1285
                    {
1286
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1287
                    }
1288
                    break;
1289
                case "CircleControl":
1290
                    {
1291
                        (control as CircleControl).StrokeColor = Brushes.Red;
1292
                    }
1293
                    break;
1294
                case "TriControl":
1295
                    {
1296
                        (control as TriControl).StrokeColor = Brushes.Red;
1297
                    }
1298
                    break;
1299
                case "RectCloudControl":
1300
                    {
1301
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1302
                    }
1303
                    break;
1304
                case "CloudControl":
1305
                    {
1306
                        (control as CloudControl).StrokeColor = Brushes.Red;
1307
                    }
1308
                    break;
1309
                case "PolygonControl":
1310
                    {
1311
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1312
                    }
1313
                    break;
1314
                case "ArcControl":
1315
                    {
1316
                        (control as ArcControl).StrokeColor = Brushes.Red;
1317
                    }
1318
                    break;
1319
                case "ArrowArcControl":
1320
                    {
1321
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1322
                    }
1323
                    break;
1324
                case "LineControl":
1325
                    {
1326
                        (control as LineControl).StrokeColor = Brushes.Red;
1327
                    }
1328
                    break;
1329
                case "ArrowControl_Multi":
1330
                    {
1331
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1332
                    }
1333
                    break;
1334
                case "TextControl":
1335
                    {
1336
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1337
                    }
1338
                    break;
1339
                case "ArrowTextControl":
1340
                    {
1341
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1342
                    }
1343
                    break;
1344
                case "InsideWhiteControl":
1345
                    {
1346
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1347
                    }
1348
                    break;
1349
                case "OverlapWhiteControl":
1350
                    {
1351
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1352
                    }
1353
                    break;
1354
                case "ClipWhiteControl":
1355
                    {
1356
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1357
                    }
1358
                    break;
1359
                case "CoordinateControl":
1360
                    {
1361
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1362
                    }
1363
                    break;
1364
            }
1365
        }
1366
        #endregion
1367

    
1368
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1369
        {
1370
            //Control_Init(e.Source);
1371
        }
1372
        private Window _dragdropWindow = null;
1373

    
1374
        [DllImport("user32.dll")]
1375
        [return: MarshalAs(UnmanagedType.Bool)]
1376
        internal static extern bool GetCursorPos(ref Win32Point pt);
1377

    
1378
        [StructLayout(LayoutKind.Sequential)]
1379
        internal struct Win32Point
1380
        {
1381
            public Int32 X;
1382
            public Int32 Y;
1383
        };
1384
        public string symbol_id = null;
1385
        public long symbol_group_id;
1386
        public int symbol_SelectedIndex;
1387
        public ImageSource symbol_img;
1388
        public string symbol_Data = null;
1389
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1390
        {
1391
            if (this._dragdropWindow != null)
1392
            {
1393
                this._dragdropWindow.Close();
1394
                this._dragdropWindow = null;
1395
            }
1396

    
1397
            symbol_id = id;
1398
            symbol_group_id = group_id;
1399
            symbol_SelectedIndex = SelectedIndex;
1400
            symbol_Data = Data_;
1401
            symbol_img = img;
1402

    
1403
      
1404
            CreateDragDropWindow2(img);
1405
        }
1406

    
1407
        private void CreateDragDropWindow2(ImageSource image)
1408
        {
1409
            this._dragdropWindow = new Window();
1410
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1411
            _dragdropWindow.WindowStyle = WindowStyle.None;
1412
            _dragdropWindow.AllowsTransparency = true;           
1413
            _dragdropWindow.AllowDrop = false;
1414
            _dragdropWindow.Background = null;
1415
            _dragdropWindow.IsHitTestVisible = false;
1416
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1417
            _dragdropWindow.Topmost = true;
1418
            _dragdropWindow.ShowInTaskbar = false;
1419
            
1420
            Rectangle r = new Rectangle();
1421
            r.Width = image.Width;
1422
            r.Height = image.Height;
1423
            r.Opacity = 0.5;            
1424
            r.Fill = new ImageBrush(image);
1425
            this._dragdropWindow.Content = r;
1426

    
1427
            Win32Point w32Mouse = new Win32Point();
1428
            GetCursorPos(ref w32Mouse);
1429

    
1430
            //w32Mouse.X = getCurrentPoint.X;
1431
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1432
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1433
            this._dragdropWindow.Show();
1434
        }
1435

    
1436
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1437
        {
1438
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1439
            {
1440
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1441

    
1442
                Point currentPos = e.GetPosition(rect);
1443

    
1444
                floatingTip.HorizontalOffset = currentPos.X + 20;
1445
                floatingTip.VerticalOffset = currentPos.Y;
1446

    
1447

    
1448
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1449
                //tool.Content = "ToolTip";
1450
                //panel.ToolTip = tool;
1451
            }
1452

    
1453
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1454
            {
1455
                #region 마우스 오버 시 색상 변경
1456
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1457
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1458

    
1459
                //if (firstCondition != null)
1460
                //{
1461
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1462

    
1463
                //    if (firstCondition.GetType().Name == "TextControl")
1464
                //    {
1465
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1466
                //        return;
1467
                //    }
1468
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1469
                //    {
1470
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1471
                //        return;
1472
                //    }
1473

    
1474
                //    if (L_Size == 0)
1475
                //    {
1476
                //        L_Size = (firstCondition as IPath).LineSize;
1477
                //        (firstCondition as IPath).LineSize *= 4;
1478
                //    }
1479
                //    switch (firstCondition.GetType().Name)
1480
                //    {
1481
                //        case "RectangleControl":
1482
                //            {
1483
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1484
                //            }
1485
                //            break;
1486
                //        case "CircleControl":
1487
                //            {
1488
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1489
                //            }
1490
                //            break;
1491
                //        case "TriControl":
1492
                //            {
1493
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1494
                //            }
1495
                //            break;
1496
                //        case "RectCloudControl":
1497
                //            {
1498
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1499
                //            }
1500
                //            break;
1501
                //        case "CloudControl":
1502
                //            {
1503
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1504
                //            }
1505
                //            break;
1506
                //        case "PolygonControl":
1507
                //            {
1508
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1509
                //            }
1510
                //            break;
1511
                //        case "ArcControl":
1512
                //            {
1513
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1514
                //            }
1515
                //            break;
1516
                //        case "LineControl":
1517
                //            {
1518
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1519
                //            }
1520
                //            break;
1521
                //        case "ArrowControl_Multi":
1522
                //            {
1523
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1524
                //            }
1525
                //            break;
1526

    
1527
                //        default:
1528
                //            {
1529

    
1530
                //            }
1531
                //            break;
1532
                //    }
1533
                //} 
1534
                #endregion
1535
            }
1536

    
1537
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1538
            #region 주석
1539
            //if (mouseButtonDown == MouseButton.Middle)
1540
            //{
1541
            //    SetCursor();
1542
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1543
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1544

    
1545
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1546
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1547
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1548

    
1549
            //    //SetCursor();
1550
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1551
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1552

    
1553
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1554

    
1555
            //    //zoomAndPanControl.ContentOffsetX += 1;
1556
            //    //zoomAndPanControl.ContentOffsetY += 1;
1557

    
1558
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1559
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1560
            //}
1561
            #endregion
1562

    
1563
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1564
            {
1565
                SetCursor();
1566
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1567
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1568

    
1569
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1570
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1571
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1572

    
1573
                if (Sync.IsChecked)
1574
                {
1575
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1576
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1577
                }
1578
            }
1579

    
1580
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1581
            {
1582
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1583
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1584
                SetCursor();
1585

    
1586
                if (IsDrawing)
1587
                {
1588
                    if (currentControl == null)
1589
                    {
1590
                        switch (controlType)
1591
                        {
1592
                            case ControlType.PenControl:
1593
                                {
1594
                                    if (inkBoard.Tag.ToString() == "Ink")
1595
                                    {
1596
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1597
                                    }
1598
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1599
                                    {
1600
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1601
                                    }
1602
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1603
                                    {
1604
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1605
                                    }
1606

    
1607
                                    //inkBoard.Strokes.Add(stroke);
1608
                                }
1609
                                break;
1610
                        }
1611
                        return;
1612
                    }
1613
                }
1614

    
1615
                if (currentControl != null)
1616
                {
1617
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1618
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1619
                    //강인구 추가
1620
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1621

    
1622
                    if ((currentControl as IPath) != null)
1623
                    {
1624
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1625
                    }
1626
                    if ((currentControl as LineControl) != null)
1627
                    {
1628
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1629
                    }
1630

    
1631
                    if ((currentControl as IShapeControl) != null)
1632
                    {
1633
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1634
                    }
1635
                    if ((currentControl as TextControl) != null)
1636
                    {
1637
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1638
                        {
1639
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1640
                        }
1641
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1642
                        {
1643
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1644
                        }
1645
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1646
                        {
1647
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1648
                        }
1649
                    }
1650
                    else if ((currentControl as ArrowTextControl) != null)
1651
                    {
1652
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1653
                        {
1654
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1655
                        }
1656
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1657
                        {
1658
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1659
                        }
1660
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1661
                        {
1662
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1663
                        }
1664
                    }
1665
                    else if ((currentControl as RectCloudControl) != null)
1666
                    {
1667
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1668
                    }
1669
                    else if ((currentControl as CloudControl) != null)
1670
                    {
1671
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1672
                    }
1673

    
1674
                    switch (controlType)
1675
                    {
1676
                        case (ControlType.Coordinate):
1677
                            {
1678
                                var control = currentControl as CoordinateControl;
1679

    
1680
                                if (control != null)
1681
                                {
1682
                                    if (move.mousemode == MouseMode.Drawing)
1683
                                    {
1684
                                        //move.control_Move(ControlList, true, moveX, moveY);
1685
                                    }
1686
                                    else
1687
                                    {
1688
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1689
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1690
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1691
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1692

    
1693

    
1694
                                        if (ViewerDataModel.Instance.IsPressShift)
1695
                                        {
1696
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1697
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1698
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1699
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1700
                                        }
1701

    
1702
                                        control.PointSet = new List<Point>
1703
                                        {
1704
                                            control.StartPoint,
1705
                                            control.LeftBottomPoint,
1706
                                            control.EndPoint,
1707
                                            control.TopRightPoint,
1708
                                        };
1709
                                        control.updateControl();
1710
                                    }
1711

    
1712
                                    //강인구 추가
1713
                                    control.ControlType = controlType;
1714
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1715
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1716
                                    //  control.Paint = PaintSet.Fill;
1717
                                }
1718
                            }
1719
                            break;
1720
                        case (ControlType.InsideWhite):
1721
                            {
1722
                                var control = currentControl as InsideWhiteControl;
1723

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

    
1737

    
1738
                                        if (ViewerDataModel.Instance.IsPressShift)
1739
                                        {
1740
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1741
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1742
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1743
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1744
                                        }
1745

    
1746
                                        control.PointSet = new List<Point>
1747
                                        {
1748
                                            control.StartPoint,
1749
                                            control.LeftBottomPoint,
1750
                                            control.EndPoint,
1751
                                            control.TopRightPoint,
1752
                                        };
1753
                                        control.updateControl();
1754
                                    }
1755

    
1756
                                    //강인구 추가
1757
                                    control.ControlType = controlType;
1758
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1759
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1760
                                    control.Paint = PaintSet.Fill;
1761
                                }
1762
                            }
1763
                            break;
1764
                        case (ControlType.OverlapWhite):
1765
                            {
1766
                                var control = currentControl as OverlapWhiteControl;
1767

    
1768
                                if (control != null)
1769
                                {
1770
                                    if (move.mousemode == MouseMode.Drawing)
1771
                                    {
1772
                                        //move.control_Move(ControlList, true, moveX, moveY);
1773
                                    }
1774
                                    else
1775
                                    {
1776
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1777
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1778
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1779
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1780

    
1781

    
1782
                                        if (ViewerDataModel.Instance.IsPressShift)
1783
                                        {
1784
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1785
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1786
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1787
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1788
                                        }
1789

    
1790
                                        control.PointSet = new List<Point>
1791
                                        {
1792
                                            control.StartPoint,
1793
                                            control.LeftBottomPoint,
1794
                                            control.EndPoint,
1795
                                            control.TopRightPoint,
1796
                                        };
1797
                                        control.updateControl();
1798
                                    }
1799

    
1800
                                    //강인구 추가
1801
                                    control.ControlType = controlType;
1802
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1803
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1804
                                    control.Paint = PaintSet.Fill;
1805
                                }
1806
                            }
1807
                            break;
1808
                        case (ControlType.ClipWhite):
1809
                            {
1810
                                var control = currentControl as ClipWhiteControl;
1811

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

    
1825

    
1826
                                        if (ViewerDataModel.Instance.IsPressShift)
1827
                                        {
1828
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1829
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1830
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1831
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1832
                                        }
1833

    
1834
                                        control.PointSet = new List<Point>
1835
                                        {
1836
                                            control.StartPoint,
1837
                                            control.LeftBottomPoint,
1838
                                            control.EndPoint,
1839
                                            control.TopRightPoint,
1840
                                        };
1841
                                        control.updateControl();
1842
                                    }
1843

    
1844
                                    //강인구 추가
1845
                                    control.ControlType = controlType;
1846
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1847
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1848
                                    control.Paint = PaintSet.Fill;
1849
                                }
1850
                            }
1851
                            break;
1852
                        case ControlType.Rectangle:
1853
                            {
1854
                                var control = currentControl as RectangleControl;
1855

    
1856
                                if (control != null)
1857
                                {
1858
                                    if (move.mousemode == MouseMode.Drawing)
1859
                                    {
1860
                                        //move.control_Move(ControlList, true, moveX, moveY);
1861
                                    }
1862
                                    else
1863
                                    {
1864
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1865
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1866
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1867
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1868

    
1869

    
1870
                                        if (ViewerDataModel.Instance.IsPressShift)
1871
                                        {
1872
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1873
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1874
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1875
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1876
                                        }
1877

    
1878
                                        control.PointSet = new List<Point>
1879
                                        {
1880
                                            control.StartPoint,
1881
                                            control.LeftBottomPoint,
1882
                                            control.EndPoint,
1883
                                            control.TopRightPoint,
1884
                                        };
1885
                                        control.updateControl();
1886
                                    }
1887

    
1888
                                    //강인구 추가
1889
                                    control.ControlType = controlType;
1890
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1891
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1892
                                }
1893
                            }
1894
                            break;
1895

    
1896
                        case ControlType.RectCloud:
1897
                            {
1898
                                var control = currentControl as RectCloudControl;
1899

    
1900
                                if (control != null)
1901
                                {
1902
                                    if (move.mousemode == MouseMode.Drawing)
1903
                                    {
1904
                                        //move.control_Move(ControlList, true, moveX, moveY);
1905
                                    }
1906
                                    else
1907
                                    {
1908
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1909
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1910
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1911
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1912

    
1913
                                        if (ViewerDataModel.Instance.IsPressShift)
1914
                                        {
1915
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1916
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1917
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1918
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
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
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1931
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1932
                                }
1933
                            }
1934
                            break;
1935

    
1936
                        case ControlType.SingleLine:
1937
                            {
1938
                                var control = currentControl as LineControl;
1939
                                if (control != null)
1940
                                {
1941
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1942
                                    control.ControlType = controlType;
1943
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1944
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1945
                                    Point tempPoint = control.EndPoint;
1946

    
1947
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1948
                                    {
1949
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1950
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1951
                                        control.EndPoint = tempPoint;
1952
                                    }
1953
                                    else
1954
                                    {
1955
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1956
                                    }
1957

    
1958
                                    control.PointSet = new List<Point>
1959
                                        {
1960
                                            control.StartPoint,
1961
                                            control.EndPoint,
1962
                                        };
1963

    
1964
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1965
                                }
1966

    
1967
                            }
1968
                            break;
1969

    
1970
                        case ControlType.CancelLine:
1971
                            {
1972
                                var control = currentControl as LineControl;
1973
                                if (control != null)
1974
                                {
1975
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1976
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1977
                                    control.ControlType = controlType;
1978
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1979
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1980
                                    Point tempPoint = control.EndPoint;
1981

    
1982
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1983
                                    {
1984
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1985
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1986
                                        control.EndPoint = tempPoint;
1987
                                    }
1988
                                    else
1989
                                    {
1990
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1991
                                    }
1992

    
1993

    
1994
                                    control.PointSet = new List<Point>
1995
                                            {
1996
                                                control.StartPoint,
1997
                                                control.EndPoint,
1998
                                            };
1999
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2000
                                }
2001

    
2002

    
2003
                            }
2004
                            break;
2005

    
2006
                        case ControlType.ArrowLine:
2007
                            {
2008
                                var control = currentControl as LineControl;
2009
                                if (control != null)
2010
                                {
2011
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
2012
                                    control.ControlType = controlType;
2013
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2014
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2015
                                    Point tempPoint = control.EndPoint;
2016

    
2017
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2018
                                    {
2019
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2020
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2021
                                        control.EndPoint = tempPoint;
2022
                                    }
2023
                                    else
2024
                                    {
2025
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2026
                                    }
2027

    
2028

    
2029
                                    control.PointSet = new List<Point>
2030
                                            {
2031
                                                control.StartPoint,
2032
                                                control.EndPoint,
2033
                                            };
2034
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2035
                                }
2036
                            }
2037
                            break;
2038

    
2039
                        case ControlType.TwinLine:
2040
                            {
2041
                                var control = currentControl as LineControl;
2042
                                if (control != null)
2043
                                {
2044
                                    control.LineStyleSet = LineStyleSet.TwinLine;
2045
                                    control.ControlType = controlType;
2046
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2047
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2048
                                    Point tempPoint = control.EndPoint;
2049

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

    
2061

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

    
2072
                        case ControlType.DimLine:
2073
                            {
2074
                                var control = currentControl as LineControl;
2075
                                if (control != null)
2076
                                {
2077
                                    control.LineStyleSet = LineStyleSet.DimLine;
2078
                                    control.ControlType = controlType;
2079
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2080
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2081
                                    Point tempPoint = control.EndPoint;
2082

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

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

    
2104
                        case ControlType.ChainLine:
2105
                            {
2106
                                var control = currentControl as PolygonControl;
2107

    
2108
                                if (control != null)
2109
                                {
2110

    
2111
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2112
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2113

    
2114
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
2115

    
2116
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2117
                                    {
2118
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2119
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
2120
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
2121
                                        //control.EndPoint = tempPoint;
2122
                                    }
2123
                                    else
2124
                                    {
2125
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2126
                                    }
2127

    
2128
                                    ///control.SetPolyPath();
2129

    
2130
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2131
                                }
2132
                            }
2133
                            break;
2134

    
2135
                        case ControlType.ArcLine:
2136
                            {
2137
                                var control = currentControl as ArcControl;
2138
                                if (control != null)
2139
                                {
2140
                                    control.isTransOn = false;
2141
                                    control.ControlType = controlType;
2142
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2143
                                    control.MidPoint = new Point(0, 0);
2144
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2145
                                    Point tempPoint = control.EndPoint;
2146

    
2147
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2148
                                    {
2149
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2150
                                        control.EndPoint = tempPoint;
2151
                                    }
2152
                                    else
2153
                                    {
2154
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2155
                                    }
2156

    
2157

    
2158
                                    control.PointSet = new List<Point>
2159
                                            {
2160
                                                control.StartPoint,
2161
                                                control.MidPoint,
2162
                                                control.EndPoint,
2163
                                            };
2164
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2165
                                }
2166
                            }
2167
                            break;
2168

    
2169
                        case ControlType.ArcArrow:
2170
                            {
2171
                                var control = currentControl as ArrowArcControl;
2172
                                if (control != null)
2173
                                {
2174
                                    control.isTransOn = false;
2175
                                    control.ControlType = controlType;
2176
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2177
                                    control.MidPoint = new Point(0, 0);
2178
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2179
                                    Point tempPoint = control.EndPoint;
2180

    
2181
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2182
                                    {
2183
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2184
                                        control.EndPoint = tempPoint;
2185
                                    }
2186
                                    else
2187
                                    {
2188
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2189
                                    }
2190

    
2191

    
2192
                                    control.PointSet = new List<Point>
2193
                                            {
2194
                                                control.StartPoint,
2195
                                                control.MidPoint,
2196
                                                control.EndPoint,
2197
                                            };
2198
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2199
                                }
2200
                            }
2201
                            break;
2202

    
2203
                        case ControlType.ArrowMultiLine:
2204
                            {
2205
                                var control = currentControl as ArrowControl_Multi;
2206
                                if (control != null)
2207
                                {
2208
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2209
                                    Point tempPoint = control.EndPoint;
2210
                                    if (control.MiddlePoint == new Point(0, 0))
2211
                                    {
2212
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2213
                                        {
2214
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2215
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2216
                                            control.EndPoint = tempPoint;
2217
                                        }
2218
                                        else
2219
                                        {
2220
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2221
                                        }
2222
                                    }
2223
                                    else
2224
                                    {
2225
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2226
                                        {
2227
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
2228
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
2229
                                            control.EndPoint = tempPoint;
2230
                                        }
2231
                                        else
2232
                                        {
2233
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
2234
                                        }
2235

    
2236
                                    }
2237

    
2238
                                    control.PointSet = new List<Point>
2239
                                            {
2240
                                                control.StartPoint,
2241
                                                control.MiddlePoint,
2242
                                                control.EndPoint,
2243
                                            };
2244
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2245
                                }
2246
                            }
2247
                            break;
2248

    
2249
                        case ControlType.Circle:
2250
                            {
2251
                                var control = currentControl as CircleControl;
2252

    
2253
                                if (control != null)
2254
                                {
2255
                                    if (move.mousemode == MouseMode.Drawing)
2256
                                    {
2257
                                        //move.control_Move(ControlList, true, moveX, moveY);
2258
                                    }
2259
                                    else
2260
                                    {
2261
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2262
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2263
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2264
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2265

    
2266
                                        if (ViewerDataModel.Instance.IsPressShift)
2267
                                        {
2268
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
2269
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
2270
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
2271
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
2272
                                        }
2273

    
2274
                                        control.PointSet = new List<Point>
2275
                                        {
2276
                                            control.StartPoint,
2277
                                            control.LeftBottomPoint,
2278
                                            control.EndPoint,
2279
                                            control.TopRightPoint,
2280
                                        };
2281
                                    }
2282

    
2283
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2284
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2285

    
2286
                                }
2287
                            }
2288
                            break;
2289

    
2290
                        case ControlType.PolygonCloud:
2291
                            {
2292
                                var control = currentControl as CloudControl;
2293

    
2294
                                if (control != null)
2295
                                {
2296
                                    control.isTransOn = true;
2297
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2298

    
2299
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2300

    
2301
                                    control.SetCloud();
2302
                                    //강인구 추가
2303
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2304
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2305
                                }
2306
                            }
2307
                            break;
2308

    
2309
                        case ControlType.Triangle:
2310
                            {
2311
                                var control = currentControl as TriControl;
2312

    
2313
                                if (control != null)
2314
                                {
2315
                                    if (move.mousemode == MouseMode.Drawing)
2316
                                    {
2317
                                        //move.control_Move(ControlList, true, moveX, moveY);
2318
                                    }
2319
                                    else
2320
                                    {
2321
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2322
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2323

    
2324
                                        if (ViewerDataModel.Instance.checkAxis)
2325
                                        {
2326
                                            Point tempPoint = control.EndPoint;
2327
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2328
                                            control.EndPoint = tempPoint;
2329
                                        }
2330

    
2331

    
2332
                                        if (ViewerDataModel.Instance.IsPressShift)
2333
                                        {
2334
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2335
                                            if (2 == Points.Count())
2336
                                            {
2337
                                                control.MidPoint = Points[0];
2338
                                                control.EndPoint = Points[1];
2339
                                            }
2340
                                        }
2341

    
2342
                                        control.PointSet = new List<Point>
2343
                                            {
2344
                                                control.StartPoint,
2345
                                                control.MidPoint,
2346
                                                control.EndPoint,
2347
                                            };
2348
                                    }
2349

    
2350
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2351
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2352
                                }
2353
                            }
2354
                            break;
2355

    
2356
                        case ControlType.ImgControl:
2357
                            {
2358
                                var control = currentControl as ImgControl;
2359

    
2360
                                if (control != null)
2361
                                {
2362
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2363
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2364
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2365
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2366

    
2367
                                    control.PointSet = new List<Point>
2368
                                        {
2369
                                            control.StartPoint,
2370
                                            control.LeftBottomPoint,
2371
                                            control.EndPoint,
2372
                                            control.TopRightPoint,
2373
                                        };
2374
                                }
2375
                            }
2376
                            break;
2377

    
2378
                        case ControlType.Date:
2379
                            {
2380
                                var control = currentControl as DateControl;
2381

    
2382
                                if (control != null)
2383
                                {
2384
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2385
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2386
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2387
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2388
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2389

    
2390
                                    control.PointSet = new List<Point>
2391
                                        {
2392
                                            control.StartPoint,
2393
                                            control.LeftBottomPoint,
2394
                                            control.EndPoint,
2395
                                            control.TopRightPoint,
2396
                                        };
2397
                                }
2398
                            }
2399
                            break;
2400

    
2401
                        case ControlType.ArrowTextControl:
2402
                            {
2403
                                var control = currentControl as ArrowTextControl;
2404

    
2405
                                if (control != null)
2406
                                {
2407
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2408
                                    Point tempPoint = control.EndPoint;
2409

    
2410
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2411

    
2412
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2413
                                    {
2414
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2415
                                        control.EndPoint = tempPoint;
2416
                                    }
2417
                                    else
2418
                                    {
2419
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2420
                                    }
2421
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2422

    
2423
                                    control.PointSet = new List<Point>
2424
                                            {
2425
                                                control.StartPoint,
2426
                                                control.MidPoint,
2427
                                                control.EndPoint,
2428
                                            };
2429
                                }
2430
                            }
2431
                            break;
2432

    
2433
                        case ControlType.ArrowTransTextControl:
2434
                            {
2435
                                var control = currentControl as ArrowTextControl;
2436

    
2437
                                if (control != null)
2438
                                {
2439
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2440
                                    Point tempPoint = control.EndPoint;
2441
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2442

    
2443
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2444
                                    {
2445
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2446
                                        control.EndPoint = tempPoint;
2447
                                    }
2448
                                    else
2449
                                    {
2450
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2451
                                    }
2452
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2453
                                    control.isFixed = true;
2454

    
2455
                                    control.PointSet = new List<Point>
2456
                                            {
2457
                                                control.StartPoint,
2458
                                                control.MidPoint,
2459
                                                control.EndPoint,
2460
                                            };
2461
                                }
2462
                            }
2463
                            break;
2464

    
2465
                        case ControlType.ArrowTextBorderControl:
2466
                            {
2467
                                var control = currentControl as ArrowTextControl;
2468

    
2469
                                if (control != null)
2470
                                {
2471
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2472
                                    Point tempPoint = control.EndPoint;
2473
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2474
                                    {
2475
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2476
                                        control.EndPoint = tempPoint;
2477
                                    }
2478
                                    else
2479
                                    {
2480
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2481
                                    }
2482
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2483
                                    control.PointSet = new List<Point>
2484
                                            {
2485
                                                control.StartPoint,
2486
                                                control.MidPoint,
2487
                                                control.EndPoint,
2488
                                            };
2489
                                }
2490

    
2491
                            }
2492
                            break;
2493
                        case ControlType.ArrowTransTextBorderControl:
2494
                            {
2495
                                var control = currentControl as ArrowTextControl;
2496

    
2497
                                if (control != null)
2498
                                {
2499
                                    control.isFixed = true;
2500
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2501
                                    Point tempPoint = control.EndPoint;
2502
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2503
                                    {
2504
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2505
                                        control.EndPoint = tempPoint;
2506
                                    }
2507
                                    else
2508
                                    {
2509
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2510
                                    }
2511

    
2512
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2513
                                    control.PointSet = new List<Point>
2514
                                            {
2515
                                                control.StartPoint,
2516
                                                control.MidPoint,
2517
                                                control.EndPoint,
2518
                                            };
2519
                                }
2520

    
2521
                            }
2522
                            break;
2523
                        case ControlType.ArrowTextCloudControl:
2524
                            {
2525
                                var control = currentControl as ArrowTextControl;
2526

    
2527
                                if (control != null)
2528
                                {
2529
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2530
                                    Point tempPoint = control.EndPoint;
2531
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2532
                                    {
2533
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2534
                                        control.EndPoint = tempPoint;
2535
                                    }
2536
                                    else
2537
                                    {
2538
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2539
                                    }
2540
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2541
                                    control.PointSet = new List<Point>
2542
                                            {
2543
                                                control.StartPoint,
2544
                                                control.MidPoint,
2545
                                                control.EndPoint,
2546
                                            };
2547
                                }
2548

    
2549
                            }
2550
                            break;
2551
                        case ControlType.ArrowTransTextCloudControl:
2552
                            {
2553
                                var control = currentControl as ArrowTextControl;
2554

    
2555
                                if (control != null)
2556
                                {
2557
                                    control.isFixed = true;
2558
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2559
                                    Point tempPoint = control.EndPoint;
2560
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2561
                                    {
2562
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2563
                                        control.EndPoint = tempPoint;
2564
                                    }
2565
                                    else
2566
                                    {
2567
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2568
                                    }
2569
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2570
                                    control.PointSet = new List<Point>
2571
                                            {
2572
                                                control.StartPoint,
2573
                                                control.MidPoint,
2574
                                                control.EndPoint,
2575
                                            };
2576
                                }
2577

    
2578
                            }
2579
                            break;
2580
                        case ControlType.PolygonControl:
2581
                            {
2582

    
2583
                                var control = currentControl as PolygonControl;
2584

    
2585
                                if (control != null)
2586
                                {
2587
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2588
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2589
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2590
                                    ///control.SetPolyPath();
2591
                                    //강인구 추가
2592
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2593
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2594
                                }
2595
                            }
2596
                            break;
2597
                        //강인구 추가
2598
                        case ControlType.Sign:
2599
                            {
2600
                                var control = currentControl as SignControl;
2601

    
2602
                                if (control != null)
2603
                                {
2604
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2605
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2606
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2607
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2608

    
2609
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2610
                                    {
2611
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2612
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2613
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2614
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2615
                                        stream.Position = 0;
2616
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2617
                                        BitmapImage returnImage = new BitmapImage();
2618
                                        returnImage.BeginInit();
2619
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2620
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2621
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2622
                                        returnImage.StreamSource = ms;
2623
                                        returnImage.EndInit();
2624
                                        stream.Close();
2625

    
2626
                                        control.SignImage = returnImage;
2627
                                    }
2628
                                    control.PointSet = new List<Point>
2629
                                        {
2630
                                            control.StartPoint,
2631
                                            control.LeftBottomPoint,
2632
                                            control.EndPoint,
2633
                                            control.TopRightPoint,
2634
                                        };
2635
                                }
2636
                            }
2637
                            break;
2638
                        //TODO: 강인구 추가
2639
                        case ControlType.Symbol:
2640
                            {
2641
                                var control = currentControl as SymControl;
2642

    
2643
                                if (control != null)
2644
                                {
2645
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2646
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2647
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2648
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2649
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2650
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2651

    
2652
                                    if (control.StartPoint != control.EndPoint)
2653
                                    {
2654
                                        if (control.PathData == null)
2655
                                        {
2656
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2657
                                            {
2658
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2659
                                            }
2660
                                        }
2661
                                    }
2662

    
2663
                                    control.PointSet = new List<Point>
2664
                                        {
2665
                                            control.StartPoint,
2666
                                            control.LeftBottomPoint,
2667
                                            control.EndPoint,
2668
                                            control.TopRightPoint,
2669
                                        };
2670
                                }
2671
                            }
2672
                            break;
2673
                        ///TODO: 
2674
                        case ControlType.Stamp:
2675
                            {
2676
                                var control = currentControl as SymControlN;
2677

    
2678
                                if (control != null)
2679
                                {
2680

    
2681
                                    if (control.StartPoint == control.EndPoint)
2682
                                    {
2683
                                        //string appovalData = "";
2684

    
2685
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2686
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2687

    
2688

    
2689
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2690

    
2691
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2692
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2693
                                        writer.Write(xamlData);
2694
                                        writer.Flush();
2695
                                        stream.Position = 0;
2696

    
2697
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2698
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2699
                                        UIElement ob = obj as UIElement;
2700

    
2701
                                        //control.ApplyTemplate();
2702

    
2703
                                        control.SetViewBox();
2704
                                        control.PathXathData = App.SystemInfo.STAMP;
2705
                                        control.Base_ViewBox.Child = ob;
2706
                                    }
2707

    
2708
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2709
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2710
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2711
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2712
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2713

    
2714

    
2715
                                    control.PointSet = new List<Point>
2716
                                    {
2717
                                        control.StartPoint,
2718
                                        control.LeftBottomPoint,
2719
                                        control.EndPoint,
2720
                                        control.TopRightPoint,
2721
                                    };
2722
                                }
2723
                            }
2724
                            break;
2725
                        case ControlType.Mark:
2726
                            {
2727
                                var control = currentControl as RectangleControl;
2728

    
2729
                                if (control != null)
2730
                                {
2731
                                    if (move.mousemode == MouseMode.Drawing)
2732
                                    {
2733
                                        //move.control_Move(ControlList, true, moveX, moveY);
2734
                                    }
2735
                                    else
2736
                                    {
2737
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2738
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2739
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2740
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2741

    
2742

    
2743
                                        control.PointSet = new List<Point>
2744
                                    {
2745
                                        control.StartPoint,
2746
                                        control.LeftBottomPoint,
2747
                                        control.EndPoint,
2748
                                        control.TopRightPoint,
2749
                                    };
2750
                                    }
2751

    
2752
                                    //강인구 추가
2753
                                    control.Paint = PaintSet.Fill;
2754
                                }
2755
                            }
2756
                            break;
2757
                        case ControlType.PenControl:
2758
                            {
2759
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2760
                                //inkBoard.Strokes.Add(stroke);
2761
                            }
2762
                            break;
2763
                        default:
2764
                            break;
2765
                    }
2766
                }
2767
            }
2768
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2769
            {
2770
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2771

    
2772
                if (isDraggingSelectionRect)
2773
                {
2774
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2775

    
2776
                    e.Handled = true;
2777
                }
2778
                else if (isLeftMouseButtonDownOnWindow)
2779
                {
2780
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2781
                    double dragDistance = Math.Abs(dragDelta.Length);
2782

    
2783
                    if (dragDistance > DragThreshold)
2784
                    {
2785
                        isDraggingSelectionRect = true;
2786

    
2787
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2788
                    }
2789

    
2790
                    e.Handled = true;
2791
                }
2792

    
2793

    
2794
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2795
                {
2796
                    //SelectionPath = new Path();
2797
                    //PathFigure pathFigure = new PathFigure();
2798
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2799
                    //SelectionPath.Opacity = 0.5;
2800
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2801
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2802
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2803
                }
2804
                else
2805
                {
2806
                    //List<Stroke> removingStroke = new List<Stroke>();
2807
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2808
                    //StrokeCollection stC = new StrokeCollection();
2809
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2810
                    //{
2811
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2812
                    //    p1.Intersect(p2);
2813
                    //    if (p1.IsEmpty)
2814
                    //    {
2815

    
2816

    
2817
                    //        p1 = SelectionPath.Data.Bounds;
2818
                    //        bool intersectCheck = false;
2819
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2820
                    //        {
2821
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2822
                    //            p1.Intersect(p3);
2823
                    //            if (!p1.IsEmpty)
2824
                    //            {
2825
                    //                intersectCheck = true;
2826
                    //            }
2827
                    //        }
2828
                    //        if (intersectCheck)
2829
                    //        {
2830
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2831
                    //        }
2832

    
2833
                    //    }
2834
                    //    else
2835
                    //    {
2836
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2837
                    //    }
2838
                    //}
2839

    
2840
                    e.Handled = true;
2841
                }
2842
            }
2843
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2844
            { //symbol      
2845
                if(_dragdropWindow != null)
2846
                {
2847
                    Win32Point w32Mouse = new Win32Point();
2848
                    GetCursorPos(ref w32Mouse);
2849

    
2850
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2851
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2852
                }                
2853
            }
2854
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2855
            {
2856
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2857
                if (control != null)
2858
                {
2859
                    this.cursor = Cursors.Hand;
2860
                    SetCursor();
2861
                }
2862
                else
2863
                {
2864
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2865

    
2866
                    SetCursor();
2867
                }
2868
            }
2869
            else
2870
            {
2871
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2872

    
2873
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2874
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2875

    
2876
                //if (hitList.Count > 0)
2877
                //{
2878

    
2879
                //}
2880

    
2881
                #region 조건 설정 : firstCondition
2882
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2883
                //pnts = generalTransform.Transform(pnts);
2884
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2885
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2886
                //                               this.DeepLayer._BaseLayer).ToObservable()
2887
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2888
                //                      select kkk).FirstOrDefault();
2889

    
2890
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2891
                //if (canvas !=null)
2892
                //{
2893
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2894
                //    {
2895
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2896
                //        if (uiElement!=null)
2897
                //        {
2898
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2899
                //        }
2900
                //    }
2901
                //}
2902

    
2903
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2904
                //hitResultsList.Clear();
2905

    
2906
                #endregion
2907
            }
2908
        }
2909

    
2910
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2911
        {
2912
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2913
            {
2914
                SetCursor();
2915
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2916
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2917

    
2918
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2919

    
2920
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2921
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2922

    
2923
                if (Sync.IsChecked)
2924
                {
2925
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2926
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2927
                }
2928
            }
2929
        }
2930

    
2931
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2932

    
2933
        private EllipseGeometry hitArea = new EllipseGeometry();
2934

    
2935
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2936
        {
2937
            IsDrawing = false;
2938

    
2939
            if (mouseHandlingMode != MouseHandlingMode.None)
2940
            {
2941
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2942
                {
2943
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2944

    
2945
                    SetCursor();
2946

    
2947
                    switch (controlType)
2948
                    {
2949
                        case ControlType.None:
2950
                            break;
2951
                        case ControlType.Rectangle:
2952
                            {
2953

    
2954
                            }
2955
                            break;
2956
                        case ControlType.PenControl:
2957
                            {
2958

    
2959
                            }
2960
                            break;
2961
                        default:
2962
                            break;
2963
                    }
2964
                }
2965
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2966
                {
2967
                    if (isLeftMouseButtonDownOnWindow)
2968
                    {
2969
                        bool wasDragSelectionApplied = false;
2970

    
2971
                        if (isDraggingSelectionRect)
2972
                        {
2973
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2974
                            {
2975
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2976
                                mouseHandlingMode = MouseHandlingMode.None;
2977
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2978
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2979
                                Set_Symbol_Capture(endPoint);
2980
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2981
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2982
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2983
                            }
2984
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2985
                            {
2986
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2987
                                mouseHandlingMode = MouseHandlingMode.None;
2988
                                Set_Capture();
2989

    
2990
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2991
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2992
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2993
                            }
2994
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2995
                            {
2996
                                ApplyDragSelectionRect();
2997
                            }
2998
                            else
2999
                            {
3000
                                double x = Canvas.GetLeft(dragZoomBorder);
3001
                                double y = Canvas.GetTop(dragZoomBorder);
3002
                                double width = dragZoomBorder.Width;
3003
                                double height = dragZoomBorder.Height;
3004
                                Rect dragRect = new Rect(x, y, width, height);
3005

    
3006
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
3007

    
3008
                                dragZoomBorder.Visibility = Visibility.Collapsed;
3009
                            }
3010

    
3011
                            isDraggingSelectionRect = false;
3012
                            e.Handled = true;
3013
                            wasDragSelectionApplied = true;
3014
                        }
3015

    
3016
                        if (isLeftMouseButtonDownOnWindow)
3017
                        {
3018
                            isLeftMouseButtonDownOnWindow = false;
3019
                            this.ReleaseMouseCapture();
3020
                            e.Handled = true;
3021
                        }
3022

    
3023
                        if (!wasDragSelectionApplied)
3024
                        {
3025
                            init();
3026
                        }
3027
                    }
3028
                }
3029
                else if (mouseButtonDown == MouseButton.Right)
3030
                {
3031
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3032
                    SetCursor();
3033
                }
3034

    
3035
                zoomAndPanControl.ReleaseMouseCapture();
3036

    
3037

    
3038
                e.Handled = true;
3039
            }
3040
            else
3041
            {
3042
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3043
                SetCursor();
3044
            }
3045
            mouseButtonDown = MouseButton.Left;
3046

    
3047
            //controlType = ControlType.SingleLine;
3048
        }
3049

    
3050
        public void Set_Symbol_Capture(Point endPoint)
3051
        {       
3052
            double x = canvasDrawingMouseDownPoint.X;
3053
            double y = canvasDrawingMouseDownPoint.Y;
3054
            if(x > endPoint.X)
3055
            {
3056
                x = endPoint.X;
3057
                y = endPoint.Y;
3058
            }
3059

    
3060
            double width = dragCaptureBorder.Width;
3061
            double height = dragCaptureBorder.Height;
3062

    
3063
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
3064

    
3065
            if (x < 0)
3066
            {
3067
                width += x;
3068
                x = 0;
3069
            }
3070
            if (y < 0)
3071
            {
3072
                height += y;
3073
                y = 0;
3074

    
3075
                width = (int)canvasImage.PixelWidth - x;
3076
            }
3077
            if (x + width > canvasImage.PixelWidth)
3078
            {
3079
                width = (int)canvasImage.PixelWidth - x;
3080
            }
3081
            if (y + height > canvasImage.PixelHeight)
3082
            {
3083
                height = (int)canvasImage.PixelHeight - y;
3084
            }
3085
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
3086

    
3087
            string uri = "";
3088
            if (userData.COMPANY != "EXT")
3089
            {
3090
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO,
3091
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
3092
            }
3093
            else
3094
            {
3095
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
3096
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
3097
            }
3098

    
3099
            var defaultBitmapImage = new BitmapImage();
3100
            defaultBitmapImage.BeginInit();
3101
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
3102
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
3103
            defaultBitmapImage.UriSource = new Uri(uri);
3104
            defaultBitmapImage.EndInit();
3105

    
3106
            //GC.Collect();
3107

    
3108
            if (defaultBitmapImage.IsDownloading)
3109
            {
3110
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
3111
                {
3112
                    defaultBitmapImage.Freeze();
3113
                    //GC.Collect();
3114
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
3115
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
3116
                };
3117
            }
3118
        }
3119

    
3120
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
3121
        {
3122
            mouseButtonDown = MouseButton.Left;
3123
        }
3124

    
3125
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
3126
        {
3127
            mouseButtonDown = MouseButton.Left;
3128
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3129
        }
3130

    
3131
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
3132
        {
3133

    
3134
        }
3135

    
3136
        /// <summary>
3137
        /// select item which's bouding rectangle is equal to given rectangle
3138
        /// </summary>
3139
        /// <author>humkyung</author>
3140
        /// <date>2018.06.14</date>
3141
        /// <param name="rect"></param>
3142
        public void SelecteItemByRect(Rect rect)
3143
        {
3144
            multi_Undo_Data = new Multi_Undo_data();
3145

    
3146
            UndoData = new Undo_data()
3147
            {
3148
                IsUndo = false,
3149
                Event = Event_Type.Select,
3150
                EventTime = DateTime.Now,
3151
                Markup_List = new List<Multi_Undo_data>()
3152
            };
3153
           
3154
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
3155

    
3156
            CommentUserInfo selected = null;
3157
            double dMinDiff = double.MaxValue;
3158
            Move tmp = new Move();
3159
            foreach (var item in Items)
3160
            {
3161
                Rect boundingBox = tmp.ItemRect(item);
3162
                double dx = rect.X - boundingBox.X;
3163
                double dy = rect.Y - boundingBox.Y;
3164
                double dxx = rect.Right - boundingBox.Right;
3165
                double dyy = rect.Bottom - boundingBox.Bottom;
3166
                double dDiff = Math.Sqrt(dx * dx + dy * dy + dxx * dxx + dyy * dyy);
3167
                if (dDiff < dMinDiff)
3168
                {
3169
                    dMinDiff = dDiff;
3170
                    selected = item;
3171
                }
3172
            }
3173

    
3174
            if (selected != null)
3175
            {
3176
                this.ReleaseAdorner();
3177

    
3178
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
3179
                adornerSet.Add(selected);
3180
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
3181

    
3182
                Control_Style(selected);
3183
                UndoData.Markup_List.Add(multi_Undo_Data);
3184
                multi_Undo_Data = new Multi_Undo_data();
3185

    
3186
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3187
                {
3188
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
3189
                });
3190
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3191

    
3192
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
3193
                SelectLayer.Children.Add(final);
3194
            }
3195
        }
3196

    
3197
        private void ApplyDragSelectionRect()
3198
        {
3199
            multi_Undo_Data = new Multi_Undo_data();
3200

    
3201
            UndoData = new Undo_data()
3202
            {
3203
                IsUndo = false,
3204
                Event = Event_Type.Select,
3205
                EventTime = DateTime.Now,
3206
                Markup_List = new List<Multi_Undo_data>()
3207
            };
3208

    
3209
            dragSelectionBorder.Visibility = Visibility.Collapsed;
3210

    
3211
            double x = Canvas.GetLeft(dragSelectionBorder);
3212
            double y = Canvas.GetTop(dragSelectionBorder);
3213
            double width = dragSelectionBorder.Width;
3214
            double height = dragSelectionBorder.Height;
3215
            Rect dragRect = new Rect(x, y, width, height);
3216
            Boolean Flag = false;
3217
            dragRect.Inflate(width / 10, height / 10);
3218
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
3219
            var Items = ViewerDataModel.Instance.MarkupControls_USER.ToList();
3220

    
3221
            dragRect = new Rect(x, y, width, height);
3222
            dragRect.Inflate(width / 10, height / 10);
3223

    
3224
            foreach (var item in Items)
3225
            {
3226
                Flag = move.control_Select(item, dragRect);
3227

    
3228
                if (Flag)
3229
                {
3230
                    adornerSet.Add(item);
3231
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
3232

    
3233
                    Control_Style(item);
3234
                    UndoData.Markup_List.Add(multi_Undo_Data);
3235
                    multi_Undo_Data = new Multi_Undo_data();
3236
                    if (item.GroupID > 0)
3237
                    {
3238

    
3239
                    }
3240
                }
3241
            }
3242
            if (adornerSet.Count > 0)
3243
            {
3244
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3245
                {
3246
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
3247
                });
3248
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3249

    
3250
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
3251
                SelectLayer.Children.Add(final);
3252
            }
3253
        }
3254

    
3255
        private void InitDragSelectionRect(Point pt1, Point pt2)
3256
        {
3257
            //캡쳐 중
3258
            if (mouseHandlingMode == MouseHandlingMode.Capture)
3259
            {
3260
                dragCaptureBorder.Visibility = Visibility.Visible;
3261
            }
3262
            //선택 중
3263
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
3264
            {
3265

    
3266
                dragSelectionBorder.Visibility = Visibility.Visible;
3267
            }
3268
            else
3269
            {
3270
                dragZoomBorder.Visibility = Visibility.Visible;
3271
            }
3272
            UpdateDragSelectionRect(pt1, pt2);
3273
        }
3274

    
3275
        /// <summary>
3276
        /// Update the position and size of the rectangle used for drag selection.
3277
        /// </summary>
3278
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
3279
        {
3280
            double x, y, width, height;
3281

    
3282
            //
3283
            // Determine x,y,width and height of the rect inverting the points if necessary.
3284
            // 
3285

    
3286
            if (pt2.X < pt1.X)
3287
            {
3288
                x = pt2.X;
3289
                width = pt1.X - pt2.X;
3290
            }
3291
            else
3292
            {
3293
                x = pt1.X;
3294
                width = pt2.X - pt1.X;
3295
            }
3296

    
3297
            if (pt2.Y < pt1.Y)
3298
            {
3299
                y = pt2.Y;
3300
                height = pt1.Y - pt2.Y;
3301
            }
3302
            else
3303
            {
3304
                y = pt1.Y;
3305
                height = pt2.Y - pt1.Y;
3306
            }
3307

    
3308
            //
3309
            // Update the coordinates of the rectangle used for drag selection.
3310
            //
3311
            //캡쳐 중
3312
            if (mouseHandlingMode == MouseHandlingMode.Capture)
3313
            {
3314
                Canvas.SetLeft(dragCaptureBorder, x);
3315
                Canvas.SetTop(dragCaptureBorder, y);
3316
                dragCaptureBorder.Width = width;
3317
                dragCaptureBorder.Height = height;
3318
            }
3319
            //선택 중
3320
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
3321
            {
3322
                Canvas.SetLeft(dragSelectionBorder, x);
3323
                Canvas.SetTop(dragSelectionBorder, y);
3324
                dragSelectionBorder.Width = width;
3325
                dragSelectionBorder.Height = height;
3326
            }
3327
            else
3328
            {
3329
                Canvas.SetLeft(dragZoomBorder, x);
3330
                Canvas.SetTop(dragZoomBorder, y);
3331
                dragZoomBorder.Width = width;
3332
                dragZoomBorder.Height = height;
3333
            }
3334
        }
3335

    
3336
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
3337
        {
3338
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
3339

    
3340
            bool result = false;
3341
            if (dragRect.Contains(controlRect))
3342
            {
3343
                result = true;
3344
                //잡은 객체들을 담은 리스트
3345
                try
3346
                {
3347
                    selected_item.Add(OverViewPathData, type.ToString());
3348
                }
3349
                catch (Exception)
3350
                {
3351

    
3352
                }
3353
            }
3354
            return result;
3355
        }
3356

    
3357
        private void drawingPannelRotate(double angle)
3358
        {
3359
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
3360
            rotate.Angle = angle;
3361
            var rotationNum = Math.Abs((rotate.Angle / 90));
3362

    
3363
            if (angle == 90 || angle == 270)
3364
            {
3365
                double emptySize = zoomAndPanCanvas.Width;
3366
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
3367
                zoomAndPanCanvas.Height = emptySize;
3368
            }
3369
            if (angle == 0)
3370
            {
3371
                translate.X = 0;
3372
                translate.Y = 0;
3373
            }
3374
            else if (angle == 90)
3375
            {
3376
                translate.X = zoomAndPanCanvas.Width;
3377
                translate.Y = 0;
3378
            }
3379
            else if (angle == 180)
3380
            {
3381
                translate.X = zoomAndPanCanvas.Width;
3382
                translate.Y = zoomAndPanCanvas.Height;
3383
            }
3384
            else
3385
            {
3386
                translate.X = 0;
3387
                translate.Y = zoomAndPanCanvas.Height;
3388
            }
3389

    
3390
            zoomAndPanControl.RotationAngle = rotate.Angle;
3391

    
3392

    
3393
            if (!testPanel2.IsHidden)
3394
            {
3395
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3396
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3397
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3398
            }
3399

    
3400
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3401
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3402
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3403
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3404
            ViewerDataModel.Instance.Angle = rotate.Angle;
3405
        }
3406

    
3407
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3408
        {
3409
            string Data_ = "";
3410

    
3411
            try
3412
            {
3413
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3414
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3415
                if (Data_ != null || Data_ != "")
3416
                {
3417
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3418
                }
3419
                else
3420
                {
3421
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3422
                }
3423

    
3424
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
3425
                {
3426
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
3427
                    STATE = 0,
3428
                };
3429
                if (Data_ != null)
3430
                {
3431
                    Image img = new Image();
3432
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
3433
                    if (Data_.Contains(".svg"))
3434
                    {
3435
                        byte[] imageData = null;
3436
                        DrawingImage image = null;
3437
                        using (System.Net.WebClient web = new System.Net.WebClient())
3438
                        {
3439
                            imageData = web.DownloadData(new Uri(Data_));
3440
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3441
                            image = SvgReader.Load(stream);
3442
                        }
3443
                        img.Source = image;
3444
                    }
3445
                    else
3446
                    {
3447
                        img.Source = new BitmapImage(new Uri(Data_));
3448
                    }
3449

    
3450
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3451
                    {
3452
                        PointSet = new List<Point>(),
3453
                        FilePath = Data_,
3454
                        ImageData = img.Source,
3455
                        StartPoint = canvasZoomPanningMouseDownPoint,
3456
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3457
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3458
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3459
                        canvasZoomPanningMouseDownPoint.Y),
3460
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3461
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3462
                    };
3463

    
3464
                    currentControl.PointSet = new List<Point>
3465
                                        {
3466
                                            currentControl.StartPoint,
3467
                                            currentControl.LeftBottomPoint,
3468
                                            currentControl.EndPoint,
3469
                                            currentControl.TopRightPoint,
3470
                                        };
3471
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3472
                    UndoData = new Undo_data()
3473
                    {
3474
                        IsUndo = false,
3475
                        Event = Event_Type.Create,
3476
                        EventTime = DateTime.Now,
3477
                        Markup_List = new List<Multi_Undo_data>()
3478
                    };
3479
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3480
                    {
3481
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3482
                    });
3483

    
3484
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3485
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3486
                    UndoData.Markup_List.Add(multi_Undo_Data);
3487
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3488

    
3489
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3490
                    currentControl.CommentID = Events.SaveCommand.shortGuid();
3491
                    currentControl.SymbolID = id;
3492
                    currentControl.GroupID = group_id;
3493
                    currentControl.ApplyTemplate();
3494
                    currentControl.SetImage();
3495

    
3496
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3497
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3498
                    SelectLayer.Children.Add(final);
3499
                }
3500
            }
3501
            catch (Exception ex)
3502
            {
3503
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3504
            }
3505
        }
3506

    
3507
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3508
        {            
3509
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3510
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3511
            {
3512
                set_option.Value = double.Parse(set_option.ContentText);
3513
            }
3514

    
3515
            InkControl_Convert();
3516

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

    
3520
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3521
            {
3522
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3523
            }
3524

    
3525
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3526
            {
3527
                if (arrow_text as ArrowTextControl != null)
3528
                {
3529
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3530
                }
3531
            }
3532

    
3533
            mouseButtonDown = e.ChangedButton;
3534
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3535

    
3536
            //if (currentControl != null)
3537
            {
3538
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3539
                if (text_item_ != null)
3540
                {
3541
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3542
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3543
                    (text_item_ as TextControl).IsEditing = false;
3544
                    (text_item_ as TextControl).EnableEditing = false;
3545
                    currentControl = null;
3546
                }
3547

    
3548
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3549
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3550
                {
3551
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3552
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3553
                    currentControl = null;
3554
                }
3555
            }
3556

    
3557
            double Ang = 0;                                          
3558
            if (rotate.Angle != 0)
3559
            {
3560
                Ang = 360 - rotate.Angle;
3561
            }
3562
            move = new Move();
3563

    
3564
            if (e.OriginalSource is System.Windows.Controls.Image)
3565
            {
3566
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3567
            }
3568

    
3569
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3570
            {                
3571
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3572
                //SetCursor();
3573

    
3574
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3575
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3576
                if(symbol_id != null)
3577
                {
3578
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3579
                }                
3580
            }
3581

    
3582
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3583
            {
3584
                if (this._dragdropWindow != null)
3585
                {
3586
                    this._dragdropWindow.Close();
3587
                    this._dragdropWindow = null;
3588
                    symbol_id = null;
3589
                }
3590
            }
3591

    
3592
            if (mouseButtonDown == MouseButton.Left)
3593
            {
3594
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3595
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3596

    
3597
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3598
                SetCursor();
3599

    
3600
                if (!ViewerDataModel.Instance.IsPressCtrl)
3601
                {
3602
                    ReleaseAdorner();
3603
                }
3604
            }
3605
            if (mouseButtonDown == MouseButton.Middle)
3606
            {
3607
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3608
                cursor = Cursors.SizeAll;
3609
                SetCursor();
3610
            }
3611
            if (mouseButtonDown == MouseButton.Right)
3612
            {
3613
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3614
                cursor = Cursors.SizeAll;
3615
                SetCursor();
3616
            }
3617
            else if (mouseButtonDown == MouseButton.XButton1)
3618
            {
3619
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3620
                {
3621
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3622
                }
3623

    
3624
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3625

    
3626
            }
3627
            else if (mouseButtonDown == MouseButton.XButton2)
3628
            {
3629
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3630
                {
3631
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3632
                }
3633
            }
3634

    
3635
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3636
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3637
            {
3638
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3639
                {
3640
                    if (SelectLayer.Children.Count == 0)
3641
                    {
3642
                        isLeftMouseButtonDownOnWindow = true;
3643
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3644
                    }
3645

    
3646
                    if (controlType == ControlType.None)
3647
                    {
3648
                        isLeftMouseButtonDownOnWindow = true;
3649
                    }
3650
                }
3651

    
3652
                //캡쳐 모드 설정
3653
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3654
                {
3655
                    dragCaptureBorder.Visibility = Visibility.Visible;
3656
                    isLeftMouseButtonDownOnWindow = true;
3657
                }
3658

    
3659
                //줌 모드 설정
3660
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3661
                {
3662
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3663
                    isLeftMouseButtonDownOnWindow = true;
3664
                }               
3665

    
3666
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3667
                if (control != null)
3668
                {
3669
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3670
                    AdornerFinal final;
3671
                    List<Point> p_set = new List<Point>();
3672
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3673
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3674
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3675
                    multi_Undo_Data = new Multi_Undo_data();
3676

    
3677
                    //강인구 Undo/Redo 보류
3678
                    UndoData = new Undo_data()
3679
                    {
3680
                        IsUndo = false,
3681
                        Event = Event_Type.Select,
3682
                        EventTime = DateTime.Now,
3683
                        Markup_List = new List<Multi_Undo_data>()
3684
                    };
3685

    
3686
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3687
                    {
3688
                        ReleaseAdorner();
3689
                        final = new AdornerFinal(control);
3690
                        //단일 컨트롤 언두 저장
3691

    
3692
                        Control_Style(control);
3693
                        UndoData.Markup_List.Add(multi_Undo_Data);
3694

    
3695
                        if ((control as IPath) != null)
3696
                        {
3697
                            if ((control as IPath).LineSize != 0)
3698
                            {
3699
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3700
                            }
3701
                        }
3702
                        if ((control as IShapeControl) != null)
3703
                        {
3704
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3705
                            {
3706
                                ViewerDataModel.Instance.checkHatchShape = true;
3707
                            }
3708
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3709
                            {
3710
                                ViewerDataModel.Instance.checkFillShape = true;
3711
                            }
3712
                            else
3713
                            {
3714
                                ViewerDataModel.Instance.checkHatchShape = false;
3715
                                ViewerDataModel.Instance.checkFillShape = false;
3716
                            }
3717
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3718
                        }
3719

    
3720
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3721

    
3722
                        if ((control as TextControl) != null)
3723
                        {
3724
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3725
                            {
3726
                                ViewerDataModel.Instance.checkTextStyle = true;
3727
                            }
3728
                            else
3729
                            {
3730
                                ViewerDataModel.Instance.checkTextStyle = false;
3731
                            }
3732

    
3733
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3734
                            {
3735
                                ViewerDataModel.Instance.checkTextStyle = true;
3736
                            }
3737
                            else
3738
                            {
3739
                                ViewerDataModel.Instance.checkTextStyle = false;
3740
                            }
3741
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3742
                            {
3743
                                ViewerDataModel.Instance.checkTextWeight = true;
3744
                            }
3745
                            else
3746
                            {
3747
                                ViewerDataModel.Instance.checkTextWeight = false;
3748
                            }
3749
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3750
                            {
3751
                                ViewerDataModel.Instance.checkUnderLine = true;
3752
                            }
3753
                            else
3754
                            {
3755
                                ViewerDataModel.Instance.checkUnderLine = false;
3756
                            }
3757
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3758
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3759

    
3760
                        }
3761
                        else if ((control as ArrowTextControl) != null)
3762
                        {
3763
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3764
                            {
3765
                                ViewerDataModel.Instance.checkTextStyle = true;
3766
                            }
3767
                            else
3768
                            {
3769
                                ViewerDataModel.Instance.checkTextStyle = false;
3770
                            }
3771

    
3772
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3773
                            {
3774
                                ViewerDataModel.Instance.checkTextStyle = true;
3775
                            }
3776
                            else
3777
                            {
3778
                                ViewerDataModel.Instance.checkTextStyle = false;
3779
                            }
3780
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3781
                            {
3782
                                ViewerDataModel.Instance.checkTextWeight = true;
3783
                            }
3784
                            else
3785
                            {
3786
                                ViewerDataModel.Instance.checkTextWeight = false;
3787
                            }
3788
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3789
                            {
3790
                                ViewerDataModel.Instance.checkUnderLine = true;
3791
                            }
3792
                            else
3793
                            {
3794
                                ViewerDataModel.Instance.checkUnderLine = false;
3795
                            }
3796
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3797
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3798
                        }
3799
                        else if ((control as RectCloudControl) != null)
3800
                        {
3801
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3802
                        }
3803
                        else if ((control as CloudControl) != null)
3804
                        {
3805
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3806
                        }
3807

    
3808
                    }
3809
                    else
3810
                    {
3811
                        comment = AddAdorner();
3812
                        comment.Add(control);
3813

    
3814
                        Control_Style(control);
3815
                        UndoData.Markup_List.Add(multi_Undo_Data);
3816

    
3817
                        final = new AdornerFinal(comment);
3818
                        //다중 컨트롤 언두 저장
3819
                    }
3820

    
3821
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3822
                    {
3823
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3824
                    });
3825

    
3826
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3827

    
3828
                    SelectLayer.Children.Add(final);
3829
                }              
3830
            }
3831
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3832
            {               
3833
                init();
3834
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3835
                if (cursor != Cursors.SizeAll)
3836
                {
3837
                    cursor = Cursors.Cross;
3838
                    SetCursor();
3839
                }
3840
                bool init_user = false;
3841
                foreach (var user in gridViewMarkup.Items)
3842
                {
3843
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3844
                    {
3845
                        init_user = true;
3846
                    }
3847
                }
3848
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3849
                {
3850
                    RadWindow.Alert(new DialogParameters
3851
                    {
3852
                        Owner = Application.Current.MainWindow,
3853
                        Theme = new VisualStudio2013Theme(),
3854
                        Header = "안내",
3855
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3856
                    });
3857
                    return;
3858
                }
3859
                else
3860
                {
3861
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3862
                    if (item != null)
3863
                    {
3864
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3865
                    }
3866
                }
3867

    
3868
                multi_Undo_Data = new Multi_Undo_data();
3869
                //강인구 Undo/Redo 보류
3870
                UndoData = new Undo_data()
3871
                {
3872
                    IsUndo = false,
3873
                    Event = Event_Type.Create,
3874
                    EventTime = DateTime.Now,
3875
                    Markup_List = new List<Multi_Undo_data>()
3876
                };
3877

    
3878
                switch (controlType)
3879
                {
3880
                    case ControlType.Coordinate:
3881
                        {
3882
                            if (mouseButtonDown == MouseButton.Left)
3883
                            {
3884
                                if (currentControl is CoordinateControl)
3885
                                {
3886
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3887
                                    {
3888
                                        return;
3889
                                    }
3890

    
3891
                                    CreateControl();
3892

    
3893
                                    (currentControl as CoordinateControl).ApplyOverViewData();
3894
                                    currentControl = null;
3895
                                    this.cursor = Cursors.Arrow;
3896
                                }
3897
                                else
3898
                                {
3899
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3900
                                    if (ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3901
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3902
                                    {
3903
                                        currentControl = null;
3904
                                        this.cursor = Cursors.Arrow;
3905
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3906
                                        return;
3907
                                    }
3908
                                    else
3909
                                    {
3910
                                        currentControl = new CoordinateControl
3911
                                        {
3912
                                            Background = new SolidColorBrush(Colors.Black),
3913
                                            ControlType = ControlType.Coordinate
3914
                                        };
3915

    
3916
                                        currentControl.CommentID = SaveCommand.shortGuid();
3917
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3918
                                        currentControl.IsNew = true;
3919

    
3920
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3921

    
3922
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3923
                                    }
3924
                                }
3925
                            }
3926
                        }
3927
                        break;
3928
                    case ControlType.InsideWhite:
3929
                        {
3930
                            if (mouseButtonDown == MouseButton.Left)
3931
                            {
3932
                                if (currentControl is InsideWhiteControl)
3933
                                {
3934
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3935
                                    {
3936
                                        return;
3937
                                    }
3938

    
3939
                                    CreateControl();
3940

    
3941
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3942
                                    currentControl = null;
3943
                                    this.cursor = Cursors.Arrow;
3944
                                }
3945
                                else
3946
                                {
3947
                                    currentControl = new InsideWhiteControl
3948
                                    {
3949
                                        Background = new SolidColorBrush(Colors.Black),
3950
                                        ControlType = ControlType.InsideWhite
3951
                                    };
3952

    
3953
                                    currentControl.CommentID = SaveCommand.shortGuid();
3954
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3955
                                    currentControl.IsNew = true;
3956
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3957

    
3958
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3959
                                }
3960
                            }
3961
                        }
3962
                        break;
3963
                    case ControlType.OverlapWhite:
3964
                        {
3965
                            if (mouseButtonDown == MouseButton.Left)
3966
                            {
3967
                                if (currentControl is OverlapWhiteControl)
3968
                                {
3969
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3970
                                    {
3971
                                        return;
3972
                                    }
3973

    
3974
                                    CreateControl();
3975

    
3976
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3977
                                    currentControl = null;
3978
                                    this.cursor = Cursors.Arrow;
3979
                                }
3980
                                else
3981
                                {
3982
                                    currentControl = new OverlapWhiteControl
3983
                                    {
3984
                                        Background = new SolidColorBrush(Colors.Black),
3985
                                        ControlType = ControlType.OverlapWhite
3986
                                    };
3987

    
3988
                                    currentControl.CommentID = SaveCommand.shortGuid();
3989
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3990
                                    currentControl.IsNew = true;
3991
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3992

    
3993
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3994
                                }
3995
                            }
3996
                        }
3997
                        break;
3998
                    case ControlType.ClipWhite:
3999
                        {
4000
                            if (mouseButtonDown == MouseButton.Left)
4001
                            {
4002
                                if (currentControl is ClipWhiteControl)
4003
                                {
4004
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4005
                                    {
4006
                                        return;
4007
                                    }
4008

    
4009
                                    CreateControl();
4010

    
4011
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
4012
                                    currentControl = null;
4013
                                    this.cursor = Cursors.Arrow;
4014
                                }
4015
                                else
4016
                                {
4017
                                    currentControl = new ClipWhiteControl
4018
                                    {
4019
                                        Background = new SolidColorBrush(Colors.Black),
4020
                                        ControlType = ControlType.ClipWhite
4021
                                    };
4022

    
4023
                                    currentControl.CommentID = SaveCommand.shortGuid();
4024
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4025
                                    currentControl.IsNew = true;
4026
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4027

    
4028
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4029
                                }
4030
                            }
4031
                        }
4032
                        break;
4033
                    case ControlType.Rectangle:
4034
                        {
4035
                            if (mouseButtonDown == MouseButton.Left)
4036
                            {
4037
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4038
                                //{
4039
                                    if (currentControl is RectangleControl)
4040
                                    {
4041
                                        //20180906 LJY TEST IsRotationDrawingEnable
4042
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4043
                                        {
4044
                                            return;
4045
                                        }
4046

    
4047
                                        CreateControl();
4048

    
4049
                                        (currentControl as RectangleControl).ApplyOverViewData();
4050
                                        currentControl = null;
4051
                                    
4052
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4053
                                    }
4054
                                    else
4055
                                    {
4056
                                        currentControl = new RectangleControl
4057
                                        {
4058
                                            Background = new SolidColorBrush(Colors.Black),
4059
                                            ControlType = ControlType.Rectangle
4060
                                        };
4061

    
4062
                                        currentControl.CommentID = SaveCommand.shortGuid();
4063
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4064
                                        currentControl.IsNew = true;
4065
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4066

    
4067
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4068
                                    }
4069
                                //}
4070
                            }
4071
                        }
4072
                        break;
4073
                    case ControlType.RectCloud:
4074
                        {
4075
                            if (mouseButtonDown == MouseButton.Left)
4076
                            {
4077
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4078
                                //{
4079
                                    if (currentControl is RectCloudControl)
4080
                                    {
4081
                                        //20180906 LJY TEST IsRotationDrawingEnable
4082
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4083
                                        {
4084
                                            return;
4085
                                        }
4086

    
4087
                                        CreateControl();
4088

    
4089
                                        (currentControl as RectCloudControl).ApplyOverViewData();
4090
                                        currentControl = null;
4091
                                    
4092
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4093
                                    }
4094
                                    else
4095
                                    {
4096
                                        currentControl = new RectCloudControl
4097
                                        {
4098
                                            Background = new SolidColorBrush(Colors.Black)
4099
                                        };
4100

    
4101
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4102
                                        currentControl.CommentID = SaveCommand.shortGuid();
4103
                                        currentControl.IsNew = true;
4104
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4105
                                    }
4106
                                //}
4107
                            }
4108
                        }
4109
                        break;
4110
                    case ControlType.Circle:
4111
                        {
4112
                            if (mouseButtonDown == MouseButton.Left)
4113
                            {
4114
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4115
                                //{
4116
                                    if (currentControl is CircleControl)
4117
                                    {
4118
                                        //20180906 LJY TEST IsRotationDrawingEnable
4119
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4120
                                        {
4121
                                            return;
4122
                                        }
4123

    
4124
                                        CreateControl();
4125

    
4126
                                        (currentControl as CircleControl).ApplyOverViewData();
4127
                                        currentControl = null;
4128
                                    }
4129
                                    else
4130
                                    {
4131
                                        currentControl = new CircleControl
4132
                                        {
4133
                                            Background = new SolidColorBrush(Colors.Black)
4134
                                        };
4135

    
4136
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4137
                                        currentControl.CommentID = SaveCommand.shortGuid();
4138
                                        currentControl.IsNew = true;
4139
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4140
                                    }
4141
                                //}
4142
                            }
4143
                        }
4144
                        break;
4145
                    case ControlType.Triangle:
4146
                        {
4147
                            if (mouseButtonDown == MouseButton.Left)
4148
                            {
4149
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4150
                                //{
4151
                                    if (currentControl is TriControl)
4152
                                    {
4153
                                        var content = currentControl as TriControl;
4154
                                        if (content.MidPoint == new Point(0, 0))
4155
                                        {
4156
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4157
                                        }
4158
                                        else
4159
                                        {
4160
                                            //20180906 LJY TEST IsRotationDrawingEnable
4161
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4162
                                            {
4163
                                                return;
4164
                                            }
4165

    
4166
                                            CreateControl();
4167

    
4168
                                            (currentControl as TriControl).ApplyOverViewData();
4169
                                            currentControl = null;
4170
                                        }
4171
                                    }
4172
                                    else
4173
                                    {
4174
                                        currentControl = new TriControl
4175
                                        {
4176
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4177
                                            Background = new SolidColorBrush(Colors.Black),
4178
                                        };
4179

    
4180
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4181
                                        currentControl.CommentID = SaveCommand.shortGuid();
4182
                                        currentControl.IsNew = true;
4183
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4184
                                    }
4185
                                //}
4186
                            }
4187
                        }
4188
                        break;
4189
                    case ControlType.SingleLine:
4190
                        {
4191
                            if (mouseButtonDown == MouseButton.Left)
4192
                            {
4193
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4194
                                //{
4195
                                    if (currentControl is LineControl)
4196
                                    {
4197
                                        //20180906 LJY TEST IsRotationDrawingEnable
4198
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4199
                                        {
4200
                                            return;
4201
                                        }
4202

    
4203
                                        CreateControl();
4204

    
4205
                                        (currentControl as LineControl).ApplyOverViewData();
4206
                                        currentControl = null;
4207
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4208
                                    }
4209
                                    else
4210
                                    {
4211
                                        currentControl = new LineControl
4212
                                        {
4213
                                            Background = new SolidColorBrush(Colors.Black)
4214
                                        };
4215

    
4216
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4217
                                        currentControl.CommentID = SaveCommand.shortGuid();
4218
                                        currentControl.IsNew = true;
4219
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4220
                                        this.MainAngle.Visibility = Visibility.Visible;
4221
                                    }
4222
                                //}
4223
                            }
4224
                        }
4225
                        break;
4226
                    case ControlType.CancelLine:
4227
                        {
4228
                            if (mouseButtonDown == MouseButton.Left)
4229
                            {
4230
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4231
                                //{
4232
                                    if (currentControl is LineControl)
4233
                                    {
4234
                                        //20180906 LJY TEST IsRotationDrawingEnable
4235
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4236
                                        {
4237
                                            return;
4238
                                        }
4239

    
4240
                                        CreateControl();
4241

    
4242
                                        (currentControl as LineControl).ApplyOverViewData();
4243
                                        currentControl = null;
4244
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4245
                                    }
4246
                                    else
4247
                                    {
4248
                                        currentControl = new LineControl
4249
                                        {
4250
                                            Background = new SolidColorBrush(Colors.Black)
4251
                                        };
4252

    
4253
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4254
                                        currentControl.CommentID = SaveCommand.shortGuid();
4255
                                        currentControl.IsNew = true;
4256
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4257
                                        this.MainAngle.Visibility = Visibility.Visible;
4258
                                    }
4259
                                //}
4260
                            }
4261
                        }
4262
                        break;
4263
                    case ControlType.ArrowLine:
4264
                        {
4265
                            if (mouseButtonDown == MouseButton.Left)
4266
                            {
4267
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4268
                                //{
4269
                                    if (currentControl is LineControl)
4270
                                    {
4271
                                        //20180906 LJY TEST IsRotationDrawingEnable
4272
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4273
                                        {
4274
                                            return;
4275
                                        }
4276

    
4277
                                        CreateControl();
4278

    
4279
                                        (currentControl as LineControl).ApplyOverViewData();
4280
                                        currentControl = null;
4281
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4282
                                    }
4283
                                    else
4284
                                    {
4285
                                        currentControl = new LineControl
4286
                                        {
4287
                                            Background = new SolidColorBrush(Colors.Black)
4288
                                        };
4289

    
4290
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4291
                                        currentControl.CommentID = SaveCommand.shortGuid();
4292
                                        currentControl.IsNew = true;
4293
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4294
                                        this.MainAngle.Visibility = Visibility.Visible;
4295
                                    }
4296
                                //}
4297
                            }
4298
                        }
4299
                        break;
4300
                    case ControlType.TwinLine:
4301
                        {
4302
                            if (mouseButtonDown == MouseButton.Left)
4303
                            {
4304
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4305
                                //{
4306
                                    if (currentControl is LineControl)
4307
                                    {
4308
                                        //20180906 LJY TEST IsRotationDrawingEnable
4309
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4310
                                        {
4311
                                            return;
4312
                                        }
4313

    
4314
                                        CreateControl();
4315

    
4316
                                        (currentControl as LineControl).ApplyOverViewData();
4317
                                        currentControl = null;
4318
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4319
                                    }
4320
                                    else
4321
                                    {
4322
                                        currentControl = new LineControl
4323
                                        {
4324
                                            Background = new SolidColorBrush(Colors.Black)
4325
                                        };
4326
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4327
                                        currentControl.CommentID = SaveCommand.shortGuid();
4328
                                        currentControl.IsNew = true;
4329
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4330
                                        this.MainAngle.Visibility = Visibility.Visible;
4331
                                    }
4332
                                //}
4333
                            }
4334
                        }
4335
                        break;
4336
                    case ControlType.DimLine:
4337
                        {
4338
                            if (mouseButtonDown == MouseButton.Left)
4339
                            {
4340
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4341
                                //{
4342
                                    if (currentControl is LineControl)
4343
                                    {
4344
                                        //20180906 LJY TEST IsRotationDrawingEnable
4345
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4346
                                        {
4347
                                            return;
4348
                                        }
4349
                                        CreateControl();
4350

    
4351
                                        (currentControl as LineControl).ApplyOverViewData();
4352
                                        currentControl = null;
4353
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4354
                                    }
4355
                                    else
4356
                                    {
4357
                                        currentControl = new LineControl
4358
                                        {
4359
                                            Background = new SolidColorBrush(Colors.Black)
4360
                                        };
4361
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4362
                                        currentControl.CommentID = SaveCommand.shortGuid();
4363
                                        currentControl.IsNew = true;
4364
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4365
                                        this.MainAngle.Visibility = Visibility.Visible;
4366
                                    }
4367
                                //}
4368
                            }
4369
                        }
4370
                        break;
4371
                    case ControlType.ChainLine:
4372
                        {
4373
                            if (currentControl is PolygonControl)
4374
                            {
4375
                                var control = currentControl as PolygonControl;
4376

    
4377
                                if (mouseButtonDown == MouseButton.Right)
4378
                                {
4379
                                    //20180906 LJY TEST IsRotationDrawingEnable
4380
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4381
                                    {
4382
                                        return;
4383
                                    }
4384

    
4385
                                    CreateControl();
4386

    
4387
                                    (currentControl as PolygonControl).ApplyOverViewData();
4388
                                    currentControl = null;
4389
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4390
                                    return;
4391
                                }
4392

    
4393
                                if (!control.IsCompleted)
4394
                                {
4395
                                    control.PointSet.Add(control.EndPoint);
4396
                                    this.MainAngle.Visibility = Visibility.Visible;
4397
                                }
4398
                            }
4399
                            else
4400
                            {
4401
                                if (mouseButtonDown == MouseButton.Left)
4402
                                {
4403
                                    MainAngle.Visibility = Visibility.Visible;
4404
                                    currentControl = new PolygonControl
4405
                                    {
4406
                                        PointSet = new List<Point>(),
4407
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
4408
                                        ControlType = ControlType.ChainLine,
4409
                                        DashSize = ViewerDataModel.Instance.DashSize,
4410
                                        LineSize = ViewerDataModel.Instance.LineSize,
4411
                                        //PointC = new StylusPointSet()
4412
                                    };
4413

    
4414
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4415
                                    //{
4416
                                        var polygonControl = (currentControl as PolygonControl);
4417
                                        currentControl.CommentID = SaveCommand.shortGuid();
4418
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4419
                                        currentControl.IsNew = true;
4420
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4421
                                        //currentControl.OnApplyTemplate();
4422
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
4423
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
4424
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4425
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4426
                                    //}
4427
                                }
4428
                            }
4429
                        }
4430
                        break;
4431
                    case ControlType.ArcLine:
4432
                        {
4433
                            if (mouseButtonDown == MouseButton.Left)
4434
                            {
4435
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4436
                                //{
4437
                                    if (currentControl is ArcControl)
4438
                                    {
4439
                                        //20180906 LJY TEST IsRotationDrawingEnable
4440
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4441
                                        {
4442
                                            return;
4443
                                        }
4444

    
4445
                                        CreateControl();
4446

    
4447
                                        (currentControl as ArcControl).ApplyOverViewData();
4448
                                        currentControl = null;
4449
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4450
                                    }
4451
                                    else
4452
                                    {
4453
                                        currentControl = new ArcControl
4454
                                        {
4455
                                            Background = new SolidColorBrush(Colors.Black)
4456
                                        };
4457
                                        currentControl.CommentID = SaveCommand.shortGuid();
4458
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4459
                                        currentControl.IsNew = true;
4460
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4461
                                        this.MainAngle.Visibility = Visibility.Visible;
4462
                                    }
4463
                                //}
4464
                            }
4465
                            else if (mouseButtonDown == MouseButton.Right)
4466
                            {
4467
                                if (currentControl != null)
4468
                                {
4469
                                    (currentControl as ArcControl).setClock();
4470
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
4471
                                    //(currentControl as ArcControl).ApplyTemplate();
4472
                                }
4473
                            }
4474
                        }
4475
                        break;
4476
                    case ControlType.ArcArrow:
4477
                        {
4478
                            if (mouseButtonDown == MouseButton.Left)
4479
                            {
4480
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4481
                                //{
4482
                                if (currentControl is ArrowArcControl)
4483
                                {
4484
                                    //20180906 LJY TEST IsRotationDrawingEnable
4485
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4486
                                    {
4487
                                        return;
4488
                                    }
4489

    
4490
                                    CreateControl();
4491

    
4492
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
4493
                                    currentControl = null;
4494
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4495
                                }
4496
                                else
4497
                                {
4498
                                    currentControl = new ArrowArcControl
4499
                                    {
4500
                                        Background = new SolidColorBrush(Colors.Black)
4501
                                    };
4502
                                    currentControl.CommentID = SaveCommand.shortGuid();
4503
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4504
                                    currentControl.IsNew = true;
4505
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4506
                                    this.MainAngle.Visibility = Visibility.Visible;
4507
                                }
4508
                                //}
4509
                            }
4510
                            else if (mouseButtonDown == MouseButton.Right)
4511
                            {
4512
                                if (currentControl != null)
4513
                                {
4514
                                    (currentControl as ArrowArcControl).setClock();
4515
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
4516
                                    //(currentControl as ArcControl).ApplyTemplate();
4517
                                }
4518
                            }
4519
                        }
4520
                        break;
4521
                    case ControlType.ArrowMultiLine:
4522
                        {
4523
                            if (mouseButtonDown == MouseButton.Left)
4524
                            {
4525
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4526
                                //{
4527

    
4528
                                    if (currentControl is ArrowControl_Multi)
4529
                                    {
4530
                                        var content = currentControl as ArrowControl_Multi;
4531
                                        if (content.MiddlePoint == new Point(0, 0))
4532
                                        {
4533
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
4534
                                            {
4535
                                                content.MiddlePoint = content.EndPoint;
4536
                                            }
4537
                                            else
4538
                                            {
4539
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4540
                                            }
4541
                                        }
4542
                                        else
4543
                                        {
4544
                                            //20180906 LJY TEST IsRotationDrawingEnable
4545
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4546
                                            {
4547
                                                return;
4548
                                            }
4549

    
4550
                                            CreateControl();
4551

    
4552
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
4553
                                            currentControl = null;
4554
                                            this.MainAngle.Visibility = Visibility.Collapsed;
4555
                                        }
4556
                                    }
4557
                                    else
4558
                                    {
4559
                                        currentControl = new ArrowControl_Multi
4560
                                        {
4561
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4562
                                            Background = new SolidColorBrush(Colors.Black)
4563
                                        };
4564
                                        currentControl.CommentID = SaveCommand.shortGuid();
4565
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4566
                                        currentControl.IsNew = true;
4567
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4568
                                        this.MainAngle.Visibility = Visibility.Visible;
4569
                                    }
4570
                                //}
4571
                            }
4572
                        }
4573
                        break;
4574
                    case ControlType.PolygonCloud:
4575
                        {
4576
                            if (currentControl is CloudControl)
4577
                            {
4578
                                var control = currentControl as CloudControl;
4579
                                if (mouseButtonDown == MouseButton.Right)
4580
                                {
4581
                                    control.IsCompleted = true;
4582
                                }
4583

    
4584
                                if (!control.IsCompleted)
4585
                                {
4586
                                    control.PointSet.Add(control.EndPoint);
4587
                                }
4588
                                else
4589
                                {
4590
                                    //20180906 LJY TEST IsRotationDrawingEnable
4591
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4592
                                    {
4593
                                        return;
4594
                                    }
4595

    
4596
                                    CreateControl();
4597

    
4598
                                    control.isTransOn = true;
4599
                                    var firstPoint = control.PointSet.First();
4600

    
4601
                                    control.PointSet.Add(firstPoint);
4602
                                    control.DrawingCloud();
4603
                                    control.ApplyOverViewData();
4604

    
4605
                                    currentControl = null;
4606
                                }
4607
                            }
4608
                            else
4609
                            {
4610
                                if (mouseButtonDown == MouseButton.Left)
4611
                                {
4612
                                    currentControl = new CloudControl
4613
                                    {
4614
                                        PointSet = new List<Point>(),
4615
                                        PointC = new StylusPointSet()
4616
                                    };
4617

    
4618
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4619
                                    //{
4620
                                        var polygonControl = (currentControl as CloudControl);
4621
                                        currentControl.CommentID = SaveCommand.shortGuid();
4622
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4623
                                        currentControl.IsNew = true;
4624
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4625

    
4626
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4627
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4628
                                    //}
4629
                                }
4630
                            }
4631
                        }
4632
                        break;
4633
                    case ControlType.ImgControl:
4634
                        {
4635
                            if (mouseButtonDown == MouseButton.Left)
4636
                            {
4637
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4638
                                //{
4639
                                    if (currentControl is ImgControl)
4640
                                    {
4641
                                        //20180906 LJY TEST IsRotationDrawingEnable
4642
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4643
                                        {
4644
                                            return;
4645
                                        }
4646

    
4647
                                        CreateControl();
4648
                                        (currentControl as ImgControl).ApplyOverViewData();
4649
                                        controlType = ControlType.ImgControl;
4650
                                        currentControl = null;
4651
                                    }
4652
                                    else
4653
                                    {
4654
                                        
4655
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4656
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4657
                                        {
4658
                                            Image img = new Image();
4659
                                            //img.Source = new BitmapImage(new Uri(filename));
4660
                                            if (filename.Contains(".svg"))
4661
                                            {
4662
                                                byte[] imageData = null;
4663
                                                DrawingImage image = null;
4664
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4665
                                                {
4666
                                                    imageData = web.DownloadData(new Uri(filename));
4667
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4668
                                                    image = SvgReader.Load(stream);
4669
                                                }
4670
                                                img.Source = image;
4671
                                            }
4672
                                            else
4673
                                            {
4674
                                                img.Source = new BitmapImage(new Uri(filename));
4675
                                            }
4676

    
4677
                                            currentControl = new ImgControl
4678
                                            {
4679
                                                    Background = new SolidColorBrush(Colors.Black),
4680
                                                    PointSet = new List<Point>(),
4681
                                                    FilePath = filename,
4682
                                                    ImageData = img.Source,
4683
                                                    StartPoint = canvasDrawingMouseDownPoint,
4684
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4685
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4686
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4687
                                                    ControlType = ControlType.ImgControl
4688
                                                };
4689

    
4690
                                        
4691
                                                currentControl.CommentID = SaveCommand.shortGuid();                                            
4692
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4693
                                                currentControl.IsNew = true;
4694
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4695

    
4696
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4697
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4698
                                        }
4699
                                    }
4700
                                //}
4701
                            }
4702
                        }
4703
                        break;
4704
                    case ControlType.Date:
4705
                        {
4706
                            if (mouseButtonDown == MouseButton.Left)
4707
                            {
4708
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4709
                                //{
4710
                                    if (currentControl is DateControl)
4711
                                    {
4712
                                        //20180906 LJY TEST IsRotationDrawingEnable
4713
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4714
                                        {
4715
                                            return;
4716
                                        }
4717

    
4718
                                        CreateControl();
4719
                                        (currentControl as DateControl).ApplyOverViewData();
4720
                                        currentControl = null;
4721

    
4722
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4723
                                        {
4724
                                            controlType = ControlType.None;
4725
                                            IsSwingMode = false;
4726
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4727
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4728
                                            mouseHandlingMode = MouseHandlingMode.None;
4729
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4730
                                            txtBatch.Visibility = Visibility.Collapsed;
4731

    
4732
                                        }
4733
                                    }
4734
                                    else
4735
                                    {
4736
                                        currentControl = new DateControl
4737
                                        {
4738
                                            Background = new SolidColorBrush(Colors.Black)
4739
                                        };
4740
                                        currentControl.CommentID = SaveCommand.shortGuid();
4741
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4742
                                        currentControl.IsNew = true;
4743
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4744

    
4745
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4746
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4747
                                }
4748
                                //}
4749
                            }
4750
                        }
4751
                        break;
4752
                    case ControlType.TextControl:
4753
                        {
4754
                            if (mouseButtonDown == MouseButton.Left)
4755
                            {
4756
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4757
                                {
4758
                                    currentControl = new TextControl
4759
                                    {
4760
                                        ControlType = controlType
4761
                                    };
4762
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4763
                                    currentControl.CommentID = SaveCommand.shortGuid();
4764
                                    currentControl.IsNew = true;
4765
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4766
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4767
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4768
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4769
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4770
                                    
4771
                                    (currentControl as TextControl).ControlType_No = 0;
4772
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4773
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4774
                                    (currentControl as TextControl).ApplyTemplate();
4775
                                    (currentControl as TextControl).Base_TextBox.Focus();
4776

    
4777
                                    CreateControl();
4778

    
4779
                                }
4780
                            }
4781
                        }
4782
                        break;
4783
                    case ControlType.TextBorder:
4784
                        {
4785
                            if (mouseButtonDown == MouseButton.Left)
4786
                            {
4787
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4788
                                {
4789
                                    currentControl = new TextControl
4790
                                    {
4791
                                        ControlType = controlType
4792
                                    };
4793

    
4794
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4795
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4796
                                    currentControl.CommentID = SaveCommand.shortGuid();
4797
                                    currentControl.IsNew = true;
4798
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4799
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4800
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4801
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4802
                                    
4803
                                    (currentControl as TextControl).ControlType_No = 1;
4804
                                    (currentControl as TextControl).Angle = Ang;
4805
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4806
                                    (currentControl as TextControl).ApplyTemplate();
4807
                                    (currentControl as TextControl).Base_TextBox.Focus();
4808
                                    CreateControl();
4809

    
4810
                                    //currentControl = null;
4811
                                }
4812
                            }
4813
                        }
4814
                        break;
4815
                    case ControlType.TextCloud:
4816
                        {
4817
                            if (mouseButtonDown == MouseButton.Left)
4818
                            {
4819
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4820
                                {
4821
                                    currentControl = new TextControl
4822
                                    {
4823
                                        ControlType = controlType
4824
                                    };
4825

    
4826
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4827
                                    currentControl.CommentID = SaveCommand.shortGuid();
4828
                                    currentControl.IsNew = true;
4829
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4830
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4831

    
4832
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4833
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4834
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4835

    
4836
                                    (currentControl as TextControl).Angle = Ang;
4837
                                    (currentControl as TextControl).ControlType_No = 2;
4838
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4839
                                    (currentControl as TextControl).ApplyTemplate();
4840
                                    (currentControl as TextControl).Base_TextBox.Focus();
4841
                                    CreateControl();
4842
                                    //currentControl = null;
4843
                                }
4844
                            }
4845
                        }
4846
                        break;
4847
                    case ControlType.ArrowTextControl:
4848
                         {
4849
                            if (mouseButtonDown == MouseButton.Left)
4850
                            {
4851
                                if (currentControl is ArrowTextControl)
4852
                                {
4853
                                    //20180906 LJY TEST IsRotationDrawingEnable
4854
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4855
                                    {
4856
                                        return;
4857
                                    }                                    
4858

    
4859
                                    CreateControl();
4860

    
4861
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4862
                                    (currentControl as ArrowTextControl).IsEditing = false;
4863
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4864
                                    (currentControl as ArrowTextControl).IsNew = false;
4865
                                    currentControl = null;
4866
                                }
4867
                                else
4868
                                {
4869
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4870
                                    //{
4871
                                        currentControl = new ArrowTextControl();
4872
                                        currentControl.CommentID = SaveCommand.shortGuid();
4873
                                        currentControl.IsNew = true;
4874
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4875
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4876

    
4877
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4878
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4879
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4880
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4881
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4882

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

    
4886
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4887
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4888
                                        this.MainAngle.Visibility = Visibility.Visible;
4889

    
4890
                                    
4891
                                    //}
4892
                                }
4893
                            }
4894
                        }
4895
                        break;
4896
                    case ControlType.ArrowTransTextControl:
4897
                        {
4898
                            if (mouseButtonDown == MouseButton.Left)
4899
                            {
4900
                                if (currentControl is ArrowTextControl)
4901
                                {
4902
                                    //20180906 LJY TEST IsRotationDrawingEnable
4903
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4904
                                    {
4905
                                        return;
4906
                                    }                                    
4907

    
4908
                                    CreateControl();
4909
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4910
                                    currentControl.IsNew = false;
4911
                                    currentControl = null;
4912
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4913
                                }
4914
                                else
4915
                                {
4916
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4917
                                    //{
4918
                                         currentControl = new ArrowTextControl();
4919
                                        currentControl.CommentID = SaveCommand.shortGuid();
4920
                                        currentControl.IsNew = true;
4921
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4922
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4923
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4924
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4925
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4926
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4927
                                        (currentControl as ArrowTextControl).isFixed = true;
4928
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4929

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

    
4933
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4934
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4935
                                        (currentControl as ArrowTextControl).isTrans = true;
4936
                                }
4937
                            }
4938
                        }
4939
                        break;
4940
                    case ControlType.ArrowTextBorderControl:
4941
                         {
4942
                            if (mouseButtonDown == MouseButton.Left)
4943
                            {
4944
                                if (currentControl is ArrowTextControl)
4945
                                {
4946
                                    //20180906 LJY TEST IsRotationDrawingEnable
4947
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4948
                                    {
4949
                                        return;
4950
                                    }
4951

    
4952
                                    CreateControl();
4953
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4954
                                    currentControl.IsNew = false;
4955
                                    currentControl = null;
4956
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4957
                                }
4958
                                else
4959
                                {
4960
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4961
                                    //{
4962
                                        currentControl = new ArrowTextControl()
4963
                                        {
4964
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4965
                                        };
4966
                                        currentControl.CommentID = SaveCommand.shortGuid();
4967
                                        currentControl.IsNew = true;
4968
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4969
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4970

    
4971
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4972

    
4973
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4974

    
4975
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4976
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4977
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4978

    
4979
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4980
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4981
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4982
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4983
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4984
                                    //}
4985
                                }
4986
                            }
4987
                        }
4988
                        break;
4989
                    case ControlType.ArrowTransTextBorderControl:
4990
                        {
4991
                            if (mouseButtonDown == MouseButton.Left)
4992
                            {
4993
                                if (currentControl is ArrowTextControl)
4994
                                {
4995
                                    //20180906 LJY TEST IsRotationDrawingEnable
4996
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4997
                                    {
4998
                                        return;
4999
                                    }
5000
                                    CreateControl();
5001
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
5002
                                    currentControl.IsNew = false;
5003
                                    currentControl = null;
5004
                                    this.MainAngle.Visibility = Visibility.Collapsed;
5005
                                }
5006
                                else
5007
                                {
5008
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5009
                                    //{
5010
                                    
5011

    
5012
                                    currentControl = new ArrowTextControl()
5013
                                        {
5014
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
5015
                                        };
5016
                                        currentControl.CommentID = SaveCommand.shortGuid();
5017
                                        currentControl.IsNew = true;
5018
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5019
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5020

    
5021
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5022

    
5023
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5024
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
5025
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5026
                                        (currentControl as ArrowTextControl).isFixed = true;
5027
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5028
                                     
5029
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
5030
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
5031
                                        (currentControl as ArrowTextControl).ApplyTemplate();
5032

    
5033
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
5034
                                        this.MainAngle.Visibility = Visibility.Visible;
5035
                                    
5036
                                    //20180911 LJY
5037
                                        (currentControl as ArrowTextControl).isTrans = true;
5038
                                    
5039

    
5040
                                    //}
5041
                                }
5042
                            }
5043
                        }
5044
                        break;
5045
                    case ControlType.ArrowTextCloudControl:
5046
                        {
5047
                            if (mouseButtonDown == MouseButton.Left)
5048
                            {
5049
                                if (currentControl is ArrowTextControl)
5050
                                {
5051
                                    //20180906 LJY TEST IsRotationDrawingEnable
5052
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5053
                                    {
5054
                                        return;
5055
                                    }
5056
                                    CreateControl();
5057
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
5058
                                    currentControl.IsNew = false;
5059
                                    currentControl = null;
5060
                                    this.MainAngle.Visibility = Visibility.Collapsed;
5061
                                }
5062
                                else
5063
                                {
5064
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5065
                                    //{
5066
                                        currentControl = new ArrowTextControl()
5067
                                        {
5068
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
5069
                                        };
5070
                                        currentControl.CommentID = SaveCommand.shortGuid();
5071
                                        currentControl.IsNew = true;
5072
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5073
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5074

    
5075
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5076
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5077
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
5078
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5079
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5080

    
5081
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
5082
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
5083
                                    
5084
                                        (currentControl as ArrowTextControl).ApplyTemplate();
5085
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
5086
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
5087
                                    //}
5088
                                }
5089
                            }
5090
                        }
5091
                        break;
5092
                    case ControlType.ArrowTransTextCloudControl:
5093
                        {
5094
                            if (mouseButtonDown == MouseButton.Left)
5095
                            {
5096
                                if (currentControl is ArrowTextControl)
5097
                                {
5098
                                    //20180906 LJY TEST IsRotationDrawingEnable
5099
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5100
                                    {
5101
                                        return;
5102
                                    }
5103
                                    CreateControl();
5104
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
5105
                                    currentControl.IsNew = false;
5106
                                    currentControl = null;
5107
                                    this.MainAngle.Visibility = Visibility.Collapsed;
5108
                                }
5109
                                else
5110
                                {
5111
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5112
                                    //{
5113
                                        currentControl = new ArrowTextControl()
5114
                                        {
5115
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
5116
                                        };
5117
                                        currentControl.CommentID = SaveCommand.shortGuid();
5118
                                        currentControl.IsNew = true; 
5119
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5120
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5121
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5122

    
5123
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5124
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
5125
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5126
                                        (currentControl as ArrowTextControl).isFixed = true;
5127
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5128

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

    
5132
                                        (currentControl as ArrowTextControl).ApplyTemplate();
5133
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
5134
                                        this.MainAngle.Visibility = Visibility.Visible;  
5135
                                    
5136
                                    //20180911 LJY
5137
                                        (currentControl as ArrowTextControl).isTrans = true;
5138
                                    //}
5139
                                }
5140
                            }
5141
                        }
5142
                        break;
5143
                    case ControlType.PolygonControl:
5144
                        {
5145
                            if (currentControl is PolygonControl)
5146
                            {
5147
                                var control = currentControl as PolygonControl;
5148

    
5149
                                if (mouseButtonDown == MouseButton.Right)
5150
                                {
5151
                                    control.IsCompleted = true;
5152
                                }
5153

    
5154
                                if (!control.IsCompleted)
5155
                                {
5156
                                    control.PointSet.Add(control.EndPoint);
5157
                                }
5158
                                else
5159
                                {
5160
                                    //20180906 LJY TEST IsRotationDrawingEnable
5161
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5162
                                    {
5163
                                        return;
5164
                                    }
5165

    
5166
                                    var firstPoint = control.PointSet.First();
5167
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
5168
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
5169
                                    control.PointSet.Add(firstPoint);
5170

    
5171
                                    ///control.SetPolyPath();
5172

    
5173
                                    control.ApplyOverViewData();
5174

    
5175
                                    CreateControl();
5176

    
5177
                                    currentControl = null;
5178
                                }
5179
                            }
5180
                            else
5181
                            {
5182
                                if (mouseButtonDown == MouseButton.Left)
5183
                                {
5184
                                    currentControl = new PolygonControl
5185
                                    {
5186
                                        PointSet = new List<Point>(),
5187
                                        //PointC = new StylusPointSet()
5188
                                    };
5189

    
5190
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5191
                                    //{
5192
                                        var polygonControl = (currentControl as PolygonControl);
5193
                                        currentControl.CommentID = SaveCommand.shortGuid();
5194
                                        currentControl.IsNew = true;
5195
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5196
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5197
                                        //currentControl.OnApplyTemplate();
5198
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
5199
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
5200
                                    //}
5201
                                }
5202
                            }
5203
                        }
5204
                        break;
5205
                    //강인구 추가
5206
                    case ControlType.Sign:
5207
                        {
5208
                            if (mouseButtonDown == MouseButton.Left)
5209
                            {
5210
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5211
                                //{
5212
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
5213

    
5214
                                    if (_sign == null)
5215
                                    {
5216
                                        txtBatch.Visibility = Visibility.Collapsed;
5217
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
5218
                                        controlType = ControlType.None;
5219

    
5220
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
5221
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
5222
                                        return;
5223
                                    }
5224

    
5225
                                    if (currentControl is SignControl)
5226
                                    {
5227
                                        //20180906 LJY TEST IsRotationDrawingEnable
5228
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5229
                                        {
5230
                                            return;
5231
                                        }
5232

    
5233
                                        CreateControl();
5234
                                        currentControl = null;
5235
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
5236
                                        {
5237
                                            txtBatch.Text = "Place Date";
5238
                                            controlType = ControlType.Date;
5239
                                        }
5240
                                    }
5241
                                    else
5242
                                    {
5243
                                        currentControl = new SignControl
5244
                                        {
5245
                                            Background = new SolidColorBrush(Colors.Black),
5246
                                            UserNumber = App.ViewInfo.UserID,
5247
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5248
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5249
                                            ControlType = ControlType.Sign
5250
                                        };
5251

    
5252
                                        currentControl.CommentID = SaveCommand.shortGuid();
5253
                                        currentControl.IsNew = true;
5254
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5255
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5256

    
5257
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
5258
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
5259
                                }
5260
                                //}
5261
                            }
5262
                        }
5263
                        break;
5264
                    case ControlType.Mark:
5265
                        {
5266
                            if (mouseButtonDown == MouseButton.Left)
5267
                            {
5268
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5269
                                //{
5270
                                    if (currentControl is RectangleControl)
5271
                                    {
5272
                                        //20180906 LJY TEST IsRotationDrawingEnable
5273
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5274
                                        {
5275
                                            return;
5276
                                        }
5277

    
5278
                                        CreateControl();
5279
                                        (currentControl as RectangleControl).ApplyOverViewData();
5280
                                        currentControl = null;
5281
                                    
5282
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5283

    
5284
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
5285
                                        {
5286
                                            txtBatch.Text = "Place Signature";
5287
                                            controlType = ControlType.Sign;
5288
                                        }
5289
                                    }
5290
                                    else
5291
                                    {
5292
                                        currentControl = new RectangleControl
5293
                                        {
5294
                                            Background = new SolidColorBrush(Colors.Black),
5295
                                            Paint = PaintSet.Fill
5296
                                        };
5297

    
5298
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5299
                                        currentControl.CommentID = SaveCommand.shortGuid();
5300
                                        currentControl.IsNew = true;
5301
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
5302
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5303
                                    }
5304
                                //}
5305
                            }
5306
                        }
5307
                        break;
5308
                    case ControlType.Symbol:
5309
                        {
5310
                            if (mouseButtonDown == MouseButton.Left)
5311
                            {
5312
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5313
                                //{
5314
                                    if (currentControl is SymControl)
5315
                                    {
5316
                                        //20180906 LJY TEST IsRotationDrawingEnable
5317
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5318
                                        {
5319
                                            return;
5320
                                        }
5321
                                        CreateControl();
5322
                                        currentControl = null;
5323
                                    
5324
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5325
                                    }
5326
                                    else
5327
                                    {
5328
                                        currentControl = new SymControl
5329
                                        {
5330
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5331
                                            Background = new SolidColorBrush(Colors.Black),
5332
                                            ControlType = ControlType.Symbol
5333
                                        };
5334

    
5335
                                        currentControl.IsNew = true;
5336
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5337
                                        currentControl.CommentID = SaveCommand.shortGuid();
5338
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5339

    
5340
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
5341
                                        (currentControl as SymControl).Angle -= rotate.Angle;
5342
                                }
5343
                                //}
5344
                            }
5345
                        }
5346
                        break;
5347
                    case ControlType.Stamp:
5348
                        {
5349
                            if (mouseButtonDown == MouseButton.Left)
5350
                            {
5351
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5352
                                //{
5353
                                    if (currentControl is SymControlN)
5354
                                    {
5355
                                        //20180906 LJY TEST IsRotationDrawingEnable
5356
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5357
                                        {
5358
                                            return;
5359
                                        }
5360

    
5361
                                        CreateControl();
5362
                                        currentControl = null;
5363
                                   
5364

    
5365
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5366
                                    }
5367
                                    else
5368
                                    {
5369
                                        currentControl = new SymControlN
5370
                                        {
5371
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5372
                                            Background = new SolidColorBrush(Colors.Black),
5373
                                            ControlType = ControlType.Stamp
5374
                                        };
5375

    
5376
                                        currentControl.IsNew = true;
5377
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5378
                                        currentControl.CommentID = SaveCommand.shortGuid();
5379
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5380
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
5381
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
5382
                                }                                    
5383
                                //}
5384
                            }
5385
                        }
5386
                        break;
5387
                    case ControlType.PenControl:
5388
                        {
5389
                            if (inkBoard.Tag.ToString() == "Ink")
5390
                            {
5391
                                inkBoard.IsEnabled = true;
5392
                                StartNewStroke(canvasDrawingMouseDownPoint);
5393
                            }
5394
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
5395
                            {
5396
                                RemovePointStroke(canvasDrawingMouseDownPoint);
5397
                            }
5398
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
5399
                            {
5400
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
5401
                            }
5402
                            IsDrawing = true;
5403
                            return;
5404
                        }
5405
                    default:
5406
                        if (currentControl != null)
5407
                        {
5408
                            currentControl.CommentID = null;
5409
                            currentControl.IsNew = false;
5410
                        }
5411
                        break;
5412
                }
5413
            }
5414
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
5415
            {
5416
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
5417
                {
5418
                    bool mouseOff = false;
5419
                    foreach (var item in SelectLayer.Children)
5420
                    {
5421
                        if (item is AdornerFinal)
5422
                        {
5423

    
5424
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
5425
                            if (over != null)
5426
                            {
5427
                                mouseOff = true;
5428
                            }
5429
                        }
5430
                    }
5431

    
5432
                    if (!mouseOff)
5433
                    {
5434
                        ReleaseAdorner();
5435
                    }
5436
                }
5437
                zoomAndPanControl.CaptureMouse();
5438
                e.Handled = true;
5439
            }
5440
        }
5441

    
5442
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5443
        {
5444
            mouseButtonDown = e.ChangedButton;
5445
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5446
        }
5447

    
5448
        private void RemoveLineStroke(Point P)
5449
        {
5450
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
5451
            if (control != null)
5452
            {
5453
                UndoData = new Undo_data()
5454
                {
5455
                    IsUndo = false,
5456
                    Event = Event_Type.Delete,
5457
                    EventTime = DateTime.Now,
5458
                    Markup_List = new List<Multi_Undo_data>()
5459
                };
5460

    
5461

    
5462
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5463
                UndoData.Markup_List.Add(multi_Undo_Data);
5464
                multi_Undo_Data = new Multi_Undo_data();
5465

    
5466
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
5467
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
5468
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
5469
                
5470
                //임시파일에서도 삭제한다.
5471
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
5472
                
5473
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5474
                {
5475
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5476
                });
5477
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5478

    
5479
            }
5480
        }
5481

    
5482
        private void RemovePointStroke(Point P)
5483
        {
5484
            foreach (Stroke hits in inkBoard.Strokes)
5485
            {
5486
                foreach (StylusPoint sty in hits.StylusPoints)
5487
                {
5488

    
5489
                }
5490
                if (hits.HitTest(P))
5491
                {
5492
                    inkBoard.Strokes.Remove(hits);
5493
                    return;
5494
                }
5495
            }
5496
        }
5497

    
5498
        private void StartNewStroke(Point P)
5499
        {
5500
            strokePoints = new StylusPointCollection();
5501
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5502
            strokePoints.Add(segment1Start);
5503
            stroke = new Stroke(strokePoints);
5504

    
5505
            stroke.DrawingAttributes.Color = Colors.Red;
5506
            stroke.DrawingAttributes.Width = 4;
5507
            stroke.DrawingAttributes.Height = 4;
5508

    
5509
            inkBoard.Strokes.Add(stroke);
5510

    
5511
        }
5512

    
5513
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5514
        {
5515
            ConsolidationMethod();
5516
        }
5517

    
5518
        public void TeamConsolidationMethod()
5519
        {
5520
            ChangeCommentReact();
5521
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5522
            {
5523
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5524
            }
5525
            else
5526
            {
5527
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5528
                {
5529
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
5530
                    {
5531
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
5532
                        return;
5533
                    }                    
5534
                }
5535
                ViewerDataModel.Instance.IsConsolidate = true;
5536
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5537
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5538

    
5539
                string project_no = App.ViewInfo.ProjectNO;
5540
                string doc_id = _DocInfo.ID;
5541
                string user_id = App.ViewInfo.UserID;
5542
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5543
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5544
                {
5545
                    markupInfoItems.Add(item);
5546
                }
5547
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5548
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5549
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
5550

    
5551
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5552
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5553
            }
5554
        }
5555
        public void ConsolidationMethod()
5556
        {
5557
            ChangeCommentReact();
5558

    
5559
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5560
            {
5561
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5562
            }
5563
            else
5564
            {
5565
                ViewerDataModel.Instance.IsConsolidate = true;
5566
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5567
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5568

    
5569
                string project_no = App.ViewInfo.ProjectNO;
5570
                string doc_id = _DocInfo.ID;
5571
                string user_id = App.ViewInfo.UserID;
5572
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5573
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5574
                {
5575
                    markupInfoItems.Add(item);
5576
                }
5577
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5578
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5579
                //this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
5580

    
5581
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5582
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5583

    
5584
            }
5585
        }
5586

    
5587
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5588
        {
5589
            if (App.ViewInfo != null)
5590
            {
5591
                btnConsolidate = (sender as RadRibbonButton);
5592
                if (!App.ViewInfo.NewCommentPermission)
5593
                {
5594
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5595
                }
5596
            }
5597
        }
5598

    
5599
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5600
        {
5601
            TeamConsolidationMethod();
5602
        }
5603

    
5604
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5605
        {
5606
            btnTeamConsolidate = sender as RadRibbonButton;
5607
            if (App.ViewInfo != null)
5608
            {
5609
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5610
                {
5611
                    if (btnConsolidate != null)
5612
                    {
5613
                        btnConsolidate.Visibility = Visibility.Collapsed;
5614
                    }
5615

    
5616
                    if (!App.ViewInfo.NewCommentPermission)
5617
                    {
5618
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5619
                    }
5620
                }
5621
                else
5622
                {
5623
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5624
                }
5625
            }
5626
        }
5627

    
5628
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5629
        {
5630
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5631
            if (item != null)
5632
            {
5633
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5634

    
5635
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5636
            }
5637
            else
5638
            {
5639
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5640
            }
5641
        }
5642

    
5643
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5644
        {
5645
            btnFinalPDF = sender as RadRibbonButton;
5646
            if (App.ViewInfo != null)
5647
            {
5648
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5649
                {
5650
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5651
                    if (btnConsolidate != null)
5652
                    {
5653
                        btnConsolidate.Visibility = Visibility.Collapsed;
5654
                    }
5655
                }
5656
            }
5657
        }
5658

    
5659
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5660
        {
5661
            ChangeCommentReact();
5662

    
5663
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5664
            {
5665
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5666
            }
5667
            else
5668
            {
5669
                ViewerDataModel.Instance.IsConsolidate = true;
5670
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5671
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5672

    
5673
                string project_no = App.ViewInfo.ProjectNO;
5674
                string doc_id = _DocInfo.ID;
5675
                string user_id = App.ViewInfo.UserID;
5676
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5677
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5678
                {
5679
                    markupInfoItems.Add(item);
5680
                }
5681
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5682
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5683
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5684
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5685

    
5686
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5687
                if (item2 != null)
5688
                {
5689
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5690

    
5691
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5692
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5693
                }
5694
                else
5695
                {
5696
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5697
                }
5698
            }
5699
        }
5700

    
5701
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5702
        {
5703
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5704

    
5705
            if (App.ViewInfo != null)
5706
            {
5707
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5708
                {
5709
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5710
                }
5711
            }
5712
        }
5713

    
5714
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5715
        {
5716
            if (CompareMode.IsChecked)
5717
            {
5718
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5719
                {
5720
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5721
                }
5722
                if (ViewerDataModel.Instance.PageNumber == 0)
5723
                {
5724
                    ViewerDataModel.Instance.PageNumber = 1;
5725
                }
5726

    
5727
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5728
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5729
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5730

    
5731
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5732
            }
5733
            else
5734
            {
5735
                da.From = 1;
5736
                da.To = 1;
5737
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5738
                da.AutoReverse = false;
5739
                canvas_compareBorder.Children.Clear();
5740
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5741
            }
5742
        }
5743

    
5744
        private void Sync_Click(object sender, RoutedEventArgs e)
5745
        {
5746
            if (Sync.IsChecked)
5747
            {
5748
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5749
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5750
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5751
            }
5752
        }
5753

    
5754
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5755
        {
5756
            if (UserList.IsChecked)
5757
            {
5758
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5759
            }
5760
            else
5761
            {
5762
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5763
            }
5764
        }
5765

    
5766
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5767
        {
5768

    
5769
            if (BalanceMode.IsChecked)
5770
            {
5771
                ViewerDataModel.Instance.PageBalanceMode = true;
5772
            }
5773
            else
5774
            {
5775
                ViewerDataModel.Instance.PageBalanceMode = false;
5776
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5777
            }
5778
        }
5779

    
5780
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5781
        {
5782
            //초기화
5783
            testPanel2.IsHidden = true;
5784
            ViewerDataModel.Instance.PageBalanceMode = false;
5785
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5786
            ViewerDataModel.Instance.PageNumber = 0;
5787
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5788
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5789
            UserList.IsChecked = false;
5790
            BalanceMode.IsChecked = false;
5791
        }
5792

    
5793
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5794
        {
5795
            if ((sender as System.Windows.Controls.Control).Tag != null)
5796
            {
5797
                //Compare 초기화
5798
                CompareMode.IsChecked = false;
5799
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5800

    
5801
                if (ViewerDataModel.Instance.PageNumber == 0)
5802
                {
5803
                    ViewerDataModel.Instance.PageNumber = 1;
5804
                }
5805

    
5806
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5807
                {
5808
                }
5809
                else
5810
                {
5811
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5812
                }
5813

    
5814
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5815
                {
5816

    
5817
                }
5818
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5819
                {
5820
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5821
                }
5822

    
5823
                if (!testPanel2.IsHidden)
5824
                {
5825
                    if (IsSyncPDFMode)
5826
                    {
5827
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5828
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5829

    
5830
                        if (pdfpath.IsDownloading)
5831
                        {
5832
                            pdfpath.DownloadCompleted += (ex, arg) =>
5833
                            {
5834
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5835
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5836
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5837
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5838
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5839
                            };
5840
                        }
5841
                        else
5842
                        {
5843
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5844
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5845
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5846

    
5847
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5848
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5849
                        }
5850

    
5851
                    }
5852
                    else
5853
                    {
5854
                        string uri = "";
5855

    
5856
                        if (userData.COMPANY != "EXT")
5857
                        {
5858
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5859
                        }
5860
                        else
5861
                        {
5862
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5863
                        }
5864

    
5865
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5866

    
5867
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5868
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5869
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5870

    
5871
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5872
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5873

    
5874
                        if (defaultBitmapImage_Compare.IsDownloading)
5875
                        {
5876
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5877
                            {
5878
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5879
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5880
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5881

    
5882
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5883
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5884
                            };
5885
                        }
5886
                    }
5887

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

    
5892
                    foreach (var item in gridSelectionRevItem)
5893
                    {
5894
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5895
                        {
5896
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5897
                        });
5898
                    }
5899

    
5900
                    //강인구 추가
5901
                    zoomAndPanControl2.ZoomTo(new Rect
5902
                    {
5903
                        X = 0,
5904
                        Y = 0,
5905
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5906
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5907
                    });
5908

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

    
5911
                }
5912
            }
5913
        }
5914

    
5915
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5916
        {
5917
            if (MarkupMode.IsChecked)
5918
            {
5919
                IsSyncPDFMode = true;
5920

    
5921
                var uri = CurrentRev.TO_VENDOR;
5922

    
5923
                if (ViewerDataModel.Instance.PageNumber == 0)
5924
                {
5925
                    ViewerDataModel.Instance.PageNumber = 1;
5926
                }
5927

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

    
5932
                if (pdfpath.IsDownloading)
5933
                {
5934
                    pdfpath.DownloadCompleted += (ex, arg) =>
5935
                    {
5936
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5937
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5938
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5939
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5940
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5941
                    };
5942
                }
5943
                else
5944
                {
5945
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5946
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5947
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5948

    
5949
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5950
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5951
                }
5952
            }
5953
            else
5954
            {
5955
                IsSyncPDFMode = false;
5956
                string uri = "";
5957
                if (userData.COMPANY != "EXT")
5958
                {
5959
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5960
                }
5961
                else
5962
                {
5963
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5964
                }
5965

    
5966
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5967

    
5968
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5969
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5970
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5971

    
5972
                if (defaultBitmapImage_Compare.IsDownloading)
5973
                {
5974
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5975
                    {
5976
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5977
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5978
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5979
                    };
5980
                }
5981
                zoomAndPanControl2.ApplyTemplate();
5982
                zoomAndPanControl2.UpdateLayout();
5983
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5984
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5985
            }
5986
        }
5987

    
5988
        private void RadButton_Click(object sender, RoutedEventArgs e)
5989
        {
5990
            gridViewHistory_Busy.IsBusy = true;
5991

    
5992
            RadButton instance = sender as RadButton;
5993
            if (instance.CommandParameter != null)
5994
            {
5995
                CurrentRev = instance.CommandParameter as VPRevision;
5996
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5997
                {
5998
                    if (ea.Error == null && ea.Result != null)
5999
                    {
6000
                        testPanel2.IsHidden = false;
6001

    
6002
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
6003
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
6004

    
6005
                        string uri = "";
6006
                        if (userData.COMPANY != "EXT")
6007
                        {
6008
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
6009
                        }
6010
                        else
6011
                        {
6012
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
6013
                        }
6014

    
6015
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6016

    
6017
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6018

    
6019
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6020
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6021
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6022

    
6023
                        if (defaultBitmapImage_Compare.IsDownloading)
6024
                        {
6025
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
6026
                            {
6027
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6028
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6029
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6030
                            };
6031
                        }
6032

    
6033
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
6034
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
6035
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
6036
                        zoomAndPanControl2.ApplyTemplate();
6037
                        zoomAndPanControl2.UpdateLayout();
6038

    
6039
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
6040
                        {
6041
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
6042
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
6043
                        }
6044

    
6045
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
6046
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
6047
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
6048

    
6049
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
6050
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
6051
                        gridViewHistory_Busy.IsBusy = false;
6052
                    }
6053

    
6054
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
6055
                };
6056
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
6057
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
6058
            }
6059
        }
6060

    
6061
        public void Sync_Event(VPRevision Currnet_Rev)
6062
        {
6063
            CurrentRev = Currnet_Rev;
6064

    
6065
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
6066
            {
6067
                if (ea.Error == null && ea.Result != null)
6068
                {
6069
                    testPanel2.IsHidden = false;
6070

    
6071
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
6072
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
6073

    
6074
                    string uri = "";
6075
                    if (userData.COMPANY != "EXT")
6076
                    {
6077
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
6078
                    }
6079
                    else
6080
                    {
6081
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
6082
                    }
6083

    
6084
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6085

    
6086
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6087

    
6088
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6089
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6090
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6091

    
6092
                    if (defaultBitmapImage_Compare.IsDownloading)
6093
                    {
6094
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
6095
                        {
6096
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6097
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6098
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6099
                        };
6100
                    }
6101

    
6102

    
6103
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
6104
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
6105
                    zoomAndPanControl2.ApplyTemplate();
6106
                    zoomAndPanControl2.UpdateLayout();
6107

    
6108
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
6109
                    {
6110
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
6111
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
6112
                    }
6113
                    //}
6114

    
6115
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
6116
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
6117
                    gridViewHistory_Busy.IsBusy = false;
6118
                }
6119
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
6120

    
6121
            };
6122
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
6123
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
6124
        }
6125

    
6126
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
6127
        {
6128
            if (sender is Image)
6129
            {
6130
                if ((sender as Image).Tag != null)
6131
                {
6132
                    var pdfUrl = (sender as Image).Tag.ToString();
6133
                    System.Diagnostics.Process.Start(pdfUrl);
6134
                }
6135
                else
6136
                {
6137
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
6138
                }
6139
            }
6140
        }
6141

    
6142
        private void Create_Symbol(object sender, RoutedEventArgs e)
6143
        {
6144
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
6145

    
6146
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
6147
            {
6148
                DialogMessage_Alert("Please Select Controls", "Alert");
6149
            }
6150
            else //선택된 것이 있으면
6151
            {
6152
                string MarkupData = "";
6153
                adorner_ = new AdornerFinal();
6154

    
6155
                foreach (var item in SelectLayer.Children)
6156
                {
6157
                    if (item.GetType().Name == "AdornerFinal")
6158
                    {
6159
                        adorner_ = (item as Controls.AdornerFinal);
6160
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
6161
                        {
6162
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
6163
                            {
6164
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
6165
                                MarkupData += markupReturn.ConvertData;
6166
                            }
6167
                        }
6168
                    }
6169
                }
6170
                DialogParameters parameters = new DialogParameters()
6171
                {
6172
                    Owner = Application.Current.MainWindow,
6173
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
6174
                    DefaultPromptResultValue = "Custom State",
6175
                    Content = "Name :",
6176
                    Header = "Insert Custom Symbol Name",
6177
                    Theme = new VisualStudio2013Theme(),
6178
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6179
                };
6180
                RadWindow.Prompt(parameters);
6181
            }
6182

    
6183
        }
6184
        public int symbolselectindex = 0;
6185
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
6186
        {
6187
            //Save save = new Save();
6188
            try
6189
            {
6190
                string svgfilename = null;
6191
                if (symbolname != null)
6192
                {
6193
                    if (symbolpng == true || symbolsvg == true)
6194
                    {
6195
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6196
                        string guid = SaveCommand.shortGuid();
6197

    
6198
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
6199
                        //Check_Uri.UriCheck();
6200
                        fileUploader.RunCompleted += (ex, arg) =>
6201
                        {
6202
                            filename = arg.Result;
6203
                            if (symbolpng == true)
6204
                            {
6205
                                if (filename != null)
6206
                                { 
6207
                                    if (symbolselectindex == 0)
6208
                                    {
6209
                                        SymbolSave(symbolname, filename, data);
6210
                                    }
6211
                                    else
6212
                                    {
6213
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6214
                                    }
6215
                                    DataBind();
6216
                                }                                
6217
                            }
6218

    
6219
                            if (symbolsvg == true)
6220
                            {
6221
                                try
6222
                                {
6223
                                    var defaultBitmapImage = new BitmapImage();
6224
                                    defaultBitmapImage.BeginInit();
6225
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
6226
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
6227
                                    Check_Uri.UriCheck(filename);
6228
                                    defaultBitmapImage.UriSource = new Uri(filename);
6229
                                    defaultBitmapImage.EndInit();
6230

    
6231
                                    System.Drawing.Bitmap image;
6232

    
6233
                                    if (defaultBitmapImage.IsDownloading)
6234
                                    {
6235
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
6236
                                        {
6237
                                            defaultBitmapImage.Freeze();
6238
                                            image = GetBitmap(defaultBitmapImage);
6239
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
6240
                                            Process potrace = new Process
6241
                                            {
6242
                                                StartInfo = new ProcessStartInfo
6243
                                                {
6244
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
6245
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
6246
                                                    RedirectStandardInput = true,
6247
                                                    RedirectStandardOutput = true,
6248
                                                    RedirectStandardError = true,
6249
                                                    UseShellExecute = false,
6250
                                                    CreateNoWindow = true,
6251
                                                    WindowStyle = ProcessWindowStyle.Hidden
6252
                                                },
6253
                                            };
6254

    
6255
                                            StringBuilder svgBuilder = new StringBuilder();
6256
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
6257
                                            {
6258
                                                svgBuilder.AppendLine(e2.Data);
6259
                                            };
6260

    
6261
                                            potrace.EnableRaisingEvents = true;
6262
                                            potrace.Start();
6263
                                            potrace.Exited += (sender, e) =>
6264
                                            {
6265
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
6266
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
6267
                                                Check_Uri.UriCheck(svgfilename);
6268
                                                if (symbolselectindex == 0)
6269
                                                {
6270
                                                    SymbolSave(symbolname, svgfilename, data);
6271
                                                }
6272
                                                else
6273
                                                {
6274
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6275
                                                }
6276

    
6277
                                                DataBind();
6278
                                            };
6279
                                            potrace.WaitForExit();
6280
                                        };
6281
                                    }
6282
                                    else
6283
                                    {
6284
                                        //GC.Collect();
6285
                                    }
6286
                                }
6287
                                catch(Exception ee)
6288
                                {
6289
                                    DialogMessage_Alert("" + ee, "Alert");
6290
                                }
6291
                            }
6292
                        };                                             
6293
                    }
6294
                }
6295
            }
6296
            catch (Exception e)
6297
            {
6298
                //DialogMessage_Alert(e + "", "Alert");
6299
            }            
6300
        }
6301

    
6302
        public void SymbolSave(string Name, string Url, string Data)
6303
        {
6304
            try
6305
            {
6306
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
6307
                {
6308
                    ID = Events.SaveCommand.shortGuid(),
6309
                    MEMBER_USER_ID = App.ViewInfo.UserID,
6310
                    NAME = Name,
6311
                    IMAGE_URL = Url,
6312
                    DATA = Data
6313
                };
6314

    
6315
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
6316
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
6317
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
6318
            }
6319
            catch (Exception)
6320
            {
6321
                throw;
6322
            }
6323
        }
6324

    
6325
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
6326
        {
6327
            try
6328
            {
6329
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
6330
                {
6331
                    ID = Events.SaveCommand.shortGuid(),
6332
                    DEPARTMENT = Department,
6333
                    NAME = Name,
6334
                    IMAGE_URL = Url,
6335
                    DATA = Data
6336
                };
6337
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
6338
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
6339
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
6340
            }
6341
            catch (Exception)
6342
            {
6343
                throw;
6344
            }
6345
        }
6346

    
6347
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
6348
        {           
6349
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6350
            DataBind();
6351
        }
6352

    
6353
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
6354
        {
6355
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6356
            DataBind();
6357
        }
6358
        private void DataBind()
6359
        {
6360
            try
6361
            {
6362
                Symbol_Custom Custom = new Symbol_Custom();
6363
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
6364
                ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
6365
                var symbol_Private = client.GetSymbolList(App.ViewInfo.UserID);
6366
                foreach (var item in symbol_Private)
6367
                {
6368
                    Custom.Name = item.NAME;
6369
                    Custom.ImageUri = item.IMAGE_URL;
6370
                    Custom.ID = item.ID;
6371
                    Custom_List.Add(Custom);
6372
                    Custom = new Symbol_Custom();
6373
                }
6374
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
6375
                
6376
                Custom = new Symbol_Custom();
6377
                Custom_List = new List<Symbol_Custom>();
6378

    
6379
                symbolPanel_Instance.deptlist.ItemsSource = client.GetPublicSymbolDeptList();
6380

    
6381
                List<SYMBOL_PUBLIC> symbol_Public;
6382

    
6383

    
6384
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
6385
                {
6386
                    symbol_Public = client.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
6387
                }
6388
                else
6389
                {
6390
                    symbol_Public = client.GetPublicSymbolList(null);
6391
                }
6392
                foreach (var item in symbol_Public)
6393
                {
6394
                    Custom.Name = item.NAME;
6395
                    Custom.ImageUri = item.IMAGE_URL;
6396
                    Custom.ID = item.ID;
6397
                    Custom_List.Add(Custom);
6398
                    Custom = new Symbol_Custom();
6399
                }
6400
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
6401
                client.Close();                
6402
            }
6403
            catch(Exception e)
6404
            {
6405
                //DialogMessage_Alert("DataBind", "Alert");
6406
            }
6407
            
6408
        }
6409
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
6410
        {
6411
            try
6412
            {
6413
                if (args.PromptResult != null)
6414
                {
6415
                    if (args.DialogResult.Value)
6416
                    {
6417
                        PngBitmapEncoder _Encoder = symImage(data);
6418

    
6419
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6420
                        _Encoder.Save(fs);
6421
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6422

    
6423
                        byte[] Img_byte = fs.ToArray();
6424

    
6425
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6426
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, SaveCommand.shortGuid() + ".png", Img_byte);
6427
                        Check_Uri.UriCheck(filename);
6428
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6429
                        {
6430
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
6431
                        }
6432
                        else
6433
                        {
6434
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6435
                        }
6436
                        DataBind();
6437
                    }
6438
                }
6439
            }
6440
            catch(Exception ex)
6441
            {
6442
                DialogMessage_Alert("" + ex, "Alert");
6443
            }
6444
        }
6445

    
6446
        public PngBitmapEncoder symImage(string data)
6447
        {
6448

    
6449
            Canvas _canvas = new Canvas();
6450
            _canvas.Background = Brushes.White;
6451
            _canvas.Width = adorner_.BorderSize.Width;
6452
            _canvas.Height = adorner_.BorderSize.Height;
6453
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
6454

    
6455
            BitmapEncoder encoder = new PngBitmapEncoder();
6456

    
6457

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

    
6460
            DrawingVisual dv = new DrawingVisual();
6461

    
6462
            _canvas.Measure(new System.Windows.Size(adorner_.BorderSize.Width + 50, adorner_.BorderSize.Height + 50));
6463
            _canvas.Arrange(new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X - 20, Y = -adorner_.BorderSize.Y - 20 }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
6464

    
6465
            using (DrawingContext ctx = dv.RenderOpen())
6466
            {
6467
                VisualBrush vb = new VisualBrush(_canvas);
6468
                ctx.DrawRectangle(vb, null, new Rect(new System.Windows.Point { X = -adorner_.BorderSize.X, Y = -adorner_.BorderSize.Y }, new Point(adorner_.BorderSize.Width + 20, adorner_.BorderSize.Height + 20)));
6469
            }
6470

    
6471
            try
6472
            {
6473
                renderBitmap.Render(dv);
6474

    
6475
                //GC.Collect();
6476
                GC.WaitForPendingFinalizers();
6477
                //GC.Collect();
6478
                // encode png data
6479
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6480
                // puch rendered bitmap into it
6481
                pngEncoder.Interlace = PngInterlaceOption.Off;
6482
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6483
                return pngEncoder;
6484

    
6485
            }
6486
            catch //(Exception ex)
6487
            {
6488
                return null;
6489
            }
6490

    
6491
        }
6492

    
6493
        public void DialogMessage_Alert(string content, string header)
6494
        {
6495
            var box = new TextBlock();
6496
            box.MinWidth = 400;
6497
            box.FontSize = 11;
6498
            //box.FontSize = 12;
6499
            box.Text = content;
6500
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6501

    
6502
            DialogParameters parameters = new DialogParameters()
6503
            {
6504
                Owner = Application.Current.MainWindow,
6505
                Content = box,
6506
                Header = header,
6507
                Theme = new VisualStudio2013Theme(),
6508
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6509
            };            
6510
            RadWindow.Alert(parameters);
6511
        }
6512

    
6513
        #region 캡쳐 기능
6514

    
6515
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6516
        {
6517
            if (x < 0)
6518
            {
6519
                width += x;
6520
                x = 0;
6521
            }
6522
            if (y < 0)
6523
            {
6524
                height += y;
6525
                y = 0;
6526

    
6527
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6528
            }
6529
            if (x + width > zoomAndPanCanvas.ActualWidth)
6530
            {
6531
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6532
            }
6533
            if (y + height > zoomAndPanCanvas.ActualHeight)
6534
            {
6535
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6536
            }
6537

    
6538
            byte[] pixels = CopyPixels(x, y, width, height);
6539

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

    
6542
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6543
        }
6544

    
6545
        public byte[] CopyPixels(int x, int y, int width, int height)
6546
        {
6547
            byte[] pixels = new byte[width * height * 4];
6548
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6549

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

    
6553
            return pixels;
6554
        }
6555

    
6556
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6557
        {
6558
            DrawingVisual drawingVisual = new DrawingVisual();
6559
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6560

    
6561
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6562
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6563
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6564
            drawingContext.Close();
6565

    
6566
            // 비트맵으로 변환합니다.
6567
            RenderTargetBitmap target =
6568
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6569
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6570

    
6571
            target.Render(drawingVisual);
6572
            return target;
6573
        }
6574

    
6575
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6576
        {
6577
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6578
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6579
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6580
            bmp.UnlockBits(data);
6581
            return bmp;
6582
        }
6583
        public string symbolname = null;
6584
        public bool symbolsvg = true;
6585
        public bool symbolpng = true;
6586

    
6587
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6588
        {
6589
            System.Drawing.Bitmap image = GetBitmap(source);
6590
            //흰색 제거
6591
            //image.MakeTransparent(System.Drawing.Color.White);
6592

    
6593
            var imageStream = new System.IO.MemoryStream();
6594
            byte[] imageBytes = null;
6595
            using (imageStream)
6596
            {
6597
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6598
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6599
                imageStream.Position = 0;
6600
                imageBytes = imageStream.ToArray();
6601
            }
6602

    
6603
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6604

    
6605
            RadWindow CheckPop = new RadWindow();
6606
            //Alert check = new Alert(Msg);
6607

    
6608
            CheckPop = new RadWindow
6609
            {
6610
                MinWidth = 400,
6611
                MinHeight = 100,
6612
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6613
                Header = "Alert",
6614
                Content = symbolPrompt,
6615
                //DialogResult = 
6616
                ResizeMode = System.Windows.ResizeMode.NoResize,
6617
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6618
                IsTopmost = true,
6619
            };
6620
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6621
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6622
            CheckPop.ShowDialog();
6623

    
6624
            /*
6625
            DialogParameters parameters = new DialogParameters()
6626
            {
6627
                Owner = Application.Current.MainWindow,
6628
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6629
                DefaultPromptResultValue = "Custom State",
6630
                Content = "Name :",
6631
                Header = "Insert Custom Symbol Name",
6632
                Theme = new VisualStudio2013Theme(),
6633
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6634
            };            
6635
            RadWindow.Prompt(parameters);
6636
            */
6637
        }
6638

    
6639
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6640
        {
6641
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6642
            KCOMDataModel.DataModel.CHECK_LIST check_;
6643
            string Result = streamToBase64.ImageToBase64(source);
6644
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6645
            string projectno = App.ViewInfo.ProjectNO;
6646
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6647

    
6648
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6649
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6650
            if (Item != null)
6651
            {
6652
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6653
            }
6654
            else
6655
            {
6656
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6657
            }
6658

    
6659
            if (Item == null)
6660
            {
6661
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6662
                {
6663
                    ID = SaveCommand.shortGuid(),
6664
                    USER_ID = App.ViewInfo.UserID,
6665
                    IMAGE_URL = Result,
6666
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6667
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6668
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6669
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6670
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6671
                    STATUS = "False",
6672
                    CREATE_TIME = DateTime.Now,
6673
                    UPDATE_TIME = DateTime.Now,
6674
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6675
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6676
                };
6677
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6678
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6679
                //this.BaseClient.AddCheckList(projectno, check_);
6680
            }
6681
            else
6682
            {
6683
                Item.IMAGE_URL = Result;
6684
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6685
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6686
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6687
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6688
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6689
            }
6690

    
6691
        }
6692

    
6693
        public void Set_Capture()
6694
        {
6695
            double x = canvasDrawingMouseDownPoint.X;
6696
            double y = canvasDrawingMouseDownPoint.Y;
6697
            double width = dragCaptureBorder.Width;
6698
            double height = dragCaptureBorder.Height;
6699

    
6700
            if (width > 5 || height > 5)
6701
            {
6702
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6703
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6704
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6705
            }
6706
        }
6707
        #endregion
6708

    
6709
        TempFile temp = new TempFile();
6710
        //MarkupInfoItem
6711
        public void CreateControl()
6712
        {
6713

    
6714
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6715
            {
6716
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6717
            });
6718
            multi_Undo_Data.Markup = currentControl;
6719
            UndoData.Markup_List.Add(multi_Undo_Data);
6720

    
6721
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6722

    
6723
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6724
        }
6725

    
6726
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6727
        {
6728
            multi_Undo_Data = new Multi_Undo_data();
6729

    
6730
            multi_Undo_Data.Markup = control;
6731

    
6732
            if ((control as IShapeControl) != null)
6733
            {
6734
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6735
            }
6736
            if ((control as IDashControl) != null)
6737
            {
6738
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6739
            }
6740
            if ((control as IPath) != null)
6741
            {
6742
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6743
            }
6744
            if ((control as UIElement) != null)
6745
            {
6746
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6747
            }
6748

    
6749
            return multi_Undo_Data;
6750
        }
6751

    
6752
        public void Undo()
6753
        {
6754
            // if (ViewerDataModel.Instance.IsPressCtrl)
6755
            //   {
6756
            //      ViewerDataModel.Instance.IsPressCtrl = false;
6757
            //   }
6758
            Undo_data undo = new Undo_data();
6759
            AdornerFinal final;
6760
            ReleaseAdorner();
6761

    
6762
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6763
            if (undo == null)
6764
                return;
6765

    
6766

    
6767

    
6768
            switch (undo.Event)
6769
            {
6770
                case (Event_Type.Create):
6771
                    {
6772
                        foreach (var item in undo.Markup_List)
6773
                        {
6774
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6775
                        }
6776
                    }
6777
                    break;
6778
                case (Event_Type.Delete):
6779
                    {
6780
                        foreach (var item in undo.Markup_List)
6781
                        {
6782
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6783
                        }
6784
                    }
6785
                    break;
6786
                case (Event_Type.Thumb):
6787
                    {
6788
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6789

    
6790
                        foreach (var item in undo.Markup_List)
6791
                        {
6792
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6793

    
6794
                            if ((item.Markup as IViewBox) != null)
6795
                            {
6796
                                (item.Markup as IViewBox).Angle = item.Angle;
6797
                            }
6798
                            if ((item.Markup as TextControl) != null)
6799
                            {
6800
                                (item.Markup as TextControl).Angle = item.Angle;
6801
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6802
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6803
                            }
6804
                            else
6805
                            {
6806
                                (item.Markup as IPath).PointSet = item.PointSet;
6807
                                (item.Markup as IPath).updateControl();
6808
                            }
6809

    
6810
                            comment.Add(item.Markup);
6811
                        }
6812
                        final = new AdornerFinal(comment);
6813
                        SelectLayer.Children.Add(final);
6814
                        ReleaseAdorner();
6815
                    }
6816
                    break;
6817
                case (Event_Type.Select):
6818
                    {
6819
                        ReleaseAdorner();
6820
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6821

    
6822
                        foreach (var item in undo.Markup_List)
6823
                        {
6824
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6825

    
6826
                            if ((item.Markup as IPath) != null)
6827
                            {
6828
                                (item.Markup as IPath).LineSize = item.LineSize;
6829
                            }
6830
                            if ((item.Markup as UIElement) != null)
6831
                            {
6832
                                (item.Markup as UIElement).Opacity = item.Opacity;
6833
                            }
6834
                            if ((item.Markup as IDashControl) != null)
6835
                            {
6836
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6837
                            }
6838
                            if ((item.Markup as IShapeControl) != null)
6839
                            {
6840
                                (item.Markup as IShapeControl).Paint = item.paint;
6841
                            }
6842

    
6843
                            comment.Add(item.Markup);
6844
                        }
6845

    
6846
                        final = new AdornerFinal(comment);
6847
                        SelectLayer.Children.Add(final);
6848
                    }
6849
                    break;
6850
                case (Event_Type.Option):
6851
                    {
6852
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6853

    
6854
                        foreach (var item in undo.Markup_List)
6855
                        {
6856
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6857

    
6858
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
6859
                            {
6860
                                (item.Markup as IPath).LineSize = undo.LineSize;
6861
                            }
6862
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
6863
                            {
6864
                                (item.Markup as UIElement).Opacity = undo.Opacity;
6865
                            }
6866
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
6867
                            {
6868
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
6869
                            }
6870
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
6871
                            {
6872
                                (item.Markup as LineControl).Interval = undo.Interval;
6873
                            }
6874
                            else if (item.Markup as IShapeControl != null)
6875
                            {
6876
                                (item.Markup as IShapeControl).Paint = undo.paint;
6877
                            }
6878
                            comment.Add(item.Markup);
6879
                        }
6880
                        final = new AdornerFinal(comment);
6881
                        SelectLayer.Children.Add(final);
6882
                    }
6883
                    break;
6884
            }
6885
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6886
            {
6887
                i.IsUndo = true;
6888
            });
6889
        }
6890

    
6891

    
6892

    
6893
        public void Redo()
6894
        {
6895
            //if (ViewerDataModel.Instance.IsPressCtrl)
6896
            //{
6897
            //    ViewerDataModel.Instance.IsPressCtrl = false;
6898
            //}
6899
            AdornerFinal final;
6900
            Undo_data redo = new Undo_data();
6901
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6902
            ReleaseAdorner();
6903
            if (redo == null)
6904
                return;
6905

    
6906
            switch (redo.Event)
6907
            {
6908
                case (Event_Type.Create):
6909
                    {
6910
                        foreach (var item in redo.Markup_List)
6911
                        {
6912
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6913
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
6914
                        }
6915
                    }
6916
                    break;
6917
                case (Event_Type.Delete):
6918
                    {
6919
                        foreach (var item in redo.Markup_List)
6920
                        {
6921
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6922
                        }
6923
                    }
6924
                    break;
6925
                case (Event_Type.Thumb):
6926
                    {
6927
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6928

    
6929
                        foreach (var item in redo.Markup_List)
6930
                        {
6931
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6932

    
6933
                            if ((item.Markup as IViewBox) != null)
6934
                            {
6935
                                (item.Markup as IViewBox).Angle = item.Angle;
6936
                            }
6937
                            if ((item.Markup as TextControl) != null)
6938
                            {
6939
                                (item.Markup as TextControl).Angle = item.Angle;
6940

    
6941
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6942
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6943
                            }
6944
                            else
6945
                            {
6946
                                (item.Markup as IPath).PointSet = item.PointSet;
6947
                                (item.Markup as IPath).updateControl();
6948
                            }
6949
                            comment.Add(item.Markup);
6950
                        }
6951
                        final = new AdornerFinal(comment);
6952
                        SelectLayer.Children.Add(final);
6953
                        ReleaseAdorner();
6954
                    }
6955
                    break;
6956
                case (Event_Type.Select):
6957
                    {
6958
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6959

    
6960
                        foreach (var item in redo.Markup_List)
6961
                        {
6962
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6963

    
6964
                            if ((item.Markup as IPath) != null)
6965
                            {
6966
                                (item.Markup as IPath).LineSize = item.LineSize;
6967
                            }
6968
                            if ((item.Markup as UIElement) != null)
6969
                            {
6970
                                (item.Markup as UIElement).Opacity = item.Opacity;
6971
                            }
6972
                            if ((item.Markup as IDashControl) != null)
6973
                            {
6974
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6975
                            }
6976
                            if ((item.Markup as IShapeControl) != null)
6977
                            {
6978
                                (item.Markup as IShapeControl).Paint = item.paint;
6979
                            }
6980

    
6981
                            comment.Add(item.Markup);
6982
                        }
6983
                        final = new AdornerFinal(comment);
6984
                        SelectLayer.Children.Add(final);
6985
                    }
6986
                    break;
6987
                case (Event_Type.Option):
6988
                    {
6989
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6990

    
6991
                        foreach (var item in redo.Markup_List)
6992
                        {
6993
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6994
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6995
                            {
6996
                                (item.Markup as IPath).LineSize = redo.LineSize;
6997
                            }
6998
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6999
                            {
7000
                                (item.Markup as UIElement).Opacity = redo.Opacity;
7001
                            }
7002
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
7003
                            {
7004
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
7005
                            }
7006
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
7007
                            {
7008
                                (item.Markup as LineControl).Interval = redo.Interval;
7009
                            }
7010
                            else if (item.Markup as IShapeControl != null)
7011
                            {
7012
                                (item.Markup as IShapeControl).Paint = redo.paint;
7013
                            }
7014
                            comment.Add(item.Markup);
7015
                        }
7016
                        final = new AdornerFinal(comment);
7017
                        SelectLayer.Children.Add(final);
7018
                    }
7019
                    break;
7020
            }
7021

    
7022
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
7023
            {
7024
                i.IsUndo = false;
7025
            });
7026
        }
7027

    
7028
        private void Comment_Move(object sender, MouseButtonEventArgs e)
7029
        {
7030
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
7031
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
7032
            {
7033
                if (items.UserID == Select_ID)
7034
                {
7035
                    foreach (var item in items.MarkupList)
7036
                    {
7037
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
7038
                        {
7039
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
7040
                                items.MarkupInfoID, SaveCommand.shortGuid());
7041
                        }
7042
                    }
7043
                }
7044
            }
7045
        }
7046
        public void EmptyControlCheck()
7047
        {
7048
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
7049
            {
7050
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
7051
                {
7052
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
7053
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
7054
                    {
7055
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
7056
                    }
7057
                }
7058
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
7059
                {
7060
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
7061
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
7062
                    {
7063
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
7064
                    }
7065
                }
7066
            }
7067
        }
7068
        public void InkControl_Convert()
7069
        {
7070
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
7071
            if (inkBoard.Strokes.Count > 0)
7072
            {
7073
                inkBoard.Strokes.ToList().ForEach(stroke =>
7074
                {
7075
                    List<Stroke> removingStroke = new List<Stroke>();
7076
                    StrokeCollection stC = new StrokeCollection();
7077

    
7078
                    removingStroke.Add(stroke);
7079

    
7080
                    InkToPath ip = new InkToPath();
7081
                    List<Point> inkPointSet = new List<Point>();
7082
                    PolygonControl pc = null;
7083
                    pc = new PolygonControl()
7084
                    {
7085
                        Angle = 0,
7086
                        PointSet = new List<Point>(),
7087
                        ControlType = ControlType.Ink
7088
                    };
7089
                    foreach (var item in removingStroke)
7090
                    {
7091
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
7092
                        inkBoard.Strokes.Remove(item);
7093
                    }
7094
                    if (inkPointSet.Count != 0)
7095
                    {
7096
                        //강인구 추가(PenControl Undo Redo 추가)
7097
                        UndoData = new Undo_data()
7098
                        {
7099
                            IsUndo = false,
7100
                            Event = Event_Type.Create,
7101
                            EventTime = DateTime.Now,
7102
                            Markup_List = new List<Multi_Undo_data>()
7103
                        };
7104

    
7105
                        pc.StartPoint = inkPointSet[0];
7106
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
7107
                        pc.PointSet = inkPointSet;
7108
                        pc.LineSize = 3;
7109
                        pc.CommentID = SaveCommand.shortGuid();
7110
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
7111
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
7112
                        ///pc.SetPolyPath();
7113

    
7114
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
7115
                        {
7116
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
7117
                        });
7118
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
7119
                        UndoData.Markup_List.Add(multi_Undo_Data);
7120
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
7121
                    }
7122
                });
7123
            }
7124
        }
7125

    
7126
        /// <summary>
7127
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
7128
        /// </summary>
7129
        /// <param name="StartP">StartPoint</param>
7130
        /// <param name="EndP">EndPoint</param>
7131
        /// <returns>Return_EndPoint</returns>
7132
        private Point GetSquareEndPoint(Point StartP, Point EndP)
7133
        {
7134
            Point Return_Point = new Point();
7135

    
7136
            double dx = EndP.X - StartP.X;
7137
            double dy = EndP.Y - StartP.Y;
7138
            double length;
7139

    
7140
            switch (controlType)
7141
            {
7142
                case ControlType.Triangle:
7143
                    {
7144
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
7145
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
7146
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
7147
                    }
7148
                    break;
7149
                default:
7150
                    {
7151
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
7152
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
7153
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
7154
                    }
7155
                    break;
7156
            }
7157

    
7158
            return Return_Point;
7159
        }
7160

    
7161
        /// <summary>
7162
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
7163
        /// </summary>
7164
        /// <author>humkyung</author>
7165
        /// <date>2018.04.26</date>
7166
        /// <param name="StartP"></param>
7167
        /// <param name="EndP"></param>
7168
        /// <returns></returns>
7169
        /// <history>humkyung 2018.05.11 apply axis lock</history>
7170
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
7171
        {
7172
            List<Point> res = new List<Point>();
7173

    
7174
            double dx = EndP.X - StartP.X;
7175
            double dy = EndP.Y - StartP.Y;
7176
            double length = Math.Sqrt(dx * dx + dy * dy);
7177
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
7178
            dx /= length;
7179
            dy /= length;
7180
            double tmp = dx;
7181
            dx = -dy; dy = tmp; /// rotate by 90 degree
7182

    
7183
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
7184
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
7185

    
7186
            return res;
7187
        }
7188

    
7189
        /// <summary>
7190
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
7191
        /// </summary>
7192
        /// <author>ingu</author>
7193
        /// <date>2018.06.05</date>
7194
        /// <param name="getPoint"></param>
7195
        /// <returns></returns>
7196
        private bool IsGetoutpoint(Point getPoint)
7197
        {
7198
            if (getPoint == new Point())
7199
            {
7200
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
7201
                currentControl = null;
7202
                return true;
7203
            }
7204

    
7205
            return false;
7206
        }
7207

    
7208
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
7209
        {
7210
            e.Effects = DragDropEffects.Copy;
7211
        }
7212

    
7213
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
7214
        {
7215
            e.Effects = DragDropEffects.Copy;
7216
        }
7217

    
7218
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
7219
        {
7220
            e.Effects = DragDropEffects.None;
7221
        }
7222

    
7223
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
7224
        {
7225
            try
7226
            {
7227
                if (e.Data.GetDataPresent(typeof(string)))
7228
                {
7229
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
7230
                    string dragData = e.Data.GetData(typeof(string)) as string;
7231
                    Move_Symbol(sender, dragData);
7232
                }
7233
            }
7234
            catch (Exception ex)
7235
            {
7236
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
7237
            }            
7238
        }
7239

    
7240
        private void Move_Symbol(object sender, string dragData)
7241
        {
7242
            try
7243
            {
7244
                if (dragData.Contains("|DZ|"))
7245
                {
7246
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
7247

    
7248
                    string[] delimiterChars = { "|DZ|" };
7249
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
7250

    
7251
                    this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
7252

    
7253
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
7254

    
7255
                    //강인구 Undo/Redo 보류
7256
                    UndoData = new Undo_data()
7257
                    {
7258
                        IsUndo = false,
7259
                        Event = Event_Type.Create,
7260
                        EventTime = DateTime.Now,
7261
                        Markup_List = new List<Multi_Undo_data>()
7262
                    };
7263

    
7264
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
7265
                    {
7266
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
7267
                    });
7268

    
7269
                    foreach (string parse in data)
7270
                    {
7271
                        if (parse != "")
7272
                        {
7273
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
7274
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.SaveCommand.shortGuid();
7275

    
7276
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
7277
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
7278

    
7279
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
7280

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

    
7283
                            UndoData.Markup_List.Add(multi_Undo_Data);
7284
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
7285
                        }
7286
                    }
7287
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
7288

    
7289
                    /// move symbol to current mouse point
7290
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
7291
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
7292
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
7293

    
7294
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
7295
                    {
7296
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
7297
                    }
7298
                    /// up to here
7299

    
7300
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
7301
                }
7302
            }
7303
            catch (Exception ex)
7304
            {
7305
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
7306
            }            
7307
        }        
7308
    }
7309
}
클립보드 이미지 추가 (최대 크기: 500 MB)