프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 122914ba

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

1

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

    
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
                temp.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.Invoke(DispatcherPriority.Normal, 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
                        temp.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\\" + App.ViewInfo.DocumentItemID + ".tmp";
513

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

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

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

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

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

    
590
                                ViewerDataModel.Instance.MarkupControls_USER.Add(InnerItem.DrawingData as CommentUserInfo);
591
                            }
592
                        }
593
                    }
594
                }
595
                SelectLayer.Children.Clear();
596
            }
597
        }
598

    
599
        public List<CommentUserInfo> AddAdorner()
600
        {
601
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
602

    
603
            if (SelectLayer.Children.Count > 0)
604
            {
605
                foreach (var item in SelectLayer.Children)
606
                {
607
                    if (item.GetType().Name == "AdornerFinal")
608
                    {
609
                        (item as AdornerFinal).unRegister();
610

    
611
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
612
                        {
613
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
614
                            {
615
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
616
                            }
617

    
618
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
619

    
620
                            UndoData.Markup_List.Add(multi_Undo_Data);
621
                            multi_Undo_Data = new Multi_Undo_data();
622
                        }
623
                    }
624
                }
625
                SelectLayer.Children.Clear();
626
            }
627
            return adornerSet;
628
        }
629

    
630
        public void ChangeCommentReact()
631
        {
632
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
633
            bool isComingNewBie = false;
634

    
635
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
636
            {
637
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
638
                {
639
                    var root = layerControl.MarkupToString(control, App.ViewInfo.UserID);
640
                   
641
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
642
                    if (existItem != null) //신규 추가 된 코멘트
643
                    {
644
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
645
                        {
646
                            existItem.Data = root.ConvertData;
647
                            existItem.IsUpdate = true;
648
                            ComingNewBieEnd = false;
649
                        }
650
                    }
651
                    else
652
                    {
653
                        if (root.CommentID != null)
654
                        {
655
                            isComingNewBie = true;
656
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
657
                            if (currentCommentCheck != null)
658
                            {
659
                                currentCommentCheck.Data = root.ConvertData;
660
                            }
661
                            else
662
                            {
663
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
664
                                {
665
                                    ID = control.CommentID,
666
                                    Data = root.ConvertData,
667
                                    Data_Type = root.DATA_TYPE,
668
                                    MarkupInfoID = App.Custom_ViewInfoId,
669
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
670
                                    Symbol_ID = control.SymbolID,
671
                                    Group_ID = control.GroupID,
672
                                });
673
                                ComingNewBieEnd = false;
674
                            }
675
                        }
676
                    }                    
677
                }
678
            }
679

    
680

    
681
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
682
            {
683
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
684
                {
685
                    ComingNewBieEnd = true;
686
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
687
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
688
                    gridViewMarkup.ItemsSource = null;
689
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
690
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
691
                }
692
            }
693

    
694
        }
695

    
696
        MarkupToPDF.Controls.Parsing.LayerControl layerControl = new MarkupToPDF.Controls.Parsing.LayerControl();
697
        bool ComingNewBieEnd = false;
698

    
699
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
700
        {
701
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
702
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
703
            {
704
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
705
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
706
            }
707
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
708
            ViewerDataModel.Instance.UndoDataList.Clear();
709
            
710
            InkControl_Convert();
711

    
712
            ReleaseAdorner();
713
            ChangeCommentReact();
714

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

    
719

    
720
            #region 페이지가 벗어난 경우
721

    
722
            if (BalancePoint < 1)
723
            {
724
                BalancePoint = 1;
725
                ViewerDataModel.Instance.PageBalanceNumber = 0;
726
            }
727

    
728
            if (pageNavigator.PageCount < BalancePoint)
729
            {
730
                BalancePoint = pageNavigator.PageCount;
731
                ViewerDataModel.Instance.PageBalanceNumber = 0;
732
            }
733

    
734
            #endregion
735

    
736
            ViewerDataModel.Instance.PageNumber = BalancePoint;
737

    
738
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
739
            string uri = "";
740
            if (userData.COMPANY != "EXT")
741
            {
742
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
743
            }
744
            else
745
            {
746
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
747
            }
748

    
749
            var defaultBitmapImage = new BitmapImage();
750
            defaultBitmapImage.BeginInit();
751
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
752
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
753
            defaultBitmapImage.UriSource = new Uri(uri);
754
            defaultBitmapImage.EndInit();
755

    
756
            ViewerDataModel.Instance.ImageViewPath = null;
757
            Logger.sendCheckLog("pageNavigator_PageChanging_GC.Collect()", 1);
758
            GC.Collect();
759

    
760

    
761
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
762
            if (defaultBitmapImage.IsDownloading)
763
            {
764
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
765
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
766
                {
767
                    Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage DownloadCompleted_Start", 1);
768
                    defaultBitmapImage.Freeze();
769
                    mainPanel.UpdateLayout();
770
                    GC.Collect();                    
771
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
772
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
773
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
774
                    Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage DownloadCompleted_End", 1);
775
                };
776
            }
777

    
778
            Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas Page Setting", 1);
779
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
780
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
781

    
782

    
783
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
784
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
785
            inkBoard.Width = zoomAndPanCanvas.Width;
786
            inkBoard.Height = zoomAndPanCanvas.Height;
787

    
788
           
789

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

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

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

    
836
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
837
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
838

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

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

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

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

    
881
            this.pageNavigator.SetNextPage();
882

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

    
891
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
892
 
893
            foreach (var item in gridSelectionItem)
894
            {
895
                if (item.UserID == App.ViewInfo.UserID)
896
                {
897
                    ViewerDataModel.Instance.current_page_commentcnt = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
898
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
899
                    {
900
                        layerControl.markupParseEx(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", item.MarkupInfoID, markupitem.ID);
901
                    });
902
                    
903
                }
904
                else
905
                {
906
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
907
                    {
908
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
909
                    });
910
                }
911
            }
912
            
913
            if (!testPanel2.IsHidden)
914
            {
915
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
916
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
917
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
918

    
919
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
920
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
921

    
922

    
923
                foreach (var item in gridSelectionRevItem)
924
                {
925
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
926
                    {
927
                        layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
928
                    });
929
                }
930

    
931
            }
932

    
933
            var instanceMain = this.ParentOfType<MainWindow>();
934
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
935
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
936

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

    
941
            //}
942
            SetCommentPages(true);
943
        }
944
        
945

    
946
        //Temp Control Load
947
        public void TempControlLoad()
948
        {
949
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
950

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

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

    
968
                        //Control                   
969
                        item = layerControl.TempMarkupParseEx(tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
970
                                               
971
                        UndoData = new Undo_data()
972
                        {
973
                            IsUndo = false,
974
                            Event = Event_Type.Create,
975
                            EventTime = DateTime.Now,
976
                            Opacity = ViewerDataModel.Instance.ControlOpacity,
977
                            Markup_List = new List<Multi_Undo_data>()
978
                        };
979

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

    
994
                        //Control                   
995
                        item = layerControl.TempMarkupParseEx(tempLoadData[k].ConvertData, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", tempLoadData[k].MarkupInfoID, tempLoadData[k].CommentID);
996

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

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

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

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

    
1051
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1052
        {
1053
            if (e.MiddleButton == MouseButtonState.Pressed)
1054
            {
1055

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

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

    
1085
        #region ZoomIn & ZoomOut
1086

    
1087
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1088
        {
1089
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1090
                zoomAndPanControl.ContentZoomFocusY));
1091
        }
1092

    
1093
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1094
        {
1095
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1096
                zoomAndPanControl.ContentZoomFocusY));
1097
        }
1098

    
1099

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

    
1113
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1114
            {
1115
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1116
            }
1117
        }
1118

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

    
1130
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1131
            {
1132
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1133
            }
1134

    
1135
        }
1136

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

    
1148
            if (Sync.IsChecked)
1149
            {
1150
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1151
            }
1152
        }
1153

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

    
1165
            if (Sync.IsChecked)
1166
            {
1167
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1168
            }
1169
        }
1170

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

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

    
1189
        #endregion
1190

    
1191
        private void init()
1192
        {
1193
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1194
            {
1195

    
1196
                ControlList.Clear();
1197
                listBox.Items.Clear();
1198
                selected_item.Clear();
1199

    
1200
                (item as IMarkupCommonData).IsSelected = false;
1201
            }
1202

    
1203
        }
1204

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

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

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

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

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

    
1361
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1362
        {
1363
            //Control_Init(e.Source);
1364
        }
1365
        private Window _dragdropWindow = null;
1366
        private bool symbolMouse = false;
1367

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

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

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

    
1397
      
1398
            CreateDragDropWindow2(img);
1399
        }
1400

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

    
1421
            Win32Point w32Mouse = new Win32Point();
1422
            GetCursorPos(ref w32Mouse);
1423

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

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

    
1436
                Point currentPos = e.GetPosition(rect);
1437

    
1438
                floatingTip.HorizontalOffset = currentPos.X + 20;
1439
                floatingTip.VerticalOffset = currentPos.Y;
1440

    
1441

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

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

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

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

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

    
1521
                //        default:
1522
                //            {
1523

    
1524
                //            }
1525
                //            break;
1526
                //    }
1527
                //} 
1528
                #endregion
1529
            }
1530

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

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

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

    
1547
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1548

    
1549
            //    //zoomAndPanControl.ContentOffsetX += 1;
1550
            //    //zoomAndPanControl.ContentOffsetY += 1;
1551

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

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

    
1563
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1564
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1565
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1566

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

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

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

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

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

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

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

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

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

    
1687

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

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

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

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

    
1731

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

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

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

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

    
1775

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

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

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

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

    
1819

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

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

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

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

    
1863

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

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

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

    
1890
                        case ControlType.RectCloud:
1891
                            {
1892
                                var control = currentControl as RectCloudControl;
1893

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

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

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

    
1924
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1925
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1926
                                }
1927
                            }
1928
                            break;
1929

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

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

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

    
1958
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1959
                                }
1960

    
1961
                            }
1962
                            break;
1963

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

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

    
1987

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

    
1996

    
1997
                            }
1998
                            break;
1999

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

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

    
2022

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

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

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

    
2055

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

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

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

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

    
2098
                        case ControlType.ChainLine:
2099
                            {
2100
                                var control = currentControl as PolygonControl;
2101

    
2102
                                if (control != null)
2103
                                {
2104

    
2105
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2106
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2107

    
2108
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
2109

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

    
2122
                                    control.SetPolyPath();
2123

    
2124
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2125
                                }
2126
                            }
2127
                            break;
2128

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

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

    
2151

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

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

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

    
2185

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

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

    
2230
                                    }
2231

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

    
2243
                        case ControlType.Circle:
2244
                            {
2245
                                var control = currentControl as CircleControl;
2246

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

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

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

    
2277
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2278
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2279

    
2280
                                }
2281
                            }
2282
                            break;
2283

    
2284
                        case ControlType.PolygonCloud:
2285
                            {
2286
                                var control = currentControl as CloudControl;
2287

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

    
2293
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2294

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

    
2303
                        case ControlType.Triangle:
2304
                            {
2305
                                var control = currentControl as TriControl;
2306

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

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

    
2325

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

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

    
2344
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2345
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2346
                                }
2347
                            }
2348
                            break;
2349

    
2350
                        case ControlType.ImgControl:
2351
                            {
2352
                                var control = currentControl as ImgControl;
2353

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

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

    
2372
                        case ControlType.Date:
2373
                            {
2374
                                var control = currentControl as DateControl;
2375

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

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

    
2395
                        case ControlType.ArrowTextControl:
2396
                            {
2397
                                var control = currentControl as ArrowTextControl;
2398

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

    
2404
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2405

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

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

    
2427
                        case ControlType.ArrowTransTextControl:
2428
                            {
2429
                                var control = currentControl as ArrowTextControl;
2430

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

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

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

    
2459
                        case ControlType.ArrowTextBorderControl:
2460
                            {
2461
                                var control = currentControl as ArrowTextControl;
2462

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

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

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

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

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

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

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

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

    
2572
                            }
2573
                            break;
2574
                        case ControlType.PolygonControl:
2575
                            {
2576

    
2577
                                var control = currentControl as PolygonControl;
2578

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

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

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

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

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

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

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

    
2673
                                if (control != null)
2674
                                {
2675

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

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

    
2683

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

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

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

    
2696
                                        //control.ApplyTemplate();
2697

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

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

    
2709

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

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

    
2737

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

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

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

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

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

    
2782
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2783
                    }
2784

    
2785
                    e.Handled = true;
2786
                }
2787

    
2788

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

    
2811

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

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

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

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

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

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

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

    
2874
                //}
2875

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

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

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

    
2901
                #endregion
2902
            }
2903
        }
2904

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

    
2913
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2914

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

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

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

    
2928
        private EllipseGeometry hitArea = new EllipseGeometry();
2929

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

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

    
2940
                    SetCursor();
2941

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

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

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

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

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

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

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

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

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

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

    
3030
                zoomAndPanControl.ReleaseMouseCapture();
3031

    
3032

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

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

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

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

    
3058
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
3059

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

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

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

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

    
3101
            GC.Collect();
3102

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

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

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

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

    
3129
        }
3130

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

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

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

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

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

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

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

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

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

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

    
3204
            dragSelectionBorder.Visibility = Visibility.Collapsed;
3205

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3347
                }
3348
            }
3349
            return result;
3350
        }
3351

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

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

    
3385
            zoomAndPanControl.RotationAngle = rotate.Angle;
3386

    
3387

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

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

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

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

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

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

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

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

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

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

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

    
3510
            InkControl_Convert();
3511

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3886
                                    CreateControl();
3887

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

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

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

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

    
3934
                                    CreateControl();
3935

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

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

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

    
3969
                                    CreateControl();
3970

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

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

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

    
4004
                                    CreateControl();
4005

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

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

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

    
4042
                                        CreateControl();
4043

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

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

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

    
4082
                                        CreateControl();
4083

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

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

    
4119
                                        CreateControl();
4120

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

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

    
4161
                                            CreateControl();
4162

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

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

    
4198
                                        CreateControl();
4199

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

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

    
4235
                                        CreateControl();
4236

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

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

    
4272
                                        CreateControl();
4273

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

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

    
4309
                                        CreateControl();
4310

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

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

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

    
4380
                                    CreateControl();
4381

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

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

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

    
4440
                                        CreateControl();
4441

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

    
4485
                                    CreateControl();
4486

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

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

    
4545
                                            CreateControl();
4546

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

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

    
4591
                                    CreateControl();
4592

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

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

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

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

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

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

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

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

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

    
4712
                                        CreateControl();
4713
                                        (currentControl as DateControl).ApplyOverViewData();
4714
                                        currentControl = null;
4715

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

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

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

    
4770
                                    CreateControl();
4771

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

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

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

    
4818
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4819
                                    currentControl.CommentID = Save.shortGuid();
4820
                                    currentControl.IsNew = true;
4821
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4822
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4823

    
4824
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4825
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4826
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4827
                                    currentControl.Focus();
4828

    
4829
                                    (currentControl as TextControl).Angle = Ang;
4830
                                    (currentControl as TextControl).ControlType_No = 2;
4831
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4832

    
4833
                                    CreateControl();
4834
                                    //currentControl = null;
4835
                                }
4836
                            }
4837
                        }
4838
                        break;
4839
                    case ControlType.ArrowTextControl:
4840
                         {
4841
                            if (mouseButtonDown == MouseButton.Left)
4842
                            {
4843
                                if (currentControl is ArrowTextControl)
4844
                                {
4845
                                    //20180906 LJY TEST IsRotationDrawingEnable
4846
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4847
                                    {
4848
                                        return;
4849
                                    }                                    
4850

    
4851
                                    CreateControl();
4852

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

    
4869
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4870
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4871
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4872
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4873
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4874

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

    
4878
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4879
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4880
                                        this.MainAngle.Visibility = Visibility.Visible;
4881

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

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

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

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

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

    
4963
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4964

    
4965
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4966

    
4967
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4968
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4969
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4970

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

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

    
5013
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5014

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

    
5025
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
5026
                                        this.MainAngle.Visibility = Visibility.Visible;
5027
                                    
5028
                                    //20180911 LJY
5029
                                        (currentControl as ArrowTextControl).isTrans = true;
5030
                                    
5031

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

    
5067
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
5068
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5069
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
5070
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5071
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5072

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

    
5115
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
5116
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
5117
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
5118
                                        (currentControl as ArrowTextControl).isFixed = true;
5119
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
5120

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

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

    
5141
                                if (mouseButtonDown == MouseButton.Right)
5142
                                {
5143
                                    control.IsCompleted = true;
5144
                                }
5145

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

    
5158
                                    var firstPoint = control.PointSet.First();
5159
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
5160
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
5161
                                    control.PointSet.Add(firstPoint);
5162

    
5163
                                    control.SetPolyPath();
5164

    
5165
                                    control.ApplyOverViewData();
5166

    
5167
                                    CreateControl();
5168

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

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

    
5207
                                    if (_sign == null)
5208
                                    {
5209
                                        txtBatch.Visibility = Visibility.Collapsed;
5210
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
5211
                                        controlType = ControlType.None;
5212

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

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

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

    
5245
                                        currentControl.CommentID = Save.shortGuid();
5246
                                        currentControl.IsNew = true;
5247
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5248
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5249

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

    
5271
                                        CreateControl();
5272
                                        (currentControl as RectangleControl).ApplyOverViewData();
5273
                                        currentControl = null;
5274
                                    
5275
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5276

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

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

    
5328
                                        currentControl.IsNew = true;
5329
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5330
                                        currentControl.CommentID = Save.shortGuid();
5331
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5332

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

    
5354
                                        CreateControl();
5355
                                        currentControl = null;
5356
                                   
5357

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

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

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

    
5425
                    if (!mouseOff)
5426
                    {
5427
                        ReleaseAdorner();
5428
                    }
5429
                }
5430
                zoomAndPanControl.CaptureMouse();
5431
                e.Handled = true;
5432
            }
5433
        }
5434

    
5435
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5436
        {
5437
            mouseButtonDown = e.ChangedButton;
5438
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5439
        }
5440

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

    
5454

    
5455
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5456
                UndoData.Markup_List.Add(multi_Undo_Data);
5457
                multi_Undo_Data = new Multi_Undo_data();
5458

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

    
5472
            }
5473
        }
5474

    
5475
        private void RemovePointStroke(Point P)
5476
        {
5477
            foreach (Stroke hits in inkBoard.Strokes)
5478
            {
5479
                foreach (StylusPoint sty in hits.StylusPoints)
5480
                {
5481

    
5482
                }
5483
                if (hits.HitTest(P))
5484
                {
5485
                    inkBoard.Strokes.Remove(hits);
5486
                    return;
5487
                }
5488
            }
5489
        }
5490

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

    
5498
            stroke.DrawingAttributes.Color = Colors.Red;
5499
            stroke.DrawingAttributes.Width = 4;
5500
            stroke.DrawingAttributes.Height = 4;
5501

    
5502
            inkBoard.Strokes.Add(stroke);
5503

    
5504
        }
5505

    
5506
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5507
        {
5508
            ConsolidationMethod();
5509
        }
5510

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

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

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

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

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

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

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

    
5592
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5593
        {
5594
            TeamConsolidationMethod();
5595
        }
5596

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

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

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

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

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

    
5652
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5653
        {
5654
            ChangeCommentReact();
5655

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

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

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

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

    
5694
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5695
        {            
5696
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5697

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

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

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

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

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

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

    
5759
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5760
        {
5761

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

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

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

    
5794
                if (ViewerDataModel.Instance.PageNumber == 0)
5795
                {
5796
                    ViewerDataModel.Instance.PageNumber = 1;
5797
                }
5798

    
5799
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5800
                {
5801
                }
5802
                else
5803
                {
5804
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5805
                }
5806

    
5807
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5808
                {
5809

    
5810
                }
5811
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5812
                {
5813
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5814
                }
5815

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

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

    
5840
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5841
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5842
                        }
5843

    
5844
                    }
5845
                    else
5846
                    {
5847
                        string uri = "";
5848

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

    
5858
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5859

    
5860
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5861
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5862
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5863

    
5864
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5865
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5866

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

    
5875
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5876
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5877
                            };
5878
                        }
5879
                    }
5880

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

    
5885
                    foreach (var item in gridSelectionRevItem)
5886
                    {
5887
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5888
                        {
5889
                            layerControl.markupParse(markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5890
                        });
5891
                    }
5892

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

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

    
5904
                }
5905
            }
5906
        }
5907

    
5908
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5909
        {
5910
            if (MarkupMode.IsChecked)
5911
            {
5912
                IsSyncPDFMode = true;
5913

    
5914
                var uri = CurrentRev.TO_VENDOR;
5915

    
5916
                if (ViewerDataModel.Instance.PageNumber == 0)
5917
                {
5918
                    ViewerDataModel.Instance.PageNumber = 1;
5919
                }
5920

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

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

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

    
5959
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5960

    
5961
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5962
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5963
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5964

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

    
5981
        private void RadButton_Click(object sender, RoutedEventArgs e)
5982
        {
5983
            gridViewHistory_Busy.IsBusy = true;
5984

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

    
5995
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5996
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5997

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

    
6008
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6009

    
6010
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6011

    
6012
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6013
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6014
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6015

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

    
6026
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
6027
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
6028
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
6029
                        zoomAndPanControl2.ApplyTemplate();
6030
                        zoomAndPanControl2.UpdateLayout();
6031

    
6032
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
6033
                        {
6034
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
6035
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
6036
                        }
6037

    
6038
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
6039
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
6040
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
6041

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

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

    
6054
        public void Sync_Event(VPRevision Currnet_Rev)
6055
        {
6056
            CurrentRev = Currnet_Rev;
6057

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

    
6064
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
6065
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
6066

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

    
6077
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
6078

    
6079
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
6080

    
6081
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6082
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6083
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6084

    
6085
                    if (defaultBitmapImage_Compare.IsDownloading)
6086
                    {
6087
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
6088
                        {
6089
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
6090
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
6091
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
6092
                        };
6093
                    }
6094
                    
6095
                    
6096
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
6097
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
6098
                    zoomAndPanControl2.ApplyTemplate();
6099
                    zoomAndPanControl2.UpdateLayout();
6100

    
6101
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
6102
                    {
6103
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
6104
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
6105
                    }
6106
                    //}
6107

    
6108
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
6109
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
6110
                    gridViewHistory_Busy.IsBusy = false;                    
6111
                }
6112
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
6113
                
6114
            };
6115
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
6116
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);           
6117
        }
6118

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

    
6135
        private void Create_Symbol(object sender, RoutedEventArgs e)
6136
        {
6137
            MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.LayerControl.MarkupReturn();
6138
            MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
6139

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

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

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

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

    
6212

    
6213

    
6214
                            if (symbolsvg == true)
6215
                            {
6216
                                //Common.Converter.SvgConverter svgConverter = new Common.Converter.SvgConverter();
6217
                                var defaultBitmapImage = new BitmapImage();
6218
                                defaultBitmapImage.BeginInit();
6219
                                defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
6220
                                defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
6221
                                defaultBitmapImage.UriSource = new Uri(filename);
6222
                                defaultBitmapImage.EndInit();
6223

    
6224
                                GC.Collect();
6225
                                System.Drawing.Bitmap image;
6226

    
6227
                                if (defaultBitmapImage.IsDownloading)
6228
                                {
6229
                                    defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
6230
                                    {
6231
                                        defaultBitmapImage.Freeze();
6232
                                        GC.Collect();
6233

    
6234
                                        image = GetBitmap(defaultBitmapImage);
6235

    
6236
                                        image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
6237

    
6238
                                        Process potrace = new Process
6239
                                        {
6240
                                            StartInfo = new ProcessStartInfo
6241
                                            {
6242
                                                //FileName = @"http://cloud.devdoftech.co.kr:5977/UserData/"+ "potrace.exe",
6243
                                                FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
6244
                                                //Arguments = "-s -u 1", //SVG
6245
                                                //Arguments = "- -o- --svg",
6246
                                                //Arguments = filename2 + "  --backend svg",
6247
                                                //Arguments = @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp" + "  --backend svg -i",
6248
                                                //Arguments = "-b svg -i " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
6249
                                                Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
6250
                                                RedirectStandardInput = true,
6251
                                                RedirectStandardOutput = true,
6252
                                                //RedirectStandardError = Program.IsDebug,
6253
                                                RedirectStandardError = true,
6254
                                                UseShellExecute = false,
6255
                                                CreateNoWindow = true,
6256
                                                WindowStyle = ProcessWindowStyle.Hidden
6257
                                            },
6258
                                            //EnableRaisingEvents = false
6259
                                        };
6260

    
6261
                                        StringBuilder svgBuilder = new StringBuilder();
6262
                                        potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) => {
6263
                                            svgBuilder.AppendLine(e2.Data);
6264
                                        };
6265

    
6266

    
6267
                                        //potrace.WaitForExit();
6268

    
6269
                                        potrace.EnableRaisingEvents = true;
6270
                                        potrace.Start();
6271
                                        potrace.Exited += (sender, e) => {
6272
                                            byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
6273
                                            //kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6274
                                            svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
6275
                                            if (symbolselectindex == 0)
6276
                                            {
6277
                                                SymbolSave(symbolname, svgfilename, data);
6278
                                            }
6279
                                            else
6280
                                            {
6281
                                                SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6282
                                            }
6283

    
6284
                                            DataBind();
6285
                                        };
6286
                                        potrace.WaitForExit();
6287
                                        //potrace.WaitForExit();
6288
                                    };
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
            Save save = new Save();
6411
            if (args.PromptResult != null)
6412
            {
6413
                if (args.DialogResult.Value)
6414
                {
6415
                    PngBitmapEncoder _Encoder = symImage(data);
6416

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

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

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

    
6426
                    if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6427
                    {
6428
                        save.SymbolSave(args.PromptResult, filename, data);
6429
                    }
6430
                    else
6431
                    {
6432
                        save.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6433
                    }
6434
                    DataBind();
6435
                }
6436
            }
6437
        }
6438

    
6439
        public PngBitmapEncoder symImage(string data)
6440
        {
6441

    
6442
            Canvas _canvas = new Canvas();
6443
            _canvas.Background = Brushes.White;
6444
            _canvas.Width = adorner_.BorderSize.Width;
6445
            _canvas.Height = adorner_.BorderSize.Height;
6446
            layerControl.markupParse(data, _canvas, "#FFFF0000", "");
6447

    
6448
            BitmapEncoder encoder = new PngBitmapEncoder();
6449

    
6450

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

    
6453
            DrawingVisual dv = new DrawingVisual();
6454

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

    
6458
            using (DrawingContext ctx = dv.RenderOpen())
6459
            {
6460
                VisualBrush vb = new VisualBrush(_canvas);
6461
                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)));
6462
            }
6463

    
6464
            try
6465
            {
6466
                renderBitmap.Render(dv);
6467

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

    
6478
            }
6479
            catch //(Exception ex)
6480
            {
6481
                return null;
6482
            }
6483

    
6484
        }
6485

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

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

    
6506
        #region 캡쳐 기능
6507

    
6508
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6509
        {
6510
            if (x < 0)
6511
            {
6512
                width += x;
6513
                x = 0;
6514
            }
6515
            if (y < 0)
6516
            {
6517
                height += y;
6518
                y = 0;
6519

    
6520
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6521
            }
6522
            if (x + width > zoomAndPanCanvas.ActualWidth)
6523
            {
6524
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6525
            }
6526
            if (y + height > zoomAndPanCanvas.ActualHeight)
6527
            {
6528
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6529
            }
6530

    
6531
            byte[] pixels = CopyPixels(x, y, width, height);
6532

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

    
6535
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6536
        }
6537

    
6538
        public byte[] CopyPixels(int x, int y, int width, int height)
6539
        {
6540
            byte[] pixels = new byte[width * height * 4];
6541
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6542

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

    
6546
            return pixels;
6547
        }
6548

    
6549
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6550
        {
6551
            DrawingVisual drawingVisual = new DrawingVisual();
6552
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6553

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

    
6559
            // 비트맵으로 변환합니다.
6560
            RenderTargetBitmap target =
6561
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6562
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6563

    
6564
            target.Render(drawingVisual);
6565
            return target;
6566
        }
6567

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

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

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

    
6596
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6597

    
6598
            RadWindow CheckPop = new RadWindow();
6599
            //Alert check = new Alert(Msg);
6600

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

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

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

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

    
6686
        public void Set_Capture()
6687
        {            
6688
            double x = canvasDrawingMouseDownPoint.X;
6689
            double y = canvasDrawingMouseDownPoint.Y;
6690
            double width = dragCaptureBorder.Width;
6691
            double height = dragCaptureBorder.Height;
6692

    
6693
            if (width > 5 || height > 5)
6694
            {
6695
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6696
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6697
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6698
            }
6699
        }
6700
        #endregion
6701

    
6702
        TempFile temp = new TempFile();
6703
        //MarkupInfoItem
6704
        public void CreateControl()
6705
        {            
6706
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6707
            {
6708
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6709
            });
6710
            multi_Undo_Data.Markup = currentControl;
6711
            UndoData.Markup_List.Add(multi_Undo_Data);
6712
           
6713
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6714

    
6715
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6716
        }
6717
        
6718
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6719
        {
6720
            multi_Undo_Data = new Multi_Undo_data();
6721

    
6722
            multi_Undo_Data.Markup = control;
6723

    
6724
            if ((control as IShapeControl) != null)
6725
            {
6726
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6727
            }
6728
            if ((control as IDashControl) != null)
6729
            {
6730
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6731
            }
6732
            if ((control as IPath) != null)
6733
            {
6734
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6735
            }
6736
            if ((control as UIElement) != null)
6737
            {
6738
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6739
            }
6740

    
6741
            return multi_Undo_Data;
6742
        }
6743

    
6744
        public void Undo()
6745
        {
6746
         // if (ViewerDataModel.Instance.IsPressCtrl)
6747
         //   {
6748
         //      ViewerDataModel.Instance.IsPressCtrl = false;
6749
         //   }
6750
            Undo_data undo = new Undo_data();
6751
            AdornerFinal final;
6752
            ReleaseAdorner();
6753

    
6754
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6755
            if (undo == null)
6756
                return;
6757

    
6758
            
6759

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

    
6782
                        foreach (var item in undo.Markup_List)
6783
                        {
6784
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6785

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

    
6802
                            comment.Add(item.Markup);
6803
                        }
6804
                        final = new AdornerFinal(comment);
6805
                        SelectLayer.Children.Add(final);
6806
                        ReleaseAdorner();
6807
                    }
6808
                    break;
6809
                case (Event_Type.Select):
6810
                    {
6811
                        ReleaseAdorner();
6812
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6813

    
6814
                        foreach (var item in undo.Markup_List)
6815
                        {
6816
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6817

    
6818
                            if ((item.Markup as IPath) != null)
6819
                            {
6820
                                (item.Markup as IPath).LineSize = item.LineSize;
6821
                            }
6822
                            if ((item.Markup as UIElement) != null)
6823
                            {
6824
                                (item.Markup as UIElement).Opacity = item.Opacity;
6825
                            }
6826
                            if ((item.Markup as IDashControl) != null)
6827
                            {
6828
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6829
                            }
6830
                            if ((item.Markup as IShapeControl) != null)
6831
                            {
6832
                                (item.Markup as IShapeControl).Paint = item.paint;
6833
                            }
6834

    
6835
                            comment.Add(item.Markup);
6836
                        }
6837

    
6838
                        final = new AdornerFinal(comment);
6839
                        SelectLayer.Children.Add(final);
6840
                    }
6841
                    break;
6842
                case (Event_Type.Option):
6843
                    {
6844
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6845

    
6846
                        foreach (var item in undo.Markup_List)
6847
                        {
6848
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6849

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

    
6883

    
6884
        
6885
        public void Redo()
6886
        {
6887
            //if (ViewerDataModel.Instance.IsPressCtrl)
6888
            //{
6889
            //    ViewerDataModel.Instance.IsPressCtrl = false;
6890
            //}
6891
            AdornerFinal final;
6892
            Undo_data redo = new Undo_data();
6893
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6894
            ReleaseAdorner();
6895
            if (redo == null)
6896
                return;
6897

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

    
6921
                        foreach (var item in redo.Markup_List)
6922
                        {
6923
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6924

    
6925
                            if ((item.Markup as IViewBox) != null)
6926
                            {
6927
                                (item.Markup as IViewBox).Angle = item.Angle;
6928
                            }
6929
                            if ((item.Markup as TextControl) != null)
6930
                            {
6931
                                (item.Markup as TextControl).Angle = item.Angle;
6932

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

    
6952
                        foreach (var item in redo.Markup_List)
6953
                        {
6954
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6955

    
6956
                            if ((item.Markup as IPath) != null)
6957
                            {
6958
                                (item.Markup as IPath).LineSize = item.LineSize;
6959
                            }
6960
                            if ((item.Markup as UIElement) != null)
6961
                            {
6962
                                (item.Markup as UIElement).Opacity = item.Opacity;
6963
                            }
6964
                            if ((item.Markup as IDashControl) != null)
6965
                            {
6966
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6967
                            }
6968
                            if ((item.Markup as IShapeControl) != null)
6969
                            {
6970
                                (item.Markup as IShapeControl).Paint = item.paint;
6971
                            }
6972

    
6973
                            comment.Add(item.Markup);
6974
                        }
6975
                        final = new AdornerFinal(comment);
6976
                        SelectLayer.Children.Add(final);
6977
                    }
6978
                    break;
6979
                case (Event_Type.Option):
6980
                    {
6981
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6982

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

    
7014
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
7015
            {
7016
                i.IsUndo = false;
7017
            });
7018
        }
7019

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

    
7069
                    removingStroke.Add(stroke);
7070

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

    
7096
                        pc.StartPoint = inkPointSet[0];
7097
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
7098
                        pc.PointSet = inkPointSet;
7099
                        pc.LineSize = 3;
7100
                        pc.CommentID = Save.shortGuid();
7101
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
7102
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
7103
                        pc.SetPolyPath();
7104

    
7105
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
7106
                        {
7107
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
7108
                        });
7109
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
7110
                        UndoData.Markup_List.Add(multi_Undo_Data);
7111
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
7112
                    }
7113
                });
7114
            }
7115
        }
7116

    
7117
        /// <summary>
7118
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
7119
        /// </summary>
7120
        /// <param name="StartP">StartPoint</param>
7121
        /// <param name="EndP">EndPoint</param>
7122
        /// <returns>Return_EndPoint</returns>
7123
        private Point GetSquareEndPoint(Point StartP, Point EndP)
7124
        {
7125
            Point Return_Point = new Point();
7126

    
7127
            double dx = EndP.X - StartP.X;
7128
            double dy = EndP.Y - StartP.Y;
7129
            double length;
7130

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

    
7149
            return Return_Point;
7150
        }
7151

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

    
7165
            double dx = EndP.X - StartP.X;
7166
            double dy = EndP.Y - StartP.Y;
7167
            double length = Math.Sqrt(dx * dx + dy * dy);
7168
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
7169
            dx /= length;
7170
            dy /= length;
7171
            double tmp = dx;
7172
            dx = -dy; dy = tmp; /// rotate by 90 degree
7173

    
7174
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
7175
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
7176

    
7177
            return res;
7178
        }
7179

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

    
7196
            return false;
7197
        }
7198

    
7199
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
7200
        {
7201
            e.Effects = DragDropEffects.Copy;
7202
        }
7203

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

    
7209
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
7210
        {
7211
            e.Effects = DragDropEffects.None;
7212
        }
7213

    
7214
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
7215
        {
7216
            if (e.Data.GetDataPresent(typeof(string)))
7217
            {
7218
                this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
7219
                string dragData = e.Data.GetData(typeof(string)) as string;
7220
                Move_Symbol(sender, dragData);
7221
            }
7222
        }
7223

    
7224
        private void Move_Symbol(object sender, string dragData)
7225
        {
7226
            if (dragData.Contains("|DZ|"))
7227
            {
7228
                List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
7229

    
7230
                string[] delimiterChars = { "|DZ|" };
7231
                string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
7232

    
7233
                this.ParentOfType<MainWindow>().dzMainMenu.ReleaseAdorner();
7234

    
7235
                Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
7236

    
7237
                //강인구 Undo/Redo 보류
7238
                UndoData = new Undo_data()
7239
                {
7240
                    IsUndo = false,
7241
                    Event = Event_Type.Create,
7242
                    EventTime = DateTime.Now,
7243
                    Markup_List = new List<Multi_Undo_data>()
7244
                };
7245

    
7246
                ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
7247
                {
7248
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
7249
                });
7250

    
7251
                foreach (string parse in data)
7252
                {
7253
                    if (parse != "")
7254
                    {
7255
                        System.Windows.Controls.Control item = this.layerControl.markupParse_Paste(parse, ViewerDataModel.Instance.MarkupControls_USER);
7256
                        (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Events.Save.shortGuid();
7257

    
7258
                        ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
7259
                        ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
7260

    
7261
                        adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
7262

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

    
7265
                        UndoData.Markup_List.Add(multi_Undo_Data);
7266
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
7267
                    }
7268
                }
7269
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
7270

    
7271
                /// move symbol to current mouse point
7272
                double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
7273
                double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
7274
                final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
7275

    
7276
                if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
7277
                {
7278
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
7279
                }
7280
                /// up to here
7281

    
7282
                ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
7283
            }
7284
        }
7285

    
7286
        private void zoomAndPanControl_PreviewDrop(object sender, DragEventArgs e)
7287
        {
7288

    
7289
        }
7290

    
7291
        private void zoomAndPanControl_GiveFeedback(object sender, GiveFeedbackEventArgs e)
7292
        {
7293

    
7294
        }
7295
    }
7296
}
클립보드 이미지 추가 (최대 크기: 500 MB)