프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 6f1b870e

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

1

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

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

    
54
            T instance = Activator.CreateInstance<T>();
55

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

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

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

    
92
        public TextBox Gui { get; private set; }
93

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

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

    
115
            Gui.Text += line + Environment.NewLine;
116
        }
117
    }
118

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

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

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

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

    
183
                }
184
            }
185
        }
186

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

    
211
        public bool IsSyncPDFMode { get; set; }
212

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

    
237
        #endregion
238

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

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

    
255
        List<TempDt> tempDtList = new List<TempDt>();
256

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

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

    
272
            return false;
273
        }
274

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

    
298
            return false;
299
        }
300

    
301

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

    
309
            ViewerDataModel.Instance._markupInfoList.Remove(item);
310

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

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

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

    
329
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
330

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

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

    
372
            Button content = (sender as Button);
373
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
374

    
375
            DeleteItem(item);
376
        }
377

    
378
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
379

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

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

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

    
409
        private void timercallback(Object o)
410
        {
411
            Stopwatch sw = new Stopwatch();
412
            sw.Start();
413
            TempFile.TempFileAdd();
414
            sw.Stop();
415

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

    
424
            ////GC.Collect();
425
        }
426
        
427
        /// <summary>
428
        /// update my markuplist
429
        ///  - update existing markup data if already exist
430
        ///  - add new markup data if control is new
431
        /// </summary>
432
        public void UpdateMyMarkupList()
433
        {
434
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
435
            bool isComingNewBie = false;
436

    
437
            /// add or update markup list
438
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
439
            {
440
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
441

    
442
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
443
                if (exist != null) //신규 추가 된 코멘트
444
                {
445
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
446
                    {
447
                        exist.Data = root.ConvertData;
448
                        exist.IsUpdate = true;
449
                        ComingNewBieEnd = false;
450
                    }
451
                }
452
                else if (root.CommentID != null)
453
                {
454
                    isComingNewBie = true;
455
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
456
                    {
457
                        ID = control.CommentID,
458
                        Data = root.ConvertData,
459
                        Data_Type = root.DATA_TYPE,
460
                        MarkupInfoID = App.Custom_ViewInfoId,
461
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
462
                        Symbol_ID = control.SymbolID,
463
                        Group_ID = control.GroupID,
464
                    });
465
                    ComingNewBieEnd = false;
466
                }
467
            }
468

    
469
            /// delete markup list
470
            int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
471
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
472
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
473
                          select markup).ToList();
474
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
475
            /// up to here
476

    
477
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
478
            {
479
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
480
                {
481
                    ComingNewBieEnd = true;
482
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
483
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
484
                    gridViewMarkup.ItemsSource = null;
485
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
486
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
487

    
488
                    GroupDescriptor descriptor = new GroupDescriptor();
489
                    descriptor.Member = "Depatment";
490
                    descriptor.DisplayContent = "DEPT";
491
                    descriptor.SortDirection = ListSortDirection.Ascending;
492
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
493
                }
494
            }
495
        }
496

    
497
        bool ComingNewBieEnd = false;
498

    
499
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
500
        {
501
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
502
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
503
            {
504
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
505
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
506
            }
507
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
508
            ViewerDataModel.Instance.UndoDataList.Clear();
509

    
510
            InkControl_Convert();
511

    
512
            SelectionSet.Instance.UnSelect(this);
513
            UpdateMyMarkupList();
514

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

    
519

    
520
            #region 페이지가 벗어난 경우
521

    
522
            if (BalancePoint < 1)
523
            {
524
                BalancePoint = 1;
525
                ViewerDataModel.Instance.PageBalanceNumber = 0;
526
            }
527

    
528
            if (pageNavigator.PageCount < BalancePoint)
529
            {
530
                BalancePoint = pageNavigator.PageCount;
531
                ViewerDataModel.Instance.PageBalanceNumber = 0;
532
            }
533

    
534
            #endregion
535

    
536
            ViewerDataModel.Instance.PageNumber = BalancePoint;
537

    
538
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
539
            string uri = "";
540
            if (userData.COMPANY != "EXT")
541
            {
542
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
543
            }
544
            else
545
            {
546
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
547
            }
548

    
549
            var defaultBitmapImage = new BitmapImage();
550
            defaultBitmapImage.BeginInit();
551
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
552
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
553
            defaultBitmapImage.UriSource = new Uri(uri);
554
            defaultBitmapImage.EndInit();
555

    
556
            ViewerDataModel.Instance.ImageViewPath = null;
557
            GC.Collect();
558

    
559
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
560
            if (defaultBitmapImage.IsDownloading)
561
            {
562
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
563
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
564
                {
565
                    defaultBitmapImage.Freeze();
566
                    mainPanel.UpdateLayout();
567
                    GC.Collect();
568
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
569
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
570
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
571
                };
572
            }
573

    
574
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
575
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
576

    
577

    
578
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
579
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
580
            inkBoard.Width = zoomAndPanCanvas.Width;
581
            inkBoard.Height = zoomAndPanCanvas.Height;
582

    
583

    
584

    
585
            if (!testPanel2.IsHidden)
586
            {
587
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
588
                //PDF모드일때 잠시 대기(강인구)
589
                if (IsSyncPDFMode)
590
                {
591
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
592
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
593

    
594
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
595
                    if (pdfpath.IsDownloading)
596
                    {
597
                        pdfpath.DownloadCompleted += (ex, arg) =>
598
                        {
599
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
600
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
601
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
602
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
603
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
604
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
605
                        };
606
                    }
607
                    else
608
                    {
609
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
610
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
611
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
612
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
613

    
614
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
615
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
616
                    }
617
                }
618
                else
619
                {
620
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
621
                    string uri2 = "";
622
                    if (userData.COMPANY != "EXT")
623
                    {
624
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
625
                    }
626
                    else
627
                    {
628
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
629
                    }
630

    
631
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
632
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
633

    
634
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
635
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
636
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
637
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
638
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
639
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
640

    
641
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
642
                    zoomAndPanControl.ZoomTo(new Rect
643
                    {
644
                        X = 0,
645
                        Y = 0,
646
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
647
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
648
                    });
649

    
650
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
651
                    if (defaultBitmapImage_Compare.IsDownloading)
652
                    {
653
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
654
                        {
655
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
656
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
657
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
658
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
659

    
660
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
661
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
662

    
663
                            zoomAndPanControl.ZoomTo(new Rect
664
                            {
665
                                X = 0,
666
                                Y = 0,
667
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
668
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
669
                            });
670
                        };
671
                    }
672
                }
673
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
674
            }
675

    
676
            this.pageNavigator.SetNextPage();
677

    
678
            if (zoomAndPanCanvas2.Width.IsNaN())
679
            {
680
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
681
            }
682

    
683
            Logger.sendCheckLog("-- pageNavigator_PageChanging_ControlData Setting --", 1);
684
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
685
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
686

    
687
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
688
            foreach (var info in gridSelectionItem)
689
            {
690
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
691
            }
692
            /// fire selection event
693
            this.gridViewMarkup.UnselectAll();
694
            this.gridViewMarkup.Select(gridSelectionItem);
695

    
696
            if (!testPanel2.IsHidden)
697
            {
698
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
699
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
700
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
701

    
702
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
703
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
704

    
705

    
706
                foreach (var item in gridSelectionRevItem)
707
                {
708
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
709
                    {
710
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
711
                    });
712
                }
713
            }
714

    
715
            var instanceMain = this.ParentOfType<MainWindow>();
716
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
717
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
718

    
719
            instanceMain.dzTopMenu.rotateOffSet = 0;
720
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
721
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
722

    
723
            //}
724
            SetCommentPages(true);
725
        }
726

    
727

    
728
        
729

    
730
        private void SetCommentPages(bool onlyMe = false)
731
        {
732
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
733
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
734
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
735
            {
736
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
737
                instance.UserName = item.UserName;
738
                instance.Depart = item.Depatment;
739
                instance.MarkupInfoID = item.MarkupInfoID;
740
                instance.IsSelected = true;
741
                instance.isConSolidation = item.Consolidate;
742
                instance.SetColor = item.DisplayColor;
743
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
744
                {
745
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
746
                }
747
                else
748
                {
749
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
750
                }
751
                _pages.Add(instance);
752
            }
753
            this.pageNavigator.SetCommentList(_pages.ToList());
754
        }
755

    
756
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
757
        {
758
            if (e.MiddleButton == MouseButtonState.Pressed)
759
            {
760

    
761
            }
762
            e.Handled = true;
763
            if (e.Delta > 0)
764
            {
765
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
766
                ZoomIn(currentContentMousePoint);
767
            }
768
            else
769
            {
770
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
771
                ZoomOut(currentContentMousePoint);
772
            }
773
        }
774

    
775
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
776
        {
777
            e.Handled = true;
778
            if (e.Delta > 0)
779
            {
780
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
781
                ZoomIn_Sync(currentContentMousePoint);
782
            }
783
            else
784
            {
785
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
786
                ZoomOut_Sync(currentContentMousePoint);
787
            }
788
        }
789

    
790
        #region ZoomIn & ZoomOut
791

    
792
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
793
        {
794
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
795
                zoomAndPanControl.ContentZoomFocusY));
796
        }
797

    
798
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
799
        {
800
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
801
                zoomAndPanControl.ContentZoomFocusY));
802
        }
803

    
804

    
805
        //강인구 추가 (줌 인아웃 수치 변경)
806
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
807
        private void ZoomOut(Point contentZoomCenter)
808
        {
809
            if (zoomAndPanControl.ContentScale > 0.39)
810
            {
811
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
812
            }
813
            else
814
            {
815
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
816
            }
817

    
818
            if (zoomAndPanControl2 != null && Sync.IsChecked)
819
            {
820
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
821
            }
822
        }
823

    
824
        private void ZoomIn(Point contentZoomCenter)
825
        {
826
            if (zoomAndPanControl.ContentScale > 0.19)
827
            {
828
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
829
            }
830
            else
831
            {
832
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
833
            }
834

    
835
            if (zoomAndPanControl2 != null && Sync.IsChecked)
836
            {
837
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
838
            }
839

    
840
        }
841

    
842
        private void ZoomOut_Sync(Point contentZoomCenter)
843
        {
844
            if (zoomAndPanControl2.ContentScale > 0.39)
845
            {
846
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
847
            }
848
            else
849
            {
850
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
851
            }
852

    
853
            if (Sync.IsChecked)
854
            {
855
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
856
            }
857
        }
858

    
859
        private void ZoomIn_Sync(Point contentZoomCenter)
860
        {
861
            if (zoomAndPanControl2.ContentScale > 0.19)
862
            {
863
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
864
            }
865
            else
866
            {
867
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
868
            }
869

    
870
            if (Sync.IsChecked)
871
            {
872
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
873
            }
874
        }
875

    
876
        private void ZoomOut()
877
        {
878
            zoomAndPanControl.ContentScale -= 0.1;
879
            //if (zoomAndPanControl2 != null)
880
            //{
881
            //    zoomAndPanControl2.ContentScale -= 0.1;
882
            //}
883
        }
884

    
885
        private void ZoomIn()
886
        {
887
            zoomAndPanControl.ContentScale += 0.1;
888
            //if (zoomAndPanControl2 != null)
889
            //{
890
            //    zoomAndPanControl2.ContentScale += 0.1;
891
            //}
892
        }
893

    
894
        #endregion
895

    
896
        private void init()
897
        {
898
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
899
            {
900

    
901
                ControlList.Clear();
902
                listBox.Items.Clear();
903
                selected_item.Clear();
904

    
905
                (item as IMarkupCommonData).IsSelected = false;
906
            }
907

    
908
        }
909

    
910
        private HitTestResultBehavior MyCallback(HitTestResult result)
911
        {
912
            //this.cursor = Cursors.UpArrow;
913
            var element = result.VisualHit;
914
            while (element != null && !(element is CommentUserInfo))
915
                element = VisualTreeHelper.GetParent(element);
916

    
917
            if (element == null)
918
            {
919
                return HitTestResultBehavior.Stop;
920
            }
921
            else
922
            {
923
                if (element is CommentUserInfo)
924
                {
925
                    if (!hitList.Contains(element))
926
                    {
927
                        hitList.Add((CommentUserInfo)element);
928
                    }
929
                    else
930
                    {
931
                        return HitTestResultBehavior.Stop;
932
                    }
933
                    //IntersectionDetail intersectionDetail =
934
                    //((GeometryHitTestResult)result).IntersectionDetail;
935
                    //switch (intersectionDetail)
936
                    //{
937
                    //    case IntersectionDetail.FullyContains:
938
                    //        // Add the hit test result to the list:
939
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
940
                    //        return HitTestResultBehavior.Continue;
941
                    //    case IntersectionDetail.Intersects:
942
                    //        // Set the behavior to return visuals at all z-order levels:
943
                    //        return HitTestResultBehavior.Continue;
944
                    //    case IntersectionDetail.FullyInside:
945
                    //        // Set the behavior to return visuals at all z-order levels:
946
                    //        return HitTestResultBehavior.Continue;
947
                    //    default:
948
                    //        return HitTestResultBehavior.Stop;
949
                    //}
950
                }
951
            }
952
            return HitTestResultBehavior.Continue;
953
        }
954

    
955
        public void ReleaseSelectPath()
956
        {
957
            if (SelectionPath == null)
958
            {
959
                SelectionPath = new Path();
960
                SelectionPath.Name = "";
961
            }
962
            if (SelectionPath.Name != "")
963
            {
964
                SelectionPath.Name = "None";
965
            }
966
            SelectionPath.Opacity = 0.01;
967
            SelectionPath.RenderTransform = null;
968
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
969
        }
970

    
971
        #region 컨트롤 초기화 
972
        public void Control_Init(object control)
973
        {
974
            if (L_Size != 0 && (control as IPath) != null)
975
            {
976
                (control as IPath).LineSize = L_Size;
977
                L_Size = 0;
978
            }
979

    
980
            switch (control.GetType().Name)
981
            {
982
                case "RectangleControl":
983
                    {
984
                        (control as RectangleControl).StrokeColor = Brushes.Red;
985
                    }
986
                    break;
987
                case "CircleControl":
988
                    {
989
                        (control as CircleControl).StrokeColor = Brushes.Red;
990
                    }
991
                    break;
992
                case "TriControl":
993
                    {
994
                        (control as TriControl).StrokeColor = Brushes.Red;
995
                    }
996
                    break;
997
                case "RectCloudControl":
998
                    {
999
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1000
                    }
1001
                    break;
1002
                case "CloudControl":
1003
                    {
1004
                        (control as CloudControl).StrokeColor = Brushes.Red;
1005
                    }
1006
                    break;
1007
                case "PolygonControl":
1008
                    {
1009
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1010
                    }
1011
                    break;
1012
                case "ArcControl":
1013
                    {
1014
                        (control as ArcControl).StrokeColor = Brushes.Red;
1015
                    }
1016
                    break;
1017
                case "ArrowArcControl":
1018
                    {
1019
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1020
                    }
1021
                    break;
1022
                case "LineControl":
1023
                    {
1024
                        (control as LineControl).StrokeColor = Brushes.Red;
1025
                    }
1026
                    break;
1027
                case "ArrowControl_Multi":
1028
                    {
1029
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1030
                    }
1031
                    break;
1032
                case "TextControl":
1033
                    {
1034
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1035
                    }
1036
                    break;
1037
                case "ArrowTextControl":
1038
                    {
1039
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1040
                    }
1041
                    break;
1042
                case "InsideWhiteControl":
1043
                    {
1044
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1045
                    }
1046
                    break;
1047
                case "OverlapWhiteControl":
1048
                    {
1049
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1050
                    }
1051
                    break;
1052
                case "ClipWhiteControl":
1053
                    {
1054
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1055
                    }
1056
                    break;
1057
                case "CoordinateControl":
1058
                    {
1059
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1060
                    }
1061
                    break;
1062
            }
1063
        }
1064
        #endregion
1065

    
1066
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1067
        {
1068
            //Control_Init(e.Source);
1069
        }
1070
        private Window _dragdropWindow = null;
1071

    
1072
        [DllImport("user32.dll")]
1073
        [return: MarshalAs(UnmanagedType.Bool)]
1074
        internal static extern bool GetCursorPos(ref Win32Point pt);
1075

    
1076
        [StructLayout(LayoutKind.Sequential)]
1077
        internal struct Win32Point
1078
        {
1079
            public Int32 X;
1080
            public Int32 Y;
1081
        };
1082
        public string symbol_id = null;
1083
        public long symbol_group_id;
1084
        public int symbol_SelectedIndex;
1085
        public ImageSource symbol_img;
1086
        public string symbol_Data = null;
1087
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1088
        {
1089
            if (this._dragdropWindow != null)
1090
            {
1091
                this._dragdropWindow.Close();
1092
                this._dragdropWindow = null;
1093
            }
1094

    
1095
            symbol_id = id;
1096
            symbol_group_id = group_id;
1097
            symbol_SelectedIndex = SelectedIndex;
1098
            symbol_Data = Data_;
1099
            symbol_img = img;
1100

    
1101
      
1102
            CreateDragDropWindow2(img);
1103
        }
1104

    
1105
        private void CreateDragDropWindow2(ImageSource image)
1106
        {
1107
            this._dragdropWindow = new Window();
1108
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1109
            _dragdropWindow.WindowStyle = WindowStyle.None;
1110
            _dragdropWindow.AllowsTransparency = true;           
1111
            _dragdropWindow.AllowDrop = false;
1112
            _dragdropWindow.Background = null;
1113
            _dragdropWindow.IsHitTestVisible = false;
1114
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1115
            _dragdropWindow.Topmost = true;
1116
            _dragdropWindow.ShowInTaskbar = false;
1117
            
1118
            Rectangle r = new Rectangle();
1119
            r.Width = image.Width;
1120
            r.Height = image.Height;
1121
            r.Opacity = 0.5;            
1122
            r.Fill = new ImageBrush(image);
1123
            this._dragdropWindow.Content = r;
1124

    
1125
            Win32Point w32Mouse = new Win32Point();
1126
            GetCursorPos(ref w32Mouse);
1127

    
1128
            //w32Mouse.X = getCurrentPoint.X;
1129
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1130
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1131
            this._dragdropWindow.Show();
1132
        }
1133

    
1134
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1135
        {
1136
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1137
            {
1138
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1139

    
1140
                Point currentPos = e.GetPosition(rect);
1141

    
1142
                floatingTip.HorizontalOffset = currentPos.X + 20;
1143
                floatingTip.VerticalOffset = currentPos.Y;
1144

    
1145

    
1146
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1147
                //tool.Content = "ToolTip";
1148
                //panel.ToolTip = tool;
1149
            }
1150

    
1151
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1152
            {
1153
                #region 마우스 오버 시 색상 변경
1154
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1155
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1156

    
1157
                //if (firstCondition != null)
1158
                //{
1159
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1160

    
1161
                //    if (firstCondition.GetType().Name == "TextControl")
1162
                //    {
1163
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1164
                //        return;
1165
                //    }
1166
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1167
                //    {
1168
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1169
                //        return;
1170
                //    }
1171

    
1172
                //    if (L_Size == 0)
1173
                //    {
1174
                //        L_Size = (firstCondition as IPath).LineSize;
1175
                //        (firstCondition as IPath).LineSize *= 4;
1176
                //    }
1177
                //    switch (firstCondition.GetType().Name)
1178
                //    {
1179
                //        case "RectangleControl":
1180
                //            {
1181
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1182
                //            }
1183
                //            break;
1184
                //        case "CircleControl":
1185
                //            {
1186
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1187
                //            }
1188
                //            break;
1189
                //        case "TriControl":
1190
                //            {
1191
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1192
                //            }
1193
                //            break;
1194
                //        case "RectCloudControl":
1195
                //            {
1196
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1197
                //            }
1198
                //            break;
1199
                //        case "CloudControl":
1200
                //            {
1201
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1202
                //            }
1203
                //            break;
1204
                //        case "PolygonControl":
1205
                //            {
1206
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1207
                //            }
1208
                //            break;
1209
                //        case "ArcControl":
1210
                //            {
1211
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1212
                //            }
1213
                //            break;
1214
                //        case "LineControl":
1215
                //            {
1216
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1217
                //            }
1218
                //            break;
1219
                //        case "ArrowControl_Multi":
1220
                //            {
1221
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1222
                //            }
1223
                //            break;
1224

    
1225
                //        default:
1226
                //            {
1227

    
1228
                //            }
1229
                //            break;
1230
                //    }
1231
                //} 
1232
                #endregion
1233
            }
1234

    
1235
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1236
            #region 주석
1237
            //if (mouseButtonDown == MouseButton.Middle)
1238
            //{
1239
            //    SetCursor();
1240
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1241
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1242

    
1243
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1244
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1245
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1246

    
1247
            //    //SetCursor();
1248
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1249
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1250

    
1251
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1252

    
1253
            //    //zoomAndPanControl.ContentOffsetX += 1;
1254
            //    //zoomAndPanControl.ContentOffsetY += 1;
1255

    
1256
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1257
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1258
            //}
1259
            #endregion
1260

    
1261
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1262
            {
1263
                SetCursor();
1264
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1265
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1266

    
1267
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1268
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1269
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1270

    
1271
                if (Sync.IsChecked)
1272
                {
1273
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1274
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1275
                }
1276
            }
1277

    
1278
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1279
            {
1280
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1281
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1282
                SetCursor();
1283

    
1284
                if (IsDrawing)
1285
                {
1286
                    if (currentControl == null)
1287
                    {
1288
                        switch (controlType)
1289
                        {
1290
                            case ControlType.PenControl:
1291
                                {
1292
                                    if (inkBoard.Tag.ToString() == "Ink")
1293
                                    {
1294
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1295
                                    }
1296
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1297
                                    {
1298
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1299
                                    }
1300
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1301
                                    {
1302
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1303
                                    }
1304

    
1305
                                    //inkBoard.Strokes.Add(stroke);
1306
                                }
1307
                                break;
1308
                        }
1309
                        return;
1310
                    }
1311
                }
1312

    
1313
                if (currentControl != null)
1314
                {
1315
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1316
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1317
                    //강인구 추가
1318
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1319

    
1320
                    if ((currentControl as IPath) != null)
1321
                    {
1322
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1323
                    }
1324
                    if ((currentControl as LineControl) != null)
1325
                    {
1326
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1327
                    }
1328

    
1329
                    if ((currentControl as IShapeControl) != null)
1330
                    {
1331
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1332
                    }
1333
                    if ((currentControl as TextControl) != null)
1334
                    {
1335
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1336
                        {
1337
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1338
                        }
1339
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1340
                        {
1341
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1342
                        }
1343
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1344
                        {
1345
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1346
                        }
1347
                    }
1348
                    else if ((currentControl as ArrowTextControl) != null)
1349
                    {
1350
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1351
                        {
1352
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1353
                        }
1354
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1355
                        {
1356
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1357
                        }
1358
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1359
                        {
1360
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1361
                        }
1362
                    }
1363
                    else if ((currentControl as RectCloudControl) != null)
1364
                    {
1365
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1366
                    }
1367
                    else if ((currentControl as CloudControl) != null)
1368
                    {
1369
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1370
                    }
1371

    
1372
                    switch (controlType)
1373
                    {
1374
                        case (ControlType.Coordinate):
1375
                            {
1376
                                var control = currentControl as CoordinateControl;
1377

    
1378
                                if (control != null)
1379
                                {
1380
                                    if (move.mousemode == MouseMode.Drawing)
1381
                                    {
1382
                                        //move.control_Move(ControlList, true, moveX, moveY);
1383
                                    }
1384
                                    else
1385
                                    {
1386
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1387
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1388
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1389
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1390

    
1391

    
1392
                                        if (ViewerDataModel.Instance.IsPressShift)
1393
                                        {
1394
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1395
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1396
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1397
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1398
                                        }
1399

    
1400
                                        control.PointSet = new List<Point>
1401
                                        {
1402
                                            control.StartPoint,
1403
                                            control.LeftBottomPoint,
1404
                                            control.EndPoint,
1405
                                            control.TopRightPoint,
1406
                                        };
1407
                                        control.updateControl();
1408
                                    }
1409

    
1410
                                    //강인구 추가
1411
                                    control.ControlType = controlType;
1412
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1413
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1414
                                    //  control.Paint = PaintSet.Fill;
1415
                                }
1416
                            }
1417
                            break;
1418
                        case (ControlType.InsideWhite):
1419
                            {
1420
                                var control = currentControl as InsideWhiteControl;
1421

    
1422
                                if (control != null)
1423
                                {
1424
                                    if (move.mousemode == MouseMode.Drawing)
1425
                                    {
1426
                                        //move.control_Move(ControlList, true, moveX, moveY);
1427
                                    }
1428
                                    else
1429
                                    {
1430
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1431
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1432
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1433
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1434

    
1435

    
1436
                                        if (ViewerDataModel.Instance.IsPressShift)
1437
                                        {
1438
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1439
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1440
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1441
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1442
                                        }
1443

    
1444
                                        control.PointSet = new List<Point>
1445
                                        {
1446
                                            control.StartPoint,
1447
                                            control.LeftBottomPoint,
1448
                                            control.EndPoint,
1449
                                            control.TopRightPoint,
1450
                                        };
1451
                                        control.updateControl();
1452
                                    }
1453

    
1454
                                    //강인구 추가
1455
                                    control.ControlType = controlType;
1456
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1457
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1458
                                    control.Paint = PaintSet.Fill;
1459
                                }
1460
                            }
1461
                            break;
1462
                        case (ControlType.OverlapWhite):
1463
                            {
1464
                                var control = currentControl as OverlapWhiteControl;
1465

    
1466
                                if (control != null)
1467
                                {
1468
                                    if (move.mousemode == MouseMode.Drawing)
1469
                                    {
1470
                                        //move.control_Move(ControlList, true, moveX, moveY);
1471
                                    }
1472
                                    else
1473
                                    {
1474
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1475
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1476
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1477
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1478

    
1479

    
1480
                                        if (ViewerDataModel.Instance.IsPressShift)
1481
                                        {
1482
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1483
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1484
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1485
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1486
                                        }
1487

    
1488
                                        control.PointSet = new List<Point>
1489
                                        {
1490
                                            control.StartPoint,
1491
                                            control.LeftBottomPoint,
1492
                                            control.EndPoint,
1493
                                            control.TopRightPoint,
1494
                                        };
1495
                                        control.updateControl();
1496
                                    }
1497

    
1498
                                    //강인구 추가
1499
                                    control.ControlType = controlType;
1500
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1501
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1502
                                    control.Paint = PaintSet.Fill;
1503
                                }
1504
                            }
1505
                            break;
1506
                        case (ControlType.ClipWhite):
1507
                            {
1508
                                var control = currentControl as ClipWhiteControl;
1509

    
1510
                                if (control != null)
1511
                                {
1512
                                    if (move.mousemode == MouseMode.Drawing)
1513
                                    {
1514
                                        //move.control_Move(ControlList, true, moveX, moveY);
1515
                                    }
1516
                                    else
1517
                                    {
1518
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1519
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1520
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1521
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1522

    
1523

    
1524
                                        if (ViewerDataModel.Instance.IsPressShift)
1525
                                        {
1526
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1527
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1528
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1529
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1530
                                        }
1531

    
1532
                                        control.PointSet = new List<Point>
1533
                                        {
1534
                                            control.StartPoint,
1535
                                            control.LeftBottomPoint,
1536
                                            control.EndPoint,
1537
                                            control.TopRightPoint,
1538
                                        };
1539
                                        control.updateControl();
1540
                                    }
1541

    
1542
                                    //강인구 추가
1543
                                    control.ControlType = controlType;
1544
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1545
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1546
                                    control.Paint = PaintSet.Fill;
1547
                                }
1548
                            }
1549
                            break;
1550
                        case ControlType.Rectangle:
1551
                            {
1552
                                var control = currentControl as RectangleControl;
1553

    
1554
                                if (control != null)
1555
                                {
1556
                                    if (move.mousemode == MouseMode.Drawing)
1557
                                    {
1558
                                        //move.control_Move(ControlList, true, moveX, moveY);
1559
                                    }
1560
                                    else
1561
                                    {
1562
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1563
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1564
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1565
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1566

    
1567

    
1568
                                        if (ViewerDataModel.Instance.IsPressShift)
1569
                                        {
1570
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1571
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1572
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1573
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1574
                                        }
1575

    
1576
                                        control.PointSet = new List<Point>
1577
                                        {
1578
                                            control.StartPoint,
1579
                                            control.LeftBottomPoint,
1580
                                            control.EndPoint,
1581
                                            control.TopRightPoint,
1582
                                        };
1583
                                        control.updateControl();
1584
                                    }
1585

    
1586
                                    //강인구 추가
1587
                                    control.ControlType = controlType;
1588
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1589
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1590
                                }
1591
                            }
1592
                            break;
1593

    
1594
                        case ControlType.RectCloud:
1595
                            {
1596
                                var control = currentControl as RectCloudControl;
1597

    
1598
                                if (control != null)
1599
                                {
1600
                                    if (move.mousemode == MouseMode.Drawing)
1601
                                    {
1602
                                        //move.control_Move(ControlList, true, moveX, moveY);
1603
                                    }
1604
                                    else
1605
                                    {
1606
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1607
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1608
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1609
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1610

    
1611
                                        if (ViewerDataModel.Instance.IsPressShift)
1612
                                        {
1613
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1614
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1615
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1616
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1617
                                        }
1618

    
1619
                                        control.PointSet = new List<Point>
1620
                                        {
1621
                                            control.StartPoint,
1622
                                            control.LeftBottomPoint,
1623
                                            control.EndPoint,
1624
                                            control.TopRightPoint,
1625
                                        };
1626
                                    }
1627

    
1628
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1629
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1630
                                }
1631
                            }
1632
                            break;
1633

    
1634
                        case ControlType.SingleLine:
1635
                            {
1636
                                var control = currentControl as LineControl;
1637
                                if (control != null)
1638
                                {
1639
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1640
                                    control.ControlType = controlType;
1641
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1642
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1643
                                    Point tempPoint = control.EndPoint;
1644

    
1645
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1646
                                    {
1647
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1648
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1649
                                        control.EndPoint = tempPoint;
1650
                                    }
1651
                                    else
1652
                                    {
1653
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1654
                                    }
1655

    
1656
                                    control.PointSet = new List<Point>
1657
                                        {
1658
                                            control.StartPoint,
1659
                                            control.EndPoint,
1660
                                        };
1661

    
1662
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1663
                                }
1664

    
1665
                            }
1666
                            break;
1667

    
1668
                        case ControlType.CancelLine:
1669
                            {
1670
                                var control = currentControl as LineControl;
1671
                                if (control != null)
1672
                                {
1673
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1674
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1675
                                    control.ControlType = controlType;
1676
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1677
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1678
                                    Point tempPoint = control.EndPoint;
1679

    
1680
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1681
                                    {
1682
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1683
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1684
                                        control.EndPoint = tempPoint;
1685
                                    }
1686
                                    else
1687
                                    {
1688
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1689
                                    }
1690

    
1691

    
1692
                                    control.PointSet = new List<Point>
1693
                                            {
1694
                                                control.StartPoint,
1695
                                                control.EndPoint,
1696
                                            };
1697
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1698
                                }
1699

    
1700

    
1701
                            }
1702
                            break;
1703

    
1704
                        case ControlType.ArrowLine:
1705
                            {
1706
                                var control = currentControl as LineControl;
1707
                                if (control != null)
1708
                                {
1709
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1710
                                    control.ControlType = controlType;
1711
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1712
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1713
                                    Point tempPoint = control.EndPoint;
1714

    
1715
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1716
                                    {
1717
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1718
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1719
                                        control.EndPoint = tempPoint;
1720
                                    }
1721
                                    else
1722
                                    {
1723
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1724
                                    }
1725

    
1726

    
1727
                                    control.PointSet = new List<Point>
1728
                                            {
1729
                                                control.StartPoint,
1730
                                                control.EndPoint,
1731
                                            };
1732
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1733
                                }
1734
                            }
1735
                            break;
1736

    
1737
                        case ControlType.TwinLine:
1738
                            {
1739
                                var control = currentControl as LineControl;
1740
                                if (control != null)
1741
                                {
1742
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1743
                                    control.ControlType = controlType;
1744
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1745
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1746
                                    Point tempPoint = control.EndPoint;
1747

    
1748
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1749
                                    {
1750
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1751
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1752
                                        control.EndPoint = tempPoint;
1753
                                    }
1754
                                    else
1755
                                    {
1756
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1757
                                    }
1758

    
1759

    
1760
                                    control.PointSet = new List<Point>
1761
                                            {
1762
                                                control.StartPoint,
1763
                                                control.EndPoint,
1764
                                            };
1765
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1766
                                }
1767
                            }
1768
                            break;
1769

    
1770
                        case ControlType.DimLine:
1771
                            {
1772
                                var control = currentControl as LineControl;
1773
                                if (control != null)
1774
                                {
1775
                                    control.LineStyleSet = LineStyleSet.DimLine;
1776
                                    control.ControlType = controlType;
1777
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1778
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1779
                                    Point tempPoint = control.EndPoint;
1780

    
1781
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1782
                                    {
1783
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1784
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1785
                                        control.EndPoint = tempPoint;
1786
                                    }
1787
                                    else
1788
                                    {
1789
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1790
                                    }
1791

    
1792
                                    control.PointSet = new List<Point>
1793
                                            {
1794
                                                control.StartPoint,
1795
                                                control.EndPoint,
1796
                                            };
1797
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1798
                                }
1799
                            }
1800
                            break;
1801

    
1802
                        case ControlType.ChainLine:
1803
                            {
1804
                                var control = currentControl as PolygonControl;
1805

    
1806
                                if (control != null)
1807
                                {
1808

    
1809
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1810
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1811

    
1812
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1813

    
1814
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1815
                                    {
1816
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1817
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1818
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1819
                                        //control.EndPoint = tempPoint;
1820
                                    }
1821
                                    else
1822
                                    {
1823
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1824
                                    }
1825

    
1826
                                    ///control.SetPolyPath();
1827

    
1828
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1829
                                }
1830
                            }
1831
                            break;
1832

    
1833
                        case ControlType.ArcLine:
1834
                            {
1835
                                var control = currentControl as ArcControl;
1836
                                if (control != null)
1837
                                {
1838
                                    control.isTransOn = false;
1839
                                    control.ControlType = controlType;
1840
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1841
                                    control.MidPoint = new Point(0, 0);
1842
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1843
                                    Point tempPoint = control.EndPoint;
1844

    
1845
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1846
                                    {
1847
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1848
                                        control.EndPoint = tempPoint;
1849
                                    }
1850
                                    else
1851
                                    {
1852
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1853
                                    }
1854

    
1855

    
1856
                                    control.PointSet = new List<Point>
1857
                                            {
1858
                                                control.StartPoint,
1859
                                                control.MidPoint,
1860
                                                control.EndPoint,
1861
                                            };
1862
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1863
                                }
1864
                            }
1865
                            break;
1866

    
1867
                        case ControlType.ArcArrow:
1868
                            {
1869
                                var control = currentControl as ArrowArcControl;
1870
                                if (control != null)
1871
                                {
1872
                                    control.isTransOn = false;
1873
                                    control.ControlType = controlType;
1874
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1875
                                    control.MidPoint = new Point(0, 0);
1876
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1877
                                    Point tempPoint = control.EndPoint;
1878

    
1879
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1880
                                    {
1881
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1882
                                        control.EndPoint = tempPoint;
1883
                                    }
1884
                                    else
1885
                                    {
1886
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1887
                                    }
1888

    
1889

    
1890
                                    control.PointSet = new List<Point>
1891
                                            {
1892
                                                control.StartPoint,
1893
                                                control.MidPoint,
1894
                                                control.EndPoint,
1895
                                            };
1896
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1897
                                }
1898
                            }
1899
                            break;
1900

    
1901
                        case ControlType.ArrowMultiLine:
1902
                            {
1903
                                var control = currentControl as ArrowControl_Multi;
1904
                                if (control != null)
1905
                                {
1906
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1907
                                    Point tempPoint = control.EndPoint;
1908
                                    if (control.MiddlePoint == new Point(0, 0))
1909
                                    {
1910
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1911
                                        {
1912
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1913
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1914
                                            control.EndPoint = tempPoint;
1915
                                        }
1916
                                        else
1917
                                        {
1918
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1919
                                        }
1920
                                    }
1921
                                    else
1922
                                    {
1923
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1924
                                        {
1925
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1926
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1927
                                            control.EndPoint = tempPoint;
1928
                                        }
1929
                                        else
1930
                                        {
1931
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1932
                                        }
1933

    
1934
                                    }
1935

    
1936
                                    control.PointSet = new List<Point>
1937
                                            {
1938
                                                control.StartPoint,
1939
                                                control.MiddlePoint,
1940
                                                control.EndPoint,
1941
                                            };
1942
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1943
                                }
1944
                            }
1945
                            break;
1946

    
1947
                        case ControlType.Circle:
1948
                            {
1949
                                var control = currentControl as CircleControl;
1950

    
1951
                                if (control != null)
1952
                                {
1953
                                    if (move.mousemode == MouseMode.Drawing)
1954
                                    {
1955
                                        //move.control_Move(ControlList, true, moveX, moveY);
1956
                                    }
1957
                                    else
1958
                                    {
1959
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1960
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1961
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1962
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1963

    
1964
                                        if (ViewerDataModel.Instance.IsPressShift)
1965
                                        {
1966
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1967
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1968
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1969
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1970
                                        }
1971

    
1972
                                        control.PointSet = new List<Point>
1973
                                        {
1974
                                            control.StartPoint,
1975
                                            control.LeftBottomPoint,
1976
                                            control.EndPoint,
1977
                                            control.TopRightPoint,
1978
                                        };
1979
                                    }
1980

    
1981
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1982
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1983

    
1984
                                }
1985
                            }
1986
                            break;
1987

    
1988
                        case ControlType.PolygonCloud:
1989
                            {
1990
                                var control = currentControl as CloudControl;
1991

    
1992
                                if (control != null)
1993
                                {
1994
                                    control.isTransOn = true;
1995
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1996

    
1997
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1998

    
1999
                                    control.SetCloud();
2000
                                    //강인구 추가
2001
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2002
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2003
                                }
2004
                            }
2005
                            break;
2006

    
2007
                        case ControlType.Triangle:
2008
                            {
2009
                                var control = currentControl as TriControl;
2010

    
2011
                                if (control != null)
2012
                                {
2013
                                    if (move.mousemode == MouseMode.Drawing)
2014
                                    {
2015
                                        //move.control_Move(ControlList, true, moveX, moveY);
2016
                                    }
2017
                                    else
2018
                                    {
2019
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2020
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2021

    
2022
                                        if (ViewerDataModel.Instance.checkAxis)
2023
                                        {
2024
                                            Point tempPoint = control.EndPoint;
2025
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2026
                                            control.EndPoint = tempPoint;
2027
                                        }
2028

    
2029

    
2030
                                        if (ViewerDataModel.Instance.IsPressShift)
2031
                                        {
2032
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2033
                                            if (2 == Points.Count())
2034
                                            {
2035
                                                control.MidPoint = Points[0];
2036
                                                control.EndPoint = Points[1];
2037
                                            }
2038
                                        }
2039

    
2040
                                        control.PointSet = new List<Point>
2041
                                            {
2042
                                                control.StartPoint,
2043
                                                control.MidPoint,
2044
                                                control.EndPoint,
2045
                                            };
2046
                                    }
2047

    
2048
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2049
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2050
                                }
2051
                            }
2052
                            break;
2053

    
2054
                        case ControlType.ImgControl:
2055
                            {
2056
                                var control = currentControl as ImgControl;
2057

    
2058
                                if (control != null)
2059
                                {
2060
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2061
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2062
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2063
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2064

    
2065
                                    control.PointSet = new List<Point>
2066
                                        {
2067
                                            control.StartPoint,
2068
                                            control.LeftBottomPoint,
2069
                                            control.EndPoint,
2070
                                            control.TopRightPoint,
2071
                                        };
2072
                                }
2073
                            }
2074
                            break;
2075

    
2076
                        case ControlType.Date:
2077
                            {
2078
                                var control = currentControl as DateControl;
2079

    
2080
                                if (control != null)
2081
                                {
2082
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2083
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2084
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2085
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2086
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2087

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

    
2099
                        case ControlType.ArrowTextControl:
2100
                            {
2101
                                var control = currentControl as ArrowTextControl;
2102

    
2103
                                if (control != null)
2104
                                {
2105
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2106
                                    Point tempPoint = control.EndPoint;
2107

    
2108
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2109

    
2110
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2111
                                    {
2112
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2113
                                        control.EndPoint = tempPoint;
2114
                                    }
2115
                                    else
2116
                                    {
2117
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2118
                                    }
2119
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2120

    
2121
                                    control.PointSet = new List<Point>
2122
                                            {
2123
                                                control.StartPoint,
2124
                                                control.MidPoint,
2125
                                                control.EndPoint,
2126
                                            };
2127
                                }
2128
                            }
2129
                            break;
2130

    
2131
                        case ControlType.ArrowTransTextControl:
2132
                            {
2133
                                var control = currentControl as ArrowTextControl;
2134

    
2135
                                if (control != null)
2136
                                {
2137
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2138
                                    Point tempPoint = control.EndPoint;
2139
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
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
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2151
                                    control.isFixed = true;
2152

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

    
2163
                        case ControlType.ArrowTextBorderControl:
2164
                            {
2165
                                var control = currentControl as ArrowTextControl;
2166

    
2167
                                if (control != null)
2168
                                {
2169
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2170
                                    Point tempPoint = control.EndPoint;
2171
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2172
                                    {
2173
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2174
                                        control.EndPoint = tempPoint;
2175
                                    }
2176
                                    else
2177
                                    {
2178
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2179
                                    }
2180
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2181
                                    control.PointSet = new List<Point>
2182
                                            {
2183
                                                control.StartPoint,
2184
                                                control.MidPoint,
2185
                                                control.EndPoint,
2186
                                            };
2187
                                }
2188

    
2189
                            }
2190
                            break;
2191
                        case ControlType.ArrowTransTextBorderControl:
2192
                            {
2193
                                var control = currentControl as ArrowTextControl;
2194

    
2195
                                if (control != null)
2196
                                {
2197
                                    control.isFixed = true;
2198
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2199
                                    Point tempPoint = control.EndPoint;
2200
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2201
                                    {
2202
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2203
                                        control.EndPoint = tempPoint;
2204
                                    }
2205
                                    else
2206
                                    {
2207
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2208
                                    }
2209

    
2210
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2211
                                    control.PointSet = new List<Point>
2212
                                            {
2213
                                                control.StartPoint,
2214
                                                control.MidPoint,
2215
                                                control.EndPoint,
2216
                                            };
2217
                                }
2218

    
2219
                            }
2220
                            break;
2221
                        case ControlType.ArrowTextCloudControl:
2222
                            {
2223
                                var control = currentControl as ArrowTextControl;
2224

    
2225
                                if (control != null)
2226
                                {
2227
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2228
                                    Point tempPoint = control.EndPoint;
2229
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2230
                                    {
2231
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2232
                                        control.EndPoint = tempPoint;
2233
                                    }
2234
                                    else
2235
                                    {
2236
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2237
                                    }
2238
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2239
                                    control.PointSet = new List<Point>
2240
                                            {
2241
                                                control.StartPoint,
2242
                                                control.MidPoint,
2243
                                                control.EndPoint,
2244
                                            };
2245
                                }
2246

    
2247
                            }
2248
                            break;
2249
                        case ControlType.ArrowTransTextCloudControl:
2250
                            {
2251
                                var control = currentControl as ArrowTextControl;
2252

    
2253
                                if (control != null)
2254
                                {
2255
                                    control.isFixed = true;
2256
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2257
                                    Point tempPoint = control.EndPoint;
2258
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2259
                                    {
2260
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2261
                                        control.EndPoint = tempPoint;
2262
                                    }
2263
                                    else
2264
                                    {
2265
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2266
                                    }
2267
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2268
                                    control.PointSet = new List<Point>
2269
                                            {
2270
                                                control.StartPoint,
2271
                                                control.MidPoint,
2272
                                                control.EndPoint,
2273
                                            };
2274
                                }
2275

    
2276
                            }
2277
                            break;
2278
                        case ControlType.PolygonControl:
2279
                            {
2280
                                var control = currentControl as PolygonControl;
2281

    
2282
                                if (control != null)
2283
                                {
2284
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2285
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2286
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2287
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2288
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2289
                                    control.updateControl();
2290
                                }
2291
                            }
2292
                            break;
2293
                        //강인구 추가
2294
                        case ControlType.Sign:
2295
                            {
2296
                                var control = currentControl as SignControl;
2297

    
2298
                                if (control != null)
2299
                                {
2300
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2301
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2302
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2303
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2304

    
2305
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2306
                                    {
2307
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2308
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2309
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2310
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2311
                                        stream.Position = 0;
2312
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2313
                                        BitmapImage returnImage = new BitmapImage();
2314
                                        returnImage.BeginInit();
2315
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2316
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2317
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2318
                                        returnImage.StreamSource = ms;
2319
                                        returnImage.EndInit();
2320
                                        stream.Close();
2321

    
2322
                                        control.SignImage = returnImage;
2323
                                    }
2324
                                    control.PointSet = new List<Point>
2325
                                        {
2326
                                            control.StartPoint,
2327
                                            control.LeftBottomPoint,
2328
                                            control.EndPoint,
2329
                                            control.TopRightPoint,
2330
                                        };
2331
                                }
2332
                            }
2333
                            break;
2334
                        //TODO: 강인구 추가
2335
                        case ControlType.Symbol:
2336
                            {
2337
                                var control = currentControl as SymControl;
2338

    
2339
                                if (control != null)
2340
                                {
2341
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2342
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2343
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2344
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2345
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2346
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2347

    
2348
                                    if (control.StartPoint != control.EndPoint)
2349
                                    {
2350
                                        if (control.PathData == null)
2351
                                        {
2352
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2353
                                            {
2354
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2355
                                            }
2356
                                        }
2357
                                    }
2358

    
2359
                                    control.PointSet = new List<Point>
2360
                                        {
2361
                                            control.StartPoint,
2362
                                            control.LeftBottomPoint,
2363
                                            control.EndPoint,
2364
                                            control.TopRightPoint,
2365
                                        };
2366
                                }
2367
                            }
2368
                            break;
2369
                        ///TODO: 
2370
                        case ControlType.Stamp:
2371
                            {
2372
                                var control = currentControl as SymControlN;
2373

    
2374
                                if (control != null)
2375
                                {
2376

    
2377
                                    if (control.StartPoint == control.EndPoint)
2378
                                    {
2379
                                        //string appovalData = "";
2380

    
2381
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2382
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2383

    
2384

    
2385
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2386

    
2387
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2388
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2389
                                        writer.Write(xamlData);
2390
                                        writer.Flush();
2391
                                        stream.Position = 0;
2392

    
2393
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2394
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2395
                                        UIElement ob = obj as UIElement;
2396

    
2397
                                        //control.ApplyTemplate();
2398

    
2399
                                        control.SetViewBox();
2400
                                        control.PathXathData = App.SystemInfo.STAMP;
2401
                                        control.Base_ViewBox.Child = ob;
2402
                                    }
2403

    
2404
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2405
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2406
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2407
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2408
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2409

    
2410

    
2411
                                    control.PointSet = new List<Point>
2412
                                    {
2413
                                        control.StartPoint,
2414
                                        control.LeftBottomPoint,
2415
                                        control.EndPoint,
2416
                                        control.TopRightPoint,
2417
                                    };
2418
                                }
2419
                            }
2420
                            break;
2421
                        case ControlType.Mark:
2422
                            {
2423
                                var control = currentControl as RectangleControl;
2424

    
2425
                                if (control != null)
2426
                                {
2427
                                    if (move.mousemode == MouseMode.Drawing)
2428
                                    {
2429
                                        //move.control_Move(ControlList, true, moveX, moveY);
2430
                                    }
2431
                                    else
2432
                                    {
2433
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2434
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2435
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2436
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2437

    
2438

    
2439
                                        control.PointSet = new List<Point>
2440
                                    {
2441
                                        control.StartPoint,
2442
                                        control.LeftBottomPoint,
2443
                                        control.EndPoint,
2444
                                        control.TopRightPoint,
2445
                                    };
2446
                                    }
2447

    
2448
                                    //강인구 추가
2449
                                    control.Paint = PaintSet.Fill;
2450
                                }
2451
                            }
2452
                            break;
2453
                        case ControlType.PenControl:
2454
                            {
2455
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2456
                                //inkBoard.Strokes.Add(stroke);
2457
                            }
2458
                            break;
2459
                        default:
2460
                            break;
2461
                    }
2462
                }
2463
            }
2464
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2465
            {
2466
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2467

    
2468
                if (isDraggingSelectionRect)
2469
                {
2470
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2471

    
2472
                    e.Handled = true;
2473
                }
2474
                else if (isLeftMouseButtonDownOnWindow)
2475
                {
2476
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2477
                    double dragDistance = Math.Abs(dragDelta.Length);
2478

    
2479
                    if (dragDistance > DragThreshold)
2480
                    {
2481
                        isDraggingSelectionRect = true;
2482

    
2483
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2484
                    }
2485

    
2486
                    e.Handled = true;
2487
                }
2488

    
2489

    
2490
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2491
                {
2492
                    //SelectionPath = new Path();
2493
                    //PathFigure pathFigure = new PathFigure();
2494
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2495
                    //SelectionPath.Opacity = 0.5;
2496
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2497
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2498
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2499
                }
2500
                else
2501
                {
2502
                    //List<Stroke> removingStroke = new List<Stroke>();
2503
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2504
                    //StrokeCollection stC = new StrokeCollection();
2505
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2506
                    //{
2507
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2508
                    //    p1.Intersect(p2);
2509
                    //    if (p1.IsEmpty)
2510
                    //    {
2511

    
2512

    
2513
                    //        p1 = SelectionPath.Data.Bounds;
2514
                    //        bool intersectCheck = false;
2515
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2516
                    //        {
2517
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2518
                    //            p1.Intersect(p3);
2519
                    //            if (!p1.IsEmpty)
2520
                    //            {
2521
                    //                intersectCheck = true;
2522
                    //            }
2523
                    //        }
2524
                    //        if (intersectCheck)
2525
                    //        {
2526
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2527
                    //        }
2528

    
2529
                    //    }
2530
                    //    else
2531
                    //    {
2532
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2533
                    //    }
2534
                    //}
2535

    
2536
                    e.Handled = true;
2537
                }
2538
            }
2539
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2540
            { //symbol      
2541
                if(_dragdropWindow != null)
2542
                {
2543
                    Win32Point w32Mouse = new Win32Point();
2544
                    GetCursorPos(ref w32Mouse);
2545

    
2546
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2547
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2548
                }                
2549
            }
2550
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2551
            {
2552
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2553
                if (control != null)
2554
                {
2555
                    this.cursor = Cursors.Hand;
2556
                    SetCursor();
2557
                }
2558
                else
2559
                {
2560
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2561

    
2562
                    SetCursor();
2563
                }
2564
            }
2565
            else
2566
            {
2567
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2568

    
2569
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2570
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2571

    
2572
                //if (hitList.Count > 0)
2573
                //{
2574

    
2575
                //}
2576

    
2577
                #region 조건 설정 : firstCondition
2578
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2579
                //pnts = generalTransform.Transform(pnts);
2580
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2581
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2582
                //                               this.DeepLayer._BaseLayer).ToObservable()
2583
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2584
                //                      select kkk).FirstOrDefault();
2585

    
2586
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2587
                //if (canvas !=null)
2588
                //{
2589
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2590
                //    {
2591
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2592
                //        if (uiElement!=null)
2593
                //        {
2594
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2595
                //        }
2596
                //    }
2597
                //}
2598

    
2599
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2600
                //hitResultsList.Clear();
2601

    
2602
                #endregion
2603
            }
2604
        }
2605

    
2606
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2607
        {
2608
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2609
            {
2610
                SetCursor();
2611
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2612
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2613

    
2614
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2615

    
2616
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2617
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2618

    
2619
                if (Sync.IsChecked)
2620
                {
2621
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2622
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2623
                }
2624
            }
2625
        }
2626

    
2627
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2628

    
2629
        private EllipseGeometry hitArea = new EllipseGeometry();
2630

    
2631
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2632
        {
2633
            IsDrawing = false;
2634

    
2635
            if (mouseHandlingMode != MouseHandlingMode.None)
2636
            {
2637
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2638
                {
2639
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2640

    
2641
                    SetCursor();
2642

    
2643
                    switch (controlType)
2644
                    {
2645
                        case ControlType.None:
2646
                            break;
2647
                        case ControlType.Rectangle:
2648
                            {
2649

    
2650
                            }
2651
                            break;
2652
                        case ControlType.PenControl:
2653
                            {
2654

    
2655
                            }
2656
                            break;
2657
                        default:
2658
                            break;
2659
                    }
2660
                }
2661
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2662
                {
2663
                    if (isLeftMouseButtonDownOnWindow)
2664
                    {
2665
                        bool wasDragSelectionApplied = false;
2666

    
2667
                        if (isDraggingSelectionRect)
2668
                        {
2669
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2670
                            {
2671
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2672
                                mouseHandlingMode = MouseHandlingMode.None;
2673
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2674
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2675
                                Set_Symbol_Capture(endPoint);
2676
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2677
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2678
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2679
                            }
2680
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2681
                            {
2682
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2683
                                mouseHandlingMode = MouseHandlingMode.None;
2684
                                Set_Capture();
2685

    
2686
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2687
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2688
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2689
                            }
2690
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2691
                            {
2692
                                ApplyDragSelectionRect();
2693
                            }
2694
                            else
2695
                            {
2696
                                double x = Canvas.GetLeft(dragZoomBorder);
2697
                                double y = Canvas.GetTop(dragZoomBorder);
2698
                                double width = dragZoomBorder.Width;
2699
                                double height = dragZoomBorder.Height;
2700
                                Rect dragRect = new Rect(x, y, width, height);
2701

    
2702
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2703

    
2704
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2705
                            }
2706

    
2707
                            isDraggingSelectionRect = false;
2708
                            e.Handled = true;
2709
                            wasDragSelectionApplied = true;
2710
                        }
2711

    
2712
                        if (isLeftMouseButtonDownOnWindow)
2713
                        {
2714
                            isLeftMouseButtonDownOnWindow = false;
2715
                            this.ReleaseMouseCapture();
2716
                            e.Handled = true;
2717
                        }
2718

    
2719
                        if (!wasDragSelectionApplied)
2720
                        {
2721
                            init();
2722
                        }
2723
                    }
2724
                }
2725
                else if (mouseButtonDown == MouseButton.Right)
2726
                {
2727
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2728
                    SetCursor();
2729
                }
2730

    
2731
                zoomAndPanControl.ReleaseMouseCapture();
2732

    
2733

    
2734
                e.Handled = true;
2735
            }
2736
            else
2737
            {
2738
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2739
                SetCursor();
2740
            }
2741
            mouseButtonDown = MouseButton.Left;
2742

    
2743
            //controlType = ControlType.SingleLine;
2744
        }
2745

    
2746
        public void Set_Symbol_Capture(Point endPoint)
2747
        {       
2748
            double x = canvasDrawingMouseDownPoint.X;
2749
            double y = canvasDrawingMouseDownPoint.Y;
2750
            if(x > endPoint.X)
2751
            {
2752
                x = endPoint.X;
2753
                y = endPoint.Y;
2754
            }
2755

    
2756
            double width = dragCaptureBorder.Width;
2757
            double height = dragCaptureBorder.Height;
2758

    
2759
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2760

    
2761
            if (x < 0)
2762
            {
2763
                width += x;
2764
                x = 0;
2765
            }
2766
            if (y < 0)
2767
            {
2768
                height += y;
2769
                y = 0;
2770

    
2771
                width = (int)canvasImage.PixelWidth - x;
2772
            }
2773
            if (x + width > canvasImage.PixelWidth)
2774
            {
2775
                width = (int)canvasImage.PixelWidth - x;
2776
            }
2777
            if (y + height > canvasImage.PixelHeight)
2778
            {
2779
                height = (int)canvasImage.PixelHeight - y;
2780
            }
2781
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2782

    
2783
            string uri = "";
2784
            if (userData.COMPANY != "EXT")
2785
            {
2786
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO,
2787
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2788
            }
2789
            else
2790
            {
2791
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2792
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2793
            }
2794

    
2795
            var defaultBitmapImage = new BitmapImage();
2796
            defaultBitmapImage.BeginInit();
2797
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2798
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2799
            defaultBitmapImage.UriSource = new Uri(uri);
2800
            defaultBitmapImage.EndInit();
2801

    
2802
            //GC.Collect();
2803

    
2804
            if (defaultBitmapImage.IsDownloading)
2805
            {
2806
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2807
                {
2808
                    defaultBitmapImage.Freeze();
2809
                    //GC.Collect();
2810
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2811
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2812
                };
2813
            }
2814
        }
2815

    
2816
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2817
        {
2818
            mouseButtonDown = MouseButton.Left;
2819
        }
2820

    
2821
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2822
        {
2823
            mouseButtonDown = MouseButton.Left;
2824
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2825
        }
2826

    
2827
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2828
        {
2829

    
2830
        }
2831

    
2832
        /// <summary>
2833
        /// select items by dragging
2834
        /// </summary>
2835
        private void ApplyDragSelectionRect()
2836
        {
2837
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2838

    
2839
            double x = Canvas.GetLeft(dragSelectionBorder);
2840
            double y = Canvas.GetTop(dragSelectionBorder);
2841
            double width = dragSelectionBorder.Width;
2842
            double height = dragSelectionBorder.Height;
2843
            Rect dragRect = new Rect(x, y, width, height);
2844
            Boolean Flag = false;
2845
            dragRect.Inflate(width / 10, height / 10);
2846
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2847
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2848

    
2849
            dragRect = new Rect(x, y, width, height);
2850
            dragRect.Inflate(width / 10, height / 10);
2851

    
2852
            foreach (var item in Items)
2853
            {
2854
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2855

    
2856
                if (Flag)
2857
                {
2858
                    adornerSet.Add(item);
2859
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2860

    
2861
                    Control_Style(item);
2862
                }
2863
            }
2864
            if (adornerSet.Count > 0)
2865
            {
2866
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2867
                SelectLayer.Children.Add(final);
2868
            }
2869
        }
2870

    
2871
        private void InitDragSelectionRect(Point pt1, Point pt2)
2872
        {
2873
            //캡쳐 중
2874
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2875
            {
2876
                dragCaptureBorder.Visibility = Visibility.Visible;
2877
            }
2878
            //선택 중
2879
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2880
            {
2881

    
2882
                dragSelectionBorder.Visibility = Visibility.Visible;
2883
            }
2884
            else
2885
            {
2886
                dragZoomBorder.Visibility = Visibility.Visible;
2887
            }
2888
            UpdateDragSelectionRect(pt1, pt2);
2889
        }
2890

    
2891
        /// <summary>
2892
        /// Update the position and size of the rectangle used for drag selection.
2893
        /// </summary>
2894
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2895
        {
2896
            double x, y, width, height;
2897

    
2898
            //
2899
            // Determine x,y,width and height of the rect inverting the points if necessary.
2900
            // 
2901

    
2902
            if (pt2.X < pt1.X)
2903
            {
2904
                x = pt2.X;
2905
                width = pt1.X - pt2.X;
2906
            }
2907
            else
2908
            {
2909
                x = pt1.X;
2910
                width = pt2.X - pt1.X;
2911
            }
2912

    
2913
            if (pt2.Y < pt1.Y)
2914
            {
2915
                y = pt2.Y;
2916
                height = pt1.Y - pt2.Y;
2917
            }
2918
            else
2919
            {
2920
                y = pt1.Y;
2921
                height = pt2.Y - pt1.Y;
2922
            }
2923

    
2924
            //
2925
            // Update the coordinates of the rectangle used for drag selection.
2926
            //
2927
            //캡쳐 중
2928
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2929
            {
2930
                Canvas.SetLeft(dragCaptureBorder, x);
2931
                Canvas.SetTop(dragCaptureBorder, y);
2932
                dragCaptureBorder.Width = width;
2933
                dragCaptureBorder.Height = height;
2934
            }
2935
            //선택 중
2936
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2937
            {
2938
                Canvas.SetLeft(dragSelectionBorder, x);
2939
                Canvas.SetTop(dragSelectionBorder, y);
2940
                dragSelectionBorder.Width = width;
2941
                dragSelectionBorder.Height = height;
2942
            }
2943
            else
2944
            {
2945
                Canvas.SetLeft(dragZoomBorder, x);
2946
                Canvas.SetTop(dragZoomBorder, y);
2947
                dragZoomBorder.Width = width;
2948
                dragZoomBorder.Height = height;
2949
            }
2950
        }
2951

    
2952
        private void drawingPannelRotate(double angle)
2953
        {
2954
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2955
            rotate.Angle = angle;
2956
            var rotationNum = Math.Abs((rotate.Angle / 90));
2957

    
2958
            if (angle == 90 || angle == 270)
2959
            {
2960
                double emptySize = zoomAndPanCanvas.Width;
2961
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2962
                zoomAndPanCanvas.Height = emptySize;
2963
            }
2964
            if (angle == 0)
2965
            {
2966
                translate.X = 0;
2967
                translate.Y = 0;
2968
            }
2969
            else if (angle == 90)
2970
            {
2971
                translate.X = zoomAndPanCanvas.Width;
2972
                translate.Y = 0;
2973
            }
2974
            else if (angle == 180)
2975
            {
2976
                translate.X = zoomAndPanCanvas.Width;
2977
                translate.Y = zoomAndPanCanvas.Height;
2978
            }
2979
            else
2980
            {
2981
                translate.X = 0;
2982
                translate.Y = zoomAndPanCanvas.Height;
2983
            }
2984

    
2985
            zoomAndPanControl.RotationAngle = rotate.Angle;
2986

    
2987

    
2988
            if (!testPanel2.IsHidden)
2989
            {
2990
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2991
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2992
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2993
            }
2994

    
2995
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2996
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2997
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2998
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2999
            ViewerDataModel.Instance.Angle = rotate.Angle;
3000
        }
3001

    
3002
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3003
        {
3004
            string Data_ = "";
3005

    
3006
            try
3007
            {
3008
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3009
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3010
                if (Data_ != null || Data_ != "")
3011
                {
3012
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3013
                }
3014
                else
3015
                {
3016
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3017
                }
3018

    
3019
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
3020
                {
3021
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
3022
                    STATE = 0,
3023
                };
3024
                if (Data_ != null)
3025
                {
3026
                    Image img = new Image();
3027
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
3028
                    if (Data_.Contains(".svg"))
3029
                    {
3030
                        byte[] imageData = null;
3031
                        DrawingImage image = null;
3032
                        using (System.Net.WebClient web = new System.Net.WebClient())
3033
                        {
3034
                            imageData = web.DownloadData(new Uri(Data_));
3035
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3036
                            image = SvgReader.Load(stream);
3037
                        }
3038
                        img.Source = image;
3039
                    }
3040
                    else
3041
                    {
3042
                        img.Source = new BitmapImage(new Uri(Data_));
3043
                    }
3044

    
3045
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3046
                    {
3047
                        PointSet = new List<Point>(),
3048
                        FilePath = Data_,
3049
                        ImageData = img.Source,
3050
                        StartPoint = canvasZoomPanningMouseDownPoint,
3051
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3052
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3053
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3054
                        canvasZoomPanningMouseDownPoint.Y),
3055
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3056
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3057
                    };
3058

    
3059
                    currentControl.PointSet = new List<Point>
3060
                                        {
3061
                                            currentControl.StartPoint,
3062
                                            currentControl.LeftBottomPoint,
3063
                                            currentControl.EndPoint,
3064
                                            currentControl.TopRightPoint,
3065
                                        };
3066
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3067
                    UndoData = new Undo_data()
3068
                    {
3069
                        IsUndo = false,
3070
                        Event = Event_Type.Create,
3071
                        EventTime = DateTime.Now,
3072
                        Markup_List = new List<Multi_Undo_data>()
3073
                    };
3074
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3075
                    {
3076
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3077
                    });
3078

    
3079
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3080
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3081
                    UndoData.Markup_List.Add(multi_Undo_Data);
3082
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3083

    
3084
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3085
                    currentControl.CommentID = Commons.shortGuid();
3086
                    currentControl.SymbolID = id;
3087
                    currentControl.GroupID = group_id;
3088
                    currentControl.ApplyTemplate();
3089
                    currentControl.SetImage();
3090

    
3091
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3092
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3093
                    SelectLayer.Children.Add(final);
3094
                }
3095
            }
3096
            catch (Exception ex)
3097
            {
3098
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3099
            }
3100
        }
3101

    
3102
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3103
        {            
3104
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3105
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3106
            {
3107
                set_option.Value = double.Parse(set_option.ContentText);
3108
            }
3109

    
3110
            InkControl_Convert();
3111

    
3112
            ///TODO:
3113
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
3114
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
3115

    
3116
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3117
            {
3118
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3119
            }
3120
            /// up to here
3121

    
3122
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3123
            {
3124
                if (arrow_text as ArrowTextControl != null)
3125
                {
3126
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3127
                }
3128
            }
3129

    
3130
            mouseButtonDown = e.ChangedButton;
3131
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3132

    
3133
            //if (currentControl != null)
3134
            {
3135
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3136
                if (text_item_ != null)
3137
                {
3138
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3139
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3140
                    (text_item_ as TextControl).IsEditing = false;
3141
                    (text_item_ as TextControl).EnableEditing = false;
3142
                    currentControl = null;
3143
                }
3144

    
3145
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3146
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3147
                {
3148
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3149
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3150
                    currentControl = null;
3151
                }
3152
            }
3153

    
3154
            double Ang = 0;                                          
3155
            if (rotate.Angle != 0)
3156
            {
3157
                Ang = 360 - rotate.Angle;
3158
            }
3159

    
3160
            if (e.OriginalSource is System.Windows.Controls.Image)
3161
            {
3162
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3163
            }
3164

    
3165
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3166
            {                
3167
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3168
                //SetCursor();
3169

    
3170
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3171
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3172
                if(symbol_id != null)
3173
                {
3174
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3175
                }                
3176
            }
3177

    
3178
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3179
            {
3180
                if (this._dragdropWindow != null)
3181
                {
3182
                    this._dragdropWindow.Close();
3183
                    this._dragdropWindow = null;
3184
                    symbol_id = null;
3185
                }
3186
            }
3187

    
3188
            if (mouseButtonDown == MouseButton.Left)
3189
            {
3190
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3191
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3192

    
3193
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3194
                SetCursor();
3195

    
3196
                if (!ViewerDataModel.Instance.IsPressCtrl)
3197
                {
3198
                    SelectionSet.Instance.UnSelect(this);
3199
                }
3200
            }
3201
            if (mouseButtonDown == MouseButton.Middle)
3202
            {
3203
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3204
                cursor = Cursors.SizeAll;
3205
                SetCursor();
3206
            }
3207
            if (mouseButtonDown == MouseButton.Right)
3208
            {
3209
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3210
                cursor = Cursors.SizeAll;
3211
                SetCursor();
3212
            }
3213
            else if (mouseButtonDown == MouseButton.XButton1)
3214
            {
3215
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3216
                {
3217
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3218
                }
3219

    
3220
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3221

    
3222
            }
3223
            else if (mouseButtonDown == MouseButton.XButton2)
3224
            {
3225
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3226
                {
3227
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3228
                }
3229
            }
3230

    
3231
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3232
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3233
            {
3234
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3235
                {
3236
                    if (SelectLayer.Children.Count == 0)
3237
                    {
3238
                        isLeftMouseButtonDownOnWindow = true;
3239
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3240
                    }
3241

    
3242
                    if (controlType == ControlType.None)
3243
                    {
3244
                        isLeftMouseButtonDownOnWindow = true;
3245
                    }
3246
                }
3247

    
3248
                //캡쳐 모드 설정
3249
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3250
                {
3251
                    dragCaptureBorder.Visibility = Visibility.Visible;
3252
                    isLeftMouseButtonDownOnWindow = true;
3253
                }
3254

    
3255
                //줌 모드 설정
3256
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3257
                {
3258
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3259
                    isLeftMouseButtonDownOnWindow = true;
3260
                }               
3261

    
3262
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3263
                if (control != null)
3264
                {
3265
                    AdornerFinal final = null;
3266

    
3267
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3268
                    {
3269
                        /// 기존 selection 해제
3270
                        SelectionSet.Instance.UnSelect(this);
3271

    
3272
                        final = new AdornerFinal(control);
3273

    
3274
                        Control_Style(control);
3275

    
3276
                        if ((control as IPath) != null)
3277
                        {
3278
                            if ((control as IPath).LineSize != 0)
3279
                            {
3280
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3281
                            }
3282
                        }
3283
                        if ((control as IShapeControl) != null)
3284
                        {
3285
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3286
                            {
3287
                                ViewerDataModel.Instance.checkHatchShape = true;
3288
                            }
3289
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3290
                            {
3291
                                ViewerDataModel.Instance.checkFillShape = true;
3292
                            }
3293
                            else
3294
                            {
3295
                                ViewerDataModel.Instance.checkHatchShape = false;
3296
                                ViewerDataModel.Instance.checkFillShape = false;
3297
                            }
3298
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3299
                        }
3300

    
3301
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3302

    
3303
                        if ((control as TextControl) != null)
3304
                        {
3305
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3306
                            {
3307
                                ViewerDataModel.Instance.checkTextStyle = true;
3308
                            }
3309
                            else
3310
                            {
3311
                                ViewerDataModel.Instance.checkTextStyle = false;
3312
                            }
3313

    
3314
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3315
                            {
3316
                                ViewerDataModel.Instance.checkTextStyle = true;
3317
                            }
3318
                            else
3319
                            {
3320
                                ViewerDataModel.Instance.checkTextStyle = false;
3321
                            }
3322
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3323
                            {
3324
                                ViewerDataModel.Instance.checkTextWeight = true;
3325
                            }
3326
                            else
3327
                            {
3328
                                ViewerDataModel.Instance.checkTextWeight = false;
3329
                            }
3330
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3331
                            {
3332
                                ViewerDataModel.Instance.checkUnderLine = true;
3333
                            }
3334
                            else
3335
                            {
3336
                                ViewerDataModel.Instance.checkUnderLine = false;
3337
                            }
3338
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3339
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3340

    
3341
                        }
3342
                        else if ((control as ArrowTextControl) != null)
3343
                        {
3344
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3345
                            {
3346
                                ViewerDataModel.Instance.checkTextStyle = true;
3347
                            }
3348
                            else
3349
                            {
3350
                                ViewerDataModel.Instance.checkTextStyle = false;
3351
                            }
3352

    
3353
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3354
                            {
3355
                                ViewerDataModel.Instance.checkTextStyle = true;
3356
                            }
3357
                            else
3358
                            {
3359
                                ViewerDataModel.Instance.checkTextStyle = false;
3360
                            }
3361
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3362
                            {
3363
                                ViewerDataModel.Instance.checkTextWeight = true;
3364
                            }
3365
                            else
3366
                            {
3367
                                ViewerDataModel.Instance.checkTextWeight = false;
3368
                            }
3369
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3370
                            {
3371
                                ViewerDataModel.Instance.checkUnderLine = true;
3372
                            }
3373
                            else
3374
                            {
3375
                                ViewerDataModel.Instance.checkUnderLine = false;
3376
                            }
3377
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3378
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3379
                        }
3380
                        else if ((control as RectCloudControl) != null)
3381
                        {
3382
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3383
                        }
3384
                        else if ((control as CloudControl) != null)
3385
                        {
3386
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3387
                        }
3388
                    }
3389
                    else
3390
                    {
3391
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3392
                        SelectionSet.Instance.UnSelect(this);
3393
                        comment.Add(control);
3394

    
3395
                        Control_Style(control);
3396

    
3397
                        final = new AdornerFinal(comment);
3398
                    }
3399

    
3400
                    if(final != null) this.SelectLayer.Children.Add(final);
3401
                }              
3402
            }
3403
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3404
            {               
3405
                init();
3406
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3407
                if (cursor != Cursors.SizeAll)
3408
                {
3409
                    cursor = Cursors.Cross;
3410
                    SetCursor();
3411
                }
3412
                bool init_user = false;
3413
                foreach (var user in gridViewMarkup.Items)
3414
                {
3415
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3416
                    {
3417
                        init_user = true;
3418
                    }
3419
                }
3420
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3421
                {
3422
                    RadWindow.Alert(new DialogParameters
3423
                    {
3424
                        Owner = Application.Current.MainWindow,
3425
                        Theme = new VisualStudio2013Theme(),
3426
                        Header = "안내",
3427
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3428
                    });
3429
                    return;
3430
                }
3431
                else
3432
                {
3433
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3434
                    if (item != null)
3435
                    {
3436
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3437
                    }
3438
                }
3439

    
3440
                multi_Undo_Data = new Multi_Undo_data();
3441
                //강인구 Undo/Redo 보류
3442
                UndoData = new Undo_data()
3443
                {
3444
                    IsUndo = false,
3445
                    Event = Event_Type.Create,
3446
                    EventTime = DateTime.Now,
3447
                    Markup_List = new List<Multi_Undo_data>()
3448
                };
3449

    
3450
                switch (controlType)
3451
                {
3452
                    case ControlType.Coordinate:
3453
                        {
3454
                            if (mouseButtonDown == MouseButton.Left)
3455
                            {
3456
                                if (currentControl is CoordinateControl)
3457
                                {
3458
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3459
                                    {
3460
                                        return;
3461
                                    }
3462

    
3463
                                    CreateControl();
3464

    
3465
                                    (currentControl as CoordinateControl).ApplyOverViewData();
3466
                                    currentControl = null;
3467
                                    this.cursor = Cursors.Arrow;
3468
                                }
3469
                                else
3470
                                {
3471
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3472
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3473
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3474
                                    {
3475
                                        currentControl = null;
3476
                                        this.cursor = Cursors.Arrow;
3477
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3478
                                        return;
3479
                                    }
3480
                                    else
3481
                                    {
3482
                                        currentControl = new CoordinateControl
3483
                                        {
3484
                                            Background = new SolidColorBrush(Colors.Black),
3485
                                            ControlType = ControlType.Coordinate
3486
                                        };
3487

    
3488
                                        currentControl.CommentID = Commons.shortGuid();
3489
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3490
                                        currentControl.IsNew = true;
3491

    
3492
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3493

    
3494
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3495
                                    }
3496
                                }
3497
                            }
3498
                        }
3499
                        break;
3500
                    case ControlType.InsideWhite:
3501
                        {
3502
                            if (mouseButtonDown == MouseButton.Left)
3503
                            {
3504
                                if (currentControl is InsideWhiteControl)
3505
                                {
3506
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3507
                                    {
3508
                                        return;
3509
                                    }
3510

    
3511
                                    CreateControl();
3512

    
3513
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3514
                                    currentControl = null;
3515
                                    this.cursor = Cursors.Arrow;
3516
                                }
3517
                                else
3518
                                {
3519
                                    currentControl = new InsideWhiteControl
3520
                                    {
3521
                                        Background = new SolidColorBrush(Colors.Black),
3522
                                        ControlType = ControlType.InsideWhite
3523
                                    };
3524

    
3525
                                    currentControl.CommentID = Commons.shortGuid();
3526
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3527
                                    currentControl.IsNew = true;
3528
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529

    
3530
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3531
                                }
3532
                            }
3533
                        }
3534
                        break;
3535
                    case ControlType.OverlapWhite:
3536
                        {
3537
                            if (mouseButtonDown == MouseButton.Left)
3538
                            {
3539
                                if (currentControl is OverlapWhiteControl)
3540
                                {
3541
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3542
                                    {
3543
                                        return;
3544
                                    }
3545

    
3546
                                    CreateControl();
3547

    
3548
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3549
                                    currentControl = null;
3550
                                    this.cursor = Cursors.Arrow;
3551
                                }
3552
                                else
3553
                                {
3554
                                    currentControl = new OverlapWhiteControl
3555
                                    {
3556
                                        Background = new SolidColorBrush(Colors.Black),
3557
                                        ControlType = ControlType.OverlapWhite
3558
                                    };
3559

    
3560
                                    currentControl.CommentID = Commons.shortGuid();
3561
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3562
                                    currentControl.IsNew = true;
3563
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3564

    
3565
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3566
                                }
3567
                            }
3568
                        }
3569
                        break;
3570
                    case ControlType.ClipWhite:
3571
                        {
3572
                            if (mouseButtonDown == MouseButton.Left)
3573
                            {
3574
                                if (currentControl is ClipWhiteControl)
3575
                                {
3576
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3577
                                    {
3578
                                        return;
3579
                                    }
3580

    
3581
                                    CreateControl();
3582

    
3583
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
3584
                                    currentControl = null;
3585
                                    this.cursor = Cursors.Arrow;
3586
                                }
3587
                                else
3588
                                {
3589
                                    currentControl = new ClipWhiteControl
3590
                                    {
3591
                                        Background = new SolidColorBrush(Colors.Black),
3592
                                        ControlType = ControlType.ClipWhite
3593
                                    };
3594

    
3595
                                    currentControl.CommentID = Commons.shortGuid();
3596
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3597
                                    currentControl.IsNew = true;
3598
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3599

    
3600
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3601
                                }
3602
                            }
3603
                        }
3604
                        break;
3605
                    case ControlType.Rectangle:
3606
                        {
3607
                            if (mouseButtonDown == MouseButton.Left)
3608
                            {
3609
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3610
                                //{
3611
                                    if (currentControl is RectangleControl)
3612
                                    {
3613
                                        //20180906 LJY TEST IsRotationDrawingEnable
3614
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3615
                                        {
3616
                                            return;
3617
                                        }
3618

    
3619
                                        CreateControl();
3620

    
3621
                                        (currentControl as RectangleControl).ApplyOverViewData();
3622
                                        currentControl = null;
3623
                                    
3624
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3625
                                    }
3626
                                    else
3627
                                    {
3628
                                        currentControl = new RectangleControl
3629
                                        {
3630
                                            Background = new SolidColorBrush(Colors.Black),
3631
                                            ControlType = ControlType.Rectangle
3632
                                        };
3633

    
3634
                                        currentControl.CommentID = Commons.shortGuid();
3635
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3636
                                        currentControl.IsNew = true;
3637
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3638

    
3639
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3640
                                    }
3641
                                //}
3642
                            }
3643
                        }
3644
                        break;
3645
                    case ControlType.RectCloud:
3646
                        {
3647
                            if (mouseButtonDown == MouseButton.Left)
3648
                            {
3649
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3650
                                //{
3651
                                    if (currentControl is RectCloudControl)
3652
                                    {
3653
                                        //20180906 LJY TEST IsRotationDrawingEnable
3654
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3655
                                        {
3656
                                            return;
3657
                                        }
3658

    
3659
                                        CreateControl();
3660

    
3661
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3662
                                        currentControl = null;
3663
                                    
3664
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3665
                                    }
3666
                                    else
3667
                                    {
3668
                                        currentControl = new RectCloudControl
3669
                                        {
3670
                                            Background = new SolidColorBrush(Colors.Black)
3671
                                        };
3672

    
3673
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3674
                                        currentControl.CommentID = Commons.shortGuid();
3675
                                        currentControl.IsNew = true;
3676
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3677
                                    }
3678
                                //}
3679
                            }
3680
                        }
3681
                        break;
3682
                    case ControlType.Circle:
3683
                        {
3684
                            if (mouseButtonDown == MouseButton.Left)
3685
                            {
3686
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3687
                                //{
3688
                                    if (currentControl is CircleControl)
3689
                                    {
3690
                                        //20180906 LJY TEST IsRotationDrawingEnable
3691
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3692
                                        {
3693
                                            return;
3694
                                        }
3695

    
3696
                                        CreateControl();
3697

    
3698
                                        (currentControl as CircleControl).ApplyOverViewData();
3699
                                        currentControl = null;
3700
                                    }
3701
                                    else
3702
                                    {
3703
                                        currentControl = new CircleControl
3704
                                        {
3705
                                            Background = new SolidColorBrush(Colors.Black)
3706
                                        };
3707

    
3708
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3709
                                        currentControl.CommentID = Commons.shortGuid();
3710
                                        currentControl.IsNew = true;
3711
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3712
                                    }
3713
                                //}
3714
                            }
3715
                        }
3716
                        break;
3717
                    case ControlType.Triangle:
3718
                        {
3719
                            if (mouseButtonDown == MouseButton.Left)
3720
                            {
3721
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3722
                                //{
3723
                                    if (currentControl is TriControl)
3724
                                    {
3725
                                        var content = currentControl as TriControl;
3726
                                        if (content.MidPoint == new Point(0, 0))
3727
                                        {
3728
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3729
                                        }
3730
                                        else
3731
                                        {
3732
                                            //20180906 LJY TEST IsRotationDrawingEnable
3733
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3734
                                            {
3735
                                                return;
3736
                                            }
3737

    
3738
                                            CreateControl();
3739

    
3740
                                            (currentControl as TriControl).ApplyOverViewData();
3741
                                            currentControl = null;
3742
                                        }
3743
                                    }
3744
                                    else
3745
                                    {
3746
                                        currentControl = new TriControl
3747
                                        {
3748
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3749
                                            Background = new SolidColorBrush(Colors.Black),
3750
                                        };
3751

    
3752
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3753
                                        currentControl.CommentID = Commons.shortGuid();
3754
                                        currentControl.IsNew = true;
3755
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3756
                                    }
3757
                                //}
3758
                            }
3759
                        }
3760
                        break;
3761
                    case ControlType.SingleLine:
3762
                        {
3763
                            if (mouseButtonDown == MouseButton.Left)
3764
                            {
3765
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3766
                                //{
3767
                                    if (currentControl is LineControl)
3768
                                    {
3769
                                        //20180906 LJY TEST IsRotationDrawingEnable
3770
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3771
                                        {
3772
                                            return;
3773
                                        }
3774

    
3775
                                        CreateControl();
3776

    
3777
                                        (currentControl as LineControl).ApplyOverViewData();
3778
                                        currentControl = null;
3779
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3780
                                    }
3781
                                    else
3782
                                    {
3783
                                        currentControl = new LineControl
3784
                                        {
3785
                                            Background = new SolidColorBrush(Colors.Black)
3786
                                        };
3787

    
3788
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3789
                                        currentControl.CommentID = Commons.shortGuid();
3790
                                        currentControl.IsNew = true;
3791
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3792
                                        this.MainAngle.Visibility = Visibility.Visible;
3793
                                    }
3794
                                //}
3795
                            }
3796
                        }
3797
                        break;
3798
                    case ControlType.CancelLine:
3799
                        {
3800
                            if (mouseButtonDown == MouseButton.Left)
3801
                            {
3802
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3803
                                //{
3804
                                    if (currentControl is LineControl)
3805
                                    {
3806
                                        //20180906 LJY TEST IsRotationDrawingEnable
3807
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3808
                                        {
3809
                                            return;
3810
                                        }
3811

    
3812
                                        CreateControl();
3813

    
3814
                                        (currentControl as LineControl).ApplyOverViewData();
3815
                                        currentControl = null;
3816
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3817
                                    }
3818
                                    else
3819
                                    {
3820
                                        currentControl = new LineControl
3821
                                        {
3822
                                            Background = new SolidColorBrush(Colors.Black)
3823
                                        };
3824

    
3825
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3826
                                        currentControl.CommentID = Commons.shortGuid();
3827
                                        currentControl.IsNew = true;
3828
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3829
                                        this.MainAngle.Visibility = Visibility.Visible;
3830
                                    }
3831
                                //}
3832
                            }
3833
                        }
3834
                        break;
3835
                    case ControlType.ArrowLine:
3836
                        {
3837
                            if (mouseButtonDown == MouseButton.Left)
3838
                            {
3839
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3840
                                //{
3841
                                    if (currentControl is LineControl)
3842
                                    {
3843
                                        //20180906 LJY TEST IsRotationDrawingEnable
3844
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3845
                                        {
3846
                                            return;
3847
                                        }
3848

    
3849
                                        CreateControl();
3850

    
3851
                                        (currentControl as LineControl).ApplyOverViewData();
3852
                                        currentControl = null;
3853
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3854
                                    }
3855
                                    else
3856
                                    {
3857
                                        currentControl = new LineControl
3858
                                        {
3859
                                            Background = new SolidColorBrush(Colors.Black)
3860
                                        };
3861

    
3862
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3863
                                        currentControl.CommentID = Commons.shortGuid();
3864
                                        currentControl.IsNew = true;
3865
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3866
                                        this.MainAngle.Visibility = Visibility.Visible;
3867
                                    }
3868
                                //}
3869
                            }
3870
                        }
3871
                        break;
3872
                    case ControlType.TwinLine:
3873
                        {
3874
                            if (mouseButtonDown == MouseButton.Left)
3875
                            {
3876
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3877
                                //{
3878
                                    if (currentControl is LineControl)
3879
                                    {
3880
                                        //20180906 LJY TEST IsRotationDrawingEnable
3881
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3882
                                        {
3883
                                            return;
3884
                                        }
3885

    
3886
                                        CreateControl();
3887

    
3888
                                        (currentControl as LineControl).ApplyOverViewData();
3889
                                        currentControl = null;
3890
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3891
                                    }
3892
                                    else
3893
                                    {
3894
                                        currentControl = new LineControl
3895
                                        {
3896
                                            Background = new SolidColorBrush(Colors.Black)
3897
                                        };
3898
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3899
                                        currentControl.CommentID = Commons.shortGuid();
3900
                                        currentControl.IsNew = true;
3901
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3902
                                        this.MainAngle.Visibility = Visibility.Visible;
3903
                                    }
3904
                                //}
3905
                            }
3906
                        }
3907
                        break;
3908
                    case ControlType.DimLine:
3909
                        {
3910
                            if (mouseButtonDown == MouseButton.Left)
3911
                            {
3912
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3913
                                //{
3914
                                    if (currentControl is LineControl)
3915
                                    {
3916
                                        //20180906 LJY TEST IsRotationDrawingEnable
3917
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3918
                                        {
3919
                                            return;
3920
                                        }
3921
                                        CreateControl();
3922

    
3923
                                        (currentControl as LineControl).ApplyOverViewData();
3924
                                        currentControl = null;
3925
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3926
                                    }
3927
                                    else
3928
                                    {
3929
                                        currentControl = new LineControl
3930
                                        {
3931
                                            Background = new SolidColorBrush(Colors.Black)
3932
                                        };
3933
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3934
                                        currentControl.CommentID = Commons.shortGuid();
3935
                                        currentControl.IsNew = true;
3936
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3937
                                        this.MainAngle.Visibility = Visibility.Visible;
3938
                                    }
3939
                                //}
3940
                            }
3941
                        }
3942
                        break;
3943
                    case ControlType.ChainLine:
3944
                        {
3945
                            if (currentControl is PolygonControl)
3946
                            {
3947
                                var control = currentControl as PolygonControl;
3948

    
3949
                                if (mouseButtonDown == MouseButton.Right)
3950
                                {
3951
                                    //20180906 LJY TEST IsRotationDrawingEnable
3952
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3953
                                    {
3954
                                        return;
3955
                                    }
3956

    
3957
                                    CreateControl();
3958

    
3959
                                    (currentControl as PolygonControl).ApplyOverViewData();
3960
                                    currentControl = null;
3961
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3962
                                    return;
3963
                                }
3964

    
3965
                                if (!control.IsCompleted)
3966
                                {
3967
                                    control.PointSet.Add(control.EndPoint);
3968
                                    this.MainAngle.Visibility = Visibility.Visible;
3969
                                }
3970
                            }
3971
                            else
3972
                            {
3973
                                if (mouseButtonDown == MouseButton.Left)
3974
                                {
3975
                                    MainAngle.Visibility = Visibility.Visible;
3976
                                    currentControl = new PolygonControl
3977
                                    {
3978
                                        PointSet = new List<Point>(),
3979
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3980
                                        ControlType = ControlType.ChainLine,
3981
                                        DashSize = ViewerDataModel.Instance.DashSize,
3982
                                        LineSize = ViewerDataModel.Instance.LineSize,
3983
                                        //PointC = new StylusPointSet()
3984
                                    };
3985

    
3986
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3987
                                    //{
3988
                                        var polygonControl = (currentControl as PolygonControl);
3989
                                        currentControl.CommentID = Commons.shortGuid();
3990
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3991
                                        currentControl.IsNew = true;
3992
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3993
                                        //currentControl.OnApplyTemplate();
3994
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3995
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3996
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3997
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3998
                                    //}
3999
                                }
4000
                            }
4001
                        }
4002
                        break;
4003
                    case ControlType.ArcLine:
4004
                        {
4005
                            if (mouseButtonDown == MouseButton.Left)
4006
                            {
4007
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4008
                                //{
4009
                                    if (currentControl is ArcControl)
4010
                                    {
4011
                                        //20180906 LJY TEST IsRotationDrawingEnable
4012
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4013
                                        {
4014
                                            return;
4015
                                        }
4016

    
4017
                                        CreateControl();
4018

    
4019
                                        (currentControl as ArcControl).ApplyOverViewData();
4020
                                        currentControl = null;
4021
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4022
                                    }
4023
                                    else
4024
                                    {
4025
                                        currentControl = new ArcControl
4026
                                        {
4027
                                            Background = new SolidColorBrush(Colors.Black)
4028
                                        };
4029
                                        currentControl.CommentID = Commons.shortGuid();
4030
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4031
                                        currentControl.IsNew = true;
4032
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4033
                                        this.MainAngle.Visibility = Visibility.Visible;
4034
                                    }
4035
                                //}
4036
                            }
4037
                            else if (mouseButtonDown == MouseButton.Right)
4038
                            {
4039
                                if (currentControl != null)
4040
                                {
4041
                                    (currentControl as ArcControl).setClock();
4042
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
4043
                                    //(currentControl as ArcControl).ApplyTemplate();
4044
                                }
4045
                            }
4046
                        }
4047
                        break;
4048
                    case ControlType.ArcArrow:
4049
                        {
4050
                            if (mouseButtonDown == MouseButton.Left)
4051
                            {
4052
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4053
                                //{
4054
                                if (currentControl is ArrowArcControl)
4055
                                {
4056
                                    //20180906 LJY TEST IsRotationDrawingEnable
4057
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4058
                                    {
4059
                                        return;
4060
                                    }
4061

    
4062
                                    CreateControl();
4063

    
4064
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
4065
                                    currentControl = null;
4066
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4067
                                }
4068
                                else
4069
                                {
4070
                                    currentControl = new ArrowArcControl
4071
                                    {
4072
                                        Background = new SolidColorBrush(Colors.Black)
4073
                                    };
4074
                                    currentControl.CommentID = Commons.shortGuid();
4075
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4076
                                    currentControl.IsNew = true;
4077
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4078
                                    this.MainAngle.Visibility = Visibility.Visible;
4079
                                }
4080
                                //}
4081
                            }
4082
                            else if (mouseButtonDown == MouseButton.Right)
4083
                            {
4084
                                if (currentControl != null)
4085
                                {
4086
                                    (currentControl as ArrowArcControl).setClock();
4087
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
4088
                                    //(currentControl as ArcControl).ApplyTemplate();
4089
                                }
4090
                            }
4091
                        }
4092
                        break;
4093
                    case ControlType.ArrowMultiLine:
4094
                        {
4095
                            if (mouseButtonDown == MouseButton.Left)
4096
                            {
4097
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4098
                                //{
4099

    
4100
                                    if (currentControl is ArrowControl_Multi)
4101
                                    {
4102
                                        var content = currentControl as ArrowControl_Multi;
4103
                                        if (content.MiddlePoint == new Point(0, 0))
4104
                                        {
4105
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
4106
                                            {
4107
                                                content.MiddlePoint = content.EndPoint;
4108
                                            }
4109
                                            else
4110
                                            {
4111
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4112
                                            }
4113
                                        }
4114
                                        else
4115
                                        {
4116
                                            //20180906 LJY TEST IsRotationDrawingEnable
4117
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4118
                                            {
4119
                                                return;
4120
                                            }
4121

    
4122
                                            CreateControl();
4123

    
4124
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
4125
                                            currentControl = null;
4126
                                            this.MainAngle.Visibility = Visibility.Collapsed;
4127
                                        }
4128
                                    }
4129
                                    else
4130
                                    {
4131
                                        currentControl = new ArrowControl_Multi
4132
                                        {
4133
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4134
                                            Background = new SolidColorBrush(Colors.Black)
4135
                                        };
4136
                                        currentControl.CommentID = Commons.shortGuid();
4137
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4138
                                        currentControl.IsNew = true;
4139
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4140
                                        this.MainAngle.Visibility = Visibility.Visible;
4141
                                    }
4142
                                //}
4143
                            }
4144
                        }
4145
                        break;
4146
                    case ControlType.PolygonCloud:
4147
                        {
4148
                            if (currentControl is CloudControl)
4149
                            {
4150
                                var control = currentControl as CloudControl;
4151
                                if (mouseButtonDown == MouseButton.Right)
4152
                                {
4153
                                    control.IsCompleted = true;
4154
                                }
4155

    
4156
                                if (!control.IsCompleted)
4157
                                {
4158
                                    control.PointSet.Add(control.EndPoint);
4159
                                }
4160
                                else
4161
                                {
4162
                                    //20180906 LJY TEST IsRotationDrawingEnable
4163
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4164
                                    {
4165
                                        return;
4166
                                    }
4167

    
4168
                                    CreateControl();
4169

    
4170
                                    control.isTransOn = true;
4171
                                    var firstPoint = control.PointSet.First();
4172

    
4173
                                    control.PointSet.Add(firstPoint);
4174
                                    control.DrawingCloud();
4175
                                    control.ApplyOverViewData();
4176

    
4177
                                    currentControl = null;
4178
                                }
4179
                            }
4180
                            else
4181
                            {
4182
                                if (mouseButtonDown == MouseButton.Left)
4183
                                {
4184
                                    currentControl = new CloudControl
4185
                                    {
4186
                                        PointSet = new List<Point>(),
4187
                                        PointC = new StylusPointSet()
4188
                                    };
4189

    
4190
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4191
                                    //{
4192
                                        var polygonControl = (currentControl as CloudControl);
4193
                                        currentControl.CommentID = Commons.shortGuid();
4194
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4195
                                        currentControl.IsNew = true;
4196
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4197

    
4198
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4199
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4200
                                    
4201
                                    //}
4202
                                }
4203
                            }
4204
                        }
4205
                        break;
4206
                    case ControlType.ImgControl:
4207
                        {
4208
                            if (mouseButtonDown == MouseButton.Left)
4209
                            {
4210
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4211
                                //{
4212
                                    if (currentControl is ImgControl)
4213
                                    {
4214
                                        //20180906 LJY TEST IsRotationDrawingEnable
4215
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4216
                                        {
4217
                                            return;
4218
                                        }
4219

    
4220
                                        CreateControl();
4221
                                        (currentControl as ImgControl).ApplyOverViewData();
4222
                                        controlType = ControlType.ImgControl;
4223
                                        currentControl = null;
4224
                                    }
4225
                                    else
4226
                                    {
4227
                                        
4228
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4229
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4230
                                        {
4231
                                            Image img = new Image();
4232
                                            //img.Source = new BitmapImage(new Uri(filename));
4233
                                            if (filename.Contains(".svg"))
4234
                                            {
4235
                                                byte[] imageData = null;
4236
                                                DrawingImage image = null;
4237
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4238
                                                {
4239
                                                    imageData = web.DownloadData(new Uri(filename));
4240
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4241
                                                    image = SvgReader.Load(stream);
4242
                                                }
4243
                                                img.Source = image;
4244
                                            }
4245
                                            else
4246
                                            {
4247
                                                img.Source = new BitmapImage(new Uri(filename));
4248
                                            }
4249

    
4250
                                            currentControl = new ImgControl
4251
                                            {
4252
                                                    Background = new SolidColorBrush(Colors.Black),
4253
                                                    PointSet = new List<Point>(),
4254
                                                    FilePath = filename,
4255
                                                    ImageData = img.Source,
4256
                                                    StartPoint = canvasDrawingMouseDownPoint,
4257
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4258
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4259
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4260
                                                    ControlType = ControlType.ImgControl
4261
                                                };
4262

    
4263
                                        
4264
                                                currentControl.CommentID = Commons.shortGuid();                                            
4265
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4266
                                                currentControl.IsNew = true;
4267
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4268

    
4269
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4270
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4271
                                        }
4272
                                    }
4273
                                //}
4274
                            }
4275
                        }
4276
                        break;
4277
                    case ControlType.Date:
4278
                        {
4279
                            if (mouseButtonDown == MouseButton.Left)
4280
                            {
4281
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4282
                                //{
4283
                                    if (currentControl is DateControl)
4284
                                    {
4285
                                        //20180906 LJY TEST IsRotationDrawingEnable
4286
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4287
                                        {
4288
                                            return;
4289
                                        }
4290

    
4291
                                        CreateControl();
4292
                                        (currentControl as DateControl).ApplyOverViewData();
4293
                                        currentControl = null;
4294

    
4295
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4296
                                        {
4297
                                            controlType = ControlType.None;
4298
                                            IsSwingMode = false;
4299
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4300
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4301
                                            mouseHandlingMode = MouseHandlingMode.None;
4302
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4303
                                            txtBatch.Visibility = Visibility.Collapsed;
4304

    
4305
                                        }
4306
                                    }
4307
                                    else
4308
                                    {
4309
                                        currentControl = new DateControl
4310
                                        {
4311
                                            Background = new SolidColorBrush(Colors.Black)
4312
                                        };
4313
                                        currentControl.CommentID = Commons.shortGuid();
4314
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4315
                                        currentControl.IsNew = true;
4316
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4317

    
4318
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4319
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4320
                                }
4321
                                //}
4322
                            }
4323
                        }
4324
                        break;
4325
                    case ControlType.TextControl:
4326
                        {
4327
                            if (mouseButtonDown == MouseButton.Left)
4328
                            {
4329
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4330
                                {
4331
                                    currentControl = new TextControl
4332
                                    {
4333
                                        ControlType = controlType
4334
                                    };
4335
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4336
                                    currentControl.CommentID = Commons.shortGuid();
4337
                                    currentControl.IsNew = true;
4338
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4339
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4340
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4341
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4342
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4343
                                    
4344
                                    (currentControl as TextControl).ControlType_No = 0;
4345
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4346
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4347
                                    (currentControl as TextControl).ApplyTemplate();
4348
                                    (currentControl as TextControl).Base_TextBox.Focus();
4349

    
4350
                                    CreateControl();
4351

    
4352
                                }
4353
                            }
4354
                        }
4355
                        break;
4356
                    case ControlType.TextBorder:
4357
                        {
4358
                            if (mouseButtonDown == MouseButton.Left)
4359
                            {
4360
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4361
                                {
4362
                                    currentControl = new TextControl
4363
                                    {
4364
                                        ControlType = controlType
4365
                                    };
4366

    
4367
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4368
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4369
                                    currentControl.CommentID = Commons.shortGuid();
4370
                                    currentControl.IsNew = true;
4371
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4372
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4373
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4374
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4375
                                    
4376
                                    (currentControl as TextControl).ControlType_No = 1;
4377
                                    (currentControl as TextControl).Angle = Ang;
4378
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4379
                                    (currentControl as TextControl).ApplyTemplate();
4380
                                    (currentControl as TextControl).Base_TextBox.Focus();
4381
                                    CreateControl();
4382

    
4383
                                    //currentControl = null;
4384
                                }
4385
                            }
4386
                        }
4387
                        break;
4388
                    case ControlType.TextCloud:
4389
                        {
4390
                            if (mouseButtonDown == MouseButton.Left)
4391
                            {
4392
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4393
                                {
4394
                                    currentControl = new TextControl
4395
                                    {
4396
                                        ControlType = controlType
4397
                                    };
4398

    
4399
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4400
                                    currentControl.CommentID = Commons.shortGuid();
4401
                                    currentControl.IsNew = true;
4402
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4403
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4404

    
4405
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4406
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4407
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4408

    
4409
                                    (currentControl as TextControl).Angle = Ang;
4410
                                    (currentControl as TextControl).ControlType_No = 2;
4411
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4412
                                    (currentControl as TextControl).ApplyTemplate();
4413
                                    (currentControl as TextControl).Base_TextBox.Focus();
4414
                                    CreateControl();
4415
                                    //currentControl = null;
4416
                                }
4417
                            }
4418
                        }
4419
                        break;
4420
                    case ControlType.ArrowTextControl:
4421
                         {
4422
                            if (mouseButtonDown == MouseButton.Left)
4423
                            {
4424
                                if (currentControl is ArrowTextControl)
4425
                                {
4426
                                    //20180906 LJY TEST IsRotationDrawingEnable
4427
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4428
                                    {
4429
                                        return;
4430
                                    }                                    
4431

    
4432
                                    CreateControl();
4433

    
4434
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4435
                                    (currentControl as ArrowTextControl).IsEditing = false;
4436
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4437
                                    (currentControl as ArrowTextControl).IsNew = false;
4438
                                    currentControl = null;
4439
                                }
4440
                                else
4441
                                {
4442
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4443
                                    //{
4444
                                        currentControl = new ArrowTextControl();
4445
                                        currentControl.CommentID = Commons.shortGuid();
4446
                                        currentControl.IsNew = true;
4447
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4448
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4449

    
4450
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4451
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4452
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4453
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4454
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4455

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

    
4459
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4460
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4461
                                        this.MainAngle.Visibility = Visibility.Visible;
4462

    
4463
                                    
4464
                                    //}
4465
                                }
4466
                            }
4467
                        }
4468
                        break;
4469
                    case ControlType.ArrowTransTextControl:
4470
                        {
4471
                            if (mouseButtonDown == MouseButton.Left)
4472
                            {
4473
                                if (currentControl is ArrowTextControl)
4474
                                {
4475
                                    //20180906 LJY TEST IsRotationDrawingEnable
4476
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4477
                                    {
4478
                                        return;
4479
                                    }                                    
4480

    
4481
                                    CreateControl();
4482
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4483
                                    currentControl.IsNew = false;
4484
                                    currentControl = null;
4485
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4486
                                }
4487
                                else
4488
                                {
4489
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4490
                                    //{
4491
                                         currentControl = new ArrowTextControl();
4492
                                        currentControl.CommentID = Commons.shortGuid();
4493
                                        currentControl.IsNew = true;
4494
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4495
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4496
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4497
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4498
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4499
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4500
                                        (currentControl as ArrowTextControl).isFixed = true;
4501
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4502

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

    
4506
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4507
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4508
                                        (currentControl as ArrowTextControl).isTrans = true;
4509
                                }
4510
                            }
4511
                        }
4512
                        break;
4513
                    case ControlType.ArrowTextBorderControl:
4514
                         {
4515
                            if (mouseButtonDown == MouseButton.Left)
4516
                            {
4517
                                if (currentControl is ArrowTextControl)
4518
                                {
4519
                                    //20180906 LJY TEST IsRotationDrawingEnable
4520
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4521
                                    {
4522
                                        return;
4523
                                    }
4524

    
4525
                                    CreateControl();
4526
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4527
                                    currentControl.IsNew = false;
4528
                                    currentControl = null;
4529
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4530
                                }
4531
                                else
4532
                                {
4533
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4534
                                    //{
4535
                                        currentControl = new ArrowTextControl()
4536
                                        {
4537
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4538
                                        };
4539
                                        currentControl.CommentID = Commons.shortGuid();
4540
                                        currentControl.IsNew = true;
4541
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4542
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4543

    
4544
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4545

    
4546
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4547

    
4548
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4549
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4550
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4551

    
4552
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4553
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4554
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4555
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4556
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4557
                                    //}
4558
                                }
4559
                            }
4560
                        }
4561
                        break;
4562
                    case ControlType.ArrowTransTextBorderControl:
4563
                        {
4564
                            if (mouseButtonDown == MouseButton.Left)
4565
                            {
4566
                                if (currentControl is ArrowTextControl)
4567
                                {
4568
                                    //20180906 LJY TEST IsRotationDrawingEnable
4569
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4570
                                    {
4571
                                        return;
4572
                                    }
4573
                                    CreateControl();
4574
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4575
                                    currentControl.IsNew = false;
4576
                                    currentControl = null;
4577
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4578
                                }
4579
                                else
4580
                                {
4581
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4582
                                    //{
4583
                                    
4584

    
4585
                                    currentControl = new ArrowTextControl()
4586
                                        {
4587
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4588
                                        };
4589
                                        currentControl.CommentID = Commons.shortGuid();
4590
                                        currentControl.IsNew = true;
4591
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4592
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4593

    
4594
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4595

    
4596
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4597
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4598
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4599
                                        (currentControl as ArrowTextControl).isFixed = true;
4600
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4601
                                     
4602
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4603
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4604
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4605

    
4606
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4607
                                        this.MainAngle.Visibility = Visibility.Visible;
4608
                                    
4609
                                    //20180911 LJY
4610
                                        (currentControl as ArrowTextControl).isTrans = true;
4611
                                    
4612

    
4613
                                    //}
4614
                                }
4615
                            }
4616
                        }
4617
                        break;
4618
                    case ControlType.ArrowTextCloudControl:
4619
                        {
4620
                            if (mouseButtonDown == MouseButton.Left)
4621
                            {
4622
                                if (currentControl is ArrowTextControl)
4623
                                {
4624
                                    //20180906 LJY TEST IsRotationDrawingEnable
4625
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4626
                                    {
4627
                                        return;
4628
                                    }
4629
                                    CreateControl();
4630
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4631
                                    currentControl.IsNew = false;
4632
                                    currentControl = null;
4633
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4634
                                }
4635
                                else
4636
                                {
4637
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4638
                                    //{
4639
                                        currentControl = new ArrowTextControl()
4640
                                        {
4641
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4642
                                        };
4643
                                        currentControl.CommentID = Commons.shortGuid();
4644
                                        currentControl.IsNew = true;
4645
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4646
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4647

    
4648
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4649
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4650
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4651
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4652
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4653

    
4654
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4655
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4656
                                    
4657
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4658
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4659
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4660
                                    //}
4661
                                }
4662
                            }
4663
                        }
4664
                        break;
4665
                    case ControlType.ArrowTransTextCloudControl:
4666
                        {
4667
                            if (mouseButtonDown == MouseButton.Left)
4668
                            {
4669
                                if (currentControl is ArrowTextControl)
4670
                                {
4671
                                    //20180906 LJY TEST IsRotationDrawingEnable
4672
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4673
                                    {
4674
                                        return;
4675
                                    }
4676
                                    CreateControl();
4677
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4678
                                    currentControl.IsNew = false;
4679
                                    currentControl = null;
4680
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4681
                                }
4682
                                else
4683
                                {
4684
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4685
                                    //{
4686
                                        currentControl = new ArrowTextControl()
4687
                                        {
4688
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4689
                                        };
4690
                                        currentControl.CommentID = Commons.shortGuid();
4691
                                        currentControl.IsNew = true; 
4692
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4693
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4694
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4695

    
4696
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4697
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4698
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4699
                                        (currentControl as ArrowTextControl).isFixed = true;
4700
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4701

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

    
4705
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4706
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4707
                                        this.MainAngle.Visibility = Visibility.Visible;  
4708
                                    
4709
                                    //20180911 LJY
4710
                                        (currentControl as ArrowTextControl).isTrans = true;
4711
                                    //}
4712
                                }
4713
                            }
4714
                        }
4715
                        break;
4716
                    case ControlType.PolygonControl:
4717
                        {
4718
                            if (currentControl is PolygonControl)
4719
                            {
4720
                                var control = currentControl as PolygonControl;
4721

    
4722
                                if (mouseButtonDown == MouseButton.Right)
4723
                                {
4724
                                    control.IsCompleted = true;
4725
                                }
4726

    
4727
                                if (!control.IsCompleted)
4728
                                {
4729
                                    control.PointSet.Add(control.EndPoint);
4730
                                }
4731
                                else
4732
                                {
4733
                                    //20180906 LJY TEST IsRotationDrawingEnable
4734
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4735
                                    {
4736
                                        return;
4737
                                    }
4738

    
4739
                                    var firstPoint = control.PointSet.First();
4740
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4741
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4742
                                    control.PointSet.Add(firstPoint);
4743

    
4744
                                    control.ApplyOverViewData();
4745

    
4746
                                    CreateControl();
4747
                                    control.updateControl();
4748
                                    currentControl = null;
4749
                                }
4750
                            }
4751
                            else
4752
                            {
4753
                                if (mouseButtonDown == MouseButton.Left)
4754
                                {
4755
                                    currentControl = new PolygonControl
4756
                                    {
4757
                                        PointSet = new List<Point>(),
4758
                                    };
4759

    
4760
                                    var polygonControl = (currentControl as PolygonControl);
4761
                                    currentControl.CommentID = Commons.shortGuid();
4762
                                    currentControl.IsNew = true;
4763
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4764
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
4765
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
4766
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4767
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4768
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4769
                                    polygonControl.ApplyTemplate();
4770
                                    polygonControl.Visibility = Visibility.Visible;
4771
                                }
4772
                            }
4773
                        }
4774
                        break;
4775
                    //강인구 추가
4776
                    case ControlType.Sign:
4777
                        {
4778
                            if (mouseButtonDown == MouseButton.Left)
4779
                            {
4780
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4781
                                //{
4782
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4783

    
4784
                                    if (_sign == null)
4785
                                    {
4786
                                        txtBatch.Visibility = Visibility.Collapsed;
4787
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4788
                                        controlType = ControlType.None;
4789

    
4790
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4791
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4792
                                        return;
4793
                                    }
4794

    
4795
                                    if (currentControl is SignControl)
4796
                                    {
4797
                                        //20180906 LJY TEST IsRotationDrawingEnable
4798
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4799
                                        {
4800
                                            return;
4801
                                        }
4802

    
4803
                                        CreateControl();
4804
                                        currentControl = null;
4805
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4806
                                        {
4807
                                            txtBatch.Text = "Place Date";
4808
                                            controlType = ControlType.Date;
4809
                                        }
4810
                                    }
4811
                                    else
4812
                                    {
4813
                                        currentControl = new SignControl
4814
                                        {
4815
                                            Background = new SolidColorBrush(Colors.Black),
4816
                                            UserNumber = App.ViewInfo.UserID,
4817
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4818
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4819
                                            ControlType = ControlType.Sign
4820
                                        };
4821

    
4822
                                        currentControl.CommentID = Commons.shortGuid();
4823
                                        currentControl.IsNew = true;
4824
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4825
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4826

    
4827
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4828
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4829
                                }
4830
                                //}
4831
                            }
4832
                        }
4833
                        break;
4834
                    case ControlType.Mark:
4835
                        {
4836
                            if (mouseButtonDown == MouseButton.Left)
4837
                            {
4838
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4839
                                //{
4840
                                    if (currentControl is RectangleControl)
4841
                                    {
4842
                                        //20180906 LJY TEST IsRotationDrawingEnable
4843
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4844
                                        {
4845
                                            return;
4846
                                        }
4847

    
4848
                                        CreateControl();
4849
                                        (currentControl as RectangleControl).ApplyOverViewData();
4850
                                        currentControl = null;
4851
                                    
4852
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4853

    
4854
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4855
                                        {
4856
                                            txtBatch.Text = "Place Signature";
4857
                                            controlType = ControlType.Sign;
4858
                                        }
4859
                                    }
4860
                                    else
4861
                                    {
4862
                                        currentControl = new RectangleControl
4863
                                        {
4864
                                            Background = new SolidColorBrush(Colors.Black),
4865
                                            Paint = PaintSet.Fill
4866
                                        };
4867

    
4868
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4869
                                        currentControl.CommentID = Commons.shortGuid();
4870
                                        currentControl.IsNew = true;
4871
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4872
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4873
                                    }
4874
                                //}
4875
                            }
4876
                        }
4877
                        break;
4878
                    case ControlType.Symbol:
4879
                        {
4880
                            if (mouseButtonDown == MouseButton.Left)
4881
                            {
4882
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4883
                                //{
4884
                                    if (currentControl is SymControl)
4885
                                    {
4886
                                        //20180906 LJY TEST IsRotationDrawingEnable
4887
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4888
                                        {
4889
                                            return;
4890
                                        }
4891
                                        CreateControl();
4892
                                        currentControl = null;
4893
                                    
4894
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4895
                                    }
4896
                                    else
4897
                                    {
4898
                                        currentControl = new SymControl
4899
                                        {
4900
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4901
                                            Background = new SolidColorBrush(Colors.Black),
4902
                                            ControlType = ControlType.Symbol
4903
                                        };
4904

    
4905
                                        currentControl.IsNew = true;
4906
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4907
                                        currentControl.CommentID = Commons.shortGuid();
4908
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4909

    
4910
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4911
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4912
                                }
4913
                                //}
4914
                            }
4915
                        }
4916
                        break;
4917
                    case ControlType.Stamp:
4918
                        {
4919
                            if (mouseButtonDown == MouseButton.Left)
4920
                            {
4921
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4922
                                //{
4923
                                    if (currentControl is SymControlN)
4924
                                    {
4925
                                        //20180906 LJY TEST IsRotationDrawingEnable
4926
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4927
                                        {
4928
                                            return;
4929
                                        }
4930

    
4931
                                        CreateControl();
4932
                                        currentControl = null;
4933
                                   
4934

    
4935
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4936
                                    }
4937
                                    else
4938
                                    {
4939
                                        currentControl = new SymControlN
4940
                                        {
4941
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4942
                                            Background = new SolidColorBrush(Colors.Black),
4943
                                            ControlType = ControlType.Stamp
4944
                                        };
4945

    
4946
                                        currentControl.IsNew = true;
4947
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4948
                                        currentControl.CommentID = Commons.shortGuid();
4949
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4950
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4951
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4952
                                }                                    
4953
                                //}
4954
                            }
4955
                        }
4956
                        break;
4957
                    case ControlType.PenControl:
4958
                        {
4959
                            if (inkBoard.Tag.ToString() == "Ink")
4960
                            {
4961
                                inkBoard.IsEnabled = true;
4962
                                StartNewStroke(canvasDrawingMouseDownPoint);
4963
                            }
4964
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4965
                            {
4966
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4967
                            }
4968
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4969
                            {
4970
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4971
                            }
4972
                            IsDrawing = true;
4973
                            return;
4974
                        }
4975
                    default:
4976
                        if (currentControl != null)
4977
                        {
4978
                            currentControl.CommentID = null;
4979
                            currentControl.IsNew = false;
4980
                        }
4981
                        break;
4982
                }
4983
            }
4984
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
4985
            {
4986
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4987
                {
4988
                    bool mouseOff = false;
4989
                    foreach (var item in SelectLayer.Children)
4990
                    {
4991
                        if (item is AdornerFinal)
4992
                        {
4993

    
4994
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4995
                            if (over != null)
4996
                            {
4997
                                mouseOff = true;
4998
                            }
4999
                        }
5000
                    }
5001

    
5002
                    if (!mouseOff)
5003
                    {
5004
                        SelectionSet.Instance.UnSelect(this);
5005
                    }
5006
                }
5007
                zoomAndPanControl.CaptureMouse();
5008
                e.Handled = true;
5009
            }
5010
        }
5011

    
5012
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5013
        {
5014
            mouseButtonDown = e.ChangedButton;
5015
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5016
        }
5017

    
5018
        private void RemoveLineStroke(Point P)
5019
        {
5020
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
5021
            if (control != null)
5022
            {
5023
                UndoData = new Undo_data()
5024
                {
5025
                    IsUndo = false,
5026
                    Event = Event_Type.Delete,
5027
                    EventTime = DateTime.Now,
5028
                    Markup_List = new List<Multi_Undo_data>()
5029
                };
5030

    
5031

    
5032
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5033
                UndoData.Markup_List.Add(multi_Undo_Data);
5034
                multi_Undo_Data = new Multi_Undo_data();
5035

    
5036
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
5037
                var Item_ = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
5038
                ViewerDataModel.Instance.MyMarkupList.Remove(Item_);
5039
                
5040
                //임시파일에서도 삭제한다.
5041
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
5042
                
5043
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5044
                {
5045
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5046
                });
5047
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5048

    
5049
            }
5050
        }
5051

    
5052
        private void RemovePointStroke(Point P)
5053
        {
5054
            foreach (Stroke hits in inkBoard.Strokes)
5055
            {
5056
                foreach (StylusPoint sty in hits.StylusPoints)
5057
                {
5058

    
5059
                }
5060
                if (hits.HitTest(P))
5061
                {
5062
                    inkBoard.Strokes.Remove(hits);
5063
                    return;
5064
                }
5065
            }
5066
        }
5067

    
5068
        private void StartNewStroke(Point P)
5069
        {
5070
            strokePoints = new StylusPointCollection();
5071
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5072
            strokePoints.Add(segment1Start);
5073
            stroke = new Stroke(strokePoints);
5074

    
5075
            stroke.DrawingAttributes.Color = Colors.Red;
5076
            stroke.DrawingAttributes.Width = 4;
5077
            stroke.DrawingAttributes.Height = 4;
5078

    
5079
            inkBoard.Strokes.Add(stroke);
5080

    
5081
        }
5082

    
5083
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5084
        {
5085
            ConsolidationMethod();
5086
        }
5087

    
5088
        /// <summary>
5089
        /// execute TeamConsolidationCommand
5090
        /// </summary>
5091
        public void TeamConsolidationMethod()
5092
        {
5093
            this.UpdateMyMarkupList();
5094
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5095
            {
5096
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5097
            }
5098
            else
5099
            {
5100

    
5101
                ViewerDataModel.Instance.IsConsolidate = true;
5102
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5103

    
5104
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5105
                {
5106
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
5107
                    {
5108
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
5109
                        return;
5110
                    }                    
5111
                }
5112
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
5113
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5114
                {
5115
                    MarkupInfoList.Add(item);
5116
                }
5117
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
5118
            }
5119
        }
5120

    
5121
        public void ConsolidationMethod()
5122
        {
5123
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5124
            {
5125
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5126
            }
5127
            else
5128
            {
5129
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
5130
                foreach (var item in this.gridViewMarkup.SelectedItems)
5131
                {
5132
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
5133
                }
5134
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
5135
                
5136
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
5137
            }
5138
        }
5139

    
5140
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5141
        {
5142
            if (App.ViewInfo != null)
5143
            {
5144
                btnConsolidate = (sender as RadRibbonButton);
5145
                if (!App.ViewInfo.NewCommentPermission)
5146
                {
5147
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5148
                }
5149
            }
5150
        }
5151

    
5152
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5153
        {
5154
            TeamConsolidationMethod();
5155
        }
5156

    
5157
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5158
        {
5159
            btnTeamConsolidate = sender as RadRibbonButton;
5160
            if (App.ViewInfo != null)
5161
            {
5162
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5163
                {
5164
                    if (btnConsolidate != null)
5165
                    {
5166
                        btnConsolidate.Visibility = Visibility.Collapsed;
5167
                    }
5168

    
5169
                    if (!App.ViewInfo.NewCommentPermission)
5170
                    {
5171
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5172
                    }
5173
                }
5174
                else
5175
                {
5176
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5177
                }
5178
            }
5179
        }
5180

    
5181
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5182
        {
5183
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5184
            if (item != null)
5185
            {
5186
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5187

    
5188
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5189
            }
5190
            else
5191
            {
5192
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5193
            }
5194
        }
5195

    
5196
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5197
        {
5198
            btnFinalPDF = sender as RadRibbonButton;
5199
            if (App.ViewInfo != null)
5200
            {
5201
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5202
                {
5203
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5204
                    if (btnConsolidate != null)
5205
                    {
5206
                        btnConsolidate.Visibility = Visibility.Collapsed;
5207
                    }
5208
                }
5209
            }
5210
        }
5211

    
5212
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5213
        {
5214
            UpdateMyMarkupList();
5215

    
5216
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5217
            {
5218
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5219
            }
5220
            else
5221
            {
5222
                ViewerDataModel.Instance.IsConsolidate = true;
5223
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5224
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5225

    
5226
                string project_no = App.ViewInfo.ProjectNO;
5227
                string doc_id = _DocInfo.ID;
5228
                string user_id = App.ViewInfo.UserID;
5229
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5230
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5231
                {
5232
                    markupInfoItems.Add(item);
5233
                }
5234
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5235
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5236
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5237
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5238

    
5239
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5240
                if (item2 != null)
5241
                {
5242
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5243

    
5244
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5245
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5246
                }
5247
                else
5248
                {
5249
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5250
                }
5251
            }
5252
        }
5253

    
5254
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5255
        {
5256
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5257

    
5258
            if (App.ViewInfo != null)
5259
            {
5260
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5261
                {
5262
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5263
                }
5264
            }
5265
        }
5266

    
5267
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5268
        {
5269
            if (CompareMode.IsChecked)
5270
            {
5271
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5272
                {
5273
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5274
                }
5275
                if (ViewerDataModel.Instance.PageNumber == 0)
5276
                {
5277
                    ViewerDataModel.Instance.PageNumber = 1;
5278
                }
5279

    
5280
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5281
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5282
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5283

    
5284
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5285
            }
5286
            else
5287
            {
5288
                da.From = 1;
5289
                da.To = 1;
5290
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5291
                da.AutoReverse = false;
5292
                canvas_compareBorder.Children.Clear();
5293
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5294
            }
5295
        }
5296

    
5297
        private void Sync_Click(object sender, RoutedEventArgs e)
5298
        {
5299
            if (Sync.IsChecked)
5300
            {
5301
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5302
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5303
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5304
            }
5305
        }
5306

    
5307
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5308
        {
5309
            if (UserList.IsChecked)
5310
            {
5311
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5312
            }
5313
            else
5314
            {
5315
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5316
            }
5317
        }
5318

    
5319
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5320
        {
5321

    
5322
            if (BalanceMode.IsChecked)
5323
            {
5324
                ViewerDataModel.Instance.PageBalanceMode = true;
5325
            }
5326
            else
5327
            {
5328
                ViewerDataModel.Instance.PageBalanceMode = false;
5329
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5330
            }
5331
        }
5332

    
5333
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5334
        {
5335
            //초기화
5336
            testPanel2.IsHidden = true;
5337
            ViewerDataModel.Instance.PageBalanceMode = false;
5338
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5339
            ViewerDataModel.Instance.PageNumber = 0;
5340
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5341
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5342
            UserList.IsChecked = false;
5343
            BalanceMode.IsChecked = false;
5344
        }
5345

    
5346
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5347
        {
5348
            if ((sender as System.Windows.Controls.Control).Tag != null)
5349
            {
5350
                //Compare 초기화
5351
                CompareMode.IsChecked = false;
5352
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5353

    
5354
                if (ViewerDataModel.Instance.PageNumber == 0)
5355
                {
5356
                    ViewerDataModel.Instance.PageNumber = 1;
5357
                }
5358

    
5359
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5360
                {
5361
                }
5362
                else
5363
                {
5364
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5365
                }
5366

    
5367
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5368
                {
5369

    
5370
                }
5371
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5372
                {
5373
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5374
                }
5375

    
5376
                if (!testPanel2.IsHidden)
5377
                {
5378
                    if (IsSyncPDFMode)
5379
                    {
5380
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5381
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5382

    
5383
                        if (pdfpath.IsDownloading)
5384
                        {
5385
                            pdfpath.DownloadCompleted += (ex, arg) =>
5386
                            {
5387
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5388
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5389
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5390
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5391
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5392
                            };
5393
                        }
5394
                        else
5395
                        {
5396
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5397
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5398
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5399

    
5400
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5401
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5402
                        }
5403

    
5404
                    }
5405
                    else
5406
                    {
5407
                        string uri = "";
5408

    
5409
                        if (userData.COMPANY != "EXT")
5410
                        {
5411
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5412
                        }
5413
                        else
5414
                        {
5415
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5416
                        }
5417

    
5418
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5419

    
5420
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5421
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5422
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5423

    
5424
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5425
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5426

    
5427
                        if (defaultBitmapImage_Compare.IsDownloading)
5428
                        {
5429
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5430
                            {
5431
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5432
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5433
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5434

    
5435
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5436
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5437
                            };
5438
                        }
5439
                    }
5440

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

    
5445
                    foreach (var item in gridSelectionRevItem)
5446
                    {
5447
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5448
                        {
5449
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5450
                        });
5451
                    }
5452

    
5453
                    //강인구 추가
5454
                    zoomAndPanControl2.ZoomTo(new Rect
5455
                    {
5456
                        X = 0,
5457
                        Y = 0,
5458
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5459
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5460
                    });
5461

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

    
5464
                }
5465
            }
5466
        }
5467

    
5468
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5469
        {
5470
            if (MarkupMode.IsChecked)
5471
            {
5472
                IsSyncPDFMode = true;
5473

    
5474
                var uri = CurrentRev.TO_VENDOR;
5475

    
5476
                if (ViewerDataModel.Instance.PageNumber == 0)
5477
                {
5478
                    ViewerDataModel.Instance.PageNumber = 1;
5479
                }
5480

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

    
5485
                if (pdfpath.IsDownloading)
5486
                {
5487
                    pdfpath.DownloadCompleted += (ex, arg) =>
5488
                    {
5489
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5490
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5491
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5492
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5493
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5494
                    };
5495
                }
5496
                else
5497
                {
5498
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5499
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5500
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5501

    
5502
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5503
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5504
                }
5505
            }
5506
            else
5507
            {
5508
                IsSyncPDFMode = false;
5509
                string uri = "";
5510
                if (userData.COMPANY != "EXT")
5511
                {
5512
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5513
                }
5514
                else
5515
                {
5516
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5517
                }
5518

    
5519
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5520

    
5521
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5522
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5523
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5524

    
5525
                if (defaultBitmapImage_Compare.IsDownloading)
5526
                {
5527
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5528
                    {
5529
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5530
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5531
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5532
                    };
5533
                }
5534
                zoomAndPanControl2.ApplyTemplate();
5535
                zoomAndPanControl2.UpdateLayout();
5536
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5537
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5538
            }
5539
        }
5540

    
5541
        private void RadButton_Click(object sender, RoutedEventArgs e)
5542
        {
5543
            gridViewHistory_Busy.IsBusy = true;
5544

    
5545
            RadButton instance = sender as RadButton;
5546
            if (instance.CommandParameter != null)
5547
            {
5548
                CurrentRev = instance.CommandParameter as VPRevision;
5549
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5550
                {
5551
                    if (ea.Error == null && ea.Result != null)
5552
                    {
5553
                        testPanel2.IsHidden = false;
5554

    
5555
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5556
                        foreach(var info in ea.Result)
5557
                        {
5558
                            if(info.UserID == App.ViewInfo.UserID)
5559
                            {
5560
                                info.userDelete = true;
5561
                                info.DisplayColor = "FFFF0000";
5562
                            }
5563
                            else
5564
                            {
5565
                                info.userDelete = false;
5566
                            }
5567
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5568
                        }
5569
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5570

    
5571
                        string uri = "";
5572
                        if (userData.COMPANY != "EXT")
5573
                        {
5574
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5575
                        }
5576
                        else
5577
                        {
5578
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5579
                        }
5580

    
5581
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5582

    
5583
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5584

    
5585
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5586
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5587
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5588

    
5589
                        if (defaultBitmapImage_Compare.IsDownloading)
5590
                        {
5591
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5592
                            {
5593
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5594
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5595
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5596
                            };
5597
                        }
5598

    
5599
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5600
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5601
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5602
                        zoomAndPanControl2.ApplyTemplate();
5603
                        zoomAndPanControl2.UpdateLayout();
5604

    
5605
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5606
                        {
5607
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5608
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5609
                        }
5610

    
5611
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5612
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5613
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5614

    
5615
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5616
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5617
                        gridViewHistory_Busy.IsBusy = false;
5618
                    }
5619

    
5620
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5621
                };
5622
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5623
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5624
            }
5625
        }
5626

    
5627
        public void Sync_Event(VPRevision Currnet_Rev)
5628
        {
5629
            CurrentRev = Currnet_Rev;
5630

    
5631
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5632
            {
5633
                if (ea.Error == null && ea.Result != null)
5634
                {
5635
                    testPanel2.IsHidden = false;
5636

    
5637
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5638
                    foreach(var info in ea.Result)
5639
                    {
5640
                        if(info.UserID == App.ViewInfo.UserID)
5641
                        {
5642
                            info.userDelete = true;
5643
                            info.DisplayColor = "FFFF0000";
5644
                        }
5645
                        else
5646
                        {
5647
                            info.userDelete = false;
5648
                        }
5649
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5650
                    }
5651
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5652

    
5653
                    string uri = "";
5654
                    if (userData.COMPANY != "EXT")
5655
                    {
5656
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5657
                    }
5658
                    else
5659
                    {
5660
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5661
                    }
5662

    
5663
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5664

    
5665
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5666

    
5667
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5668
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5669
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5670

    
5671
                    if (defaultBitmapImage_Compare.IsDownloading)
5672
                    {
5673
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5674
                        {
5675
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5676
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5677
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5678
                        };
5679
                    }
5680

    
5681

    
5682
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5683
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5684
                    zoomAndPanControl2.ApplyTemplate();
5685
                    zoomAndPanControl2.UpdateLayout();
5686

    
5687
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5688
                    {
5689
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5690
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5691
                    }
5692
                    //}
5693

    
5694
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5695
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5696
                    gridViewHistory_Busy.IsBusy = false;
5697
                }
5698
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5699

    
5700
            };
5701
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5702
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5703
        }
5704

    
5705
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5706
        {
5707
            if (sender is Image)
5708
            {
5709
                if ((sender as Image).Tag != null)
5710
                {
5711
                    var pdfUrl = (sender as Image).Tag.ToString();
5712
                    System.Diagnostics.Process.Start(pdfUrl);
5713
                }
5714
                else
5715
                {
5716
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5717
                }
5718
            }
5719
        }
5720

    
5721
        private void Create_Symbol(object sender, RoutedEventArgs e)
5722
        {
5723
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5724

    
5725
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5726
            {
5727
                DialogMessage_Alert("Please Select Controls", "Alert");
5728
            }
5729
            else //선택된 것이 있으면
5730
            {
5731
                string MarkupData = "";
5732
                adorner_ = new AdornerFinal();
5733

    
5734
                foreach (var item in SelectLayer.Children)
5735
                {
5736
                    if (item.GetType().Name == "AdornerFinal")
5737
                    {
5738
                        adorner_ = (item as Controls.AdornerFinal);
5739
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5740
                        {
5741
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5742
                            {
5743
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5744
                                MarkupData += markupReturn.ConvertData;
5745
                            }
5746
                        }
5747
                    }
5748
                }
5749
                DialogParameters parameters = new DialogParameters()
5750
                {
5751
                    Owner = Application.Current.MainWindow,
5752
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5753
                    DefaultPromptResultValue = "Custom State",
5754
                    Content = "Name :",
5755
                    Header = "Insert Custom Symbol Name",
5756
                    Theme = new VisualStudio2013Theme(),
5757
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5758
                };
5759
                RadWindow.Prompt(parameters);
5760
            }
5761

    
5762
        }
5763
        public int symbolselectindex = 0;
5764
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5765
        {
5766
            //Save save = new Save();
5767
            try
5768
            {
5769
                string svgfilename = null;
5770
                if (symbolname != null)
5771
                {
5772
                    if (symbolpng == true || symbolsvg == true)
5773
                    {
5774
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5775
                        string guid = Commons.shortGuid();
5776

    
5777
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5778
                        //Check_Uri.UriCheck();
5779
                        fileUploader.RunCompleted += (ex, arg) =>
5780
                        {
5781
                            filename = arg.Result;
5782
                            if (symbolpng == true)
5783
                            {
5784
                                if (filename != null)
5785
                                { 
5786
                                    if (symbolselectindex == 0)
5787
                                    {
5788
                                        SymbolSave(symbolname, filename, data);
5789
                                    }
5790
                                    else
5791
                                    {
5792
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5793
                                    }
5794
                                    DataBind();
5795
                                }                                
5796
                            }
5797

    
5798
                            if (symbolsvg == true)
5799
                            {
5800
                                try
5801
                                {
5802
                                    var defaultBitmapImage = new BitmapImage();
5803
                                    defaultBitmapImage.BeginInit();
5804
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5805
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5806
                                    Check_Uri.UriCheck(filename);
5807
                                    defaultBitmapImage.UriSource = new Uri(filename);
5808
                                    defaultBitmapImage.EndInit();
5809

    
5810
                                    System.Drawing.Bitmap image;
5811

    
5812
                                    if (defaultBitmapImage.IsDownloading)
5813
                                    {
5814
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5815
                                        {
5816
                                            defaultBitmapImage.Freeze();
5817
                                            image = GetBitmap(defaultBitmapImage);
5818
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5819
                                            Process potrace = new Process
5820
                                            {
5821
                                                StartInfo = new ProcessStartInfo
5822
                                                {
5823
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5824
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5825
                                                    RedirectStandardInput = true,
5826
                                                    RedirectStandardOutput = true,
5827
                                                    RedirectStandardError = true,
5828
                                                    UseShellExecute = false,
5829
                                                    CreateNoWindow = true,
5830
                                                    WindowStyle = ProcessWindowStyle.Hidden
5831
                                                },
5832
                                            };
5833

    
5834
                                            StringBuilder svgBuilder = new StringBuilder();
5835
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5836
                                            {
5837
                                                svgBuilder.AppendLine(e2.Data);
5838
                                            };
5839

    
5840
                                            potrace.EnableRaisingEvents = true;
5841
                                            potrace.Start();
5842
                                            potrace.Exited += (sender, e) =>
5843
                                            {
5844
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5845
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5846
                                                Check_Uri.UriCheck(svgfilename);
5847
                                                if (symbolselectindex == 0)
5848
                                                {
5849
                                                    SymbolSave(symbolname, svgfilename, data);
5850
                                                }
5851
                                                else
5852
                                                {
5853
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5854
                                                }
5855

    
5856
                                                DataBind();
5857
                                            };
5858
                                            potrace.WaitForExit();
5859
                                        };
5860
                                    }
5861
                                    else
5862
                                    {
5863
                                        //GC.Collect();
5864
                                    }
5865
                                }
5866
                                catch(Exception ee)
5867
                                {
5868
                                    DialogMessage_Alert("" + ee, "Alert");
5869
                                }
5870
                            }
5871
                        };                                             
5872
                    }
5873
                }
5874
            }
5875
            catch (Exception e)
5876
            {
5877
                //DialogMessage_Alert(e + "", "Alert");
5878
            }            
5879
        }
5880

    
5881
        public void SymbolSave(string Name, string Url, string Data)
5882
        {
5883
            try
5884
            {
5885
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5886
                {
5887
                    ID = Commons.shortGuid(),
5888
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5889
                    NAME = Name,
5890
                    IMAGE_URL = Url,
5891
                    DATA = Data
5892
                };
5893

    
5894
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5895
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5896
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5897
            }
5898
            catch (Exception)
5899
            {
5900
                throw;
5901
            }
5902
        }
5903

    
5904
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5905
        {
5906
            try
5907
            {
5908
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5909
                {
5910
                    ID = Commons.shortGuid(),
5911
                    DEPARTMENT = Department,
5912
                    NAME = Name,
5913
                    IMAGE_URL = Url,
5914
                    DATA = Data
5915
                };
5916
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5917
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5918
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5919
            }
5920
            catch (Exception)
5921
            {
5922
                throw;
5923
            }
5924
        }
5925

    
5926
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5927
        {           
5928
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5929
            DataBind();
5930
        }
5931

    
5932
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5933
        {
5934
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5935
            DataBind();
5936
        }
5937
        private void DataBind()
5938
        {
5939
            try
5940
            {
5941
                Symbol_Custom Custom = new Symbol_Custom();
5942
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5943
                //ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
5944
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5945
                foreach (var item in symbol_Private)
5946
                {
5947
                    Custom.Name = item.NAME;
5948
                    Custom.ImageUri = item.IMAGE_URL;
5949
                    Custom.ID = item.ID;
5950
                    Custom_List.Add(Custom);
5951
                    Custom = new Symbol_Custom();
5952
                }
5953
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5954
                
5955
                Custom = new Symbol_Custom();
5956
                Custom_List = new List<Symbol_Custom>();
5957

    
5958
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5959

    
5960
                List<SYMBOL_PUBLIC> symbol_Public;
5961

    
5962
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5963
                {
5964
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5965
                }
5966
                else
5967
                {
5968
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5969
                }
5970
                foreach (var item in symbol_Public)
5971
                {
5972
                    Custom.Name = item.NAME;
5973
                    Custom.ImageUri = item.IMAGE_URL;
5974
                    Custom.ID = item.ID;
5975
                    Custom_List.Add(Custom);
5976
                    Custom = new Symbol_Custom();
5977
                }
5978
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5979
                BaseClient.Close();                
5980
            }
5981
            catch(Exception e)
5982
            {
5983
                //DialogMessage_Alert("DataBind", "Alert");
5984
            }
5985
            
5986
        }
5987
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5988
        {
5989
            try
5990
            {
5991
                if (args.PromptResult != null)
5992
                {
5993
                    if (args.DialogResult.Value)
5994
                    {
5995
                        PngBitmapEncoder _Encoder = symImage(data);
5996

    
5997
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5998
                        _Encoder.Save(fs);
5999
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6000

    
6001
                        byte[] Img_byte = fs.ToArray();
6002

    
6003
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6004
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
6005
                        Check_Uri.UriCheck(filename);
6006
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6007
                        {
6008
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
6009
                        }
6010
                        else
6011
                        {
6012
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6013
                        }
6014
                        DataBind();
6015
                    }
6016
                }
6017
            }
6018
            catch(Exception ex)
6019
            {
6020
                DialogMessage_Alert("" + ex, "Alert");
6021
            }
6022
        }
6023

    
6024
        public PngBitmapEncoder symImage(string data)
6025
        {
6026

    
6027
            Canvas _canvas = new Canvas();
6028
            _canvas.Background = Brushes.White;
6029
            _canvas.Width = adorner_.BorderSize.Width;
6030
            _canvas.Height = adorner_.BorderSize.Height;
6031
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
6032

    
6033
            BitmapEncoder encoder = new PngBitmapEncoder();
6034

    
6035

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

    
6038
            DrawingVisual dv = new DrawingVisual();
6039

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

    
6043
            using (DrawingContext ctx = dv.RenderOpen())
6044
            {
6045
                VisualBrush vb = new VisualBrush(_canvas);
6046
                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)));
6047
            }
6048

    
6049
            try
6050
            {
6051
                renderBitmap.Render(dv);
6052

    
6053
                //GC.Collect();
6054
                GC.WaitForPendingFinalizers();
6055
                //GC.Collect();
6056
                // encode png data
6057
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6058
                // puch rendered bitmap into it
6059
                pngEncoder.Interlace = PngInterlaceOption.Off;
6060
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6061
                return pngEncoder;
6062

    
6063
            }
6064
            catch //(Exception ex)
6065
            {
6066
                return null;
6067
            }
6068

    
6069
        }
6070

    
6071
        public void DialogMessage_Alert(string content, string header)
6072
        {
6073
            var box = new TextBlock();
6074
            box.MinWidth = 400;
6075
            box.FontSize = 11;
6076
            //box.FontSize = 12;
6077
            box.Text = content;
6078
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6079

    
6080
            DialogParameters parameters = new DialogParameters()
6081
            {
6082
                Owner = Application.Current.MainWindow,
6083
                Content = box,
6084
                Header = header,
6085
                Theme = new VisualStudio2013Theme(),
6086
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6087
            };            
6088
            RadWindow.Alert(parameters);
6089
        }
6090

    
6091
        #region 캡쳐 기능
6092

    
6093
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6094
        {
6095
            if (x < 0)
6096
            {
6097
                width += x;
6098
                x = 0;
6099
            }
6100
            if (y < 0)
6101
            {
6102
                height += y;
6103
                y = 0;
6104

    
6105
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6106
            }
6107
            if (x + width > zoomAndPanCanvas.ActualWidth)
6108
            {
6109
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6110
            }
6111
            if (y + height > zoomAndPanCanvas.ActualHeight)
6112
            {
6113
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6114
            }
6115

    
6116
            byte[] pixels = CopyPixels(x, y, width, height);
6117

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

    
6120
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6121
        }
6122

    
6123
        public byte[] CopyPixels(int x, int y, int width, int height)
6124
        {
6125
            byte[] pixels = new byte[width * height * 4];
6126
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6127

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

    
6131
            return pixels;
6132
        }
6133

    
6134
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6135
        {
6136
            DrawingVisual drawingVisual = new DrawingVisual();
6137
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6138

    
6139
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6140
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6141
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6142
            drawingContext.Close();
6143

    
6144
            // 비트맵으로 변환합니다.
6145
            RenderTargetBitmap target =
6146
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6147
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6148

    
6149
            target.Render(drawingVisual);
6150
            return target;
6151
        }
6152

    
6153
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6154
        {
6155
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6156
            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);
6157
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6158
            bmp.UnlockBits(data);
6159
            return bmp;
6160
        }
6161
        public string symbolname = null;
6162
        public bool symbolsvg = true;
6163
        public bool symbolpng = true;
6164

    
6165
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6166
        {
6167
            System.Drawing.Bitmap image = GetBitmap(source);
6168
            //흰색 제거
6169
            //image.MakeTransparent(System.Drawing.Color.White);
6170

    
6171
            var imageStream = new System.IO.MemoryStream();
6172
            byte[] imageBytes = null;
6173
            using (imageStream)
6174
            {
6175
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6176
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6177
                imageStream.Position = 0;
6178
                imageBytes = imageStream.ToArray();
6179
            }
6180

    
6181
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6182

    
6183
            RadWindow CheckPop = new RadWindow();
6184
            //Alert check = new Alert(Msg);
6185

    
6186
            CheckPop = new RadWindow
6187
            {
6188
                MinWidth = 400,
6189
                MinHeight = 100,
6190
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6191
                Header = "Alert",
6192
                Content = symbolPrompt,
6193
                //DialogResult = 
6194
                ResizeMode = System.Windows.ResizeMode.NoResize,
6195
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6196
                IsTopmost = true,
6197
            };
6198
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6199
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6200
            CheckPop.ShowDialog();
6201

    
6202
            /*
6203
            DialogParameters parameters = new DialogParameters()
6204
            {
6205
                Owner = Application.Current.MainWindow,
6206
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6207
                DefaultPromptResultValue = "Custom State",
6208
                Content = "Name :",
6209
                Header = "Insert Custom Symbol Name",
6210
                Theme = new VisualStudio2013Theme(),
6211
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6212
            };            
6213
            RadWindow.Prompt(parameters);
6214
            */
6215
        }
6216

    
6217
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6218
        {
6219
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6220
            KCOMDataModel.DataModel.CHECK_LIST check_;
6221
            string Result = streamToBase64.ImageToBase64(source);
6222
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6223
            string projectno = App.ViewInfo.ProjectNO;
6224
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6225

    
6226
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6227
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6228
            if (Item != null)
6229
            {
6230
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6231
            }
6232
            else
6233
            {
6234
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6235
            }
6236

    
6237
            if (Item == null)
6238
            {
6239
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6240
                {
6241
                    ID = Commons.shortGuid(),
6242
                    USER_ID = App.ViewInfo.UserID,
6243
                    IMAGE_URL = Result,
6244
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6245
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6246
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6247
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6248
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6249
                    STATUS = "False",
6250
                    CREATE_TIME = DateTime.Now,
6251
                    UPDATE_TIME = DateTime.Now,
6252
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6253
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6254
                };
6255
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6256
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6257
                //this.BaseClient.AddCheckList(projectno, check_);
6258
            }
6259
            else
6260
            {
6261
                Item.IMAGE_URL = Result;
6262
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6263
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6264
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6265
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6266
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6267
            }
6268

    
6269
        }
6270

    
6271
        public void Set_Capture()
6272
        {
6273
            double x = canvasDrawingMouseDownPoint.X;
6274
            double y = canvasDrawingMouseDownPoint.Y;
6275
            double width = dragCaptureBorder.Width;
6276
            double height = dragCaptureBorder.Height;
6277

    
6278
            if (width > 5 || height > 5)
6279
            {
6280
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6281
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6282
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6283
            }
6284
        }
6285
        #endregion
6286

    
6287
        //MarkupInfoItem
6288
        public void CreateControl()
6289
        {
6290

    
6291
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6292
            {
6293
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6294
            });
6295
            multi_Undo_Data.Markup = currentControl;
6296
            UndoData.Markup_List.Add(multi_Undo_Data);
6297

    
6298
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6299

    
6300
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6301
        }
6302

    
6303
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6304
        {
6305
            multi_Undo_Data = new Multi_Undo_data();
6306

    
6307
            multi_Undo_Data.Markup = control;
6308

    
6309
            if ((control as IShapeControl) != null)
6310
            {
6311
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6312
            }
6313
            if ((control as IDashControl) != null)
6314
            {
6315
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6316
            }
6317
            if ((control as IPath) != null)
6318
            {
6319
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6320
            }
6321
            if ((control as UIElement) != null)
6322
            {
6323
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6324
            }
6325

    
6326
            return multi_Undo_Data;
6327
        }
6328

    
6329
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6330
        {
6331
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6332
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6333
            {
6334
                if (items.UserID == Select_ID)
6335
                {
6336
                    foreach (var item in items.MarkupList)
6337
                    {
6338
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6339
                        {
6340
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6341
                                items.MarkupInfoID, Commons.shortGuid());
6342
                        }
6343
                    }
6344
                }
6345
            }
6346
        }
6347

    
6348
        public void InkControl_Convert()
6349
        {
6350
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6351
            if (inkBoard.Strokes.Count > 0)
6352
            {
6353
                inkBoard.Strokes.ToList().ForEach(stroke =>
6354
                {
6355
                    List<Stroke> removingStroke = new List<Stroke>();
6356
                    StrokeCollection stC = new StrokeCollection();
6357

    
6358
                    removingStroke.Add(stroke);
6359

    
6360
                    InkToPath ip = new InkToPath();
6361
                    List<Point> inkPointSet = new List<Point>();
6362
                    PolygonControl pc = null;
6363
                    pc = new PolygonControl()
6364
                    {
6365
                        Angle = 0,
6366
                        PointSet = new List<Point>(),
6367
                        ControlType = ControlType.Ink
6368
                    };
6369
                    foreach (var item in removingStroke)
6370
                    {
6371
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6372
                        inkBoard.Strokes.Remove(item);
6373
                    }
6374
                    if (inkPointSet.Count != 0)
6375
                    {
6376
                        //강인구 추가(PenControl Undo Redo 추가)
6377
                        UndoData = new Undo_data()
6378
                        {
6379
                            IsUndo = false,
6380
                            Event = Event_Type.Create,
6381
                            EventTime = DateTime.Now,
6382
                            Markup_List = new List<Multi_Undo_data>()
6383
                        };
6384

    
6385
                        pc.StartPoint = inkPointSet[0];
6386
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6387
                        pc.PointSet = inkPointSet;
6388
                        pc.LineSize = 3;
6389
                        pc.CommentID = Commons.shortGuid();
6390
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6391
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6392
                        ///pc.SetPolyPath();
6393

    
6394
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6395
                        {
6396
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6397
                        });
6398
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6399
                        UndoData.Markup_List.Add(multi_Undo_Data);
6400
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6401
                    }
6402
                });
6403
            }
6404
        }
6405

    
6406
        /// <summary>
6407
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6408
        /// </summary>
6409
        /// <param name="StartP">StartPoint</param>
6410
        /// <param name="EndP">EndPoint</param>
6411
        /// <returns>Return_EndPoint</returns>
6412
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6413
        {
6414
            Point Return_Point = new Point();
6415

    
6416
            double dx = EndP.X - StartP.X;
6417
            double dy = EndP.Y - StartP.Y;
6418
            double length;
6419

    
6420
            switch (controlType)
6421
            {
6422
                case ControlType.Triangle:
6423
                    {
6424
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6425
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6426
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6427
                    }
6428
                    break;
6429
                default:
6430
                    {
6431
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6432
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6433
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6434
                    }
6435
                    break;
6436
            }
6437

    
6438
            return Return_Point;
6439
        }
6440

    
6441
        /// <summary>
6442
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6443
        /// </summary>
6444
        /// <author>humkyung</author>
6445
        /// <date>2018.04.26</date>
6446
        /// <param name="StartP"></param>
6447
        /// <param name="EndP"></param>
6448
        /// <returns></returns>
6449
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6450
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6451
        {
6452
            List<Point> res = new List<Point>();
6453

    
6454
            double dx = EndP.X - StartP.X;
6455
            double dy = EndP.Y - StartP.Y;
6456
            double length = Math.Sqrt(dx * dx + dy * dy);
6457
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6458
            dx /= length;
6459
            dy /= length;
6460
            double tmp = dx;
6461
            dx = -dy; dy = tmp; /// rotate by 90 degree
6462

    
6463
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6464
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6465

    
6466
            return res;
6467
        }
6468

    
6469
        /// <summary>
6470
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6471
        /// </summary>
6472
        /// <author>ingu</author>
6473
        /// <date>2018.06.05</date>
6474
        /// <param name="getPoint"></param>
6475
        /// <returns></returns>
6476
        private bool IsGetoutpoint(Point getPoint)
6477
        {
6478
            if (getPoint == new Point())
6479
            {
6480
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6481
                currentControl = null;
6482
                return true;
6483
            }
6484

    
6485
            return false;
6486
        }
6487

    
6488
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6489
        {
6490
            e.Effects = DragDropEffects.Copy;
6491
        }
6492

    
6493
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6494
        {
6495
            e.Effects = DragDropEffects.Copy;
6496
        }
6497

    
6498
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6499
        {
6500
            e.Effects = DragDropEffects.None;
6501
        }
6502

    
6503
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6504
        {
6505
            try
6506
            {
6507
                if (e.Data.GetDataPresent(typeof(string)))
6508
                {
6509
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6510
                    string dragData = e.Data.GetData(typeof(string)) as string;
6511
                    Move_Symbol(sender, dragData);
6512
                }
6513
            }
6514
            catch (Exception ex)
6515
            {
6516
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6517
            }            
6518
        }
6519

    
6520
        private void Move_Symbol(object sender, string dragData)
6521
        {
6522
            try
6523
            {
6524
                if (dragData.Contains("|DZ|"))
6525
                {
6526
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6527

    
6528
                    string[] delimiterChars = { "|DZ|" };
6529
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6530

    
6531
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6532

    
6533
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6534

    
6535
                    //강인구 Undo/Redo 보류
6536
                    UndoData = new Undo_data()
6537
                    {
6538
                        IsUndo = false,
6539
                        Event = Event_Type.Create,
6540
                        EventTime = DateTime.Now,
6541
                        Markup_List = new List<Multi_Undo_data>()
6542
                    };
6543

    
6544
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6545
                    {
6546
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6547
                    });
6548

    
6549
                    foreach (string parse in data)
6550
                    {
6551
                        if (parse != "")
6552
                        {
6553
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
6554
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
6555

    
6556
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6557
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6558

    
6559
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6560

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

    
6563
                            UndoData.Markup_List.Add(multi_Undo_Data);
6564
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6565
                        }
6566
                    }
6567
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6568

    
6569
                    /// move symbol to current mouse point
6570
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6571
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6572
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6573

    
6574
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6575
                    {
6576
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6577
                    }
6578
                    /// up to here
6579

    
6580
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6581
                }
6582
            }
6583
            catch (Exception ex)
6584
            {
6585
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
6586
            }            
6587
        }        
6588
    }
6589
}
클립보드 이미지 추가 (최대 크기: 500 MB)