프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
180
                }
181
            }
182
        }
183

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

    
208
        public bool IsSyncPDFMode { get; set; }
209

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

    
234
        #endregion
235

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

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

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

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

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

    
269
            return false;
270
        }
271

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

    
295
            return false;
296
        }
297

    
298

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

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

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

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

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

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

    
358
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
359
        {
360
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
361
            this.ReleaseAdorner();
362

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

    
366
            DeleteItem(item);
367
        }
368

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

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

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

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

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

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

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

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

    
432
                    EmptyControlCheck();
433

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

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

    
492
                        TempFile.WriteTemp(tempDtList);
493
                        tempDtList.Clear();
494
                    }
495
                }
496
            }));
497

    
498
        }
499

    
500

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

    
511
        List<TempLoadData> tempLoadData = new List<TempLoadData>();
512
        //public string FilePath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\" + ;
513
        public static string PathString = System.IO.Path.GetTempPath() + "\\MARKUS\\" + 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
                    TempFile.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 = layerControl.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
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
904
                    });
905

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

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

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

    
925

    
926
                foreach (var item in gridSelectionRevItem)
927
                {
928
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
929
                    {
930
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
931
                    });
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 = layerControl.TempMarkupParseEx(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 = layerControl.TempMarkupParseEx(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
                                        GetUserSign getUser = new GetUserSign();
2608
                                        var _sign = getUser.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2609
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2610
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2611
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2612
                                        stream.Position = 0;
2613
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2614
                                        BitmapImage returnImage = new BitmapImage();
2615
                                        returnImage.BeginInit();
2616
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2617
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2618
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2619
                                        returnImage.StreamSource = ms;
2620
                                        returnImage.EndInit();
2621
                                        stream.Close();
2622

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

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

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

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

    
2675
                                if (control != null)
2676
                                {
2677

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

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

    
2685

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

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

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

    
2698
                                        //control.ApplyTemplate();
2699

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

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

    
2711

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

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

    
2739

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

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

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

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

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

    
2784
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2785
                    }
2786

    
2787
                    e.Handled = true;
2788
                }
2789

    
2790

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

    
2813

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

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

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

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

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

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

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

    
2876
                //}
2877

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

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

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

    
2903
                #endregion
2904
            }
2905
        }
2906

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

    
2915
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2916

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

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

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

    
2930
        private EllipseGeometry hitArea = new EllipseGeometry();
2931

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

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

    
2942
                    SetCursor();
2943

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

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

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

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

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

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

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

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

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

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

    
3032
                zoomAndPanControl.ReleaseMouseCapture();
3033

    
3034

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

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

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

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

    
3060
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
3061

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

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

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

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

    
3103
            //GC.Collect();
3104

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

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

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

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

    
3131
        }
3132

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

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

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

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

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

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

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

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

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

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

    
3206
            dragSelectionBorder.Visibility = Visibility.Collapsed;
3207

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3349
                }
3350
            }
3351
            return result;
3352
        }
3353

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

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

    
3387
            zoomAndPanControl.RotationAngle = rotate.Angle;
3388

    
3389

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

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

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

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

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

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

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

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

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

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

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

    
3512
            InkControl_Convert();
3513

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3888
                                    CreateControl();
3889

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

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

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

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

    
3936
                                    CreateControl();
3937

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

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

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

    
3971
                                    CreateControl();
3972

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

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

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

    
4006
                                    CreateControl();
4007

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

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

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

    
4044
                                        CreateControl();
4045

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

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

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

    
4084
                                        CreateControl();
4085

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

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

    
4121
                                        CreateControl();
4122

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

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

    
4163
                                            CreateControl();
4164

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

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

    
4200
                                        CreateControl();
4201

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

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

    
4237
                                        CreateControl();
4238

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

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

    
4274
                                        CreateControl();
4275

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

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

    
4311
                                        CreateControl();
4312

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

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

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

    
4382
                                    CreateControl();
4383

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

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

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

    
4442
                                        CreateControl();
4443

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

    
4487
                                    CreateControl();
4488

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

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

    
4547
                                            CreateControl();
4548

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

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

    
4593
                                    CreateControl();
4594

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4774
                                    CreateControl();
4775

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

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

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

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

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

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

    
4856
                                    CreateControl();
4857

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5168
                                    control.SetPolyPath();
5169

    
5170
                                    control.ApplyOverViewData();
5171

    
5172
                                    CreateControl();
5173

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5359
                                        CreateControl();
5360
                                        currentControl = null;
5361
                                   
5362

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

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

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

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

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

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

    
5459

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

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

    
5477
            }
5478
        }
5479

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

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

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

    
5503
            stroke.DrawingAttributes.Color = Colors.Red;
5504
            stroke.DrawingAttributes.Width = 4;
5505
            stroke.DrawingAttributes.Height = 4;
5506

    
5507
            inkBoard.Strokes.Add(stroke);
5508

    
5509
        }
5510

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

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

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

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

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

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

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

    
5582
            }
5583
        }
5584

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

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

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

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

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

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

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

    
5657
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5658
        {
5659
            ChangeCommentReact();
5660

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

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

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

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

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

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

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

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

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

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

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

    
5764
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5765
        {
5766

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

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

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

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

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

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

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

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

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

    
5845
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5846
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5847
                        }
5848

    
5849
                    }
5850
                    else
5851
                    {
5852
                        string uri = "";
5853

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

    
5863
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5864

    
5865
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5866
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5867
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5868

    
5869
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5870
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5871

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

    
5880
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5881
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5882
                            };
5883
                        }
5884
                    }
5885

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

    
5890
                    foreach (var item in gridSelectionRevItem)
5891
                    {
5892
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5893
                        {
5894
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5895
                        });
5896
                    }
5897

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

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

    
5909
                }
5910
            }
5911
        }
5912

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

    
5919
                var uri = CurrentRev.TO_VENDOR;
5920

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

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

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

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

    
5964
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5965

    
5966
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5967
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5968
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5969

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

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

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

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

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

    
6013
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6014

    
6015
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6016

    
6017
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6018
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6019
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6020

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

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

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

    
6043
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
6044
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
6045
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
6046

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

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

    
6059
        public void Sync_Event(VPRevision Currnet_Rev)
6060
        {
6061
            CurrentRev = Currnet_Rev;
6062

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

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

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

    
6082
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6083

    
6084
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6085

    
6086
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6087
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6088
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6089

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

    
6100

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

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

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

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

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

    
6140
        private void Create_Symbol(object sender, RoutedEventArgs e)
6141
        {
6142
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
6143
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
6144

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

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

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

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

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

    
6230
                                    System.Drawing.Bitmap image;
6231

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

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

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

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

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

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

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

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

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

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

    
6380
                List<SYMBOL_PUBLIC> symbol_Public;
6381

    
6382

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

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

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

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

    
6446
        public PngBitmapEncoder symImage(string data)
6447
        {
6448

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

    
6455
            BitmapEncoder encoder = new PngBitmapEncoder();
6456

    
6457

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

    
6460
            DrawingVisual dv = new DrawingVisual();
6461

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

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

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

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

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

    
6491
        }
6492

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

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

    
6513
        #region 캡쳐 기능
6514

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

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

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

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

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

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

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

    
6553
            return pixels;
6554
        }
6555

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

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

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

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

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

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

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

    
6603
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6604

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

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

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

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

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

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

    
6691
        }
6692

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

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

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

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

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

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

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

    
6730
            multi_Undo_Data.Markup = control;
6731

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

    
6749
            return multi_Undo_Data;
6750
        }
6751

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

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

    
6766

    
6767

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

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

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

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

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

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

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

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

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

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

    
6891

    
6892

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

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

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

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

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

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

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

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

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

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

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

    
7077
                    removingStroke.Add(stroke);
7078

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

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

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

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

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

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

    
7157
            return Return_Point;
7158
        }
7159

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

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

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

    
7185
            return res;
7186
        }
7187

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

    
7204
            return false;
7205
        }
7206

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

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

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

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

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

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

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

    
7252
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
7253

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

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

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

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

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

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

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

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

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

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