프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 661b7416

이력 | 보기 | 이력해설 | 다운로드 (356 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
                temp.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.Save.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.Save.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
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
360
        {
361
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
362
            this.ReleaseAdorner();
363

    
364
            Button content = (sender as Button);
365
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
366

    
367
            DeleteItem(item);
368
        }
369

    
370
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
371

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

    
380
            if (App.ParameterMode)
381
            {
382
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
383
                imageViewer_Compare = new Image();
384
                layerControl.ProjectNo = App.ViewInfo.ProjectNO;
385
                ViewerDataModel.Instance.Capture_Opacity = 0;
386
                da.From = 0.8;
387
                da.To = 0;
388
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
389
                da.AutoReverse = true;
390
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
391

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

    
402
        private void timercallback(Object o)
403
        {
404
            Stopwatch sw = new Stopwatch();
405
            sw.Start();
406
            TempFileAdd();
407
            sw.Stop();
408

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

    
417
            ////GC.Collect();
418
        }
419

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

    
433
                    EmptyControlCheck();
434

    
435
                    if (undoTime > updatetime)
436
                    {
437
                        if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
438
                        {
439
                            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
440
                            {
441
                                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
442

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

    
493
                        temp.WriteTemp(tempDtList);
494
                        tempDtList.Clear();
495
                    }
496
                }
497
            }));
498

    
499
        }
500

    
501

    
502
        public class TempLoadData
503
        {
504
            public int PageNumber { get; set; }
505
            public string CommentID { get; set; }
506
            public string ConvertData { get; set; }
507
            public string DATA_TYPE { get; set; }
508
            public string MarkupInfoID { get; set; }
509
            public int IsUpdate { get; set; }
510
        }
511

    
512
        List<TempLoadData> tempLoadData = new List<TempLoadData>();
513
        public string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" + App.ViewInfo.DocumentItemID + ".tmp";
514

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

    
536
                            tempLoadData.Add(new TempLoadData()
537
                            {
538
                                PageNumber = PageNumber,
539
                                CommentID = CommentID,
540
                                ConvertData = ConvertData,
541
                                DATA_TYPE = DATA_TYPE,
542
                                MarkupInfoID = MarkupInfoID,
543
                                IsUpdate = IsUpdate
544
                            });
545
                        }
546

    
547
                        if (PageNumber > 0)
548
                        {
549
                            this.pageNavigator.GotoPage(PageNumber);
550
                        }
551

    
552
                        // Temp Object add               
553
                        if (pageNavigator.CurrentPage.PageNumber == PageNumber)
554
                        {
555
                            TempControlLoad();
556
                        }
557
                        tempLoadData.Clear();
558
                    }
559
                }
560
                else //파일 삭제
561
                {
562
                    temp.Remove();
563
                }
564
            }            
565
        }
566

    
567

    
568
        public void ReleaseAdorner()
569
        {
570
            try
571
            {
572
                Logger.sendCheckLog("pageNavigator_PageChanging_ReleaseAdorner", 1);
573
                if (SelectLayer.Children.Count > 0)
574
                {
575
                    foreach (var item in SelectLayer.Children)
576
                    {
577
                        if (item.GetType().Name == "AdornerFinal")
578
                        {
579
                            (item as AdornerFinal).unRegister();
580

    
581
                            foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
582
                            {
583
                                if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
584
                                {
585
                                    if (InnerItem.DrawingData.GetType().Name == "PolygonControl")
586
                                    {
587
                                        if ((InnerItem.DrawingData as PolygonControl).CommentID == null)
588
                                        {
589
                                            (InnerItem.DrawingData as PolygonControl).CommentID = KCOM.Events.Save.shortGuid();
590
                                        }
591
                                    }
592

    
593
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
594
                                }
595
                            }
596
                        }
597
                    }
598
                    SelectLayer.Children.Clear();
599
                }
600
            }
601
            catch (Exception ex)
602
            {
603
                Logger.sendResLog("ReleaseAdorner", ex.ToString(), 0);
604
            }            
605
        }
606

    
607
        public List<CommentUserInfo> AddAdorner()
608
        {
609
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
610

    
611
            if (SelectLayer.Children.Count > 0)
612
            {
613
                foreach (var item in SelectLayer.Children)
614
                {
615
                    if (item.GetType().Name == "AdornerFinal")
616
                    {
617
                        (item as AdornerFinal).unRegister();
618

    
619
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
620
                        {
621
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
622
                            {
623
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
624
                            }
625

    
626
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
627

    
628
                            UndoData.Markup_List.Add(multi_Undo_Data);
629
                            multi_Undo_Data = new Multi_Undo_data();
630
                        }
631
                    }
632
                }
633
                SelectLayer.Children.Clear();
634
            }
635
            return adornerSet;
636
        }
637

    
638
        public void ChangeCommentReact()
639
        {
640
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
641
            bool isComingNewBie = false;
642

    
643
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
644
            {
645
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
646
                {
647
                    var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
648

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

    
688

    
689
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
690
            {
691
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
692
                {
693
                    ComingNewBieEnd = true;
694
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
695
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
696
                    gridViewMarkup.ItemsSource = null;
697
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
698
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
699
                }
700
            }
701

    
702
        }
703

    
704
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
705
        bool ComingNewBieEnd = false;
706

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

    
718
            InkControl_Convert();
719

    
720
            ReleaseAdorner();
721
            ChangeCommentReact();
722

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

    
727

    
728
            #region 페이지가 벗어난 경우
729

    
730
            if (BalancePoint < 1)
731
            {
732
                BalancePoint = 1;
733
                ViewerDataModel.Instance.PageBalanceNumber = 0;
734
            }
735

    
736
            if (pageNavigator.PageCount < BalancePoint)
737
            {
738
                BalancePoint = pageNavigator.PageCount;
739
                ViewerDataModel.Instance.PageBalanceNumber = 0;
740
            }
741

    
742
            #endregion
743

    
744
            ViewerDataModel.Instance.PageNumber = BalancePoint;
745

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

    
757
            var defaultBitmapImage = new BitmapImage();
758
            defaultBitmapImage.BeginInit();
759
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
760
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
761
            defaultBitmapImage.UriSource = new Uri(uri);
762
            defaultBitmapImage.EndInit();
763

    
764
            ViewerDataModel.Instance.ImageViewPath = null;
765
            GC.Collect();
766

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

    
782
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
783
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
784

    
785

    
786
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
787
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
788
            inkBoard.Width = zoomAndPanCanvas.Width;
789
            inkBoard.Height = zoomAndPanCanvas.Height;
790

    
791

    
792

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

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

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

    
839
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
840
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
841

    
842
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
843
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
844
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
845
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
846
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
847
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
848

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

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

    
868
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
869
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
870

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

    
884
            this.pageNavigator.SetNextPage();
885

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

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

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

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

    
917
            if (!testPanel2.IsHidden)
918
            {
919
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
920
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
921
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
922

    
923
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
924
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
925

    
926

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

    
936
            var instanceMain = this.ParentOfType<MainWindow>();
937
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
938
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
939

    
940
            instanceMain.dzTopMenu.rotateOffSet = 0;
941
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
942
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
943

    
944
            //}
945
            SetCommentPages(true);
946
        }
947

    
948

    
949
        //Temp Control Load
950
        public void TempControlLoad()
951
        {
952
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
953

    
954
            for (int k = 0; k < tempLoadData.Count; k++)
955
            {
956
                System.Windows.Controls.Control item = null;
957
                Multi_Undo_data multi_Undo_Data;
958

    
959

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

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

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

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

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

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

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

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

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

    
1054
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1055
        {
1056
            if (e.MiddleButton == MouseButtonState.Pressed)
1057
            {
1058

    
1059
            }
1060
            e.Handled = true;
1061
            if (e.Delta > 0)
1062
            {
1063
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1064
                ZoomIn(currentContentMousePoint);
1065
            }
1066
            else
1067
            {
1068
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1069
                ZoomOut(currentContentMousePoint);
1070
            }
1071
        }
1072

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

    
1088
        #region ZoomIn & ZoomOut
1089

    
1090
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1091
        {
1092
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1093
                zoomAndPanControl.ContentZoomFocusY));
1094
        }
1095

    
1096
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1097
        {
1098
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1099
                zoomAndPanControl.ContentZoomFocusY));
1100
        }
1101

    
1102

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

    
1116
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1117
            {
1118
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1119
            }
1120
        }
1121

    
1122
        private void ZoomIn(Point contentZoomCenter)
1123
        {
1124
            if (zoomAndPanControl.ContentScale > 0.19)
1125
            {
1126
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1127
            }
1128
            else
1129
            {
1130
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1131
            }
1132

    
1133
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1134
            {
1135
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1136
            }
1137

    
1138
        }
1139

    
1140
        private void ZoomOut_Sync(Point contentZoomCenter)
1141
        {
1142
            if (zoomAndPanControl2.ContentScale > 0.39)
1143
            {
1144
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1145
            }
1146
            else
1147
            {
1148
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1149
            }
1150

    
1151
            if (Sync.IsChecked)
1152
            {
1153
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1154
            }
1155
        }
1156

    
1157
        private void ZoomIn_Sync(Point contentZoomCenter)
1158
        {
1159
            if (zoomAndPanControl2.ContentScale > 0.19)
1160
            {
1161
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1162
            }
1163
            else
1164
            {
1165
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1166
            }
1167

    
1168
            if (Sync.IsChecked)
1169
            {
1170
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1171
            }
1172
        }
1173

    
1174
        private void ZoomOut()
1175
        {
1176
            zoomAndPanControl.ContentScale -= 0.1;
1177
            //if (zoomAndPanControl2 != null)
1178
            //{
1179
            //    zoomAndPanControl2.ContentScale -= 0.1;
1180
            //}
1181
        }
1182

    
1183
        private void ZoomIn()
1184
        {
1185
            zoomAndPanControl.ContentScale += 0.1;
1186
            //if (zoomAndPanControl2 != null)
1187
            //{
1188
            //    zoomAndPanControl2.ContentScale += 0.1;
1189
            //}
1190
        }
1191

    
1192
        #endregion
1193

    
1194
        private void init()
1195
        {
1196
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1197
            {
1198

    
1199
                ControlList.Clear();
1200
                listBox.Items.Clear();
1201
                selected_item.Clear();
1202

    
1203
                (item as IMarkupCommonData).IsSelected = false;
1204
            }
1205

    
1206
        }
1207

    
1208
        private HitTestResultBehavior MyCallback(HitTestResult result)
1209
        {
1210
            //this.cursor = Cursors.UpArrow;
1211
            var element = result.VisualHit;
1212
            while (element != null && !(element is CommentUserInfo))
1213
                element = VisualTreeHelper.GetParent(element);
1214

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

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

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

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

    
1364
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1365
        {
1366
            //Control_Init(e.Source);
1367
        }
1368
        private Window _dragdropWindow = null;
1369

    
1370
        [DllImport("user32.dll")]
1371
        [return: MarshalAs(UnmanagedType.Bool)]
1372
        internal static extern bool GetCursorPos(ref Win32Point pt);
1373

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

    
1393
            symbol_id = id;
1394
            symbol_group_id = group_id;
1395
            symbol_SelectedIndex = SelectedIndex;
1396
            symbol_Data = Data_;
1397
            symbol_img = img;
1398

    
1399
      
1400
            CreateDragDropWindow2(img);
1401
        }
1402

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

    
1423
            Win32Point w32Mouse = new Win32Point();
1424
            GetCursorPos(ref w32Mouse);
1425

    
1426
            //w32Mouse.X = getCurrentPoint.X;
1427
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1428
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1429
            this._dragdropWindow.Show();
1430
        }
1431

    
1432
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1433
        {
1434
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1435
            {
1436
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1437

    
1438
                Point currentPos = e.GetPosition(rect);
1439

    
1440
                floatingTip.HorizontalOffset = currentPos.X + 20;
1441
                floatingTip.VerticalOffset = currentPos.Y;
1442

    
1443

    
1444
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1445
                //tool.Content = "ToolTip";
1446
                //panel.ToolTip = tool;
1447
            }
1448

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

    
1455
                //if (firstCondition != null)
1456
                //{
1457
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1458

    
1459
                //    if (firstCondition.GetType().Name == "TextControl")
1460
                //    {
1461
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1462
                //        return;
1463
                //    }
1464
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1465
                //    {
1466
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1467
                //        return;
1468
                //    }
1469

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

    
1523
                //        default:
1524
                //            {
1525

    
1526
                //            }
1527
                //            break;
1528
                //    }
1529
                //} 
1530
                #endregion
1531
            }
1532

    
1533
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1534
            #region 주석
1535
            //if (mouseButtonDown == MouseButton.Middle)
1536
            //{
1537
            //    SetCursor();
1538
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1539
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1540

    
1541
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1542
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1543
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1544

    
1545
            //    //SetCursor();
1546
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1547
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1548

    
1549
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1550

    
1551
            //    //zoomAndPanControl.ContentOffsetX += 1;
1552
            //    //zoomAndPanControl.ContentOffsetY += 1;
1553

    
1554
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1555
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1556
            //}
1557
            #endregion
1558

    
1559
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1560
            {
1561
                SetCursor();
1562
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1563
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1564

    
1565
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1566
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1567
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1568

    
1569
                if (Sync.IsChecked)
1570
                {
1571
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1572
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1573
                }
1574
            }
1575

    
1576
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1577
            {
1578
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1579
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1580
                SetCursor();
1581

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

    
1603
                                    //inkBoard.Strokes.Add(stroke);
1604
                                }
1605
                                break;
1606
                        }
1607
                        return;
1608
                    }
1609
                }
1610

    
1611
                if (currentControl != null)
1612
                {
1613
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1614
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1615
                    //강인구 추가
1616
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1617

    
1618
                    if ((currentControl as IPath) != null)
1619
                    {
1620
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1621
                    }
1622
                    if ((currentControl as LineControl) != null)
1623
                    {
1624
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1625
                    }
1626

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

    
1670
                    switch (controlType)
1671
                    {
1672
                        case (ControlType.Coordinate):
1673
                            {
1674
                                var control = currentControl as CoordinateControl;
1675

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

    
1689

    
1690
                                        if (ViewerDataModel.Instance.IsPressShift)
1691
                                        {
1692
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1693
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1694
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1695
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1696
                                        }
1697

    
1698
                                        control.PointSet = new List<Point>
1699
                                        {
1700
                                            control.StartPoint,
1701
                                            control.LeftBottomPoint,
1702
                                            control.EndPoint,
1703
                                            control.TopRightPoint,
1704
                                        };
1705
                                        control.updateControl();
1706
                                    }
1707

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

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

    
1733

    
1734
                                        if (ViewerDataModel.Instance.IsPressShift)
1735
                                        {
1736
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1737
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1738
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1739
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1740
                                        }
1741

    
1742
                                        control.PointSet = new List<Point>
1743
                                        {
1744
                                            control.StartPoint,
1745
                                            control.LeftBottomPoint,
1746
                                            control.EndPoint,
1747
                                            control.TopRightPoint,
1748
                                        };
1749
                                        control.updateControl();
1750
                                    }
1751

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

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

    
1777

    
1778
                                        if (ViewerDataModel.Instance.IsPressShift)
1779
                                        {
1780
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1781
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1782
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1783
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1784
                                        }
1785

    
1786
                                        control.PointSet = new List<Point>
1787
                                        {
1788
                                            control.StartPoint,
1789
                                            control.LeftBottomPoint,
1790
                                            control.EndPoint,
1791
                                            control.TopRightPoint,
1792
                                        };
1793
                                        control.updateControl();
1794
                                    }
1795

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

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

    
1821

    
1822
                                        if (ViewerDataModel.Instance.IsPressShift)
1823
                                        {
1824
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1825
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1826
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1827
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1828
                                        }
1829

    
1830
                                        control.PointSet = new List<Point>
1831
                                        {
1832
                                            control.StartPoint,
1833
                                            control.LeftBottomPoint,
1834
                                            control.EndPoint,
1835
                                            control.TopRightPoint,
1836
                                        };
1837
                                        control.updateControl();
1838
                                    }
1839

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

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

    
1865

    
1866
                                        if (ViewerDataModel.Instance.IsPressShift)
1867
                                        {
1868
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1869
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1870
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1871
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1872
                                        }
1873

    
1874
                                        control.PointSet = new List<Point>
1875
                                        {
1876
                                            control.StartPoint,
1877
                                            control.LeftBottomPoint,
1878
                                            control.EndPoint,
1879
                                            control.TopRightPoint,
1880
                                        };
1881
                                        control.updateControl();
1882
                                    }
1883

    
1884
                                    //강인구 추가
1885
                                    control.ControlType = controlType;
1886
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1887
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1888
                                }
1889
                            }
1890
                            break;
1891

    
1892
                        case ControlType.RectCloud:
1893
                            {
1894
                                var control = currentControl as RectCloudControl;
1895

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

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

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

    
1926
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1927
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1928
                                }
1929
                            }
1930
                            break;
1931

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

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

    
1954
                                    control.PointSet = new List<Point>
1955
                                        {
1956
                                            control.StartPoint,
1957
                                            control.EndPoint,
1958
                                        };
1959

    
1960
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1961
                                }
1962

    
1963
                            }
1964
                            break;
1965

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

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

    
1989

    
1990
                                    control.PointSet = new List<Point>
1991
                                            {
1992
                                                control.StartPoint,
1993
                                                control.EndPoint,
1994
                                            };
1995
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1996
                                }
1997

    
1998

    
1999
                            }
2000
                            break;
2001

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

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

    
2024

    
2025
                                    control.PointSet = new List<Point>
2026
                                            {
2027
                                                control.StartPoint,
2028
                                                control.EndPoint,
2029
                                            };
2030
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2031
                                }
2032
                            }
2033
                            break;
2034

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

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

    
2057

    
2058
                                    control.PointSet = new List<Point>
2059
                                            {
2060
                                                control.StartPoint,
2061
                                                control.EndPoint,
2062
                                            };
2063
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2064
                                }
2065
                            }
2066
                            break;
2067

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

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

    
2090
                                    control.PointSet = new List<Point>
2091
                                            {
2092
                                                control.StartPoint,
2093
                                                control.EndPoint,
2094
                                            };
2095
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2096
                                }
2097
                            }
2098
                            break;
2099

    
2100
                        case ControlType.ChainLine:
2101
                            {
2102
                                var control = currentControl as PolygonControl;
2103

    
2104
                                if (control != null)
2105
                                {
2106

    
2107
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2108
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2109

    
2110
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
2111

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

    
2124
                                    ///control.SetPolyPath();
2125

    
2126
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2127
                                }
2128
                            }
2129
                            break;
2130

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

    
2143
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2144
                                    {
2145
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2146
                                        control.EndPoint = tempPoint;
2147
                                    }
2148
                                    else
2149
                                    {
2150
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2151
                                    }
2152

    
2153

    
2154
                                    control.PointSet = new List<Point>
2155
                                            {
2156
                                                control.StartPoint,
2157
                                                control.MidPoint,
2158
                                                control.EndPoint,
2159
                                            };
2160
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2161
                                }
2162
                            }
2163
                            break;
2164

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

    
2177
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2178
                                    {
2179
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2180
                                        control.EndPoint = tempPoint;
2181
                                    }
2182
                                    else
2183
                                    {
2184
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2185
                                    }
2186

    
2187

    
2188
                                    control.PointSet = new List<Point>
2189
                                            {
2190
                                                control.StartPoint,
2191
                                                control.MidPoint,
2192
                                                control.EndPoint,
2193
                                            };
2194
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2195
                                }
2196
                            }
2197
                            break;
2198

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

    
2232
                                    }
2233

    
2234
                                    control.PointSet = new List<Point>
2235
                                            {
2236
                                                control.StartPoint,
2237
                                                control.MiddlePoint,
2238
                                                control.EndPoint,
2239
                                            };
2240
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2241
                                }
2242
                            }
2243
                            break;
2244

    
2245
                        case ControlType.Circle:
2246
                            {
2247
                                var control = currentControl as CircleControl;
2248

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

    
2262
                                        if (ViewerDataModel.Instance.IsPressShift)
2263
                                        {
2264
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
2265
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
2266
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
2267
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
2268
                                        }
2269

    
2270
                                        control.PointSet = new List<Point>
2271
                                        {
2272
                                            control.StartPoint,
2273
                                            control.LeftBottomPoint,
2274
                                            control.EndPoint,
2275
                                            control.TopRightPoint,
2276
                                        };
2277
                                    }
2278

    
2279
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2280
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2281

    
2282
                                }
2283
                            }
2284
                            break;
2285

    
2286
                        case ControlType.PolygonCloud:
2287
                            {
2288
                                var control = currentControl as CloudControl;
2289

    
2290
                                if (control != null)
2291
                                {
2292
                                    control.isTransOn = true;
2293
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2294

    
2295
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2296

    
2297
                                    control.SetCloud();
2298
                                    //강인구 추가
2299
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2300
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2301
                                }
2302
                            }
2303
                            break;
2304

    
2305
                        case ControlType.Triangle:
2306
                            {
2307
                                var control = currentControl as TriControl;
2308

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

    
2320
                                        if (ViewerDataModel.Instance.checkAxis)
2321
                                        {
2322
                                            Point tempPoint = control.EndPoint;
2323
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2324
                                            control.EndPoint = tempPoint;
2325
                                        }
2326

    
2327

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

    
2338
                                        control.PointSet = new List<Point>
2339
                                            {
2340
                                                control.StartPoint,
2341
                                                control.MidPoint,
2342
                                                control.EndPoint,
2343
                                            };
2344
                                    }
2345

    
2346
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2347
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2348
                                }
2349
                            }
2350
                            break;
2351

    
2352
                        case ControlType.ImgControl:
2353
                            {
2354
                                var control = currentControl as ImgControl;
2355

    
2356
                                if (control != null)
2357
                                {
2358
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2359
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2360
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2361
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2362

    
2363
                                    control.PointSet = new List<Point>
2364
                                        {
2365
                                            control.StartPoint,
2366
                                            control.LeftBottomPoint,
2367
                                            control.EndPoint,
2368
                                            control.TopRightPoint,
2369
                                        };
2370
                                }
2371
                            }
2372
                            break;
2373

    
2374
                        case ControlType.Date:
2375
                            {
2376
                                var control = currentControl as DateControl;
2377

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

    
2386
                                    control.PointSet = new List<Point>
2387
                                        {
2388
                                            control.StartPoint,
2389
                                            control.LeftBottomPoint,
2390
                                            control.EndPoint,
2391
                                            control.TopRightPoint,
2392
                                        };
2393
                                }
2394
                            }
2395
                            break;
2396

    
2397
                        case ControlType.ArrowTextControl:
2398
                            {
2399
                                var control = currentControl as ArrowTextControl;
2400

    
2401
                                if (control != null)
2402
                                {
2403
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2404
                                    Point tempPoint = control.EndPoint;
2405

    
2406
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2407

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

    
2419
                                    control.PointSet = new List<Point>
2420
                                            {
2421
                                                control.StartPoint,
2422
                                                control.MidPoint,
2423
                                                control.EndPoint,
2424
                                            };
2425
                                }
2426
                            }
2427
                            break;
2428

    
2429
                        case ControlType.ArrowTransTextControl:
2430
                            {
2431
                                var control = currentControl as ArrowTextControl;
2432

    
2433
                                if (control != null)
2434
                                {
2435
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2436
                                    Point tempPoint = control.EndPoint;
2437
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2438

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

    
2451
                                    control.PointSet = new List<Point>
2452
                                            {
2453
                                                control.StartPoint,
2454
                                                control.MidPoint,
2455
                                                control.EndPoint,
2456
                                            };
2457
                                }
2458
                            }
2459
                            break;
2460

    
2461
                        case ControlType.ArrowTextBorderControl:
2462
                            {
2463
                                var control = currentControl as ArrowTextControl;
2464

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

    
2487
                            }
2488
                            break;
2489
                        case ControlType.ArrowTransTextBorderControl:
2490
                            {
2491
                                var control = currentControl as ArrowTextControl;
2492

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

    
2508
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2509
                                    control.PointSet = new List<Point>
2510
                                            {
2511
                                                control.StartPoint,
2512
                                                control.MidPoint,
2513
                                                control.EndPoint,
2514
                                            };
2515
                                }
2516

    
2517
                            }
2518
                            break;
2519
                        case ControlType.ArrowTextCloudControl:
2520
                            {
2521
                                var control = currentControl as ArrowTextControl;
2522

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

    
2545
                            }
2546
                            break;
2547
                        case ControlType.ArrowTransTextCloudControl:
2548
                            {
2549
                                var control = currentControl as ArrowTextControl;
2550

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

    
2574
                            }
2575
                            break;
2576
                        case ControlType.PolygonControl:
2577
                            {
2578

    
2579
                                var control = currentControl as PolygonControl;
2580

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

    
2598
                                if (control != null)
2599
                                {
2600
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2601
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2602
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2603
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2604

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

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

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

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

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

    
2674
                                if (control != null)
2675
                                {
2676

    
2677
                                    if (control.StartPoint == control.EndPoint)
2678
                                    {
2679
                                        //string appovalData = "";
2680

    
2681
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2682
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2683

    
2684

    
2685
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2686

    
2687
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2688
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2689
                                        writer.Write(xamlData);
2690
                                        writer.Flush();
2691
                                        stream.Position = 0;
2692

    
2693
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2694
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2695
                                        UIElement ob = obj as UIElement;
2696

    
2697
                                        //control.ApplyTemplate();
2698

    
2699
                                        control.SetViewBox();
2700
                                        control.PathXathData = App.SystemInfo.STAMP;
2701
                                        control.Base_ViewBox.Child = ob;
2702
                                    }
2703

    
2704
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2705
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2706
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2707
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2708
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2709

    
2710

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

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

    
2738

    
2739
                                        control.PointSet = new List<Point>
2740
                                    {
2741
                                        control.StartPoint,
2742
                                        control.LeftBottomPoint,
2743
                                        control.EndPoint,
2744
                                        control.TopRightPoint,
2745
                                    };
2746
                                    }
2747

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

    
2768
                if (isDraggingSelectionRect)
2769
                {
2770
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2771

    
2772
                    e.Handled = true;
2773
                }
2774
                else if (isLeftMouseButtonDownOnWindow)
2775
                {
2776
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2777
                    double dragDistance = Math.Abs(dragDelta.Length);
2778

    
2779
                    if (dragDistance > DragThreshold)
2780
                    {
2781
                        isDraggingSelectionRect = true;
2782

    
2783
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2784
                    }
2785

    
2786
                    e.Handled = true;
2787
                }
2788

    
2789

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

    
2812

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

    
2829
                    //    }
2830
                    //    else
2831
                    //    {
2832
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2833
                    //    }
2834
                    //}
2835

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

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

    
2862
                    SetCursor();
2863
                }
2864
            }
2865
            else
2866
            {
2867
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2868

    
2869
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2870
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2871

    
2872
                //if (hitList.Count > 0)
2873
                //{
2874

    
2875
                //}
2876

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

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

    
2899
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2900
                //hitResultsList.Clear();
2901

    
2902
                #endregion
2903
            }
2904
        }
2905

    
2906
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2907
        {
2908
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2909
            {
2910
                SetCursor();
2911
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2912
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2913

    
2914
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2915

    
2916
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2917
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2918

    
2919
                if (Sync.IsChecked)
2920
                {
2921
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2922
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2923
                }
2924
            }
2925
        }
2926

    
2927
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2928

    
2929
        private EllipseGeometry hitArea = new EllipseGeometry();
2930

    
2931
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2932
        {
2933
            IsDrawing = false;
2934

    
2935
            if (mouseHandlingMode != MouseHandlingMode.None)
2936
            {
2937
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2938
                {
2939
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2940

    
2941
                    SetCursor();
2942

    
2943
                    switch (controlType)
2944
                    {
2945
                        case ControlType.None:
2946
                            break;
2947
                        case ControlType.Rectangle:
2948
                            {
2949

    
2950
                            }
2951
                            break;
2952
                        case ControlType.PenControl:
2953
                            {
2954

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

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

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

    
3002
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
3003

    
3004
                                dragZoomBorder.Visibility = Visibility.Collapsed;
3005
                            }
3006

    
3007
                            isDraggingSelectionRect = false;
3008
                            e.Handled = true;
3009
                            wasDragSelectionApplied = true;
3010
                        }
3011

    
3012
                        if (isLeftMouseButtonDownOnWindow)
3013
                        {
3014
                            isLeftMouseButtonDownOnWindow = false;
3015
                            this.ReleaseMouseCapture();
3016
                            e.Handled = true;
3017
                        }
3018

    
3019
                        if (!wasDragSelectionApplied)
3020
                        {
3021
                            init();
3022
                        }
3023
                    }
3024
                }
3025
                else if (mouseButtonDown == MouseButton.Right)
3026
                {
3027
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3028
                    SetCursor();
3029
                }
3030

    
3031
                zoomAndPanControl.ReleaseMouseCapture();
3032

    
3033

    
3034
                e.Handled = true;
3035
            }
3036
            else
3037
            {
3038
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3039
                SetCursor();
3040
            }
3041
            mouseButtonDown = MouseButton.Left;
3042

    
3043
            //controlType = ControlType.SingleLine;
3044
        }
3045

    
3046
        public void Set_Symbol_Capture(Point endPoint)
3047
        {       
3048
            double x = canvasDrawingMouseDownPoint.X;
3049
            double y = canvasDrawingMouseDownPoint.Y;
3050
            if(x > endPoint.X)
3051
            {
3052
                x = endPoint.X;
3053
                y = endPoint.Y;
3054
            }
3055

    
3056
            double width = dragCaptureBorder.Width;
3057
            double height = dragCaptureBorder.Height;
3058

    
3059
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
3060

    
3061
            if (x < 0)
3062
            {
3063
                width += x;
3064
                x = 0;
3065
            }
3066
            if (y < 0)
3067
            {
3068
                height += y;
3069
                y = 0;
3070

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

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

    
3095
            var defaultBitmapImage = new BitmapImage();
3096
            defaultBitmapImage.BeginInit();
3097
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
3098
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
3099
            defaultBitmapImage.UriSource = new Uri(uri);
3100
            defaultBitmapImage.EndInit();
3101

    
3102
            //GC.Collect();
3103

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

    
3116
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
3117
        {
3118
            mouseButtonDown = MouseButton.Left;
3119
        }
3120

    
3121
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
3122
        {
3123
            mouseButtonDown = MouseButton.Left;
3124
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3125
        }
3126

    
3127
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
3128
        {
3129

    
3130
        }
3131

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

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

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

    
3170
            if (selected != null)
3171
            {
3172
                this.ReleaseAdorner();
3173

    
3174
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
3175
                adornerSet.Add(selected);
3176
                ViewerDataModel.Instance.MarkupControls_USER.Remove(selected);
3177

    
3178
                Control_Style(selected);
3179
                UndoData.Markup_List.Add(multi_Undo_Data);
3180
                multi_Undo_Data = new Multi_Undo_data();
3181

    
3182
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3183
                {
3184
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
3185
                });
3186
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3187

    
3188
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
3189
                SelectLayer.Children.Add(final);
3190
            }
3191
        }
3192

    
3193
        private void ApplyDragSelectionRect()
3194
        {
3195
            multi_Undo_Data = new Multi_Undo_data();
3196

    
3197
            UndoData = new Undo_data()
3198
            {
3199
                IsUndo = false,
3200
                Event = Event_Type.Select,
3201
                EventTime = DateTime.Now,
3202
                Markup_List = new List<Multi_Undo_data>()
3203
            };
3204

    
3205
            dragSelectionBorder.Visibility = Visibility.Collapsed;
3206

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

    
3217
            dragRect = new Rect(x, y, width, height);
3218
            dragRect.Inflate(width / 10, height / 10);
3219

    
3220
            foreach (var item in Items)
3221
            {
3222
                Flag = move.control_Select(item, dragRect);
3223

    
3224
                if (Flag)
3225
                {
3226
                    adornerSet.Add(item);
3227
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
3228

    
3229
                    Control_Style(item);
3230
                    UndoData.Markup_List.Add(multi_Undo_Data);
3231
                    multi_Undo_Data = new Multi_Undo_data();
3232
                    if (item.GroupID > 0)
3233
                    {
3234

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

    
3246
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
3247
                SelectLayer.Children.Add(final);
3248
            }
3249
        }
3250

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

    
3262
                dragSelectionBorder.Visibility = Visibility.Visible;
3263
            }
3264
            else
3265
            {
3266
                dragZoomBorder.Visibility = Visibility.Visible;
3267
            }
3268
            UpdateDragSelectionRect(pt1, pt2);
3269
        }
3270

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

    
3278
            //
3279
            // Determine x,y,width and height of the rect inverting the points if necessary.
3280
            // 
3281

    
3282
            if (pt2.X < pt1.X)
3283
            {
3284
                x = pt2.X;
3285
                width = pt1.X - pt2.X;
3286
            }
3287
            else
3288
            {
3289
                x = pt1.X;
3290
                width = pt2.X - pt1.X;
3291
            }
3292

    
3293
            if (pt2.Y < pt1.Y)
3294
            {
3295
                y = pt2.Y;
3296
                height = pt1.Y - pt2.Y;
3297
            }
3298
            else
3299
            {
3300
                y = pt1.Y;
3301
                height = pt2.Y - pt1.Y;
3302
            }
3303

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

    
3332
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
3333
        {
3334
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
3335

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

    
3348
                }
3349
            }
3350
            return result;
3351
        }
3352

    
3353
        private void drawingPannelRotate(double angle)
3354
        {
3355
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
3356
            rotate.Angle = angle;
3357
            var rotationNum = Math.Abs((rotate.Angle / 90));
3358

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

    
3386
            zoomAndPanControl.RotationAngle = rotate.Angle;
3387

    
3388

    
3389
            if (!testPanel2.IsHidden)
3390
            {
3391
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3392
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3393
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3394
            }
3395

    
3396
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3397
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3398
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3399
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3400
            ViewerDataModel.Instance.Angle = rotate.Angle;
3401
        }
3402

    
3403
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3404
        {
3405
            string Data_ = "";
3406

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

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

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

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

    
3480
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3481
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3482
                    UndoData.Markup_List.Add(multi_Undo_Data);
3483
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3484

    
3485
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3486
                    currentControl.CommentID = Events.Save.shortGuid();
3487
                    currentControl.SymbolID = id;
3488
                    currentControl.GroupID = group_id;
3489
                    currentControl.ApplyTemplate();
3490
                    currentControl.SetImage();
3491

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

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

    
3511
            InkControl_Convert();
3512

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

    
3516
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3517
            {
3518
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3519
            }
3520

    
3521
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3522
            {
3523
                if (arrow_text as ArrowTextControl != null)
3524
                {
3525
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3526
                }
3527
            }
3528

    
3529
            mouseButtonDown = e.ChangedButton;
3530
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3531

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

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

    
3553
            double Ang = 0;                                          
3554
            if (rotate.Angle != 0)
3555
            {
3556
                Ang = 360 - rotate.Angle;
3557
            }
3558
            move = new Move();
3559

    
3560
            if (e.OriginalSource is System.Windows.Controls.Image)
3561
            {
3562
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3563
            }
3564

    
3565
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3566
            {                
3567
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3568
                //SetCursor();
3569

    
3570
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3571
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3572
                if(symbol_id != null)
3573
                {
3574
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3575
                }                
3576
            }
3577

    
3578
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3579
            {
3580
                if (this._dragdropWindow != null)
3581
                {
3582
                    this._dragdropWindow.Close();
3583
                    this._dragdropWindow = null;
3584
                    symbol_id = null;
3585
                }
3586
            }
3587

    
3588
            if (mouseButtonDown == MouseButton.Left)
3589
            {
3590
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3591
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3592

    
3593
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3594
                SetCursor();
3595

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

    
3620
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3621

    
3622
            }
3623
            else if (mouseButtonDown == MouseButton.XButton2)
3624
            {
3625
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3626
                {
3627
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3628
                }
3629
            }
3630

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

    
3642
                    if (controlType == ControlType.None)
3643
                    {
3644
                        isLeftMouseButtonDownOnWindow = true;
3645
                    }
3646
                }
3647

    
3648
                //캡쳐 모드 설정
3649
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3650
                {
3651
                    dragCaptureBorder.Visibility = Visibility.Visible;
3652
                    isLeftMouseButtonDownOnWindow = true;
3653
                }
3654

    
3655
                //줌 모드 설정
3656
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3657
                {
3658
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3659
                    isLeftMouseButtonDownOnWindow = true;
3660
                }               
3661

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

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

    
3682
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3683
                    {
3684
                        ReleaseAdorner();
3685
                        final = new AdornerFinal(control);
3686
                        //단일 컨트롤 언두 저장
3687

    
3688
                        Control_Style(control);
3689
                        UndoData.Markup_List.Add(multi_Undo_Data);
3690

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

    
3716
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3717

    
3718
                        if ((control as TextControl) != null)
3719
                        {
3720
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3721
                            {
3722
                                ViewerDataModel.Instance.checkTextStyle = true;
3723
                            }
3724
                            else
3725
                            {
3726
                                ViewerDataModel.Instance.checkTextStyle = false;
3727
                            }
3728

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

    
3756
                        }
3757
                        else if ((control as ArrowTextControl) != null)
3758
                        {
3759
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3760
                            {
3761
                                ViewerDataModel.Instance.checkTextStyle = true;
3762
                            }
3763
                            else
3764
                            {
3765
                                ViewerDataModel.Instance.checkTextStyle = false;
3766
                            }
3767

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

    
3804
                    }
3805
                    else
3806
                    {
3807
                        comment = AddAdorner();
3808
                        comment.Add(control);
3809

    
3810
                        Control_Style(control);
3811
                        UndoData.Markup_List.Add(multi_Undo_Data);
3812

    
3813
                        final = new AdornerFinal(comment);
3814
                        //다중 컨트롤 언두 저장
3815
                    }
3816

    
3817
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3818
                    {
3819
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3820
                    });
3821

    
3822
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3823

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

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

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

    
3887
                                    CreateControl();
3888

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

    
3912
                                        currentControl.CommentID = Save.shortGuid();
3913
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3914
                                        currentControl.IsNew = true;
3915

    
3916
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3917

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

    
3935
                                    CreateControl();
3936

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

    
3949
                                    currentControl.CommentID = Save.shortGuid();
3950
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3951
                                    currentControl.IsNew = true;
3952
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3953

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

    
3970
                                    CreateControl();
3971

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

    
3984
                                    currentControl.CommentID = Save.shortGuid();
3985
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3986
                                    currentControl.IsNew = true;
3987
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3988

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

    
4005
                                    CreateControl();
4006

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

    
4019
                                    currentControl.CommentID = Save.shortGuid();
4020
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4021
                                    currentControl.IsNew = true;
4022
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4023

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

    
4043
                                        CreateControl();
4044

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

    
4058
                                        currentControl.CommentID = Save.shortGuid();
4059
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4060
                                        currentControl.IsNew = true;
4061
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4062

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

    
4083
                                        CreateControl();
4084

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

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

    
4120
                                        CreateControl();
4121

    
4122
                                        (currentControl as CircleControl).ApplyOverViewData();
4123
                                        currentControl = null;
4124
                                    }
4125
                                    else
4126
                                    {
4127
                                        currentControl = new CircleControl
4128
                                        {
4129
                                            Background = new SolidColorBrush(Colors.Black)
4130
                                        };
4131

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

    
4162
                                            CreateControl();
4163

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

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

    
4199
                                        CreateControl();
4200

    
4201
                                        (currentControl as LineControl).ApplyOverViewData();
4202
                                        currentControl = null;
4203
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4204
                                    }
4205
                                    else
4206
                                    {
4207
                                        currentControl = new LineControl
4208
                                        {
4209
                                            Background = new SolidColorBrush(Colors.Black)
4210
                                        };
4211

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

    
4236
                                        CreateControl();
4237

    
4238
                                        (currentControl as LineControl).ApplyOverViewData();
4239
                                        currentControl = null;
4240
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4241
                                    }
4242
                                    else
4243
                                    {
4244
                                        currentControl = new LineControl
4245
                                        {
4246
                                            Background = new SolidColorBrush(Colors.Black)
4247
                                        };
4248

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

    
4273
                                        CreateControl();
4274

    
4275
                                        (currentControl as LineControl).ApplyOverViewData();
4276
                                        currentControl = null;
4277
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4278
                                    }
4279
                                    else
4280
                                    {
4281
                                        currentControl = new LineControl
4282
                                        {
4283
                                            Background = new SolidColorBrush(Colors.Black)
4284
                                        };
4285

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

    
4310
                                        CreateControl();
4311

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

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

    
4373
                                if (mouseButtonDown == MouseButton.Right)
4374
                                {
4375
                                    //20180906 LJY TEST IsRotationDrawingEnable
4376
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4377
                                    {
4378
                                        return;
4379
                                    }
4380

    
4381
                                    CreateControl();
4382

    
4383
                                    (currentControl as PolygonControl).ApplyOverViewData();
4384
                                    currentControl = null;
4385
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4386
                                    return;
4387
                                }
4388

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

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

    
4441
                                        CreateControl();
4442

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

    
4486
                                    CreateControl();
4487

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

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

    
4546
                                            CreateControl();
4547

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

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

    
4592
                                    CreateControl();
4593

    
4594
                                    control.isTransOn = true;
4595
                                    var firstPoint = control.PointSet.First();
4596

    
4597
                                    control.PointSet.Add(firstPoint);
4598
                                    control.DrawingCloud();
4599
                                    control.ApplyOverViewData();
4600

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

    
4614
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4615
                                    //{
4616
                                        var polygonControl = (currentControl as CloudControl);
4617
                                        currentControl.CommentID = Save.shortGuid();
4618
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4619
                                        currentControl.IsNew = true;
4620
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4621

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

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

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

    
4686
                                        
4687
                                                currentControl.CommentID = Save.shortGuid();                                            
4688
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4689
                                                currentControl.IsNew = true;
4690
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4691

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

    
4714
                                        CreateControl();
4715
                                        (currentControl as DateControl).ApplyOverViewData();
4716
                                        currentControl = null;
4717

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

    
4728
                                        }
4729
                                    }
4730
                                    else
4731
                                    {
4732
                                        currentControl = new DateControl
4733
                                        {
4734
                                            Background = new SolidColorBrush(Colors.Black)
4735
                                        };
4736
                                        currentControl.CommentID = Save.shortGuid();
4737
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4738
                                        currentControl.IsNew = true;
4739
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4740

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

    
4773
                                    CreateControl();
4774

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

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

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

    
4822
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4823
                                    currentControl.CommentID = Save.shortGuid();
4824
                                    currentControl.IsNew = true;
4825
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4826
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4827

    
4828
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4829
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4830
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4831

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

    
4855
                                    CreateControl();
4856

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

    
4873
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4874
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4875
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4876
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4877
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4878

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

    
4882
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4883
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4884
                                        this.MainAngle.Visibility = Visibility.Visible;
4885

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

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

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

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

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

    
4967
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4968

    
4969
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4970

    
4971
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4972
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4973
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4974

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

    
5008
                                    currentControl = new ArrowTextControl()
5009
                                        {
5010
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
5011
                                        };
5012
                                        currentControl.CommentID = Save.shortGuid();
5013
                                        currentControl.IsNew = true;
5014
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5015
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5016

    
5017
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5018

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

    
5029
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
5030
                                        this.MainAngle.Visibility = Visibility.Visible;
5031
                                    
5032
                                    //20180911 LJY
5033
                                        (currentControl as ArrowTextControl).isTrans = true;
5034
                                    
5035

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

    
5071
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5072
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5073
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
5074
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5075
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5076

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

    
5119
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5120
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
5121
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5122
                                        (currentControl as ArrowTextControl).isFixed = true;
5123
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5124

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

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

    
5145
                                if (mouseButtonDown == MouseButton.Right)
5146
                                {
5147
                                    control.IsCompleted = true;
5148
                                }
5149

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

    
5162
                                    var firstPoint = control.PointSet.First();
5163
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
5164
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
5165
                                    control.PointSet.Add(firstPoint);
5166

    
5167
                                    ///control.SetPolyPath();
5168

    
5169
                                    control.ApplyOverViewData();
5170

    
5171
                                    CreateControl();
5172

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

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

    
5210
                                    if (_sign == null)
5211
                                    {
5212
                                        txtBatch.Visibility = Visibility.Collapsed;
5213
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
5214
                                        controlType = ControlType.None;
5215

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

    
5221
                                    if (currentControl is SignControl)
5222
                                    {
5223
                                        //20180906 LJY TEST IsRotationDrawingEnable
5224
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5225
                                        {
5226
                                            return;
5227
                                        }
5228

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

    
5248
                                        currentControl.CommentID = Save.shortGuid();
5249
                                        currentControl.IsNew = true;
5250
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5251
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5252

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

    
5274
                                        CreateControl();
5275
                                        (currentControl as RectangleControl).ApplyOverViewData();
5276
                                        currentControl = null;
5277
                                    
5278
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5279

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

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

    
5331
                                        currentControl.IsNew = true;
5332
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5333
                                        currentControl.CommentID = Save.shortGuid();
5334
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5335

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

    
5357
                                        CreateControl();
5358
                                        currentControl = null;
5359
                                   
5360

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

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

    
5420
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
5421
                            if (over != null)
5422
                            {
5423
                                mouseOff = true;
5424
                            }
5425
                        }
5426
                    }
5427

    
5428
                    if (!mouseOff)
5429
                    {
5430
                        ReleaseAdorner();
5431
                    }
5432
                }
5433
                zoomAndPanControl.CaptureMouse();
5434
                e.Handled = true;
5435
            }
5436
        }
5437

    
5438
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5439
        {
5440
            mouseButtonDown = e.ChangedButton;
5441
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5442
        }
5443

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

    
5457

    
5458
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5459
                UndoData.Markup_List.Add(multi_Undo_Data);
5460
                multi_Undo_Data = new Multi_Undo_data();
5461

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

    
5475
            }
5476
        }
5477

    
5478
        private void RemovePointStroke(Point P)
5479
        {
5480
            foreach (Stroke hits in inkBoard.Strokes)
5481
            {
5482
                foreach (StylusPoint sty in hits.StylusPoints)
5483
                {
5484

    
5485
                }
5486
                if (hits.HitTest(P))
5487
                {
5488
                    inkBoard.Strokes.Remove(hits);
5489
                    return;
5490
                }
5491
            }
5492
        }
5493

    
5494
        private void StartNewStroke(Point P)
5495
        {
5496
            strokePoints = new StylusPointCollection();
5497
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5498
            strokePoints.Add(segment1Start);
5499
            stroke = new Stroke(strokePoints);
5500

    
5501
            stroke.DrawingAttributes.Color = Colors.Red;
5502
            stroke.DrawingAttributes.Width = 4;
5503
            stroke.DrawingAttributes.Height = 4;
5504

    
5505
            inkBoard.Strokes.Add(stroke);
5506

    
5507
        }
5508

    
5509
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5510
        {
5511
            ConsolidationMethod();
5512
        }
5513

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

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

    
5547
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5548
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5549
            }
5550
        }
5551
        public void ConsolidationMethod()
5552
        {
5553
            ChangeCommentReact();
5554

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

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

    
5577
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5578
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5579

    
5580
            }
5581
        }
5582

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

    
5595
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5596
        {
5597
            TeamConsolidationMethod();
5598
        }
5599

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

    
5612
                    if (!App.ViewInfo.NewCommentPermission)
5613
                    {
5614
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5615
                    }
5616
                }
5617
                else
5618
                {
5619
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5620
                }
5621
            }
5622
        }
5623

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

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

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

    
5655
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5656
        {
5657
            ChangeCommentReact();
5658

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

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

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

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

    
5697
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5698
        {
5699
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5700

    
5701
            if (App.ViewInfo != null)
5702
            {
5703
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5704
                {
5705
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5706
                }
5707
            }
5708
        }
5709

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

    
5723
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5724
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5725
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5726

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

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

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

    
5762
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5763
        {
5764

    
5765
            if (BalanceMode.IsChecked)
5766
            {
5767
                ViewerDataModel.Instance.PageBalanceMode = true;
5768
            }
5769
            else
5770
            {
5771
                ViewerDataModel.Instance.PageBalanceMode = false;
5772
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5773
            }
5774
        }
5775

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

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

    
5797
                if (ViewerDataModel.Instance.PageNumber == 0)
5798
                {
5799
                    ViewerDataModel.Instance.PageNumber = 1;
5800
                }
5801

    
5802
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5803
                {
5804
                }
5805
                else
5806
                {
5807
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5808
                }
5809

    
5810
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5811
                {
5812

    
5813
                }
5814
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5815
                {
5816
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5817
                }
5818

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

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

    
5843
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5844
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5845
                        }
5846

    
5847
                    }
5848
                    else
5849
                    {
5850
                        string uri = "";
5851

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

    
5861
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5862

    
5863
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5864
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5865
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5866

    
5867
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5868
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5869

    
5870
                        if (defaultBitmapImage_Compare.IsDownloading)
5871
                        {
5872
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5873
                            {
5874
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5875
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5876
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5877

    
5878
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5879
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5880
                            };
5881
                        }
5882
                    }
5883

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

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

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

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

    
5907
                }
5908
            }
5909
        }
5910

    
5911
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5912
        {
5913
            if (MarkupMode.IsChecked)
5914
            {
5915
                IsSyncPDFMode = true;
5916

    
5917
                var uri = CurrentRev.TO_VENDOR;
5918

    
5919
                if (ViewerDataModel.Instance.PageNumber == 0)
5920
                {
5921
                    ViewerDataModel.Instance.PageNumber = 1;
5922
                }
5923

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

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

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

    
5962
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5963

    
5964
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5965
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5966
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5967

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

    
5984
        private void RadButton_Click(object sender, RoutedEventArgs e)
5985
        {
5986
            gridViewHistory_Busy.IsBusy = true;
5987

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

    
5998
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5999
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
6000

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

    
6011
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6012

    
6013
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6014

    
6015
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6016
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6017
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6018

    
6019
                        if (defaultBitmapImage_Compare.IsDownloading)
6020
                        {
6021
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
6022
                            {
6023
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6024
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6025
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6026
                            };
6027
                        }
6028

    
6029
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
6030
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
6031
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
6032
                        zoomAndPanControl2.ApplyTemplate();
6033
                        zoomAndPanControl2.UpdateLayout();
6034

    
6035
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
6036
                        {
6037
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
6038
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
6039
                        }
6040

    
6041
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
6042
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
6043
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
6044

    
6045
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
6046
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
6047
                        gridViewHistory_Busy.IsBusy = false;
6048
                    }
6049

    
6050
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
6051
                };
6052
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
6053
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
6054
            }
6055
        }
6056

    
6057
        public void Sync_Event(VPRevision Currnet_Rev)
6058
        {
6059
            CurrentRev = Currnet_Rev;
6060

    
6061
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
6062
            {
6063
                if (ea.Error == null && ea.Result != null)
6064
                {
6065
                    testPanel2.IsHidden = false;
6066

    
6067
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
6068
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
6069

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

    
6080
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6081

    
6082
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6083

    
6084
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6085
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6086
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6087

    
6088
                    if (defaultBitmapImage_Compare.IsDownloading)
6089
                    {
6090
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
6091
                        {
6092
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6093
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6094
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6095
                        };
6096
                    }
6097

    
6098

    
6099
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
6100
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
6101
                    zoomAndPanControl2.ApplyTemplate();
6102
                    zoomAndPanControl2.UpdateLayout();
6103

    
6104
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
6105
                    {
6106
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
6107
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
6108
                    }
6109
                    //}
6110

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

    
6117
            };
6118
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
6119
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
6120
        }
6121

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

    
6138
        private void Create_Symbol(object sender, RoutedEventArgs e)
6139
        {
6140
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
6141

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

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

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

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

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

    
6227
                                    System.Drawing.Bitmap image;
6228

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

    
6251
                                            StringBuilder svgBuilder = new StringBuilder();
6252
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
6253
                                            {
6254
                                                svgBuilder.AppendLine(e2.Data);
6255
                                            };
6256

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

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

    
6298
        public void SymbolSave(string Name, string Url, string Data)
6299
        {
6300
            try
6301
            {
6302
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
6303
                {
6304
                    ID = Events.Save.shortGuid(),
6305
                    MEMBER_USER_ID = App.ViewInfo.UserID,
6306
                    NAME = Name,
6307
                    IMAGE_URL = Url,
6308
                    DATA = Data
6309
                };
6310

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

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

    
6343
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
6344
        {           
6345
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6346
            DataBind();
6347
        }
6348

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

    
6375
                symbolPanel_Instance.deptlist.ItemsSource = client.GetPublicSymbolDeptList();
6376

    
6377
                List<SYMBOL_PUBLIC> symbol_Public;
6378

    
6379

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

    
6416
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6417
                        _Encoder.Save(fs);
6418
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6419

    
6420
                        byte[] Img_byte = fs.ToArray();
6421

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

    
6443
        public PngBitmapEncoder symImage(string data)
6444
        {
6445

    
6446
            Canvas _canvas = new Canvas();
6447
            _canvas.Background = Brushes.White;
6448
            _canvas.Width = adorner_.BorderSize.Width;
6449
            _canvas.Height = adorner_.BorderSize.Height;
6450
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
6451

    
6452
            BitmapEncoder encoder = new PngBitmapEncoder();
6453

    
6454

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

    
6457
            DrawingVisual dv = new DrawingVisual();
6458

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

    
6462
            using (DrawingContext ctx = dv.RenderOpen())
6463
            {
6464
                VisualBrush vb = new VisualBrush(_canvas);
6465
                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)));
6466
            }
6467

    
6468
            try
6469
            {
6470
                renderBitmap.Render(dv);
6471

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

    
6482
            }
6483
            catch //(Exception ex)
6484
            {
6485
                return null;
6486
            }
6487

    
6488
        }
6489

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

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

    
6510
        #region 캡쳐 기능
6511

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

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

    
6535
            byte[] pixels = CopyPixels(x, y, width, height);
6536

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

    
6539
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6540
        }
6541

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

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

    
6550
            return pixels;
6551
        }
6552

    
6553
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6554
        {
6555
            DrawingVisual drawingVisual = new DrawingVisual();
6556
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6557

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

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

    
6568
            target.Render(drawingVisual);
6569
            return target;
6570
        }
6571

    
6572
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6573
        {
6574
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6575
            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);
6576
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6577
            bmp.UnlockBits(data);
6578
            return bmp;
6579
        }
6580
        public string symbolname = null;
6581
        public bool symbolsvg = true;
6582
        public bool symbolpng = true;
6583

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

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

    
6600
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6601

    
6602
            RadWindow CheckPop = new RadWindow();
6603
            //Alert check = new Alert(Msg);
6604

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

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

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

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

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

    
6688
        }
6689

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

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

    
6706
        TempFile temp = new TempFile();
6707
        //MarkupInfoItem
6708
        public void CreateControl()
6709
        {
6710

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

    
6718
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6719

    
6720
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6721
        }
6722

    
6723
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6724
        {
6725
            multi_Undo_Data = new Multi_Undo_data();
6726

    
6727
            multi_Undo_Data.Markup = control;
6728

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

    
6746
            return multi_Undo_Data;
6747
        }
6748

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

    
6759
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6760
            if (undo == null)
6761
                return;
6762

    
6763

    
6764

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

    
6787
                        foreach (var item in undo.Markup_List)
6788
                        {
6789
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6790

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

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

    
6819
                        foreach (var item in undo.Markup_List)
6820
                        {
6821
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6822

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

    
6840
                            comment.Add(item.Markup);
6841
                        }
6842

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

    
6851
                        foreach (var item in undo.Markup_List)
6852
                        {
6853
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6854

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

    
6888

    
6889

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

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

    
6926
                        foreach (var item in redo.Markup_List)
6927
                        {
6928
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6929

    
6930
                            if ((item.Markup as IViewBox) != null)
6931
                            {
6932
                                (item.Markup as IViewBox).Angle = item.Angle;
6933
                            }
6934
                            if ((item.Markup as TextControl) != null)
6935
                            {
6936
                                (item.Markup as TextControl).Angle = item.Angle;
6937

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

    
6957
                        foreach (var item in redo.Markup_List)
6958
                        {
6959
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6960

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

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

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

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

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

    
7075
                    removingStroke.Add(stroke);
7076

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

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

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

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

    
7133
            double dx = EndP.X - StartP.X;
7134
            double dy = EndP.Y - StartP.Y;
7135
            double length;
7136

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

    
7155
            return Return_Point;
7156
        }
7157

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

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

    
7180
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
7181
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
7182

    
7183
            return res;
7184
        }
7185

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

    
7202
            return false;
7203
        }
7204

    
7205
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
7206
        {
7207
            e.Effects = DragDropEffects.Copy;
7208
        }
7209

    
7210
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
7211
        {
7212
            e.Effects = DragDropEffects.Copy;
7213
        }
7214

    
7215
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
7216
        {
7217
            e.Effects = DragDropEffects.None;
7218
        }
7219

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

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

    
7245
                    string[] delimiterChars = { "|DZ|" };
7246
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
7247

    
7248
                    this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
7249

    
7250
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
7251

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

    
7261
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
7262
                    {
7263
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
7264
                    });
7265

    
7266
                    foreach (string parse in data)
7267
                    {
7268
                        if (parse != "")
7269
                        {
7270
                            System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
7271
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
7272

    
7273
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
7274
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
7275

    
7276
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
7277

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

    
7280
                            UndoData.Markup_List.Add(multi_Undo_Data);
7281
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
7282
                        }
7283
                    }
7284
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
7285

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

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

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