프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

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

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

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

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

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

    
270
            return false;
271
        }
272

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

    
296
            return false;
297
        }
298

    
299

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

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

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

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

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

    
327
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
328

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

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

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

    
373
            DeleteItem(item);
374
        }
375

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

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

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

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

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

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

    
422
            ////GC.Collect();
423
        }
424
        
425
        public List<CommentUserInfo> AddAdorner()
426
        {
427
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
428

    
429
            if (SelectLayer.Children.Count > 0)
430
            {
431
                foreach (var item in SelectLayer.Children)
432
                {
433
                    if (item.GetType().Name == "AdornerFinal")
434
                    {
435
                        (item as AdornerFinal).unRegister();
436

    
437
                        foreach (var InnerItem in (item as AdornerFinal).MemberSet.Cast<AdornerMember>())
438
                        {
439
                            if (!ViewerDataModel.Instance.MarkupControls_USER.Contains(InnerItem.DrawingData))
440
                            {
441
                                adornerSet.Add(InnerItem.DrawingData as CommentUserInfo);
442
                            }
443

    
444
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
445

    
446
                            UndoData.Markup_List.Add(multi_Undo_Data);
447
                            multi_Undo_Data = new Multi_Undo_data();
448
                        }
449
                    }
450
                }
451
                SelectLayer.Children.Clear();
452
            }
453
            return adornerSet;
454
        }
455

    
456
        public void ChangeCommentReact()
457
        {
458
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
459
            bool isComingNewBie = false;
460

    
461
            if (ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
462
            {
463
                foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
464
                {
465
                    var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
466

    
467
                    var existItem = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.ID == root.CommentID).FirstOrDefault();
468
                    if (existItem != null) //신규 추가 된 코멘트
469
                    {
470
                        if (existItem.Data != root.ConvertData) //코멘트가 같은지
471
                        {
472
                            existItem.Data = root.ConvertData;
473
                            existItem.IsUpdate = true;
474
                            ComingNewBieEnd = false;
475
                        }
476
                    }
477
                    else
478
                    {
479
                        if (root.CommentID != null)
480
                        {
481
                            isComingNewBie = true;
482
                            var currentCommentCheck = ViewerDataModel.Instance.MarkupList_USER.Where(dt => dt.ID == control.CommentID).FirstOrDefault();
483
                            if (currentCommentCheck != null)
484
                            {
485
                                currentCommentCheck.Data = root.ConvertData;
486
                            }
487
                            else
488
                            {
489
                                ViewerDataModel.Instance.MarkupList_USER.Add(new MarkupItemEx
490
                                {
491
                                    ID = control.CommentID,
492
                                    Data = root.ConvertData,
493
                                    Data_Type = root.DATA_TYPE,
494
                                    MarkupInfoID = App.Custom_ViewInfoId,
495
                                    PageNumber = this.pageNavigator.CurrentPage.PageNumber,
496
                                    Symbol_ID = control.SymbolID,
497
                                    Group_ID = control.GroupID,
498
                                });
499
                                ComingNewBieEnd = false;
500
                            }
501
                        }
502
                    }
503
                }
504
            }
505

    
506

    
507
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
508
            {
509
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
510
                {
511
                    ComingNewBieEnd = true;
512
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
513
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
514
                    gridViewMarkup.ItemsSource = null;
515
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
516
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
517
                }
518
            }
519
        }
520

    
521
        bool ComingNewBieEnd = false;
522

    
523
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
524
        {
525
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
526
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
527
            {
528
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
529
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
530
            }
531
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
532
            ViewerDataModel.Instance.UndoDataList.Clear();
533

    
534
            InkControl_Convert();
535

    
536
            SelectionSet.Instance.UnSelect(this);
537
            ChangeCommentReact();
538

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

    
543

    
544
            #region 페이지가 벗어난 경우
545

    
546
            if (BalancePoint < 1)
547
            {
548
                BalancePoint = 1;
549
                ViewerDataModel.Instance.PageBalanceNumber = 0;
550
            }
551

    
552
            if (pageNavigator.PageCount < BalancePoint)
553
            {
554
                BalancePoint = pageNavigator.PageCount;
555
                ViewerDataModel.Instance.PageBalanceNumber = 0;
556
            }
557

    
558
            #endregion
559

    
560
            ViewerDataModel.Instance.PageNumber = BalancePoint;
561

    
562
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
563
            string uri = "";
564
            if (userData.COMPANY != "EXT")
565
            {
566
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
567
            }
568
            else
569
            {
570
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
571
            }
572

    
573
            var defaultBitmapImage = new BitmapImage();
574
            defaultBitmapImage.BeginInit();
575
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
576
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
577
            defaultBitmapImage.UriSource = new Uri(uri);
578
            defaultBitmapImage.EndInit();
579

    
580
            ViewerDataModel.Instance.ImageViewPath = null;
581
            GC.Collect();
582

    
583
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
584
            if (defaultBitmapImage.IsDownloading)
585
            {
586
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
587
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
588
                {
589
                    defaultBitmapImage.Freeze();
590
                    mainPanel.UpdateLayout();
591
                    GC.Collect();
592
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
593
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
594
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
595
                };
596
            }
597

    
598
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
599
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
600

    
601

    
602
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
603
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
604
            inkBoard.Width = zoomAndPanCanvas.Width;
605
            inkBoard.Height = zoomAndPanCanvas.Height;
606

    
607

    
608

    
609
            if (!testPanel2.IsHidden)
610
            {
611
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
612
                //PDF모드일때 잠시 대기(강인구)
613
                if (IsSyncPDFMode)
614
                {
615
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
616
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
617

    
618
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
619
                    if (pdfpath.IsDownloading)
620
                    {
621
                        pdfpath.DownloadCompleted += (ex, arg) =>
622
                        {
623
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
624
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
625
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
626
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
627
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
628
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
629
                        };
630
                    }
631
                    else
632
                    {
633
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
634
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
635
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
636
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
637

    
638
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
639
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
640
                    }
641
                }
642
                else
643
                {
644
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
645
                    string uri2 = "";
646
                    if (userData.COMPANY != "EXT")
647
                    {
648
                        uri2 = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
649
                    }
650
                    else
651
                    {
652
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
653
                    }
654

    
655
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
656
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
657

    
658
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
659
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
660
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
661
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
662
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
663
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
664

    
665
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
666
                    zoomAndPanControl.ZoomTo(new Rect
667
                    {
668
                        X = 0,
669
                        Y = 0,
670
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
671
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
672
                    });
673

    
674
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
675
                    if (defaultBitmapImage_Compare.IsDownloading)
676
                    {
677
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
678
                        {
679
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
680
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
681
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
682
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
683

    
684
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
685
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
686

    
687
                            zoomAndPanControl.ZoomTo(new Rect
688
                            {
689
                                X = 0,
690
                                Y = 0,
691
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
692
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
693
                            });
694
                        };
695
                    }
696
                }
697
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
698
            }
699

    
700
            this.pageNavigator.SetNextPage();
701

    
702
            if (zoomAndPanCanvas2.Width.IsNaN())
703
            {
704
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
705
            }
706
            Logger.sendCheckLog("pageNavigator_PageChanging_ControlData Setting", 1);
707
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();  //전체 제거
708
            Common.ViewerDataModel.Instance.MarkupControls.Clear();  //전체 제거
709

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

    
712
            foreach (var item in gridSelectionItem)
713
            {
714
                if (item.UserID == App.ViewInfo.UserID)
715
                {
716
                    ViewerDataModel.Instance.current_page_commentcnt = ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().Count;
717
                    ViewerDataModel.Instance.MarkupList_USER.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
718
                    {
719
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, item.DisplayColor, "", 
720
                            item.MarkupInfoID, markupitem.ID);
721
                    });
722

    
723
                }
724
                else
725
                {
726
                    ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.PageNumber == pageNavigator.CurrentPage.PageNumber && data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(delegate (MarkupItemEx markupitem)
727
                    {
728
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls, item.DisplayColor, "", item.MarkupInfoID);
729
                    });
730
                }
731
            }
732

    
733
            if (!testPanel2.IsHidden)
734
            {
735
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
736
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
737
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
738

    
739
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
740
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
741

    
742

    
743
                foreach (var item in gridSelectionRevItem)
744
                {
745
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
746
                    {
747
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
748
                    });
749
                }
750
            }
751

    
752
            var instanceMain = this.ParentOfType<MainWindow>();
753
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
754
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
755

    
756
            instanceMain.dzTopMenu.rotateOffSet = 0;
757
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
758
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
759

    
760
            //}
761
            SetCommentPages(true);
762
        }
763

    
764

    
765
        
766

    
767
        private void SetCommentPages(bool onlyMe = false)
768
        {
769
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
770
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
771
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
772
            {
773
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
774
                instance.UserName = item.UserName;
775
                instance.Depart = item.Depatment;
776
                instance.MarkupInfoID = item.MarkupInfoID;
777
                instance.IsSelected = true;
778
                instance.isConSolidation = item.Consolidate;
779
                instance.SetColor = item.DisplayColor;
780
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
781
                {
782
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_USER.Select(d => d.PageNumber).ToList();
783
                }
784
                else
785
                {
786
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
787
                }
788
                _pages.Add(instance);
789
            }
790
            this.pageNavigator.SetCommentList(_pages.ToList());
791
        }
792

    
793
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
794
        {
795
            if (e.MiddleButton == MouseButtonState.Pressed)
796
            {
797

    
798
            }
799
            e.Handled = true;
800
            if (e.Delta > 0)
801
            {
802
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
803
                ZoomIn(currentContentMousePoint);
804
            }
805
            else
806
            {
807
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
808
                ZoomOut(currentContentMousePoint);
809
            }
810
        }
811

    
812
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
813
        {
814
            e.Handled = true;
815
            if (e.Delta > 0)
816
            {
817
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
818
                ZoomIn_Sync(currentContentMousePoint);
819
            }
820
            else
821
            {
822
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
823
                ZoomOut_Sync(currentContentMousePoint);
824
            }
825
        }
826

    
827
        #region ZoomIn & ZoomOut
828

    
829
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
830
        {
831
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
832
                zoomAndPanControl.ContentZoomFocusY));
833
        }
834

    
835
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
836
        {
837
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
838
                zoomAndPanControl.ContentZoomFocusY));
839
        }
840

    
841

    
842
        //강인구 추가 (줌 인아웃 수치 변경)
843
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
844
        private void ZoomOut(Point contentZoomCenter)
845
        {
846
            if (zoomAndPanControl.ContentScale > 0.39)
847
            {
848
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
849
            }
850
            else
851
            {
852
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
853
            }
854

    
855
            if (zoomAndPanControl2 != null && Sync.IsChecked)
856
            {
857
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
858
            }
859
        }
860

    
861
        private void ZoomIn(Point contentZoomCenter)
862
        {
863
            if (zoomAndPanControl.ContentScale > 0.19)
864
            {
865
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
866
            }
867
            else
868
            {
869
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
870
            }
871

    
872
            if (zoomAndPanControl2 != null && Sync.IsChecked)
873
            {
874
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
875
            }
876

    
877
        }
878

    
879
        private void ZoomOut_Sync(Point contentZoomCenter)
880
        {
881
            if (zoomAndPanControl2.ContentScale > 0.39)
882
            {
883
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
884
            }
885
            else
886
            {
887
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
888
            }
889

    
890
            if (Sync.IsChecked)
891
            {
892
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
893
            }
894
        }
895

    
896
        private void ZoomIn_Sync(Point contentZoomCenter)
897
        {
898
            if (zoomAndPanControl2.ContentScale > 0.19)
899
            {
900
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
901
            }
902
            else
903
            {
904
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
905
            }
906

    
907
            if (Sync.IsChecked)
908
            {
909
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
910
            }
911
        }
912

    
913
        private void ZoomOut()
914
        {
915
            zoomAndPanControl.ContentScale -= 0.1;
916
            //if (zoomAndPanControl2 != null)
917
            //{
918
            //    zoomAndPanControl2.ContentScale -= 0.1;
919
            //}
920
        }
921

    
922
        private void ZoomIn()
923
        {
924
            zoomAndPanControl.ContentScale += 0.1;
925
            //if (zoomAndPanControl2 != null)
926
            //{
927
            //    zoomAndPanControl2.ContentScale += 0.1;
928
            //}
929
        }
930

    
931
        #endregion
932

    
933
        private void init()
934
        {
935
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
936
            {
937

    
938
                ControlList.Clear();
939
                listBox.Items.Clear();
940
                selected_item.Clear();
941

    
942
                (item as IMarkupCommonData).IsSelected = false;
943
            }
944

    
945
        }
946

    
947
        private HitTestResultBehavior MyCallback(HitTestResult result)
948
        {
949
            //this.cursor = Cursors.UpArrow;
950
            var element = result.VisualHit;
951
            while (element != null && !(element is CommentUserInfo))
952
                element = VisualTreeHelper.GetParent(element);
953

    
954
            if (element == null)
955
            {
956
                return HitTestResultBehavior.Stop;
957
            }
958
            else
959
            {
960
                if (element is CommentUserInfo)
961
                {
962
                    if (!hitList.Contains(element))
963
                    {
964
                        hitList.Add((CommentUserInfo)element);
965
                    }
966
                    else
967
                    {
968
                        return HitTestResultBehavior.Stop;
969
                    }
970
                    //IntersectionDetail intersectionDetail =
971
                    //((GeometryHitTestResult)result).IntersectionDetail;
972
                    //switch (intersectionDetail)
973
                    //{
974
                    //    case IntersectionDetail.FullyContains:
975
                    //        // Add the hit test result to the list:
976
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
977
                    //        return HitTestResultBehavior.Continue;
978
                    //    case IntersectionDetail.Intersects:
979
                    //        // Set the behavior to return visuals at all z-order levels:
980
                    //        return HitTestResultBehavior.Continue;
981
                    //    case IntersectionDetail.FullyInside:
982
                    //        // Set the behavior to return visuals at all z-order levels:
983
                    //        return HitTestResultBehavior.Continue;
984
                    //    default:
985
                    //        return HitTestResultBehavior.Stop;
986
                    //}
987
                }
988
            }
989
            return HitTestResultBehavior.Continue;
990
        }
991

    
992
        public void ReleaseSelectPath()
993
        {
994
            if (SelectionPath == null)
995
            {
996
                SelectionPath = new Path();
997
                SelectionPath.Name = "";
998
            }
999
            if (SelectionPath.Name != "")
1000
            {
1001
                SelectionPath.Name = "None";
1002
            }
1003
            SelectionPath.Opacity = 0.01;
1004
            SelectionPath.RenderTransform = null;
1005
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1006
        }
1007

    
1008
        #region 컨트롤 초기화 
1009
        public void Control_Init(object control)
1010
        {
1011
            if (L_Size != 0 && (control as IPath) != null)
1012
            {
1013
                (control as IPath).LineSize = L_Size;
1014
                L_Size = 0;
1015
            }
1016

    
1017
            switch (control.GetType().Name)
1018
            {
1019
                case "RectangleControl":
1020
                    {
1021
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1022
                    }
1023
                    break;
1024
                case "CircleControl":
1025
                    {
1026
                        (control as CircleControl).StrokeColor = Brushes.Red;
1027
                    }
1028
                    break;
1029
                case "TriControl":
1030
                    {
1031
                        (control as TriControl).StrokeColor = Brushes.Red;
1032
                    }
1033
                    break;
1034
                case "RectCloudControl":
1035
                    {
1036
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1037
                    }
1038
                    break;
1039
                case "CloudControl":
1040
                    {
1041
                        (control as CloudControl).StrokeColor = Brushes.Red;
1042
                    }
1043
                    break;
1044
                case "PolygonControl":
1045
                    {
1046
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1047
                    }
1048
                    break;
1049
                case "ArcControl":
1050
                    {
1051
                        (control as ArcControl).StrokeColor = Brushes.Red;
1052
                    }
1053
                    break;
1054
                case "ArrowArcControl":
1055
                    {
1056
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1057
                    }
1058
                    break;
1059
                case "LineControl":
1060
                    {
1061
                        (control as LineControl).StrokeColor = Brushes.Red;
1062
                    }
1063
                    break;
1064
                case "ArrowControl_Multi":
1065
                    {
1066
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1067
                    }
1068
                    break;
1069
                case "TextControl":
1070
                    {
1071
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1072
                    }
1073
                    break;
1074
                case "ArrowTextControl":
1075
                    {
1076
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1077
                    }
1078
                    break;
1079
                case "InsideWhiteControl":
1080
                    {
1081
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1082
                    }
1083
                    break;
1084
                case "OverlapWhiteControl":
1085
                    {
1086
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1087
                    }
1088
                    break;
1089
                case "ClipWhiteControl":
1090
                    {
1091
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1092
                    }
1093
                    break;
1094
                case "CoordinateControl":
1095
                    {
1096
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1097
                    }
1098
                    break;
1099
            }
1100
        }
1101
        #endregion
1102

    
1103
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1104
        {
1105
            //Control_Init(e.Source);
1106
        }
1107
        private Window _dragdropWindow = null;
1108

    
1109
        [DllImport("user32.dll")]
1110
        [return: MarshalAs(UnmanagedType.Bool)]
1111
        internal static extern bool GetCursorPos(ref Win32Point pt);
1112

    
1113
        [StructLayout(LayoutKind.Sequential)]
1114
        internal struct Win32Point
1115
        {
1116
            public Int32 X;
1117
            public Int32 Y;
1118
        };
1119
        public string symbol_id = null;
1120
        public long symbol_group_id;
1121
        public int symbol_SelectedIndex;
1122
        public ImageSource symbol_img;
1123
        public string symbol_Data = null;
1124
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1125
        {
1126
            if (this._dragdropWindow != null)
1127
            {
1128
                this._dragdropWindow.Close();
1129
                this._dragdropWindow = null;
1130
            }
1131

    
1132
            symbol_id = id;
1133
            symbol_group_id = group_id;
1134
            symbol_SelectedIndex = SelectedIndex;
1135
            symbol_Data = Data_;
1136
            symbol_img = img;
1137

    
1138
      
1139
            CreateDragDropWindow2(img);
1140
        }
1141

    
1142
        private void CreateDragDropWindow2(ImageSource image)
1143
        {
1144
            this._dragdropWindow = new Window();
1145
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1146
            _dragdropWindow.WindowStyle = WindowStyle.None;
1147
            _dragdropWindow.AllowsTransparency = true;           
1148
            _dragdropWindow.AllowDrop = false;
1149
            _dragdropWindow.Background = null;
1150
            _dragdropWindow.IsHitTestVisible = false;
1151
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1152
            _dragdropWindow.Topmost = true;
1153
            _dragdropWindow.ShowInTaskbar = false;
1154
            
1155
            Rectangle r = new Rectangle();
1156
            r.Width = image.Width;
1157
            r.Height = image.Height;
1158
            r.Opacity = 0.5;            
1159
            r.Fill = new ImageBrush(image);
1160
            this._dragdropWindow.Content = r;
1161

    
1162
            Win32Point w32Mouse = new Win32Point();
1163
            GetCursorPos(ref w32Mouse);
1164

    
1165
            //w32Mouse.X = getCurrentPoint.X;
1166
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1167
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1168
            this._dragdropWindow.Show();
1169
        }
1170

    
1171
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1172
        {
1173
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1174
            {
1175
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1176

    
1177
                Point currentPos = e.GetPosition(rect);
1178

    
1179
                floatingTip.HorizontalOffset = currentPos.X + 20;
1180
                floatingTip.VerticalOffset = currentPos.Y;
1181

    
1182

    
1183
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1184
                //tool.Content = "ToolTip";
1185
                //panel.ToolTip = tool;
1186
            }
1187

    
1188
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1189
            {
1190
                #region 마우스 오버 시 색상 변경
1191
                //var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1192
                //Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1193

    
1194
                //if (firstCondition != null)
1195
                //{
1196
                //    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1197

    
1198
                //    if (firstCondition.GetType().Name == "TextControl")
1199
                //    {
1200
                //        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1201
                //        return;
1202
                //    }
1203
                //    else if (firstCondition.GetType().Name == "ArrowTextControl")
1204
                //    {
1205
                //        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1206
                //        return;
1207
                //    }
1208

    
1209
                //    if (L_Size == 0)
1210
                //    {
1211
                //        L_Size = (firstCondition as IPath).LineSize;
1212
                //        (firstCondition as IPath).LineSize *= 4;
1213
                //    }
1214
                //    switch (firstCondition.GetType().Name)
1215
                //    {
1216
                //        case "RectangleControl":
1217
                //            {
1218
                //                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1219
                //            }
1220
                //            break;
1221
                //        case "CircleControl":
1222
                //            {
1223
                //                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1224
                //            }
1225
                //            break;
1226
                //        case "TriControl":
1227
                //            {
1228
                //                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1229
                //            }
1230
                //            break;
1231
                //        case "RectCloudControl":
1232
                //            {
1233
                //                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1234
                //            }
1235
                //            break;
1236
                //        case "CloudControl":
1237
                //            {
1238
                //                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1239
                //            }
1240
                //            break;
1241
                //        case "PolygonControl":
1242
                //            {
1243
                //                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1244
                //            }
1245
                //            break;
1246
                //        case "ArcControl":
1247
                //            {
1248
                //                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1249
                //            }
1250
                //            break;
1251
                //        case "LineControl":
1252
                //            {
1253
                //                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1254
                //            }
1255
                //            break;
1256
                //        case "ArrowControl_Multi":
1257
                //            {
1258
                //                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1259
                //            }
1260
                //            break;
1261

    
1262
                //        default:
1263
                //            {
1264

    
1265
                //            }
1266
                //            break;
1267
                //    }
1268
                //} 
1269
                #endregion
1270
            }
1271

    
1272
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1273
            #region 주석
1274
            //if (mouseButtonDown == MouseButton.Middle)
1275
            //{
1276
            //    SetCursor();
1277
            //    Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1278
            //    Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1279

    
1280
            //    Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1281
            //    zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1282
            //    zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1283

    
1284
            //    //SetCursor();
1285
            //    //Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1286
            //    //Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1287

    
1288
            //    //Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1289

    
1290
            //    //zoomAndPanControl.ContentOffsetX += 1;
1291
            //    //zoomAndPanControl.ContentOffsetY += 1;
1292

    
1293
            //    //zoomAndPanControl.ContentOffsetX += dragOffset.X;
1294
            //    //zoomAndPanControl.ContentOffsetY += dragOffset.Y;
1295
            //}
1296
            #endregion
1297

    
1298
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
1299
            {
1300
                SetCursor();
1301
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1302
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1303

    
1304
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1305
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1306
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1307

    
1308
                if (Sync.IsChecked)
1309
                {
1310
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1311
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1312
                }
1313
            }
1314

    
1315
            if (mouseHandlingMode == MouseHandlingMode.Drawing && mouseButtonDown == MouseButton.Left)
1316
            {
1317
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1318
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1319
                SetCursor();
1320

    
1321
                if (IsDrawing)
1322
                {
1323
                    if (currentControl == null)
1324
                    {
1325
                        switch (controlType)
1326
                        {
1327
                            case ControlType.PenControl:
1328
                                {
1329
                                    if (inkBoard.Tag.ToString() == "Ink")
1330
                                    {
1331
                                        stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1332
                                    }
1333
                                    else if (inkBoard.Tag.ToString() == "EraseByPoint")
1334
                                    {
1335
                                        RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1336
                                    }
1337
                                    else if (inkBoard.Tag.ToString() == "EraseByStroke")
1338
                                    {
1339
                                        RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1340
                                    }
1341

    
1342
                                    //inkBoard.Strokes.Add(stroke);
1343
                                }
1344
                                break;
1345
                        }
1346
                        return;
1347
                    }
1348
                }
1349

    
1350
                if (currentControl != null)
1351
                {
1352
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1353
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1354
                    //강인구 추가
1355
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1356

    
1357
                    if ((currentControl as IPath) != null)
1358
                    {
1359
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1360
                    }
1361
                    if ((currentControl as LineControl) != null)
1362
                    {
1363
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1364
                    }
1365

    
1366
                    if ((currentControl as IShapeControl) != null)
1367
                    {
1368
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1369
                    }
1370
                    if ((currentControl as TextControl) != null)
1371
                    {
1372
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1373
                        {
1374
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1375
                        }
1376
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1377
                        {
1378
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1379
                        }
1380
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1381
                        {
1382
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1383
                        }
1384
                    }
1385
                    else if ((currentControl as ArrowTextControl) != null)
1386
                    {
1387
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1388
                        {
1389
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1390
                        }
1391
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1392
                        {
1393
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1394
                        }
1395
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1396
                        {
1397
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1398
                        }
1399
                    }
1400
                    else if ((currentControl as RectCloudControl) != null)
1401
                    {
1402
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1403
                    }
1404
                    else if ((currentControl as CloudControl) != null)
1405
                    {
1406
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1407
                    }
1408

    
1409
                    switch (controlType)
1410
                    {
1411
                        case (ControlType.Coordinate):
1412
                            {
1413
                                var control = currentControl as CoordinateControl;
1414

    
1415
                                if (control != null)
1416
                                {
1417
                                    if (move.mousemode == MouseMode.Drawing)
1418
                                    {
1419
                                        //move.control_Move(ControlList, true, moveX, moveY);
1420
                                    }
1421
                                    else
1422
                                    {
1423
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1424
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1425
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1426
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1427

    
1428

    
1429
                                        if (ViewerDataModel.Instance.IsPressShift)
1430
                                        {
1431
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1432
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1433
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1434
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1435
                                        }
1436

    
1437
                                        control.PointSet = new List<Point>
1438
                                        {
1439
                                            control.StartPoint,
1440
                                            control.LeftBottomPoint,
1441
                                            control.EndPoint,
1442
                                            control.TopRightPoint,
1443
                                        };
1444
                                        control.updateControl();
1445
                                    }
1446

    
1447
                                    //강인구 추가
1448
                                    control.ControlType = controlType;
1449
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1450
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1451
                                    //  control.Paint = PaintSet.Fill;
1452
                                }
1453
                            }
1454
                            break;
1455
                        case (ControlType.InsideWhite):
1456
                            {
1457
                                var control = currentControl as InsideWhiteControl;
1458

    
1459
                                if (control != null)
1460
                                {
1461
                                    if (move.mousemode == MouseMode.Drawing)
1462
                                    {
1463
                                        //move.control_Move(ControlList, true, moveX, moveY);
1464
                                    }
1465
                                    else
1466
                                    {
1467
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1468
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1469
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1470
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1471

    
1472

    
1473
                                        if (ViewerDataModel.Instance.IsPressShift)
1474
                                        {
1475
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1476
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1477
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1478
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1479
                                        }
1480

    
1481
                                        control.PointSet = new List<Point>
1482
                                        {
1483
                                            control.StartPoint,
1484
                                            control.LeftBottomPoint,
1485
                                            control.EndPoint,
1486
                                            control.TopRightPoint,
1487
                                        };
1488
                                        control.updateControl();
1489
                                    }
1490

    
1491
                                    //강인구 추가
1492
                                    control.ControlType = controlType;
1493
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1494
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1495
                                    control.Paint = PaintSet.Fill;
1496
                                }
1497
                            }
1498
                            break;
1499
                        case (ControlType.OverlapWhite):
1500
                            {
1501
                                var control = currentControl as OverlapWhiteControl;
1502

    
1503
                                if (control != null)
1504
                                {
1505
                                    if (move.mousemode == MouseMode.Drawing)
1506
                                    {
1507
                                        //move.control_Move(ControlList, true, moveX, moveY);
1508
                                    }
1509
                                    else
1510
                                    {
1511
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1512
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1513
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1514
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1515

    
1516

    
1517
                                        if (ViewerDataModel.Instance.IsPressShift)
1518
                                        {
1519
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1520
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1521
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1522
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1523
                                        }
1524

    
1525
                                        control.PointSet = new List<Point>
1526
                                        {
1527
                                            control.StartPoint,
1528
                                            control.LeftBottomPoint,
1529
                                            control.EndPoint,
1530
                                            control.TopRightPoint,
1531
                                        };
1532
                                        control.updateControl();
1533
                                    }
1534

    
1535
                                    //강인구 추가
1536
                                    control.ControlType = controlType;
1537
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1538
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1539
                                    control.Paint = PaintSet.Fill;
1540
                                }
1541
                            }
1542
                            break;
1543
                        case (ControlType.ClipWhite):
1544
                            {
1545
                                var control = currentControl as ClipWhiteControl;
1546

    
1547
                                if (control != null)
1548
                                {
1549
                                    if (move.mousemode == MouseMode.Drawing)
1550
                                    {
1551
                                        //move.control_Move(ControlList, true, moveX, moveY);
1552
                                    }
1553
                                    else
1554
                                    {
1555
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1556
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1557
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1558
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1559

    
1560

    
1561
                                        if (ViewerDataModel.Instance.IsPressShift)
1562
                                        {
1563
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1564
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1565
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1566
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1567
                                        }
1568

    
1569
                                        control.PointSet = new List<Point>
1570
                                        {
1571
                                            control.StartPoint,
1572
                                            control.LeftBottomPoint,
1573
                                            control.EndPoint,
1574
                                            control.TopRightPoint,
1575
                                        };
1576
                                        control.updateControl();
1577
                                    }
1578

    
1579
                                    //강인구 추가
1580
                                    control.ControlType = controlType;
1581
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1582
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1583
                                    control.Paint = PaintSet.Fill;
1584
                                }
1585
                            }
1586
                            break;
1587
                        case ControlType.Rectangle:
1588
                            {
1589
                                var control = currentControl as RectangleControl;
1590

    
1591
                                if (control != null)
1592
                                {
1593
                                    if (move.mousemode == MouseMode.Drawing)
1594
                                    {
1595
                                        //move.control_Move(ControlList, true, moveX, moveY);
1596
                                    }
1597
                                    else
1598
                                    {
1599
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1600
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1601
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1602
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1603

    
1604

    
1605
                                        if (ViewerDataModel.Instance.IsPressShift)
1606
                                        {
1607
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1608
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1609
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1610
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1611
                                        }
1612

    
1613
                                        control.PointSet = new List<Point>
1614
                                        {
1615
                                            control.StartPoint,
1616
                                            control.LeftBottomPoint,
1617
                                            control.EndPoint,
1618
                                            control.TopRightPoint,
1619
                                        };
1620
                                        control.updateControl();
1621
                                    }
1622

    
1623
                                    //강인구 추가
1624
                                    control.ControlType = controlType;
1625
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1626
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1627
                                }
1628
                            }
1629
                            break;
1630

    
1631
                        case ControlType.RectCloud:
1632
                            {
1633
                                var control = currentControl as RectCloudControl;
1634

    
1635
                                if (control != null)
1636
                                {
1637
                                    if (move.mousemode == MouseMode.Drawing)
1638
                                    {
1639
                                        //move.control_Move(ControlList, true, moveX, moveY);
1640
                                    }
1641
                                    else
1642
                                    {
1643
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1644
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1645
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1646
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1647

    
1648
                                        if (ViewerDataModel.Instance.IsPressShift)
1649
                                        {
1650
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1651
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1652
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1653
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1654
                                        }
1655

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

    
1665
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1666
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1667
                                }
1668
                            }
1669
                            break;
1670

    
1671
                        case ControlType.SingleLine:
1672
                            {
1673
                                var control = currentControl as LineControl;
1674
                                if (control != null)
1675
                                {
1676
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1677
                                    control.ControlType = controlType;
1678
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1679
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1680
                                    Point tempPoint = control.EndPoint;
1681

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

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

    
1699
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1700
                                }
1701

    
1702
                            }
1703
                            break;
1704

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

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

    
1728

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

    
1737

    
1738
                            }
1739
                            break;
1740

    
1741
                        case ControlType.ArrowLine:
1742
                            {
1743
                                var control = currentControl as LineControl;
1744
                                if (control != null)
1745
                                {
1746
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1747
                                    control.ControlType = controlType;
1748
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1749
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1750
                                    Point tempPoint = control.EndPoint;
1751

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

    
1763

    
1764
                                    control.PointSet = new List<Point>
1765
                                            {
1766
                                                control.StartPoint,
1767
                                                control.EndPoint,
1768
                                            };
1769
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1770
                                }
1771
                            }
1772
                            break;
1773

    
1774
                        case ControlType.TwinLine:
1775
                            {
1776
                                var control = currentControl as LineControl;
1777
                                if (control != null)
1778
                                {
1779
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1780
                                    control.ControlType = controlType;
1781
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1782
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1783
                                    Point tempPoint = control.EndPoint;
1784

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

    
1796

    
1797
                                    control.PointSet = new List<Point>
1798
                                            {
1799
                                                control.StartPoint,
1800
                                                control.EndPoint,
1801
                                            };
1802
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1803
                                }
1804
                            }
1805
                            break;
1806

    
1807
                        case ControlType.DimLine:
1808
                            {
1809
                                var control = currentControl as LineControl;
1810
                                if (control != null)
1811
                                {
1812
                                    control.LineStyleSet = LineStyleSet.DimLine;
1813
                                    control.ControlType = controlType;
1814
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1815
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1816
                                    Point tempPoint = control.EndPoint;
1817

    
1818
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1819
                                    {
1820
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1821
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1822
                                        control.EndPoint = tempPoint;
1823
                                    }
1824
                                    else
1825
                                    {
1826
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1827
                                    }
1828

    
1829
                                    control.PointSet = new List<Point>
1830
                                            {
1831
                                                control.StartPoint,
1832
                                                control.EndPoint,
1833
                                            };
1834
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1835
                                }
1836
                            }
1837
                            break;
1838

    
1839
                        case ControlType.ChainLine:
1840
                            {
1841
                                var control = currentControl as PolygonControl;
1842

    
1843
                                if (control != null)
1844
                                {
1845

    
1846
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1847
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1848

    
1849
                                    Point tempPoint = control.PointSet[control.PointSet.Count - 1];
1850

    
1851
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1852
                                    {
1853
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1854
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 2], ref tempPoint, true);
1855
                                        control.PointSet[control.PointSet.Count - 1] = tempPoint;
1856
                                        //control.EndPoint = tempPoint;
1857
                                    }
1858
                                    else
1859
                                    {
1860
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1861
                                    }
1862

    
1863
                                    ///control.SetPolyPath();
1864

    
1865
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1866
                                }
1867
                            }
1868
                            break;
1869

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

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

    
1892

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

    
1904
                        case ControlType.ArcArrow:
1905
                            {
1906
                                var control = currentControl as ArrowArcControl;
1907
                                if (control != null)
1908
                                {
1909
                                    control.isTransOn = false;
1910
                                    control.ControlType = controlType;
1911
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1912
                                    control.MidPoint = new Point(0, 0);
1913
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1914
                                    Point tempPoint = control.EndPoint;
1915

    
1916
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1917
                                    {
1918
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1919
                                        control.EndPoint = tempPoint;
1920
                                    }
1921
                                    else
1922
                                    {
1923
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1924
                                    }
1925

    
1926

    
1927
                                    control.PointSet = new List<Point>
1928
                                            {
1929
                                                control.StartPoint,
1930
                                                control.MidPoint,
1931
                                                control.EndPoint,
1932
                                            };
1933
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1934
                                }
1935
                            }
1936
                            break;
1937

    
1938
                        case ControlType.ArrowMultiLine:
1939
                            {
1940
                                var control = currentControl as ArrowControl_Multi;
1941
                                if (control != null)
1942
                                {
1943
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1944
                                    Point tempPoint = control.EndPoint;
1945
                                    if (control.MiddlePoint == new Point(0, 0))
1946
                                    {
1947
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1948
                                        {
1949
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1950
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1951
                                            control.EndPoint = tempPoint;
1952
                                        }
1953
                                        else
1954
                                        {
1955
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1956
                                        }
1957
                                    }
1958
                                    else
1959
                                    {
1960
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1961
                                        {
1962
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1963
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1964
                                            control.EndPoint = tempPoint;
1965
                                        }
1966
                                        else
1967
                                        {
1968
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1969
                                        }
1970

    
1971
                                    }
1972

    
1973
                                    control.PointSet = new List<Point>
1974
                                            {
1975
                                                control.StartPoint,
1976
                                                control.MiddlePoint,
1977
                                                control.EndPoint,
1978
                                            };
1979
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1980
                                }
1981
                            }
1982
                            break;
1983

    
1984
                        case ControlType.Circle:
1985
                            {
1986
                                var control = currentControl as CircleControl;
1987

    
1988
                                if (control != null)
1989
                                {
1990
                                    if (move.mousemode == MouseMode.Drawing)
1991
                                    {
1992
                                        //move.control_Move(ControlList, true, moveX, moveY);
1993
                                    }
1994
                                    else
1995
                                    {
1996
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1997
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1998
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1999
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2000

    
2001
                                        if (ViewerDataModel.Instance.IsPressShift)
2002
                                        {
2003
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
2004
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
2005
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
2006
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
2007
                                        }
2008

    
2009
                                        control.PointSet = new List<Point>
2010
                                        {
2011
                                            control.StartPoint,
2012
                                            control.LeftBottomPoint,
2013
                                            control.EndPoint,
2014
                                            control.TopRightPoint,
2015
                                        };
2016
                                    }
2017

    
2018
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2019
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2020

    
2021
                                }
2022
                            }
2023
                            break;
2024

    
2025
                        case ControlType.PolygonCloud:
2026
                            {
2027
                                var control = currentControl as CloudControl;
2028

    
2029
                                if (control != null)
2030
                                {
2031
                                    control.isTransOn = true;
2032
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2033

    
2034
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2035

    
2036
                                    control.SetCloud();
2037
                                    //강인구 추가
2038
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2039
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2040
                                }
2041
                            }
2042
                            break;
2043

    
2044
                        case ControlType.Triangle:
2045
                            {
2046
                                var control = currentControl as TriControl;
2047

    
2048
                                if (control != null)
2049
                                {
2050
                                    if (move.mousemode == MouseMode.Drawing)
2051
                                    {
2052
                                        //move.control_Move(ControlList, true, moveX, moveY);
2053
                                    }
2054
                                    else
2055
                                    {
2056
                                        control.Paint = ViewerDataModel.Instance.paintSet;
2057
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2058

    
2059
                                        if (ViewerDataModel.Instance.checkAxis)
2060
                                        {
2061
                                            Point tempPoint = control.EndPoint;
2062
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2063
                                            control.EndPoint = tempPoint;
2064
                                        }
2065

    
2066

    
2067
                                        if (ViewerDataModel.Instance.IsPressShift)
2068
                                        {
2069
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
2070
                                            if (2 == Points.Count())
2071
                                            {
2072
                                                control.MidPoint = Points[0];
2073
                                                control.EndPoint = Points[1];
2074
                                            }
2075
                                        }
2076

    
2077
                                        control.PointSet = new List<Point>
2078
                                            {
2079
                                                control.StartPoint,
2080
                                                control.MidPoint,
2081
                                                control.EndPoint,
2082
                                            };
2083
                                    }
2084

    
2085
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2086
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2087
                                }
2088
                            }
2089
                            break;
2090

    
2091
                        case ControlType.ImgControl:
2092
                            {
2093
                                var control = currentControl as ImgControl;
2094

    
2095
                                if (control != null)
2096
                                {
2097
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2098
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2099
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2100
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2101

    
2102
                                    control.PointSet = new List<Point>
2103
                                        {
2104
                                            control.StartPoint,
2105
                                            control.LeftBottomPoint,
2106
                                            control.EndPoint,
2107
                                            control.TopRightPoint,
2108
                                        };
2109
                                }
2110
                            }
2111
                            break;
2112

    
2113
                        case ControlType.Date:
2114
                            {
2115
                                var control = currentControl as DateControl;
2116

    
2117
                                if (control != null)
2118
                                {
2119
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2120
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2121
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2122
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2123
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2124

    
2125
                                    control.PointSet = new List<Point>
2126
                                        {
2127
                                            control.StartPoint,
2128
                                            control.LeftBottomPoint,
2129
                                            control.EndPoint,
2130
                                            control.TopRightPoint,
2131
                                        };
2132
                                }
2133
                            }
2134
                            break;
2135

    
2136
                        case ControlType.ArrowTextControl:
2137
                            {
2138
                                var control = currentControl as ArrowTextControl;
2139

    
2140
                                if (control != null)
2141
                                {
2142
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2143
                                    Point tempPoint = control.EndPoint;
2144

    
2145
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2146

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

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

    
2168
                        case ControlType.ArrowTransTextControl:
2169
                            {
2170
                                var control = currentControl as ArrowTextControl;
2171

    
2172
                                if (control != null)
2173
                                {
2174
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2175
                                    Point tempPoint = control.EndPoint;
2176
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2177

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

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

    
2200
                        case ControlType.ArrowTextBorderControl:
2201
                            {
2202
                                var control = currentControl as ArrowTextControl;
2203

    
2204
                                if (control != null)
2205
                                {
2206
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2207
                                    Point tempPoint = control.EndPoint;
2208
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2209
                                    {
2210
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2211
                                        control.EndPoint = tempPoint;
2212
                                    }
2213
                                    else
2214
                                    {
2215
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2216
                                    }
2217
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2218
                                    control.PointSet = new List<Point>
2219
                                            {
2220
                                                control.StartPoint,
2221
                                                control.MidPoint,
2222
                                                control.EndPoint,
2223
                                            };
2224
                                }
2225

    
2226
                            }
2227
                            break;
2228
                        case ControlType.ArrowTransTextBorderControl:
2229
                            {
2230
                                var control = currentControl as ArrowTextControl;
2231

    
2232
                                if (control != null)
2233
                                {
2234
                                    control.isFixed = true;
2235
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2236
                                    Point tempPoint = control.EndPoint;
2237
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2238
                                    {
2239
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2240
                                        control.EndPoint = tempPoint;
2241
                                    }
2242
                                    else
2243
                                    {
2244
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2245
                                    }
2246

    
2247
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2248
                                    control.PointSet = new List<Point>
2249
                                            {
2250
                                                control.StartPoint,
2251
                                                control.MidPoint,
2252
                                                control.EndPoint,
2253
                                            };
2254
                                }
2255

    
2256
                            }
2257
                            break;
2258
                        case ControlType.ArrowTextCloudControl:
2259
                            {
2260
                                var control = currentControl as ArrowTextControl;
2261

    
2262
                                if (control != null)
2263
                                {
2264
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2265
                                    Point tempPoint = control.EndPoint;
2266
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2267
                                    {
2268
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2269
                                        control.EndPoint = tempPoint;
2270
                                    }
2271
                                    else
2272
                                    {
2273
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2274
                                    }
2275
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2276
                                    control.PointSet = new List<Point>
2277
                                            {
2278
                                                control.StartPoint,
2279
                                                control.MidPoint,
2280
                                                control.EndPoint,
2281
                                            };
2282
                                }
2283

    
2284
                            }
2285
                            break;
2286
                        case ControlType.ArrowTransTextCloudControl:
2287
                            {
2288
                                var control = currentControl as ArrowTextControl;
2289

    
2290
                                if (control != null)
2291
                                {
2292
                                    control.isFixed = true;
2293
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2294
                                    Point tempPoint = control.EndPoint;
2295
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2296
                                    {
2297
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2298
                                        control.EndPoint = tempPoint;
2299
                                    }
2300
                                    else
2301
                                    {
2302
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2303
                                    }
2304
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2305
                                    control.PointSet = new List<Point>
2306
                                            {
2307
                                                control.StartPoint,
2308
                                                control.MidPoint,
2309
                                                control.EndPoint,
2310
                                            };
2311
                                }
2312

    
2313
                            }
2314
                            break;
2315
                        case ControlType.PolygonControl:
2316
                            {
2317
                                var control = currentControl as PolygonControl;
2318

    
2319
                                if (control != null)
2320
                                {
2321
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2322
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2323
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2324
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2325
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2326
                                    control.updateControl();
2327
                                }
2328
                            }
2329
                            break;
2330
                        //강인구 추가
2331
                        case ControlType.Sign:
2332
                            {
2333
                                var control = currentControl as SignControl;
2334

    
2335
                                if (control != null)
2336
                                {
2337
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2338
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2339
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2340
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2341

    
2342
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2343
                                    {
2344
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2345
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2346
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2347
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2348
                                        stream.Position = 0;
2349
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2350
                                        BitmapImage returnImage = new BitmapImage();
2351
                                        returnImage.BeginInit();
2352
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2353
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2354
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2355
                                        returnImage.StreamSource = ms;
2356
                                        returnImage.EndInit();
2357
                                        stream.Close();
2358

    
2359
                                        control.SignImage = returnImage;
2360
                                    }
2361
                                    control.PointSet = new List<Point>
2362
                                        {
2363
                                            control.StartPoint,
2364
                                            control.LeftBottomPoint,
2365
                                            control.EndPoint,
2366
                                            control.TopRightPoint,
2367
                                        };
2368
                                }
2369
                            }
2370
                            break;
2371
                        //TODO: 강인구 추가
2372
                        case ControlType.Symbol:
2373
                            {
2374
                                var control = currentControl as SymControl;
2375

    
2376
                                if (control != null)
2377
                                {
2378
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2379
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2380
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2381
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2382
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2383
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2384

    
2385
                                    if (control.StartPoint != control.EndPoint)
2386
                                    {
2387
                                        if (control.PathData == null)
2388
                                        {
2389
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2390
                                            {
2391
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2392
                                            }
2393
                                        }
2394
                                    }
2395

    
2396
                                    control.PointSet = new List<Point>
2397
                                        {
2398
                                            control.StartPoint,
2399
                                            control.LeftBottomPoint,
2400
                                            control.EndPoint,
2401
                                            control.TopRightPoint,
2402
                                        };
2403
                                }
2404
                            }
2405
                            break;
2406
                        ///TODO: 
2407
                        case ControlType.Stamp:
2408
                            {
2409
                                var control = currentControl as SymControlN;
2410

    
2411
                                if (control != null)
2412
                                {
2413

    
2414
                                    if (control.StartPoint == control.EndPoint)
2415
                                    {
2416
                                        //string appovalData = "";
2417

    
2418
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2419
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2420

    
2421

    
2422
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2423

    
2424
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2425
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2426
                                        writer.Write(xamlData);
2427
                                        writer.Flush();
2428
                                        stream.Position = 0;
2429

    
2430
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2431
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2432
                                        UIElement ob = obj as UIElement;
2433

    
2434
                                        //control.ApplyTemplate();
2435

    
2436
                                        control.SetViewBox();
2437
                                        control.PathXathData = App.SystemInfo.STAMP;
2438
                                        control.Base_ViewBox.Child = ob;
2439
                                    }
2440

    
2441
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2442
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2443
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2444
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2445
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2446

    
2447

    
2448
                                    control.PointSet = new List<Point>
2449
                                    {
2450
                                        control.StartPoint,
2451
                                        control.LeftBottomPoint,
2452
                                        control.EndPoint,
2453
                                        control.TopRightPoint,
2454
                                    };
2455
                                }
2456
                            }
2457
                            break;
2458
                        case ControlType.Mark:
2459
                            {
2460
                                var control = currentControl as RectangleControl;
2461

    
2462
                                if (control != null)
2463
                                {
2464
                                    if (move.mousemode == MouseMode.Drawing)
2465
                                    {
2466
                                        //move.control_Move(ControlList, true, moveX, moveY);
2467
                                    }
2468
                                    else
2469
                                    {
2470
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2471
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2472
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2473
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2474

    
2475

    
2476
                                        control.PointSet = new List<Point>
2477
                                    {
2478
                                        control.StartPoint,
2479
                                        control.LeftBottomPoint,
2480
                                        control.EndPoint,
2481
                                        control.TopRightPoint,
2482
                                    };
2483
                                    }
2484

    
2485
                                    //강인구 추가
2486
                                    control.Paint = PaintSet.Fill;
2487
                                }
2488
                            }
2489
                            break;
2490
                        case ControlType.PenControl:
2491
                            {
2492
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2493
                                //inkBoard.Strokes.Add(stroke);
2494
                            }
2495
                            break;
2496
                        default:
2497
                            break;
2498
                    }
2499
                }
2500
            }
2501
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Selecting || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.Capture || mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragZoom)
2502
            {
2503
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2504

    
2505
                if (isDraggingSelectionRect)
2506
                {
2507
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2508

    
2509
                    e.Handled = true;
2510
                }
2511
                else if (isLeftMouseButtonDownOnWindow)
2512
                {
2513
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2514
                    double dragDistance = Math.Abs(dragDelta.Length);
2515

    
2516
                    if (dragDistance > DragThreshold)
2517
                    {
2518
                        isDraggingSelectionRect = true;
2519

    
2520
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2521
                    }
2522

    
2523
                    e.Handled = true;
2524
                }
2525

    
2526

    
2527
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2528
                {
2529
                    //SelectionPath = new Path();
2530
                    //PathFigure pathFigure = new PathFigure();
2531
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2532
                    //SelectionPath.Opacity = 0.5;
2533
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2534
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2535
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2536
                }
2537
                else
2538
                {
2539
                    //List<Stroke> removingStroke = new List<Stroke>();
2540
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2541
                    //StrokeCollection stC = new StrokeCollection();
2542
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2543
                    //{
2544
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2545
                    //    p1.Intersect(p2);
2546
                    //    if (p1.IsEmpty)
2547
                    //    {
2548

    
2549

    
2550
                    //        p1 = SelectionPath.Data.Bounds;
2551
                    //        bool intersectCheck = false;
2552
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2553
                    //        {
2554
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2555
                    //            p1.Intersect(p3);
2556
                    //            if (!p1.IsEmpty)
2557
                    //            {
2558
                    //                intersectCheck = true;
2559
                    //            }
2560
                    //        }
2561
                    //        if (intersectCheck)
2562
                    //        {
2563
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2564
                    //        }
2565

    
2566
                    //    }
2567
                    //    else
2568
                    //    {
2569
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2570
                    //    }
2571
                    //}
2572

    
2573
                    e.Handled = true;
2574
                }
2575
            }
2576
            else if (mouseButtonDown == MouseButton.Left && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2577
            { //symbol      
2578
                if(_dragdropWindow != null)
2579
                {
2580
                    Win32Point w32Mouse = new Win32Point();
2581
                    GetCursorPos(ref w32Mouse);
2582

    
2583
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2584
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2585
                }                
2586
            }
2587
            else if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2588
            {
2589
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2590
                if (control != null)
2591
                {
2592
                    this.cursor = Cursors.Hand;
2593
                    SetCursor();
2594
                }
2595
                else
2596
                {
2597
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2598

    
2599
                    SetCursor();
2600
                }
2601
            }
2602
            else
2603
            {
2604
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2605

    
2606
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2607
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2608

    
2609
                //if (hitList.Count > 0)
2610
                //{
2611

    
2612
                //}
2613

    
2614
                #region 조건 설정 : firstCondition
2615
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2616
                //pnts = generalTransform.Transform(pnts);
2617
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2618
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2619
                //                               this.DeepLayer._BaseLayer).ToObservable()
2620
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2621
                //                      select kkk).FirstOrDefault();
2622

    
2623
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2624
                //if (canvas !=null)
2625
                //{
2626
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2627
                //    {
2628
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2629
                //        if (uiElement!=null)
2630
                //        {
2631
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2632
                //        }
2633
                //    }
2634
                //}
2635

    
2636
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2637
                //hitResultsList.Clear();
2638

    
2639
                #endregion
2640
            }
2641
        }
2642

    
2643
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2644
        {
2645
            if ((mouseButtonDown == MouseButton.Middle) || (mouseButtonDown == MouseButton.Right))
2646
            {
2647
                SetCursor();
2648
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2649
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2650

    
2651
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2652

    
2653
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2654
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2655

    
2656
                if (Sync.IsChecked)
2657
                {
2658
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2659
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2660
                }
2661
            }
2662
        }
2663

    
2664
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2665

    
2666
        private EllipseGeometry hitArea = new EllipseGeometry();
2667

    
2668
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2669
        {
2670
            IsDrawing = false;
2671

    
2672
            if (mouseHandlingMode != MouseHandlingMode.None)
2673
            {
2674
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2675
                {
2676
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2677

    
2678
                    SetCursor();
2679

    
2680
                    switch (controlType)
2681
                    {
2682
                        case ControlType.None:
2683
                            break;
2684
                        case ControlType.Rectangle:
2685
                            {
2686

    
2687
                            }
2688
                            break;
2689
                        case ControlType.PenControl:
2690
                            {
2691

    
2692
                            }
2693
                            break;
2694
                        default:
2695
                            break;
2696
                    }
2697
                }
2698
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2699
                {
2700
                    if (isLeftMouseButtonDownOnWindow)
2701
                    {
2702
                        bool wasDragSelectionApplied = false;
2703

    
2704
                        if (isDraggingSelectionRect)
2705
                        {
2706
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2707
                            {
2708
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2709
                                mouseHandlingMode = MouseHandlingMode.None;
2710
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2711
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2712
                                Set_Symbol_Capture(endPoint);
2713
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2714
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2715
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2716
                            }
2717
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2718
                            {
2719
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2720
                                mouseHandlingMode = MouseHandlingMode.None;
2721
                                Set_Capture();
2722

    
2723
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2724
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2725
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2726
                            }
2727
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2728
                            {
2729
                                ApplyDragSelectionRect();
2730
                            }
2731
                            else
2732
                            {
2733
                                double x = Canvas.GetLeft(dragZoomBorder);
2734
                                double y = Canvas.GetTop(dragZoomBorder);
2735
                                double width = dragZoomBorder.Width;
2736
                                double height = dragZoomBorder.Height;
2737
                                Rect dragRect = new Rect(x, y, width, height);
2738

    
2739
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2740

    
2741
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2742
                            }
2743

    
2744
                            isDraggingSelectionRect = false;
2745
                            e.Handled = true;
2746
                            wasDragSelectionApplied = true;
2747
                        }
2748

    
2749
                        if (isLeftMouseButtonDownOnWindow)
2750
                        {
2751
                            isLeftMouseButtonDownOnWindow = false;
2752
                            this.ReleaseMouseCapture();
2753
                            e.Handled = true;
2754
                        }
2755

    
2756
                        if (!wasDragSelectionApplied)
2757
                        {
2758
                            init();
2759
                        }
2760
                    }
2761
                }
2762
                else if (mouseButtonDown == MouseButton.Right)
2763
                {
2764
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2765
                    SetCursor();
2766
                }
2767

    
2768
                zoomAndPanControl.ReleaseMouseCapture();
2769

    
2770

    
2771
                e.Handled = true;
2772
            }
2773
            else
2774
            {
2775
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2776
                SetCursor();
2777
            }
2778
            mouseButtonDown = MouseButton.Left;
2779

    
2780
            //controlType = ControlType.SingleLine;
2781
        }
2782

    
2783
        public void Set_Symbol_Capture(Point endPoint)
2784
        {       
2785
            double x = canvasDrawingMouseDownPoint.X;
2786
            double y = canvasDrawingMouseDownPoint.Y;
2787
            if(x > endPoint.X)
2788
            {
2789
                x = endPoint.X;
2790
                y = endPoint.Y;
2791
            }
2792

    
2793
            double width = dragCaptureBorder.Width;
2794
            double height = dragCaptureBorder.Height;
2795

    
2796
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2797

    
2798
            if (x < 0)
2799
            {
2800
                width += x;
2801
                x = 0;
2802
            }
2803
            if (y < 0)
2804
            {
2805
                height += y;
2806
                y = 0;
2807

    
2808
                width = (int)canvasImage.PixelWidth - x;
2809
            }
2810
            if (x + width > canvasImage.PixelWidth)
2811
            {
2812
                width = (int)canvasImage.PixelWidth - x;
2813
            }
2814
            if (y + height > canvasImage.PixelHeight)
2815
            {
2816
                height = (int)canvasImage.PixelHeight - y;
2817
            }
2818
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2819

    
2820
            string uri = "";
2821
            if (userData.COMPANY != "EXT")
2822
            {
2823
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO,
2824
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2825
            }
2826
            else
2827
            {
2828
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2829
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2830
            }
2831

    
2832
            var defaultBitmapImage = new BitmapImage();
2833
            defaultBitmapImage.BeginInit();
2834
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2835
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2836
            defaultBitmapImage.UriSource = new Uri(uri);
2837
            defaultBitmapImage.EndInit();
2838

    
2839
            //GC.Collect();
2840

    
2841
            if (defaultBitmapImage.IsDownloading)
2842
            {
2843
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2844
                {
2845
                    defaultBitmapImage.Freeze();
2846
                    //GC.Collect();
2847
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2848
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2849
                };
2850
            }
2851
        }
2852

    
2853
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2854
        {
2855
            mouseButtonDown = MouseButton.Left;
2856
        }
2857

    
2858
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2859
        {
2860
            mouseButtonDown = MouseButton.Left;
2861
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2862
        }
2863

    
2864
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2865
        {
2866

    
2867
        }
2868

    
2869
        /// <summary>
2870
        /// select items by dragging
2871
        /// </summary>
2872
        private void ApplyDragSelectionRect()
2873
        {
2874
            /*
2875
            multi_Undo_Data = new Multi_Undo_data();
2876

    
2877
            UndoData = new Undo_data()
2878
            {
2879
                IsUndo = false,
2880
                Event = Event_Type.Select,
2881
                EventTime = DateTime.Now,
2882
                Markup_List = new List<Multi_Undo_data>()
2883
            };
2884
            */
2885

    
2886
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2887

    
2888
            double x = Canvas.GetLeft(dragSelectionBorder);
2889
            double y = Canvas.GetTop(dragSelectionBorder);
2890
            double width = dragSelectionBorder.Width;
2891
            double height = dragSelectionBorder.Height;
2892
            Rect dragRect = new Rect(x, y, width, height);
2893
            Boolean Flag = false;
2894
            dragRect.Inflate(width / 10, height / 10);
2895
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2896
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2897

    
2898
            dragRect = new Rect(x, y, width, height);
2899
            dragRect.Inflate(width / 10, height / 10);
2900

    
2901
            foreach (var item in Items)
2902
            {
2903
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2904

    
2905
                if (Flag)
2906
                {
2907
                    adornerSet.Add(item);
2908
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2909

    
2910
                    Control_Style(item);
2911
                    /*
2912
                    UndoData.Markup_List.Add(multi_Undo_Data);
2913
                    multi_Undo_Data = new Multi_Undo_data();
2914
                    if (item.GroupID > 0)
2915
                    {
2916

    
2917
                    }
2918
                    */
2919
                }
2920
            }
2921
            if (adornerSet.Count > 0)
2922
            {
2923
                /*
2924
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2925
                {
2926
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2927
                });
2928
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2929
                */
2930

    
2931
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2932
                SelectLayer.Children.Add(final);
2933
            }
2934
        }
2935

    
2936
        private void InitDragSelectionRect(Point pt1, Point pt2)
2937
        {
2938
            //캡쳐 중
2939
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2940
            {
2941
                dragCaptureBorder.Visibility = Visibility.Visible;
2942
            }
2943
            //선택 중
2944
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2945
            {
2946

    
2947
                dragSelectionBorder.Visibility = Visibility.Visible;
2948
            }
2949
            else
2950
            {
2951
                dragZoomBorder.Visibility = Visibility.Visible;
2952
            }
2953
            UpdateDragSelectionRect(pt1, pt2);
2954
        }
2955

    
2956
        /// <summary>
2957
        /// Update the position and size of the rectangle used for drag selection.
2958
        /// </summary>
2959
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2960
        {
2961
            double x, y, width, height;
2962

    
2963
            //
2964
            // Determine x,y,width and height of the rect inverting the points if necessary.
2965
            // 
2966

    
2967
            if (pt2.X < pt1.X)
2968
            {
2969
                x = pt2.X;
2970
                width = pt1.X - pt2.X;
2971
            }
2972
            else
2973
            {
2974
                x = pt1.X;
2975
                width = pt2.X - pt1.X;
2976
            }
2977

    
2978
            if (pt2.Y < pt1.Y)
2979
            {
2980
                y = pt2.Y;
2981
                height = pt1.Y - pt2.Y;
2982
            }
2983
            else
2984
            {
2985
                y = pt1.Y;
2986
                height = pt2.Y - pt1.Y;
2987
            }
2988

    
2989
            //
2990
            // Update the coordinates of the rectangle used for drag selection.
2991
            //
2992
            //캡쳐 중
2993
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2994
            {
2995
                Canvas.SetLeft(dragCaptureBorder, x);
2996
                Canvas.SetTop(dragCaptureBorder, y);
2997
                dragCaptureBorder.Width = width;
2998
                dragCaptureBorder.Height = height;
2999
            }
3000
            //선택 중
3001
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
3002
            {
3003
                Canvas.SetLeft(dragSelectionBorder, x);
3004
                Canvas.SetTop(dragSelectionBorder, y);
3005
                dragSelectionBorder.Width = width;
3006
                dragSelectionBorder.Height = height;
3007
            }
3008
            else
3009
            {
3010
                Canvas.SetLeft(dragZoomBorder, x);
3011
                Canvas.SetTop(dragZoomBorder, y);
3012
                dragZoomBorder.Width = width;
3013
                dragZoomBorder.Height = height;
3014
            }
3015
        }
3016

    
3017
        private void drawingPannelRotate(double angle)
3018
        {
3019
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
3020
            rotate.Angle = angle;
3021
            var rotationNum = Math.Abs((rotate.Angle / 90));
3022

    
3023
            if (angle == 90 || angle == 270)
3024
            {
3025
                double emptySize = zoomAndPanCanvas.Width;
3026
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
3027
                zoomAndPanCanvas.Height = emptySize;
3028
            }
3029
            if (angle == 0)
3030
            {
3031
                translate.X = 0;
3032
                translate.Y = 0;
3033
            }
3034
            else if (angle == 90)
3035
            {
3036
                translate.X = zoomAndPanCanvas.Width;
3037
                translate.Y = 0;
3038
            }
3039
            else if (angle == 180)
3040
            {
3041
                translate.X = zoomAndPanCanvas.Width;
3042
                translate.Y = zoomAndPanCanvas.Height;
3043
            }
3044
            else
3045
            {
3046
                translate.X = 0;
3047
                translate.Y = zoomAndPanCanvas.Height;
3048
            }
3049

    
3050
            zoomAndPanControl.RotationAngle = rotate.Angle;
3051

    
3052

    
3053
            if (!testPanel2.IsHidden)
3054
            {
3055
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3056
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3057
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3058
            }
3059

    
3060
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3061
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3062
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3063
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3064
            ViewerDataModel.Instance.Angle = rotate.Angle;
3065
        }
3066

    
3067
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3068
        {
3069
            string Data_ = "";
3070

    
3071
            try
3072
            {
3073
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3074
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3075
                if (Data_ != null || Data_ != "")
3076
                {
3077
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3078
                }
3079
                else
3080
                {
3081
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3082
                }
3083

    
3084
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
3085
                {
3086
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
3087
                    STATE = 0,
3088
                };
3089
                if (Data_ != null)
3090
                {
3091
                    Image img = new Image();
3092
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
3093
                    if (Data_.Contains(".svg"))
3094
                    {
3095
                        byte[] imageData = null;
3096
                        DrawingImage image = null;
3097
                        using (System.Net.WebClient web = new System.Net.WebClient())
3098
                        {
3099
                            imageData = web.DownloadData(new Uri(Data_));
3100
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3101
                            image = SvgReader.Load(stream);
3102
                        }
3103
                        img.Source = image;
3104
                    }
3105
                    else
3106
                    {
3107
                        img.Source = new BitmapImage(new Uri(Data_));
3108
                    }
3109

    
3110
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3111
                    {
3112
                        PointSet = new List<Point>(),
3113
                        FilePath = Data_,
3114
                        ImageData = img.Source,
3115
                        StartPoint = canvasZoomPanningMouseDownPoint,
3116
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3117
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3118
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3119
                        canvasZoomPanningMouseDownPoint.Y),
3120
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3121
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3122
                    };
3123

    
3124
                    currentControl.PointSet = new List<Point>
3125
                                        {
3126
                                            currentControl.StartPoint,
3127
                                            currentControl.LeftBottomPoint,
3128
                                            currentControl.EndPoint,
3129
                                            currentControl.TopRightPoint,
3130
                                        };
3131
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3132
                    UndoData = new Undo_data()
3133
                    {
3134
                        IsUndo = false,
3135
                        Event = Event_Type.Create,
3136
                        EventTime = DateTime.Now,
3137
                        Markup_List = new List<Multi_Undo_data>()
3138
                    };
3139
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3140
                    {
3141
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3142
                    });
3143

    
3144
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3145
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3146
                    UndoData.Markup_List.Add(multi_Undo_Data);
3147
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3148

    
3149
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3150
                    currentControl.CommentID = Commons.shortGuid();
3151
                    currentControl.SymbolID = id;
3152
                    currentControl.GroupID = group_id;
3153
                    currentControl.ApplyTemplate();
3154
                    currentControl.SetImage();
3155

    
3156
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3157
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3158
                    SelectLayer.Children.Add(final);
3159
                }
3160
            }
3161
            catch (Exception ex)
3162
            {
3163
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3164
            }
3165
        }
3166

    
3167
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3168
        {            
3169
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3170
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3171
            {
3172
                set_option.Value = double.Parse(set_option.ContentText);
3173
            }
3174

    
3175
            InkControl_Convert();
3176

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

    
3180
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3181
            {
3182
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3183
            }
3184

    
3185
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3186
            {
3187
                if (arrow_text as ArrowTextControl != null)
3188
                {
3189
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3190
                }
3191
            }
3192

    
3193
            mouseButtonDown = e.ChangedButton;
3194
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3195

    
3196
            //if (currentControl != null)
3197
            {
3198
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3199
                if (text_item_ != null)
3200
                {
3201
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3202
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3203
                    (text_item_ as TextControl).IsEditing = false;
3204
                    (text_item_ as TextControl).EnableEditing = false;
3205
                    currentControl = null;
3206
                }
3207

    
3208
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3209
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3210
                {
3211
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3212
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3213
                    currentControl = null;
3214
                }
3215
            }
3216

    
3217
            double Ang = 0;                                          
3218
            if (rotate.Angle != 0)
3219
            {
3220
                Ang = 360 - rotate.Angle;
3221
            }
3222
            move = new Move();
3223

    
3224
            if (e.OriginalSource is System.Windows.Controls.Image)
3225
            {
3226
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3227
            }
3228

    
3229
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3230
            {                
3231
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3232
                //SetCursor();
3233

    
3234
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3235
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3236
                if(symbol_id != null)
3237
                {
3238
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3239
                }                
3240
            }
3241

    
3242
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3243
            {
3244
                if (this._dragdropWindow != null)
3245
                {
3246
                    this._dragdropWindow.Close();
3247
                    this._dragdropWindow = null;
3248
                    symbol_id = null;
3249
                }
3250
            }
3251

    
3252
            if (mouseButtonDown == MouseButton.Left)
3253
            {
3254
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3255
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3256

    
3257
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3258
                SetCursor();
3259

    
3260
                if (!ViewerDataModel.Instance.IsPressCtrl)
3261
                {
3262
                    SelectionSet.Instance.UnSelect(this);
3263
                }
3264
            }
3265
            if (mouseButtonDown == MouseButton.Middle)
3266
            {
3267
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3268
                cursor = Cursors.SizeAll;
3269
                SetCursor();
3270
            }
3271
            if (mouseButtonDown == MouseButton.Right)
3272
            {
3273
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3274
                cursor = Cursors.SizeAll;
3275
                SetCursor();
3276
            }
3277
            else if (mouseButtonDown == MouseButton.XButton1)
3278
            {
3279
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3280
                {
3281
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3282
                }
3283

    
3284
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3285

    
3286
            }
3287
            else if (mouseButtonDown == MouseButton.XButton2)
3288
            {
3289
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3290
                {
3291
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3292
                }
3293
            }
3294

    
3295
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3296
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3297
            {
3298
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3299
                {
3300
                    if (SelectLayer.Children.Count == 0)
3301
                    {
3302
                        isLeftMouseButtonDownOnWindow = true;
3303
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3304
                    }
3305

    
3306
                    if (controlType == ControlType.None)
3307
                    {
3308
                        isLeftMouseButtonDownOnWindow = true;
3309
                    }
3310
                }
3311

    
3312
                //캡쳐 모드 설정
3313
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3314
                {
3315
                    dragCaptureBorder.Visibility = Visibility.Visible;
3316
                    isLeftMouseButtonDownOnWindow = true;
3317
                }
3318

    
3319
                //줌 모드 설정
3320
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3321
                {
3322
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3323
                    isLeftMouseButtonDownOnWindow = true;
3324
                }               
3325

    
3326
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3327
                if (control != null)
3328
                {
3329
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3330
                    AdornerFinal final;
3331
                    List<Point> p_set = new List<Point>();
3332
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3333
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3334
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3335
                    multi_Undo_Data = new Multi_Undo_data();
3336

    
3337
                    //강인구 Undo/Redo 보류
3338
                    UndoData = new Undo_data()
3339
                    {
3340
                        IsUndo = false,
3341
                        Event = Event_Type.Select,
3342
                        EventTime = DateTime.Now,
3343
                        Markup_List = new List<Multi_Undo_data>()
3344
                    };
3345

    
3346
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3347
                    {
3348
                        SelectionSet.Instance.UnSelect(this);
3349
                        final = new AdornerFinal(control);
3350
                        //단일 컨트롤 언두 저장
3351

    
3352
                        Control_Style(control);
3353
                        UndoData.Markup_List.Add(multi_Undo_Data);
3354

    
3355
                        if ((control as IPath) != null)
3356
                        {
3357
                            if ((control as IPath).LineSize != 0)
3358
                            {
3359
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3360
                            }
3361
                        }
3362
                        if ((control as IShapeControl) != null)
3363
                        {
3364
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3365
                            {
3366
                                ViewerDataModel.Instance.checkHatchShape = true;
3367
                            }
3368
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3369
                            {
3370
                                ViewerDataModel.Instance.checkFillShape = true;
3371
                            }
3372
                            else
3373
                            {
3374
                                ViewerDataModel.Instance.checkHatchShape = false;
3375
                                ViewerDataModel.Instance.checkFillShape = false;
3376
                            }
3377
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3378
                        }
3379

    
3380
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3381

    
3382
                        if ((control as TextControl) != null)
3383
                        {
3384
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3385
                            {
3386
                                ViewerDataModel.Instance.checkTextStyle = true;
3387
                            }
3388
                            else
3389
                            {
3390
                                ViewerDataModel.Instance.checkTextStyle = false;
3391
                            }
3392

    
3393
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3394
                            {
3395
                                ViewerDataModel.Instance.checkTextStyle = true;
3396
                            }
3397
                            else
3398
                            {
3399
                                ViewerDataModel.Instance.checkTextStyle = false;
3400
                            }
3401
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3402
                            {
3403
                                ViewerDataModel.Instance.checkTextWeight = true;
3404
                            }
3405
                            else
3406
                            {
3407
                                ViewerDataModel.Instance.checkTextWeight = false;
3408
                            }
3409
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3410
                            {
3411
                                ViewerDataModel.Instance.checkUnderLine = true;
3412
                            }
3413
                            else
3414
                            {
3415
                                ViewerDataModel.Instance.checkUnderLine = false;
3416
                            }
3417
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3418
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3419

    
3420
                        }
3421
                        else if ((control as ArrowTextControl) != null)
3422
                        {
3423
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3424
                            {
3425
                                ViewerDataModel.Instance.checkTextStyle = true;
3426
                            }
3427
                            else
3428
                            {
3429
                                ViewerDataModel.Instance.checkTextStyle = false;
3430
                            }
3431

    
3432
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3433
                            {
3434
                                ViewerDataModel.Instance.checkTextStyle = true;
3435
                            }
3436
                            else
3437
                            {
3438
                                ViewerDataModel.Instance.checkTextStyle = false;
3439
                            }
3440
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3441
                            {
3442
                                ViewerDataModel.Instance.checkTextWeight = true;
3443
                            }
3444
                            else
3445
                            {
3446
                                ViewerDataModel.Instance.checkTextWeight = false;
3447
                            }
3448
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3449
                            {
3450
                                ViewerDataModel.Instance.checkUnderLine = true;
3451
                            }
3452
                            else
3453
                            {
3454
                                ViewerDataModel.Instance.checkUnderLine = false;
3455
                            }
3456
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3457
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3458
                        }
3459
                        else if ((control as RectCloudControl) != null)
3460
                        {
3461
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3462
                        }
3463
                        else if ((control as CloudControl) != null)
3464
                        {
3465
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3466
                        }
3467

    
3468
                    }
3469
                    else
3470
                    {
3471
                        comment = AddAdorner();
3472
                        comment.Add(control);
3473

    
3474
                        Control_Style(control);
3475
                        UndoData.Markup_List.Add(multi_Undo_Data);
3476

    
3477
                        final = new AdornerFinal(comment);
3478
                        //다중 컨트롤 언두 저장
3479
                    }
3480

    
3481
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3482
                    {
3483
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3484
                    });
3485

    
3486
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3487

    
3488
                    SelectLayer.Children.Add(final);
3489
                }              
3490
            }
3491
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3492
            {               
3493
                init();
3494
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3495
                if (cursor != Cursors.SizeAll)
3496
                {
3497
                    cursor = Cursors.Cross;
3498
                    SetCursor();
3499
                }
3500
                bool init_user = false;
3501
                foreach (var user in gridViewMarkup.Items)
3502
                {
3503
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3504
                    {
3505
                        init_user = true;
3506
                    }
3507
                }
3508
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3509
                {
3510
                    RadWindow.Alert(new DialogParameters
3511
                    {
3512
                        Owner = Application.Current.MainWindow,
3513
                        Theme = new VisualStudio2013Theme(),
3514
                        Header = "안내",
3515
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3516
                    });
3517
                    return;
3518
                }
3519
                else
3520
                {
3521
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3522
                    if (item != null)
3523
                    {
3524
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3525
                    }
3526
                }
3527

    
3528
                multi_Undo_Data = new Multi_Undo_data();
3529
                //강인구 Undo/Redo 보류
3530
                UndoData = new Undo_data()
3531
                {
3532
                    IsUndo = false,
3533
                    Event = Event_Type.Create,
3534
                    EventTime = DateTime.Now,
3535
                    Markup_List = new List<Multi_Undo_data>()
3536
                };
3537

    
3538
                switch (controlType)
3539
                {
3540
                    case ControlType.Coordinate:
3541
                        {
3542
                            if (mouseButtonDown == MouseButton.Left)
3543
                            {
3544
                                if (currentControl is CoordinateControl)
3545
                                {
3546
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3547
                                    {
3548
                                        return;
3549
                                    }
3550

    
3551
                                    CreateControl();
3552

    
3553
                                    (currentControl as CoordinateControl).ApplyOverViewData();
3554
                                    currentControl = null;
3555
                                    this.cursor = Cursors.Arrow;
3556
                                }
3557
                                else
3558
                                {
3559
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3560
                                    if (ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3561
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3562
                                    {
3563
                                        currentControl = null;
3564
                                        this.cursor = Cursors.Arrow;
3565
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3566
                                        return;
3567
                                    }
3568
                                    else
3569
                                    {
3570
                                        currentControl = new CoordinateControl
3571
                                        {
3572
                                            Background = new SolidColorBrush(Colors.Black),
3573
                                            ControlType = ControlType.Coordinate
3574
                                        };
3575

    
3576
                                        currentControl.CommentID = Commons.shortGuid();
3577
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3578
                                        currentControl.IsNew = true;
3579

    
3580
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3581

    
3582
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3583
                                    }
3584
                                }
3585
                            }
3586
                        }
3587
                        break;
3588
                    case ControlType.InsideWhite:
3589
                        {
3590
                            if (mouseButtonDown == MouseButton.Left)
3591
                            {
3592
                                if (currentControl is InsideWhiteControl)
3593
                                {
3594
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3595
                                    {
3596
                                        return;
3597
                                    }
3598

    
3599
                                    CreateControl();
3600

    
3601
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3602
                                    currentControl = null;
3603
                                    this.cursor = Cursors.Arrow;
3604
                                }
3605
                                else
3606
                                {
3607
                                    currentControl = new InsideWhiteControl
3608
                                    {
3609
                                        Background = new SolidColorBrush(Colors.Black),
3610
                                        ControlType = ControlType.InsideWhite
3611
                                    };
3612

    
3613
                                    currentControl.CommentID = Commons.shortGuid();
3614
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3615
                                    currentControl.IsNew = true;
3616
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3617

    
3618
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3619
                                }
3620
                            }
3621
                        }
3622
                        break;
3623
                    case ControlType.OverlapWhite:
3624
                        {
3625
                            if (mouseButtonDown == MouseButton.Left)
3626
                            {
3627
                                if (currentControl is OverlapWhiteControl)
3628
                                {
3629
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3630
                                    {
3631
                                        return;
3632
                                    }
3633

    
3634
                                    CreateControl();
3635

    
3636
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3637
                                    currentControl = null;
3638
                                    this.cursor = Cursors.Arrow;
3639
                                }
3640
                                else
3641
                                {
3642
                                    currentControl = new OverlapWhiteControl
3643
                                    {
3644
                                        Background = new SolidColorBrush(Colors.Black),
3645
                                        ControlType = ControlType.OverlapWhite
3646
                                    };
3647

    
3648
                                    currentControl.CommentID = Commons.shortGuid();
3649
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3650
                                    currentControl.IsNew = true;
3651
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3652

    
3653
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3654
                                }
3655
                            }
3656
                        }
3657
                        break;
3658
                    case ControlType.ClipWhite:
3659
                        {
3660
                            if (mouseButtonDown == MouseButton.Left)
3661
                            {
3662
                                if (currentControl is ClipWhiteControl)
3663
                                {
3664
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3665
                                    {
3666
                                        return;
3667
                                    }
3668

    
3669
                                    CreateControl();
3670

    
3671
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
3672
                                    currentControl = null;
3673
                                    this.cursor = Cursors.Arrow;
3674
                                }
3675
                                else
3676
                                {
3677
                                    currentControl = new ClipWhiteControl
3678
                                    {
3679
                                        Background = new SolidColorBrush(Colors.Black),
3680
                                        ControlType = ControlType.ClipWhite
3681
                                    };
3682

    
3683
                                    currentControl.CommentID = Commons.shortGuid();
3684
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3685
                                    currentControl.IsNew = true;
3686
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3687

    
3688
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3689
                                }
3690
                            }
3691
                        }
3692
                        break;
3693
                    case ControlType.Rectangle:
3694
                        {
3695
                            if (mouseButtonDown == MouseButton.Left)
3696
                            {
3697
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3698
                                //{
3699
                                    if (currentControl is RectangleControl)
3700
                                    {
3701
                                        //20180906 LJY TEST IsRotationDrawingEnable
3702
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3703
                                        {
3704
                                            return;
3705
                                        }
3706

    
3707
                                        CreateControl();
3708

    
3709
                                        (currentControl as RectangleControl).ApplyOverViewData();
3710
                                        currentControl = null;
3711
                                    
3712
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3713
                                    }
3714
                                    else
3715
                                    {
3716
                                        currentControl = new RectangleControl
3717
                                        {
3718
                                            Background = new SolidColorBrush(Colors.Black),
3719
                                            ControlType = ControlType.Rectangle
3720
                                        };
3721

    
3722
                                        currentControl.CommentID = Commons.shortGuid();
3723
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3724
                                        currentControl.IsNew = true;
3725
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3726

    
3727
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3728
                                    }
3729
                                //}
3730
                            }
3731
                        }
3732
                        break;
3733
                    case ControlType.RectCloud:
3734
                        {
3735
                            if (mouseButtonDown == MouseButton.Left)
3736
                            {
3737
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3738
                                //{
3739
                                    if (currentControl is RectCloudControl)
3740
                                    {
3741
                                        //20180906 LJY TEST IsRotationDrawingEnable
3742
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3743
                                        {
3744
                                            return;
3745
                                        }
3746

    
3747
                                        CreateControl();
3748

    
3749
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3750
                                        currentControl = null;
3751
                                    
3752
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3753
                                    }
3754
                                    else
3755
                                    {
3756
                                        currentControl = new RectCloudControl
3757
                                        {
3758
                                            Background = new SolidColorBrush(Colors.Black)
3759
                                        };
3760

    
3761
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3762
                                        currentControl.CommentID = Commons.shortGuid();
3763
                                        currentControl.IsNew = true;
3764
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3765
                                    }
3766
                                //}
3767
                            }
3768
                        }
3769
                        break;
3770
                    case ControlType.Circle:
3771
                        {
3772
                            if (mouseButtonDown == MouseButton.Left)
3773
                            {
3774
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3775
                                //{
3776
                                    if (currentControl is CircleControl)
3777
                                    {
3778
                                        //20180906 LJY TEST IsRotationDrawingEnable
3779
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3780
                                        {
3781
                                            return;
3782
                                        }
3783

    
3784
                                        CreateControl();
3785

    
3786
                                        (currentControl as CircleControl).ApplyOverViewData();
3787
                                        currentControl = null;
3788
                                    }
3789
                                    else
3790
                                    {
3791
                                        currentControl = new CircleControl
3792
                                        {
3793
                                            Background = new SolidColorBrush(Colors.Black)
3794
                                        };
3795

    
3796
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3797
                                        currentControl.CommentID = Commons.shortGuid();
3798
                                        currentControl.IsNew = true;
3799
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3800
                                    }
3801
                                //}
3802
                            }
3803
                        }
3804
                        break;
3805
                    case ControlType.Triangle:
3806
                        {
3807
                            if (mouseButtonDown == MouseButton.Left)
3808
                            {
3809
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3810
                                //{
3811
                                    if (currentControl is TriControl)
3812
                                    {
3813
                                        var content = currentControl as TriControl;
3814
                                        if (content.MidPoint == new Point(0, 0))
3815
                                        {
3816
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3817
                                        }
3818
                                        else
3819
                                        {
3820
                                            //20180906 LJY TEST IsRotationDrawingEnable
3821
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3822
                                            {
3823
                                                return;
3824
                                            }
3825

    
3826
                                            CreateControl();
3827

    
3828
                                            (currentControl as TriControl).ApplyOverViewData();
3829
                                            currentControl = null;
3830
                                        }
3831
                                    }
3832
                                    else
3833
                                    {
3834
                                        currentControl = new TriControl
3835
                                        {
3836
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3837
                                            Background = new SolidColorBrush(Colors.Black),
3838
                                        };
3839

    
3840
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3841
                                        currentControl.CommentID = Commons.shortGuid();
3842
                                        currentControl.IsNew = true;
3843
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3844
                                    }
3845
                                //}
3846
                            }
3847
                        }
3848
                        break;
3849
                    case ControlType.SingleLine:
3850
                        {
3851
                            if (mouseButtonDown == MouseButton.Left)
3852
                            {
3853
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3854
                                //{
3855
                                    if (currentControl is LineControl)
3856
                                    {
3857
                                        //20180906 LJY TEST IsRotationDrawingEnable
3858
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3859
                                        {
3860
                                            return;
3861
                                        }
3862

    
3863
                                        CreateControl();
3864

    
3865
                                        (currentControl as LineControl).ApplyOverViewData();
3866
                                        currentControl = null;
3867
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3868
                                    }
3869
                                    else
3870
                                    {
3871
                                        currentControl = new LineControl
3872
                                        {
3873
                                            Background = new SolidColorBrush(Colors.Black)
3874
                                        };
3875

    
3876
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3877
                                        currentControl.CommentID = Commons.shortGuid();
3878
                                        currentControl.IsNew = true;
3879
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3880
                                        this.MainAngle.Visibility = Visibility.Visible;
3881
                                    }
3882
                                //}
3883
                            }
3884
                        }
3885
                        break;
3886
                    case ControlType.CancelLine:
3887
                        {
3888
                            if (mouseButtonDown == MouseButton.Left)
3889
                            {
3890
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3891
                                //{
3892
                                    if (currentControl is LineControl)
3893
                                    {
3894
                                        //20180906 LJY TEST IsRotationDrawingEnable
3895
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3896
                                        {
3897
                                            return;
3898
                                        }
3899

    
3900
                                        CreateControl();
3901

    
3902
                                        (currentControl as LineControl).ApplyOverViewData();
3903
                                        currentControl = null;
3904
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3905
                                    }
3906
                                    else
3907
                                    {
3908
                                        currentControl = new LineControl
3909
                                        {
3910
                                            Background = new SolidColorBrush(Colors.Black)
3911
                                        };
3912

    
3913
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3914
                                        currentControl.CommentID = Commons.shortGuid();
3915
                                        currentControl.IsNew = true;
3916
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3917
                                        this.MainAngle.Visibility = Visibility.Visible;
3918
                                    }
3919
                                //}
3920
                            }
3921
                        }
3922
                        break;
3923
                    case ControlType.ArrowLine:
3924
                        {
3925
                            if (mouseButtonDown == MouseButton.Left)
3926
                            {
3927
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3928
                                //{
3929
                                    if (currentControl is LineControl)
3930
                                    {
3931
                                        //20180906 LJY TEST IsRotationDrawingEnable
3932
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3933
                                        {
3934
                                            return;
3935
                                        }
3936

    
3937
                                        CreateControl();
3938

    
3939
                                        (currentControl as LineControl).ApplyOverViewData();
3940
                                        currentControl = null;
3941
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3942
                                    }
3943
                                    else
3944
                                    {
3945
                                        currentControl = new LineControl
3946
                                        {
3947
                                            Background = new SolidColorBrush(Colors.Black)
3948
                                        };
3949

    
3950
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3951
                                        currentControl.CommentID = Commons.shortGuid();
3952
                                        currentControl.IsNew = true;
3953
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3954
                                        this.MainAngle.Visibility = Visibility.Visible;
3955
                                    }
3956
                                //}
3957
                            }
3958
                        }
3959
                        break;
3960
                    case ControlType.TwinLine:
3961
                        {
3962
                            if (mouseButtonDown == MouseButton.Left)
3963
                            {
3964
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3965
                                //{
3966
                                    if (currentControl is LineControl)
3967
                                    {
3968
                                        //20180906 LJY TEST IsRotationDrawingEnable
3969
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3970
                                        {
3971
                                            return;
3972
                                        }
3973

    
3974
                                        CreateControl();
3975

    
3976
                                        (currentControl as LineControl).ApplyOverViewData();
3977
                                        currentControl = null;
3978
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3979
                                    }
3980
                                    else
3981
                                    {
3982
                                        currentControl = new LineControl
3983
                                        {
3984
                                            Background = new SolidColorBrush(Colors.Black)
3985
                                        };
3986
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3987
                                        currentControl.CommentID = Commons.shortGuid();
3988
                                        currentControl.IsNew = true;
3989
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3990
                                        this.MainAngle.Visibility = Visibility.Visible;
3991
                                    }
3992
                                //}
3993
                            }
3994
                        }
3995
                        break;
3996
                    case ControlType.DimLine:
3997
                        {
3998
                            if (mouseButtonDown == MouseButton.Left)
3999
                            {
4000
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4001
                                //{
4002
                                    if (currentControl is LineControl)
4003
                                    {
4004
                                        //20180906 LJY TEST IsRotationDrawingEnable
4005
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4006
                                        {
4007
                                            return;
4008
                                        }
4009
                                        CreateControl();
4010

    
4011
                                        (currentControl as LineControl).ApplyOverViewData();
4012
                                        currentControl = null;
4013
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4014
                                    }
4015
                                    else
4016
                                    {
4017
                                        currentControl = new LineControl
4018
                                        {
4019
                                            Background = new SolidColorBrush(Colors.Black)
4020
                                        };
4021
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4022
                                        currentControl.CommentID = Commons.shortGuid();
4023
                                        currentControl.IsNew = true;
4024
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4025
                                        this.MainAngle.Visibility = Visibility.Visible;
4026
                                    }
4027
                                //}
4028
                            }
4029
                        }
4030
                        break;
4031
                    case ControlType.ChainLine:
4032
                        {
4033
                            if (currentControl is PolygonControl)
4034
                            {
4035
                                var control = currentControl as PolygonControl;
4036

    
4037
                                if (mouseButtonDown == MouseButton.Right)
4038
                                {
4039
                                    //20180906 LJY TEST IsRotationDrawingEnable
4040
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4041
                                    {
4042
                                        return;
4043
                                    }
4044

    
4045
                                    CreateControl();
4046

    
4047
                                    (currentControl as PolygonControl).ApplyOverViewData();
4048
                                    currentControl = null;
4049
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4050
                                    return;
4051
                                }
4052

    
4053
                                if (!control.IsCompleted)
4054
                                {
4055
                                    control.PointSet.Add(control.EndPoint);
4056
                                    this.MainAngle.Visibility = Visibility.Visible;
4057
                                }
4058
                            }
4059
                            else
4060
                            {
4061
                                if (mouseButtonDown == MouseButton.Left)
4062
                                {
4063
                                    MainAngle.Visibility = Visibility.Visible;
4064
                                    currentControl = new PolygonControl
4065
                                    {
4066
                                        PointSet = new List<Point>(),
4067
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
4068
                                        ControlType = ControlType.ChainLine,
4069
                                        DashSize = ViewerDataModel.Instance.DashSize,
4070
                                        LineSize = ViewerDataModel.Instance.LineSize,
4071
                                        //PointC = new StylusPointSet()
4072
                                    };
4073

    
4074
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4075
                                    //{
4076
                                        var polygonControl = (currentControl as PolygonControl);
4077
                                        currentControl.CommentID = Commons.shortGuid();
4078
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4079
                                        currentControl.IsNew = true;
4080
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4081
                                        //currentControl.OnApplyTemplate();
4082
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
4083
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
4084
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4085
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4086
                                    //}
4087
                                }
4088
                            }
4089
                        }
4090
                        break;
4091
                    case ControlType.ArcLine:
4092
                        {
4093
                            if (mouseButtonDown == MouseButton.Left)
4094
                            {
4095
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4096
                                //{
4097
                                    if (currentControl is ArcControl)
4098
                                    {
4099
                                        //20180906 LJY TEST IsRotationDrawingEnable
4100
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4101
                                        {
4102
                                            return;
4103
                                        }
4104

    
4105
                                        CreateControl();
4106

    
4107
                                        (currentControl as ArcControl).ApplyOverViewData();
4108
                                        currentControl = null;
4109
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4110
                                    }
4111
                                    else
4112
                                    {
4113
                                        currentControl = new ArcControl
4114
                                        {
4115
                                            Background = new SolidColorBrush(Colors.Black)
4116
                                        };
4117
                                        currentControl.CommentID = Commons.shortGuid();
4118
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4119
                                        currentControl.IsNew = true;
4120
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4121
                                        this.MainAngle.Visibility = Visibility.Visible;
4122
                                    }
4123
                                //}
4124
                            }
4125
                            else if (mouseButtonDown == MouseButton.Right)
4126
                            {
4127
                                if (currentControl != null)
4128
                                {
4129
                                    (currentControl as ArcControl).setClock();
4130
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
4131
                                    //(currentControl as ArcControl).ApplyTemplate();
4132
                                }
4133
                            }
4134
                        }
4135
                        break;
4136
                    case ControlType.ArcArrow:
4137
                        {
4138
                            if (mouseButtonDown == MouseButton.Left)
4139
                            {
4140
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4141
                                //{
4142
                                if (currentControl is ArrowArcControl)
4143
                                {
4144
                                    //20180906 LJY TEST IsRotationDrawingEnable
4145
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4146
                                    {
4147
                                        return;
4148
                                    }
4149

    
4150
                                    CreateControl();
4151

    
4152
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
4153
                                    currentControl = null;
4154
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4155
                                }
4156
                                else
4157
                                {
4158
                                    currentControl = new ArrowArcControl
4159
                                    {
4160
                                        Background = new SolidColorBrush(Colors.Black)
4161
                                    };
4162
                                    currentControl.CommentID = Commons.shortGuid();
4163
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4164
                                    currentControl.IsNew = true;
4165
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4166
                                    this.MainAngle.Visibility = Visibility.Visible;
4167
                                }
4168
                                //}
4169
                            }
4170
                            else if (mouseButtonDown == MouseButton.Right)
4171
                            {
4172
                                if (currentControl != null)
4173
                                {
4174
                                    (currentControl as ArrowArcControl).setClock();
4175
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
4176
                                    //(currentControl as ArcControl).ApplyTemplate();
4177
                                }
4178
                            }
4179
                        }
4180
                        break;
4181
                    case ControlType.ArrowMultiLine:
4182
                        {
4183
                            if (mouseButtonDown == MouseButton.Left)
4184
                            {
4185
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4186
                                //{
4187

    
4188
                                    if (currentControl is ArrowControl_Multi)
4189
                                    {
4190
                                        var content = currentControl as ArrowControl_Multi;
4191
                                        if (content.MiddlePoint == new Point(0, 0))
4192
                                        {
4193
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
4194
                                            {
4195
                                                content.MiddlePoint = content.EndPoint;
4196
                                            }
4197
                                            else
4198
                                            {
4199
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4200
                                            }
4201
                                        }
4202
                                        else
4203
                                        {
4204
                                            //20180906 LJY TEST IsRotationDrawingEnable
4205
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4206
                                            {
4207
                                                return;
4208
                                            }
4209

    
4210
                                            CreateControl();
4211

    
4212
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
4213
                                            currentControl = null;
4214
                                            this.MainAngle.Visibility = Visibility.Collapsed;
4215
                                        }
4216
                                    }
4217
                                    else
4218
                                    {
4219
                                        currentControl = new ArrowControl_Multi
4220
                                        {
4221
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4222
                                            Background = new SolidColorBrush(Colors.Black)
4223
                                        };
4224
                                        currentControl.CommentID = Commons.shortGuid();
4225
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4226
                                        currentControl.IsNew = true;
4227
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4228
                                        this.MainAngle.Visibility = Visibility.Visible;
4229
                                    }
4230
                                //}
4231
                            }
4232
                        }
4233
                        break;
4234
                    case ControlType.PolygonCloud:
4235
                        {
4236
                            if (currentControl is CloudControl)
4237
                            {
4238
                                var control = currentControl as CloudControl;
4239
                                if (mouseButtonDown == MouseButton.Right)
4240
                                {
4241
                                    control.IsCompleted = true;
4242
                                }
4243

    
4244
                                if (!control.IsCompleted)
4245
                                {
4246
                                    control.PointSet.Add(control.EndPoint);
4247
                                }
4248
                                else
4249
                                {
4250
                                    //20180906 LJY TEST IsRotationDrawingEnable
4251
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4252
                                    {
4253
                                        return;
4254
                                    }
4255

    
4256
                                    CreateControl();
4257

    
4258
                                    control.isTransOn = true;
4259
                                    var firstPoint = control.PointSet.First();
4260

    
4261
                                    control.PointSet.Add(firstPoint);
4262
                                    control.DrawingCloud();
4263
                                    control.ApplyOverViewData();
4264

    
4265
                                    currentControl = null;
4266
                                }
4267
                            }
4268
                            else
4269
                            {
4270
                                if (mouseButtonDown == MouseButton.Left)
4271
                                {
4272
                                    currentControl = new CloudControl
4273
                                    {
4274
                                        PointSet = new List<Point>(),
4275
                                        PointC = new StylusPointSet()
4276
                                    };
4277

    
4278
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4279
                                    //{
4280
                                        var polygonControl = (currentControl as CloudControl);
4281
                                        currentControl.CommentID = Commons.shortGuid();
4282
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4283
                                        currentControl.IsNew = true;
4284
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4285

    
4286
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4287
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4288
                                    
4289
                                    //}
4290
                                }
4291
                            }
4292
                        }
4293
                        break;
4294
                    case ControlType.ImgControl:
4295
                        {
4296
                            if (mouseButtonDown == MouseButton.Left)
4297
                            {
4298
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4299
                                //{
4300
                                    if (currentControl is ImgControl)
4301
                                    {
4302
                                        //20180906 LJY TEST IsRotationDrawingEnable
4303
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4304
                                        {
4305
                                            return;
4306
                                        }
4307

    
4308
                                        CreateControl();
4309
                                        (currentControl as ImgControl).ApplyOverViewData();
4310
                                        controlType = ControlType.ImgControl;
4311
                                        currentControl = null;
4312
                                    }
4313
                                    else
4314
                                    {
4315
                                        
4316
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4317
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4318
                                        {
4319
                                            Image img = new Image();
4320
                                            //img.Source = new BitmapImage(new Uri(filename));
4321
                                            if (filename.Contains(".svg"))
4322
                                            {
4323
                                                byte[] imageData = null;
4324
                                                DrawingImage image = null;
4325
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4326
                                                {
4327
                                                    imageData = web.DownloadData(new Uri(filename));
4328
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4329
                                                    image = SvgReader.Load(stream);
4330
                                                }
4331
                                                img.Source = image;
4332
                                            }
4333
                                            else
4334
                                            {
4335
                                                img.Source = new BitmapImage(new Uri(filename));
4336
                                            }
4337

    
4338
                                            currentControl = new ImgControl
4339
                                            {
4340
                                                    Background = new SolidColorBrush(Colors.Black),
4341
                                                    PointSet = new List<Point>(),
4342
                                                    FilePath = filename,
4343
                                                    ImageData = img.Source,
4344
                                                    StartPoint = canvasDrawingMouseDownPoint,
4345
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4346
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4347
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4348
                                                    ControlType = ControlType.ImgControl
4349
                                                };
4350

    
4351
                                        
4352
                                                currentControl.CommentID = Commons.shortGuid();                                            
4353
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4354
                                                currentControl.IsNew = true;
4355
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4356

    
4357
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4358
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4359
                                        }
4360
                                    }
4361
                                //}
4362
                            }
4363
                        }
4364
                        break;
4365
                    case ControlType.Date:
4366
                        {
4367
                            if (mouseButtonDown == MouseButton.Left)
4368
                            {
4369
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4370
                                //{
4371
                                    if (currentControl is DateControl)
4372
                                    {
4373
                                        //20180906 LJY TEST IsRotationDrawingEnable
4374
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4375
                                        {
4376
                                            return;
4377
                                        }
4378

    
4379
                                        CreateControl();
4380
                                        (currentControl as DateControl).ApplyOverViewData();
4381
                                        currentControl = null;
4382

    
4383
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4384
                                        {
4385
                                            controlType = ControlType.None;
4386
                                            IsSwingMode = false;
4387
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4388
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4389
                                            mouseHandlingMode = MouseHandlingMode.None;
4390
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4391
                                            txtBatch.Visibility = Visibility.Collapsed;
4392

    
4393
                                        }
4394
                                    }
4395
                                    else
4396
                                    {
4397
                                        currentControl = new DateControl
4398
                                        {
4399
                                            Background = new SolidColorBrush(Colors.Black)
4400
                                        };
4401
                                        currentControl.CommentID = Commons.shortGuid();
4402
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4403
                                        currentControl.IsNew = true;
4404
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4405

    
4406
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4407
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4408
                                }
4409
                                //}
4410
                            }
4411
                        }
4412
                        break;
4413
                    case ControlType.TextControl:
4414
                        {
4415
                            if (mouseButtonDown == MouseButton.Left)
4416
                            {
4417
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4418
                                {
4419
                                    currentControl = new TextControl
4420
                                    {
4421
                                        ControlType = controlType
4422
                                    };
4423
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4424
                                    currentControl.CommentID = Commons.shortGuid();
4425
                                    currentControl.IsNew = true;
4426
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4427
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4428
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4429
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4430
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4431
                                    
4432
                                    (currentControl as TextControl).ControlType_No = 0;
4433
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4434
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4435
                                    (currentControl as TextControl).ApplyTemplate();
4436
                                    (currentControl as TextControl).Base_TextBox.Focus();
4437

    
4438
                                    CreateControl();
4439

    
4440
                                }
4441
                            }
4442
                        }
4443
                        break;
4444
                    case ControlType.TextBorder:
4445
                        {
4446
                            if (mouseButtonDown == MouseButton.Left)
4447
                            {
4448
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4449
                                {
4450
                                    currentControl = new TextControl
4451
                                    {
4452
                                        ControlType = controlType
4453
                                    };
4454

    
4455
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4456
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4457
                                    currentControl.CommentID = Commons.shortGuid();
4458
                                    currentControl.IsNew = true;
4459
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4460
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4461
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4462
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4463
                                    
4464
                                    (currentControl as TextControl).ControlType_No = 1;
4465
                                    (currentControl as TextControl).Angle = Ang;
4466
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4467
                                    (currentControl as TextControl).ApplyTemplate();
4468
                                    (currentControl as TextControl).Base_TextBox.Focus();
4469
                                    CreateControl();
4470

    
4471
                                    //currentControl = null;
4472
                                }
4473
                            }
4474
                        }
4475
                        break;
4476
                    case ControlType.TextCloud:
4477
                        {
4478
                            if (mouseButtonDown == MouseButton.Left)
4479
                            {
4480
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4481
                                {
4482
                                    currentControl = new TextControl
4483
                                    {
4484
                                        ControlType = controlType
4485
                                    };
4486

    
4487
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4488
                                    currentControl.CommentID = Commons.shortGuid();
4489
                                    currentControl.IsNew = true;
4490
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4491
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4492

    
4493
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4494
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4495
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4496

    
4497
                                    (currentControl as TextControl).Angle = Ang;
4498
                                    (currentControl as TextControl).ControlType_No = 2;
4499
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4500
                                    (currentControl as TextControl).ApplyTemplate();
4501
                                    (currentControl as TextControl).Base_TextBox.Focus();
4502
                                    CreateControl();
4503
                                    //currentControl = null;
4504
                                }
4505
                            }
4506
                        }
4507
                        break;
4508
                    case ControlType.ArrowTextControl:
4509
                         {
4510
                            if (mouseButtonDown == MouseButton.Left)
4511
                            {
4512
                                if (currentControl is ArrowTextControl)
4513
                                {
4514
                                    //20180906 LJY TEST IsRotationDrawingEnable
4515
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4516
                                    {
4517
                                        return;
4518
                                    }                                    
4519

    
4520
                                    CreateControl();
4521

    
4522
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4523
                                    (currentControl as ArrowTextControl).IsEditing = false;
4524
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4525
                                    (currentControl as ArrowTextControl).IsNew = false;
4526
                                    currentControl = null;
4527
                                }
4528
                                else
4529
                                {
4530
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4531
                                    //{
4532
                                        currentControl = new ArrowTextControl();
4533
                                        currentControl.CommentID = Commons.shortGuid();
4534
                                        currentControl.IsNew = true;
4535
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4536
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4537

    
4538
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4539
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4540
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4541
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4542
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4543

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

    
4547
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4548
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4549
                                        this.MainAngle.Visibility = Visibility.Visible;
4550

    
4551
                                    
4552
                                    //}
4553
                                }
4554
                            }
4555
                        }
4556
                        break;
4557
                    case ControlType.ArrowTransTextControl:
4558
                        {
4559
                            if (mouseButtonDown == MouseButton.Left)
4560
                            {
4561
                                if (currentControl is ArrowTextControl)
4562
                                {
4563
                                    //20180906 LJY TEST IsRotationDrawingEnable
4564
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4565
                                    {
4566
                                        return;
4567
                                    }                                    
4568

    
4569
                                    CreateControl();
4570
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4571
                                    currentControl.IsNew = false;
4572
                                    currentControl = null;
4573
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4574
                                }
4575
                                else
4576
                                {
4577
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4578
                                    //{
4579
                                         currentControl = new ArrowTextControl();
4580
                                        currentControl.CommentID = Commons.shortGuid();
4581
                                        currentControl.IsNew = true;
4582
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4583
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4584
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4585
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4586
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4587
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4588
                                        (currentControl as ArrowTextControl).isFixed = true;
4589
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4590

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

    
4594
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4595
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4596
                                        (currentControl as ArrowTextControl).isTrans = true;
4597
                                }
4598
                            }
4599
                        }
4600
                        break;
4601
                    case ControlType.ArrowTextBorderControl:
4602
                         {
4603
                            if (mouseButtonDown == MouseButton.Left)
4604
                            {
4605
                                if (currentControl is ArrowTextControl)
4606
                                {
4607
                                    //20180906 LJY TEST IsRotationDrawingEnable
4608
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4609
                                    {
4610
                                        return;
4611
                                    }
4612

    
4613
                                    CreateControl();
4614
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4615
                                    currentControl.IsNew = false;
4616
                                    currentControl = null;
4617
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4618
                                }
4619
                                else
4620
                                {
4621
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4622
                                    //{
4623
                                        currentControl = new ArrowTextControl()
4624
                                        {
4625
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4626
                                        };
4627
                                        currentControl.CommentID = Commons.shortGuid();
4628
                                        currentControl.IsNew = true;
4629
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4630
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4631

    
4632
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4633

    
4634
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4635

    
4636
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4637
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4638
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4639

    
4640
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4641
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4642
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4643
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4644
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4645
                                    //}
4646
                                }
4647
                            }
4648
                        }
4649
                        break;
4650
                    case ControlType.ArrowTransTextBorderControl:
4651
                        {
4652
                            if (mouseButtonDown == MouseButton.Left)
4653
                            {
4654
                                if (currentControl is ArrowTextControl)
4655
                                {
4656
                                    //20180906 LJY TEST IsRotationDrawingEnable
4657
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4658
                                    {
4659
                                        return;
4660
                                    }
4661
                                    CreateControl();
4662
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4663
                                    currentControl.IsNew = false;
4664
                                    currentControl = null;
4665
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4666
                                }
4667
                                else
4668
                                {
4669
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4670
                                    //{
4671
                                    
4672

    
4673
                                    currentControl = new ArrowTextControl()
4674
                                        {
4675
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4676
                                        };
4677
                                        currentControl.CommentID = Commons.shortGuid();
4678
                                        currentControl.IsNew = true;
4679
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4680
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4681

    
4682
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4683

    
4684
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4685
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4686
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4687
                                        (currentControl as ArrowTextControl).isFixed = true;
4688
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4689
                                     
4690
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4691
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4692
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4693

    
4694
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4695
                                        this.MainAngle.Visibility = Visibility.Visible;
4696
                                    
4697
                                    //20180911 LJY
4698
                                        (currentControl as ArrowTextControl).isTrans = true;
4699
                                    
4700

    
4701
                                    //}
4702
                                }
4703
                            }
4704
                        }
4705
                        break;
4706
                    case ControlType.ArrowTextCloudControl:
4707
                        {
4708
                            if (mouseButtonDown == MouseButton.Left)
4709
                            {
4710
                                if (currentControl is ArrowTextControl)
4711
                                {
4712
                                    //20180906 LJY TEST IsRotationDrawingEnable
4713
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4714
                                    {
4715
                                        return;
4716
                                    }
4717
                                    CreateControl();
4718
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4719
                                    currentControl.IsNew = false;
4720
                                    currentControl = null;
4721
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4722
                                }
4723
                                else
4724
                                {
4725
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4726
                                    //{
4727
                                        currentControl = new ArrowTextControl()
4728
                                        {
4729
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4730
                                        };
4731
                                        currentControl.CommentID = Commons.shortGuid();
4732
                                        currentControl.IsNew = true;
4733
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4734
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4735

    
4736
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4737
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4738
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4739
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4740
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4741

    
4742
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4743
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4744
                                    
4745
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4746
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4747
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4748
                                    //}
4749
                                }
4750
                            }
4751
                        }
4752
                        break;
4753
                    case ControlType.ArrowTransTextCloudControl:
4754
                        {
4755
                            if (mouseButtonDown == MouseButton.Left)
4756
                            {
4757
                                if (currentControl is ArrowTextControl)
4758
                                {
4759
                                    //20180906 LJY TEST IsRotationDrawingEnable
4760
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4761
                                    {
4762
                                        return;
4763
                                    }
4764
                                    CreateControl();
4765
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4766
                                    currentControl.IsNew = false;
4767
                                    currentControl = null;
4768
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4769
                                }
4770
                                else
4771
                                {
4772
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4773
                                    //{
4774
                                        currentControl = new ArrowTextControl()
4775
                                        {
4776
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4777
                                        };
4778
                                        currentControl.CommentID = Commons.shortGuid();
4779
                                        currentControl.IsNew = true; 
4780
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4781
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4782
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4783

    
4784
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4785
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4786
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4787
                                        (currentControl as ArrowTextControl).isFixed = true;
4788
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4789

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

    
4793
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4794
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4795
                                        this.MainAngle.Visibility = Visibility.Visible;  
4796
                                    
4797
                                    //20180911 LJY
4798
                                        (currentControl as ArrowTextControl).isTrans = true;
4799
                                    //}
4800
                                }
4801
                            }
4802
                        }
4803
                        break;
4804
                    case ControlType.PolygonControl:
4805
                        {
4806
                            if (currentControl is PolygonControl)
4807
                            {
4808
                                var control = currentControl as PolygonControl;
4809

    
4810
                                if (mouseButtonDown == MouseButton.Right)
4811
                                {
4812
                                    control.IsCompleted = true;
4813
                                }
4814

    
4815
                                if (!control.IsCompleted)
4816
                                {
4817
                                    control.PointSet.Add(control.EndPoint);
4818
                                }
4819
                                else
4820
                                {
4821
                                    //20180906 LJY TEST IsRotationDrawingEnable
4822
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4823
                                    {
4824
                                        return;
4825
                                    }
4826

    
4827
                                    var firstPoint = control.PointSet.First();
4828
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4829
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4830
                                    control.PointSet.Add(firstPoint);
4831

    
4832
                                    control.ApplyOverViewData();
4833

    
4834
                                    CreateControl();
4835
                                    control.updateControl();
4836
                                    currentControl = null;
4837
                                }
4838
                            }
4839
                            else
4840
                            {
4841
                                if (mouseButtonDown == MouseButton.Left)
4842
                                {
4843
                                    currentControl = new PolygonControl
4844
                                    {
4845
                                        PointSet = new List<Point>(),
4846
                                    };
4847

    
4848
                                    var polygonControl = (currentControl as PolygonControl);
4849
                                    currentControl.CommentID = Commons.shortGuid();
4850
                                    currentControl.IsNew = true;
4851
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4852
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
4853
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
4854
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4855
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4856
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4857
                                    polygonControl.ApplyTemplate();
4858
                                    polygonControl.Visibility = Visibility.Visible;
4859
                                }
4860
                            }
4861
                        }
4862
                        break;
4863
                    //강인구 추가
4864
                    case ControlType.Sign:
4865
                        {
4866
                            if (mouseButtonDown == MouseButton.Left)
4867
                            {
4868
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4869
                                //{
4870
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4871

    
4872
                                    if (_sign == null)
4873
                                    {
4874
                                        txtBatch.Visibility = Visibility.Collapsed;
4875
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4876
                                        controlType = ControlType.None;
4877

    
4878
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4879
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4880
                                        return;
4881
                                    }
4882

    
4883
                                    if (currentControl is SignControl)
4884
                                    {
4885
                                        //20180906 LJY TEST IsRotationDrawingEnable
4886
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4887
                                        {
4888
                                            return;
4889
                                        }
4890

    
4891
                                        CreateControl();
4892
                                        currentControl = null;
4893
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4894
                                        {
4895
                                            txtBatch.Text = "Place Date";
4896
                                            controlType = ControlType.Date;
4897
                                        }
4898
                                    }
4899
                                    else
4900
                                    {
4901
                                        currentControl = new SignControl
4902
                                        {
4903
                                            Background = new SolidColorBrush(Colors.Black),
4904
                                            UserNumber = App.ViewInfo.UserID,
4905
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4906
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4907
                                            ControlType = ControlType.Sign
4908
                                        };
4909

    
4910
                                        currentControl.CommentID = Commons.shortGuid();
4911
                                        currentControl.IsNew = true;
4912
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4913
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4914

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

    
4936
                                        CreateControl();
4937
                                        (currentControl as RectangleControl).ApplyOverViewData();
4938
                                        currentControl = null;
4939
                                    
4940
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4941

    
4942
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4943
                                        {
4944
                                            txtBatch.Text = "Place Signature";
4945
                                            controlType = ControlType.Sign;
4946
                                        }
4947
                                    }
4948
                                    else
4949
                                    {
4950
                                        currentControl = new RectangleControl
4951
                                        {
4952
                                            Background = new SolidColorBrush(Colors.Black),
4953
                                            Paint = PaintSet.Fill
4954
                                        };
4955

    
4956
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4957
                                        currentControl.CommentID = Commons.shortGuid();
4958
                                        currentControl.IsNew = true;
4959
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4960
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4961
                                    }
4962
                                //}
4963
                            }
4964
                        }
4965
                        break;
4966
                    case ControlType.Symbol:
4967
                        {
4968
                            if (mouseButtonDown == MouseButton.Left)
4969
                            {
4970
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4971
                                //{
4972
                                    if (currentControl is SymControl)
4973
                                    {
4974
                                        //20180906 LJY TEST IsRotationDrawingEnable
4975
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4976
                                        {
4977
                                            return;
4978
                                        }
4979
                                        CreateControl();
4980
                                        currentControl = null;
4981
                                    
4982
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4983
                                    }
4984
                                    else
4985
                                    {
4986
                                        currentControl = new SymControl
4987
                                        {
4988
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4989
                                            Background = new SolidColorBrush(Colors.Black),
4990
                                            ControlType = ControlType.Symbol
4991
                                        };
4992

    
4993
                                        currentControl.IsNew = true;
4994
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4995
                                        currentControl.CommentID = Commons.shortGuid();
4996
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4997

    
4998
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4999
                                        (currentControl as SymControl).Angle -= rotate.Angle;
5000
                                }
5001
                                //}
5002
                            }
5003
                        }
5004
                        break;
5005
                    case ControlType.Stamp:
5006
                        {
5007
                            if (mouseButtonDown == MouseButton.Left)
5008
                            {
5009
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5010
                                //{
5011
                                    if (currentControl is SymControlN)
5012
                                    {
5013
                                        //20180906 LJY TEST IsRotationDrawingEnable
5014
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5015
                                        {
5016
                                            return;
5017
                                        }
5018

    
5019
                                        CreateControl();
5020
                                        currentControl = null;
5021
                                   
5022

    
5023
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5024
                                    }
5025
                                    else
5026
                                    {
5027
                                        currentControl = new SymControlN
5028
                                        {
5029
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5030
                                            Background = new SolidColorBrush(Colors.Black),
5031
                                            ControlType = ControlType.Stamp
5032
                                        };
5033

    
5034
                                        currentControl.IsNew = true;
5035
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5036
                                        currentControl.CommentID = Commons.shortGuid();
5037
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5038
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
5039
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
5040
                                }                                    
5041
                                //}
5042
                            }
5043
                        }
5044
                        break;
5045
                    case ControlType.PenControl:
5046
                        {
5047
                            if (inkBoard.Tag.ToString() == "Ink")
5048
                            {
5049
                                inkBoard.IsEnabled = true;
5050
                                StartNewStroke(canvasDrawingMouseDownPoint);
5051
                            }
5052
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
5053
                            {
5054
                                RemovePointStroke(canvasDrawingMouseDownPoint);
5055
                            }
5056
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
5057
                            {
5058
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
5059
                            }
5060
                            IsDrawing = true;
5061
                            return;
5062
                        }
5063
                    default:
5064
                        if (currentControl != null)
5065
                        {
5066
                            currentControl.CommentID = null;
5067
                            currentControl.IsNew = false;
5068
                        }
5069
                        break;
5070
                }
5071
            }
5072
            if (mouseHandlingMode != MouseHandlingMode.None && mouseButtonDown == MouseButton.Left)
5073
            {
5074
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
5075
                {
5076
                    bool mouseOff = false;
5077
                    foreach (var item in SelectLayer.Children)
5078
                    {
5079
                        if (item is AdornerFinal)
5080
                        {
5081

    
5082
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
5083
                            if (over != null)
5084
                            {
5085
                                mouseOff = true;
5086
                            }
5087
                        }
5088
                    }
5089

    
5090
                    if (!mouseOff)
5091
                    {
5092
                        SelectionSet.Instance.UnSelect(this);
5093
                    }
5094
                }
5095
                zoomAndPanControl.CaptureMouse();
5096
                e.Handled = true;
5097
            }
5098
        }
5099

    
5100
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5101
        {
5102
            mouseButtonDown = e.ChangedButton;
5103
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5104
        }
5105

    
5106
        private void RemoveLineStroke(Point P)
5107
        {
5108
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
5109
            if (control != null)
5110
            {
5111
                UndoData = new Undo_data()
5112
                {
5113
                    IsUndo = false,
5114
                    Event = Event_Type.Delete,
5115
                    EventTime = DateTime.Now,
5116
                    Markup_List = new List<Multi_Undo_data>()
5117
                };
5118

    
5119

    
5120
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5121
                UndoData.Markup_List.Add(multi_Undo_Data);
5122
                multi_Undo_Data = new Multi_Undo_data();
5123

    
5124
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
5125
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
5126
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
5127
                
5128
                //임시파일에서도 삭제한다.
5129
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
5130
                
5131
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5132
                {
5133
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5134
                });
5135
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5136

    
5137
            }
5138
        }
5139

    
5140
        private void RemovePointStroke(Point P)
5141
        {
5142
            foreach (Stroke hits in inkBoard.Strokes)
5143
            {
5144
                foreach (StylusPoint sty in hits.StylusPoints)
5145
                {
5146

    
5147
                }
5148
                if (hits.HitTest(P))
5149
                {
5150
                    inkBoard.Strokes.Remove(hits);
5151
                    return;
5152
                }
5153
            }
5154
        }
5155

    
5156
        private void StartNewStroke(Point P)
5157
        {
5158
            strokePoints = new StylusPointCollection();
5159
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5160
            strokePoints.Add(segment1Start);
5161
            stroke = new Stroke(strokePoints);
5162

    
5163
            stroke.DrawingAttributes.Color = Colors.Red;
5164
            stroke.DrawingAttributes.Width = 4;
5165
            stroke.DrawingAttributes.Height = 4;
5166

    
5167
            inkBoard.Strokes.Add(stroke);
5168

    
5169
        }
5170

    
5171
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5172
        {
5173
            ConsolidationMethod();
5174
        }
5175

    
5176
        public void TeamConsolidationMethod()
5177
        {
5178
            ChangeCommentReact();
5179
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5180
            {
5181
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5182
            }
5183
            else
5184
            {
5185
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5186
                {
5187
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
5188
                    {
5189
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
5190
                        return;
5191
                    }                    
5192
                }
5193
                ViewerDataModel.Instance.IsConsolidate = true;
5194
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5195
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5196

    
5197
                string project_no = App.ViewInfo.ProjectNO;
5198
                string doc_id = _DocInfo.ID;
5199
                string user_id = App.ViewInfo.UserID;
5200
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5201
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5202
                {
5203
                    markupInfoItems.Add(item);
5204
                }
5205
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5206
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5207
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
5208

    
5209
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5210
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5211
            }
5212
        }
5213
        public void ConsolidationMethod()
5214
        {
5215
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5216
            {
5217
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5218
            }
5219
            else
5220
            {
5221
                /*
5222
                ViewerDataModel.Instance.IsConsolidate = true;
5223
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5224

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

    
5236
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5237
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5238
                */
5239
                
5240
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
5241
                foreach (var item in this.gridViewMarkup.SelectedItems)
5242
                {
5243
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
5244
                }
5245
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
5246

    
5247
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
5248
            }
5249
        }
5250

    
5251
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5252
        {
5253
            if (App.ViewInfo != null)
5254
            {
5255
                btnConsolidate = (sender as RadRibbonButton);
5256
                if (!App.ViewInfo.NewCommentPermission)
5257
                {
5258
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5259
                }
5260
            }
5261
        }
5262

    
5263
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5264
        {
5265
            TeamConsolidationMethod();
5266
        }
5267

    
5268
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5269
        {
5270
            btnTeamConsolidate = sender as RadRibbonButton;
5271
            if (App.ViewInfo != null)
5272
            {
5273
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5274
                {
5275
                    if (btnConsolidate != null)
5276
                    {
5277
                        btnConsolidate.Visibility = Visibility.Collapsed;
5278
                    }
5279

    
5280
                    if (!App.ViewInfo.NewCommentPermission)
5281
                    {
5282
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5283
                    }
5284
                }
5285
                else
5286
                {
5287
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5288
                }
5289
            }
5290
        }
5291

    
5292
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5293
        {
5294
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5295
            if (item != null)
5296
            {
5297
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5298

    
5299
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5300
            }
5301
            else
5302
            {
5303
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5304
            }
5305
        }
5306

    
5307
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5308
        {
5309
            btnFinalPDF = sender as RadRibbonButton;
5310
            if (App.ViewInfo != null)
5311
            {
5312
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5313
                {
5314
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5315
                    if (btnConsolidate != null)
5316
                    {
5317
                        btnConsolidate.Visibility = Visibility.Collapsed;
5318
                    }
5319
                }
5320
            }
5321
        }
5322

    
5323
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5324
        {
5325
            ChangeCommentReact();
5326

    
5327
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5328
            {
5329
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5330
            }
5331
            else
5332
            {
5333
                ViewerDataModel.Instance.IsConsolidate = true;
5334
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5335
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5336

    
5337
                string project_no = App.ViewInfo.ProjectNO;
5338
                string doc_id = _DocInfo.ID;
5339
                string user_id = App.ViewInfo.UserID;
5340
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5341
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5342
                {
5343
                    markupInfoItems.Add(item);
5344
                }
5345
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5346
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5347
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5348
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5349

    
5350
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5351
                if (item2 != null)
5352
                {
5353
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5354

    
5355
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5356
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5357
                }
5358
                else
5359
                {
5360
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5361
                }
5362
            }
5363
        }
5364

    
5365
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5366
        {
5367
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5368

    
5369
            if (App.ViewInfo != null)
5370
            {
5371
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5372
                {
5373
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5374
                }
5375
            }
5376
        }
5377

    
5378
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5379
        {
5380
            if (CompareMode.IsChecked)
5381
            {
5382
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5383
                {
5384
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5385
                }
5386
                if (ViewerDataModel.Instance.PageNumber == 0)
5387
                {
5388
                    ViewerDataModel.Instance.PageNumber = 1;
5389
                }
5390

    
5391
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5392
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5393
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5394

    
5395
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5396
            }
5397
            else
5398
            {
5399
                da.From = 1;
5400
                da.To = 1;
5401
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5402
                da.AutoReverse = false;
5403
                canvas_compareBorder.Children.Clear();
5404
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5405
            }
5406
        }
5407

    
5408
        private void Sync_Click(object sender, RoutedEventArgs e)
5409
        {
5410
            if (Sync.IsChecked)
5411
            {
5412
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5413
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5414
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5415
            }
5416
        }
5417

    
5418
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5419
        {
5420
            if (UserList.IsChecked)
5421
            {
5422
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5423
            }
5424
            else
5425
            {
5426
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5427
            }
5428
        }
5429

    
5430
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5431
        {
5432

    
5433
            if (BalanceMode.IsChecked)
5434
            {
5435
                ViewerDataModel.Instance.PageBalanceMode = true;
5436
            }
5437
            else
5438
            {
5439
                ViewerDataModel.Instance.PageBalanceMode = false;
5440
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5441
            }
5442
        }
5443

    
5444
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5445
        {
5446
            //초기화
5447
            testPanel2.IsHidden = true;
5448
            ViewerDataModel.Instance.PageBalanceMode = false;
5449
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5450
            ViewerDataModel.Instance.PageNumber = 0;
5451
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5452
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5453
            UserList.IsChecked = false;
5454
            BalanceMode.IsChecked = false;
5455
        }
5456

    
5457
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5458
        {
5459
            if ((sender as System.Windows.Controls.Control).Tag != null)
5460
            {
5461
                //Compare 초기화
5462
                CompareMode.IsChecked = false;
5463
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5464

    
5465
                if (ViewerDataModel.Instance.PageNumber == 0)
5466
                {
5467
                    ViewerDataModel.Instance.PageNumber = 1;
5468
                }
5469

    
5470
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5471
                {
5472
                }
5473
                else
5474
                {
5475
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5476
                }
5477

    
5478
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5479
                {
5480

    
5481
                }
5482
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5483
                {
5484
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5485
                }
5486

    
5487
                if (!testPanel2.IsHidden)
5488
                {
5489
                    if (IsSyncPDFMode)
5490
                    {
5491
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5492
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5493

    
5494
                        if (pdfpath.IsDownloading)
5495
                        {
5496
                            pdfpath.DownloadCompleted += (ex, arg) =>
5497
                            {
5498
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5499
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5500
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5501
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5502
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5503
                            };
5504
                        }
5505
                        else
5506
                        {
5507
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5508
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5509
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5510

    
5511
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5512
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5513
                        }
5514

    
5515
                    }
5516
                    else
5517
                    {
5518
                        string uri = "";
5519

    
5520
                        if (userData.COMPANY != "EXT")
5521
                        {
5522
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5523
                        }
5524
                        else
5525
                        {
5526
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5527
                        }
5528

    
5529
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5530

    
5531
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5532
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5533
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5534

    
5535
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5536
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5537

    
5538
                        if (defaultBitmapImage_Compare.IsDownloading)
5539
                        {
5540
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5541
                            {
5542
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5543
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5544
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5545

    
5546
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5547
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5548
                            };
5549
                        }
5550
                    }
5551

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

    
5556
                    foreach (var item in gridSelectionRevItem)
5557
                    {
5558
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5559
                        {
5560
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5561
                        });
5562
                    }
5563

    
5564
                    //강인구 추가
5565
                    zoomAndPanControl2.ZoomTo(new Rect
5566
                    {
5567
                        X = 0,
5568
                        Y = 0,
5569
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5570
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5571
                    });
5572

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

    
5575
                }
5576
            }
5577
        }
5578

    
5579
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5580
        {
5581
            if (MarkupMode.IsChecked)
5582
            {
5583
                IsSyncPDFMode = true;
5584

    
5585
                var uri = CurrentRev.TO_VENDOR;
5586

    
5587
                if (ViewerDataModel.Instance.PageNumber == 0)
5588
                {
5589
                    ViewerDataModel.Instance.PageNumber = 1;
5590
                }
5591

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

    
5596
                if (pdfpath.IsDownloading)
5597
                {
5598
                    pdfpath.DownloadCompleted += (ex, arg) =>
5599
                    {
5600
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5601
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5602
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5603
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5604
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5605
                    };
5606
                }
5607
                else
5608
                {
5609
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5610
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5611
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5612

    
5613
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5614
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5615
                }
5616
            }
5617
            else
5618
            {
5619
                IsSyncPDFMode = false;
5620
                string uri = "";
5621
                if (userData.COMPANY != "EXT")
5622
                {
5623
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5624
                }
5625
                else
5626
                {
5627
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5628
                }
5629

    
5630
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5631

    
5632
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5633
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5634
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5635

    
5636
                if (defaultBitmapImage_Compare.IsDownloading)
5637
                {
5638
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5639
                    {
5640
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5641
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5642
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5643
                    };
5644
                }
5645
                zoomAndPanControl2.ApplyTemplate();
5646
                zoomAndPanControl2.UpdateLayout();
5647
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5648
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5649
            }
5650
        }
5651

    
5652
        private void RadButton_Click(object sender, RoutedEventArgs e)
5653
        {
5654
            gridViewHistory_Busy.IsBusy = true;
5655

    
5656
            RadButton instance = sender as RadButton;
5657
            if (instance.CommandParameter != null)
5658
            {
5659
                CurrentRev = instance.CommandParameter as VPRevision;
5660
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5661
                {
5662
                    if (ea.Error == null && ea.Result != null)
5663
                    {
5664
                        testPanel2.IsHidden = false;
5665

    
5666
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5667
                        foreach(var info in ea.Result)
5668
                        {
5669
                            if(info.UserID == App.ViewInfo.UserID)
5670
                            {
5671
                                info.userDelete = true;
5672
                                info.DisplayColor = "FFFF0000";
5673
                            }
5674
                            else
5675
                            {
5676
                                info.userDelete = false;
5677
                            }
5678
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5679
                        }
5680
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5681

    
5682
                        string uri = "";
5683
                        if (userData.COMPANY != "EXT")
5684
                        {
5685
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5686
                        }
5687
                        else
5688
                        {
5689
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5690
                        }
5691

    
5692
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5693

    
5694
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5695

    
5696
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5697
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5698
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5699

    
5700
                        if (defaultBitmapImage_Compare.IsDownloading)
5701
                        {
5702
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5703
                            {
5704
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5705
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5706
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5707
                            };
5708
                        }
5709

    
5710
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5711
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5712
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5713
                        zoomAndPanControl2.ApplyTemplate();
5714
                        zoomAndPanControl2.UpdateLayout();
5715

    
5716
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5717
                        {
5718
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5719
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5720
                        }
5721

    
5722
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5723
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5724
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5725

    
5726
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5727
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5728
                        gridViewHistory_Busy.IsBusy = false;
5729
                    }
5730

    
5731
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5732
                };
5733
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5734
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5735
            }
5736
        }
5737

    
5738
        public void Sync_Event(VPRevision Currnet_Rev)
5739
        {
5740
            CurrentRev = Currnet_Rev;
5741

    
5742
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5743
            {
5744
                if (ea.Error == null && ea.Result != null)
5745
                {
5746
                    testPanel2.IsHidden = false;
5747

    
5748
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5749
                    foreach(var info in ea.Result)
5750
                    {
5751
                        if(info.UserID == App.ViewInfo.UserID)
5752
                        {
5753
                            info.userDelete = true;
5754
                            info.DisplayColor = "FFFF0000";
5755
                        }
5756
                        else
5757
                        {
5758
                            info.userDelete = false;
5759
                        }
5760
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5761
                    }
5762
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5763

    
5764
                    string uri = "";
5765
                    if (userData.COMPANY != "EXT")
5766
                    {
5767
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5768
                    }
5769
                    else
5770
                    {
5771
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5772
                    }
5773

    
5774
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5775

    
5776
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5777

    
5778
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5779
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5780
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5781

    
5782
                    if (defaultBitmapImage_Compare.IsDownloading)
5783
                    {
5784
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5785
                        {
5786
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5787
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5788
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5789
                        };
5790
                    }
5791

    
5792

    
5793
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5794
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5795
                    zoomAndPanControl2.ApplyTemplate();
5796
                    zoomAndPanControl2.UpdateLayout();
5797

    
5798
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5799
                    {
5800
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5801
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5802
                    }
5803
                    //}
5804

    
5805
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5806
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5807
                    gridViewHistory_Busy.IsBusy = false;
5808
                }
5809
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5810

    
5811
            };
5812
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5813
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5814
        }
5815

    
5816
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5817
        {
5818
            if (sender is Image)
5819
            {
5820
                if ((sender as Image).Tag != null)
5821
                {
5822
                    var pdfUrl = (sender as Image).Tag.ToString();
5823
                    System.Diagnostics.Process.Start(pdfUrl);
5824
                }
5825
                else
5826
                {
5827
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5828
                }
5829
            }
5830
        }
5831

    
5832
        private void Create_Symbol(object sender, RoutedEventArgs e)
5833
        {
5834
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5835

    
5836
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5837
            {
5838
                DialogMessage_Alert("Please Select Controls", "Alert");
5839
            }
5840
            else //선택된 것이 있으면
5841
            {
5842
                string MarkupData = "";
5843
                adorner_ = new AdornerFinal();
5844

    
5845
                foreach (var item in SelectLayer.Children)
5846
                {
5847
                    if (item.GetType().Name == "AdornerFinal")
5848
                    {
5849
                        adorner_ = (item as Controls.AdornerFinal);
5850
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5851
                        {
5852
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5853
                            {
5854
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5855
                                MarkupData += markupReturn.ConvertData;
5856
                            }
5857
                        }
5858
                    }
5859
                }
5860
                DialogParameters parameters = new DialogParameters()
5861
                {
5862
                    Owner = Application.Current.MainWindow,
5863
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5864
                    DefaultPromptResultValue = "Custom State",
5865
                    Content = "Name :",
5866
                    Header = "Insert Custom Symbol Name",
5867
                    Theme = new VisualStudio2013Theme(),
5868
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5869
                };
5870
                RadWindow.Prompt(parameters);
5871
            }
5872

    
5873
        }
5874
        public int symbolselectindex = 0;
5875
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5876
        {
5877
            //Save save = new Save();
5878
            try
5879
            {
5880
                string svgfilename = null;
5881
                if (symbolname != null)
5882
                {
5883
                    if (symbolpng == true || symbolsvg == true)
5884
                    {
5885
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5886
                        string guid = Commons.shortGuid();
5887

    
5888
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5889
                        //Check_Uri.UriCheck();
5890
                        fileUploader.RunCompleted += (ex, arg) =>
5891
                        {
5892
                            filename = arg.Result;
5893
                            if (symbolpng == true)
5894
                            {
5895
                                if (filename != null)
5896
                                { 
5897
                                    if (symbolselectindex == 0)
5898
                                    {
5899
                                        SymbolSave(symbolname, filename, data);
5900
                                    }
5901
                                    else
5902
                                    {
5903
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5904
                                    }
5905
                                    DataBind();
5906
                                }                                
5907
                            }
5908

    
5909
                            if (symbolsvg == true)
5910
                            {
5911
                                try
5912
                                {
5913
                                    var defaultBitmapImage = new BitmapImage();
5914
                                    defaultBitmapImage.BeginInit();
5915
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5916
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5917
                                    Check_Uri.UriCheck(filename);
5918
                                    defaultBitmapImage.UriSource = new Uri(filename);
5919
                                    defaultBitmapImage.EndInit();
5920

    
5921
                                    System.Drawing.Bitmap image;
5922

    
5923
                                    if (defaultBitmapImage.IsDownloading)
5924
                                    {
5925
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5926
                                        {
5927
                                            defaultBitmapImage.Freeze();
5928
                                            image = GetBitmap(defaultBitmapImage);
5929
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5930
                                            Process potrace = new Process
5931
                                            {
5932
                                                StartInfo = new ProcessStartInfo
5933
                                                {
5934
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5935
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5936
                                                    RedirectStandardInput = true,
5937
                                                    RedirectStandardOutput = true,
5938
                                                    RedirectStandardError = true,
5939
                                                    UseShellExecute = false,
5940
                                                    CreateNoWindow = true,
5941
                                                    WindowStyle = ProcessWindowStyle.Hidden
5942
                                                },
5943
                                            };
5944

    
5945
                                            StringBuilder svgBuilder = new StringBuilder();
5946
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5947
                                            {
5948
                                                svgBuilder.AppendLine(e2.Data);
5949
                                            };
5950

    
5951
                                            potrace.EnableRaisingEvents = true;
5952
                                            potrace.Start();
5953
                                            potrace.Exited += (sender, e) =>
5954
                                            {
5955
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5956
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5957
                                                Check_Uri.UriCheck(svgfilename);
5958
                                                if (symbolselectindex == 0)
5959
                                                {
5960
                                                    SymbolSave(symbolname, svgfilename, data);
5961
                                                }
5962
                                                else
5963
                                                {
5964
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5965
                                                }
5966

    
5967
                                                DataBind();
5968
                                            };
5969
                                            potrace.WaitForExit();
5970
                                        };
5971
                                    }
5972
                                    else
5973
                                    {
5974
                                        //GC.Collect();
5975
                                    }
5976
                                }
5977
                                catch(Exception ee)
5978
                                {
5979
                                    DialogMessage_Alert("" + ee, "Alert");
5980
                                }
5981
                            }
5982
                        };                                             
5983
                    }
5984
                }
5985
            }
5986
            catch (Exception e)
5987
            {
5988
                //DialogMessage_Alert(e + "", "Alert");
5989
            }            
5990
        }
5991

    
5992
        public void SymbolSave(string Name, string Url, string Data)
5993
        {
5994
            try
5995
            {
5996
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5997
                {
5998
                    ID = Commons.shortGuid(),
5999
                    MEMBER_USER_ID = App.ViewInfo.UserID,
6000
                    NAME = Name,
6001
                    IMAGE_URL = Url,
6002
                    DATA = Data
6003
                };
6004

    
6005
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
6006
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
6007
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
6008
            }
6009
            catch (Exception)
6010
            {
6011
                throw;
6012
            }
6013
        }
6014

    
6015
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
6016
        {
6017
            try
6018
            {
6019
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
6020
                {
6021
                    ID = Commons.shortGuid(),
6022
                    DEPARTMENT = Department,
6023
                    NAME = Name,
6024
                    IMAGE_URL = Url,
6025
                    DATA = Data
6026
                };
6027
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
6028
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
6029
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
6030
            }
6031
            catch (Exception)
6032
            {
6033
                throw;
6034
            }
6035
        }
6036

    
6037
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
6038
        {           
6039
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6040
            DataBind();
6041
        }
6042

    
6043
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
6044
        {
6045
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6046
            DataBind();
6047
        }
6048
        private void DataBind()
6049
        {
6050
            try
6051
            {
6052
                Symbol_Custom Custom = new Symbol_Custom();
6053
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
6054
                //ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
6055
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
6056
                foreach (var item in symbol_Private)
6057
                {
6058
                    Custom.Name = item.NAME;
6059
                    Custom.ImageUri = item.IMAGE_URL;
6060
                    Custom.ID = item.ID;
6061
                    Custom_List.Add(Custom);
6062
                    Custom = new Symbol_Custom();
6063
                }
6064
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
6065
                
6066
                Custom = new Symbol_Custom();
6067
                Custom_List = new List<Symbol_Custom>();
6068

    
6069
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
6070

    
6071
                List<SYMBOL_PUBLIC> symbol_Public;
6072

    
6073
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
6074
                {
6075
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
6076
                }
6077
                else
6078
                {
6079
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
6080
                }
6081
                foreach (var item in symbol_Public)
6082
                {
6083
                    Custom.Name = item.NAME;
6084
                    Custom.ImageUri = item.IMAGE_URL;
6085
                    Custom.ID = item.ID;
6086
                    Custom_List.Add(Custom);
6087
                    Custom = new Symbol_Custom();
6088
                }
6089
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
6090
                BaseClient.Close();                
6091
            }
6092
            catch(Exception e)
6093
            {
6094
                //DialogMessage_Alert("DataBind", "Alert");
6095
            }
6096
            
6097
        }
6098
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
6099
        {
6100
            try
6101
            {
6102
                if (args.PromptResult != null)
6103
                {
6104
                    if (args.DialogResult.Value)
6105
                    {
6106
                        PngBitmapEncoder _Encoder = symImage(data);
6107

    
6108
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6109
                        _Encoder.Save(fs);
6110
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6111

    
6112
                        byte[] Img_byte = fs.ToArray();
6113

    
6114
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6115
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
6116
                        Check_Uri.UriCheck(filename);
6117
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6118
                        {
6119
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
6120
                        }
6121
                        else
6122
                        {
6123
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6124
                        }
6125
                        DataBind();
6126
                    }
6127
                }
6128
            }
6129
            catch(Exception ex)
6130
            {
6131
                DialogMessage_Alert("" + ex, "Alert");
6132
            }
6133
        }
6134

    
6135
        public PngBitmapEncoder symImage(string data)
6136
        {
6137

    
6138
            Canvas _canvas = new Canvas();
6139
            _canvas.Background = Brushes.White;
6140
            _canvas.Width = adorner_.BorderSize.Width;
6141
            _canvas.Height = adorner_.BorderSize.Height;
6142
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
6143

    
6144
            BitmapEncoder encoder = new PngBitmapEncoder();
6145

    
6146

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

    
6149
            DrawingVisual dv = new DrawingVisual();
6150

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

    
6154
            using (DrawingContext ctx = dv.RenderOpen())
6155
            {
6156
                VisualBrush vb = new VisualBrush(_canvas);
6157
                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)));
6158
            }
6159

    
6160
            try
6161
            {
6162
                renderBitmap.Render(dv);
6163

    
6164
                //GC.Collect();
6165
                GC.WaitForPendingFinalizers();
6166
                //GC.Collect();
6167
                // encode png data
6168
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6169
                // puch rendered bitmap into it
6170
                pngEncoder.Interlace = PngInterlaceOption.Off;
6171
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6172
                return pngEncoder;
6173

    
6174
            }
6175
            catch //(Exception ex)
6176
            {
6177
                return null;
6178
            }
6179

    
6180
        }
6181

    
6182
        public void DialogMessage_Alert(string content, string header)
6183
        {
6184
            var box = new TextBlock();
6185
            box.MinWidth = 400;
6186
            box.FontSize = 11;
6187
            //box.FontSize = 12;
6188
            box.Text = content;
6189
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6190

    
6191
            DialogParameters parameters = new DialogParameters()
6192
            {
6193
                Owner = Application.Current.MainWindow,
6194
                Content = box,
6195
                Header = header,
6196
                Theme = new VisualStudio2013Theme(),
6197
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6198
            };            
6199
            RadWindow.Alert(parameters);
6200
        }
6201

    
6202
        #region 캡쳐 기능
6203

    
6204
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6205
        {
6206
            if (x < 0)
6207
            {
6208
                width += x;
6209
                x = 0;
6210
            }
6211
            if (y < 0)
6212
            {
6213
                height += y;
6214
                y = 0;
6215

    
6216
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6217
            }
6218
            if (x + width > zoomAndPanCanvas.ActualWidth)
6219
            {
6220
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6221
            }
6222
            if (y + height > zoomAndPanCanvas.ActualHeight)
6223
            {
6224
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6225
            }
6226

    
6227
            byte[] pixels = CopyPixels(x, y, width, height);
6228

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

    
6231
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6232
        }
6233

    
6234
        public byte[] CopyPixels(int x, int y, int width, int height)
6235
        {
6236
            byte[] pixels = new byte[width * height * 4];
6237
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6238

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

    
6242
            return pixels;
6243
        }
6244

    
6245
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6246
        {
6247
            DrawingVisual drawingVisual = new DrawingVisual();
6248
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6249

    
6250
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6251
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6252
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6253
            drawingContext.Close();
6254

    
6255
            // 비트맵으로 변환합니다.
6256
            RenderTargetBitmap target =
6257
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6258
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6259

    
6260
            target.Render(drawingVisual);
6261
            return target;
6262
        }
6263

    
6264
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6265
        {
6266
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6267
            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);
6268
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6269
            bmp.UnlockBits(data);
6270
            return bmp;
6271
        }
6272
        public string symbolname = null;
6273
        public bool symbolsvg = true;
6274
        public bool symbolpng = true;
6275

    
6276
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6277
        {
6278
            System.Drawing.Bitmap image = GetBitmap(source);
6279
            //흰색 제거
6280
            //image.MakeTransparent(System.Drawing.Color.White);
6281

    
6282
            var imageStream = new System.IO.MemoryStream();
6283
            byte[] imageBytes = null;
6284
            using (imageStream)
6285
            {
6286
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6287
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6288
                imageStream.Position = 0;
6289
                imageBytes = imageStream.ToArray();
6290
            }
6291

    
6292
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6293

    
6294
            RadWindow CheckPop = new RadWindow();
6295
            //Alert check = new Alert(Msg);
6296

    
6297
            CheckPop = new RadWindow
6298
            {
6299
                MinWidth = 400,
6300
                MinHeight = 100,
6301
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6302
                Header = "Alert",
6303
                Content = symbolPrompt,
6304
                //DialogResult = 
6305
                ResizeMode = System.Windows.ResizeMode.NoResize,
6306
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6307
                IsTopmost = true,
6308
            };
6309
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6310
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6311
            CheckPop.ShowDialog();
6312

    
6313
            /*
6314
            DialogParameters parameters = new DialogParameters()
6315
            {
6316
                Owner = Application.Current.MainWindow,
6317
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6318
                DefaultPromptResultValue = "Custom State",
6319
                Content = "Name :",
6320
                Header = "Insert Custom Symbol Name",
6321
                Theme = new VisualStudio2013Theme(),
6322
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6323
            };            
6324
            RadWindow.Prompt(parameters);
6325
            */
6326
        }
6327

    
6328
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6329
        {
6330
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6331
            KCOMDataModel.DataModel.CHECK_LIST check_;
6332
            string Result = streamToBase64.ImageToBase64(source);
6333
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6334
            string projectno = App.ViewInfo.ProjectNO;
6335
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6336

    
6337
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6338
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6339
            if (Item != null)
6340
            {
6341
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6342
            }
6343
            else
6344
            {
6345
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6346
            }
6347

    
6348
            if (Item == null)
6349
            {
6350
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6351
                {
6352
                    ID = Commons.shortGuid(),
6353
                    USER_ID = App.ViewInfo.UserID,
6354
                    IMAGE_URL = Result,
6355
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6356
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6357
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6358
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6359
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6360
                    STATUS = "False",
6361
                    CREATE_TIME = DateTime.Now,
6362
                    UPDATE_TIME = DateTime.Now,
6363
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6364
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6365
                };
6366
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6367
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6368
                //this.BaseClient.AddCheckList(projectno, check_);
6369
            }
6370
            else
6371
            {
6372
                Item.IMAGE_URL = Result;
6373
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6374
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6375
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6376
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6377
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6378
            }
6379

    
6380
        }
6381

    
6382
        public void Set_Capture()
6383
        {
6384
            double x = canvasDrawingMouseDownPoint.X;
6385
            double y = canvasDrawingMouseDownPoint.Y;
6386
            double width = dragCaptureBorder.Width;
6387
            double height = dragCaptureBorder.Height;
6388

    
6389
            if (width > 5 || height > 5)
6390
            {
6391
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6392
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6393
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6394
            }
6395
        }
6396
        #endregion
6397

    
6398
        //MarkupInfoItem
6399
        public void CreateControl()
6400
        {
6401

    
6402
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6403
            {
6404
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6405
            });
6406
            multi_Undo_Data.Markup = currentControl;
6407
            UndoData.Markup_List.Add(multi_Undo_Data);
6408

    
6409
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6410

    
6411
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6412
        }
6413

    
6414
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6415
        {
6416
            multi_Undo_Data = new Multi_Undo_data();
6417

    
6418
            multi_Undo_Data.Markup = control;
6419

    
6420
            if ((control as IShapeControl) != null)
6421
            {
6422
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6423
            }
6424
            if ((control as IDashControl) != null)
6425
            {
6426
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6427
            }
6428
            if ((control as IPath) != null)
6429
            {
6430
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6431
            }
6432
            if ((control as UIElement) != null)
6433
            {
6434
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6435
            }
6436

    
6437
            return multi_Undo_Data;
6438
        }
6439

    
6440
        public void Undo()
6441
        {
6442
            // if (ViewerDataModel.Instance.IsPressCtrl)
6443
            //   {
6444
            //      ViewerDataModel.Instance.IsPressCtrl = false;
6445
            //   }
6446
            Undo_data undo = new Undo_data();
6447
            AdornerFinal final;
6448
            SelectionSet.Instance.UnSelect(this);
6449

    
6450
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6451
            if (undo == null)
6452
                return;
6453

    
6454

    
6455

    
6456
            switch (undo.Event)
6457
            {
6458
                case (Event_Type.Create):
6459
                    {
6460
                        foreach (var item in undo.Markup_List)
6461
                        {
6462
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6463
                        }
6464
                    }
6465
                    break;
6466
                case (Event_Type.Delete):
6467
                    {
6468
                        foreach (var item in undo.Markup_List)
6469
                        {
6470
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6471
                        }
6472
                    }
6473
                    break;
6474
                case (Event_Type.Thumb):
6475
                    {
6476
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6477

    
6478
                        foreach (var item in undo.Markup_List)
6479
                        {
6480
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6481

    
6482
                            if ((item.Markup as IViewBox) != null)
6483
                            {
6484
                                (item.Markup as IViewBox).Angle = item.Angle;
6485
                            }
6486
                            if ((item.Markup as TextControl) != null)
6487
                            {
6488
                                (item.Markup as TextControl).Angle = item.Angle;
6489
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6490
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6491
                            }
6492
                            else
6493
                            {
6494
                                (item.Markup as IPath).PointSet = item.PointSet;
6495
                                (item.Markup as IPath).updateControl();
6496
                            }
6497

    
6498
                            comment.Add(item.Markup);
6499
                        }
6500
                        final = new AdornerFinal(comment);
6501
                        SelectLayer.Children.Add(final);
6502
                        SelectionSet.Instance.UnSelect(this);
6503
                    }
6504
                    break;
6505
                case (Event_Type.Select):
6506
                    {
6507
                        SelectionSet.Instance.UnSelect(this);
6508
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6509

    
6510
                        foreach (var item in undo.Markup_List)
6511
                        {
6512
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6513

    
6514
                            if ((item.Markup as IPath) != null)
6515
                            {
6516
                                (item.Markup as IPath).LineSize = item.LineSize;
6517
                            }
6518
                            if ((item.Markup as UIElement) != null)
6519
                            {
6520
                                (item.Markup as UIElement).Opacity = item.Opacity;
6521
                            }
6522
                            if ((item.Markup as IDashControl) != null)
6523
                            {
6524
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6525
                            }
6526
                            if ((item.Markup as IShapeControl) != null)
6527
                            {
6528
                                (item.Markup as IShapeControl).Paint = item.paint;
6529
                            }
6530

    
6531
                            comment.Add(item.Markup);
6532
                        }
6533

    
6534
                        final = new AdornerFinal(comment);
6535
                        SelectLayer.Children.Add(final);
6536
                    }
6537
                    break;
6538
                case (Event_Type.Option):
6539
                    {
6540
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6541

    
6542
                        foreach (var item in undo.Markup_List)
6543
                        {
6544
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6545

    
6546
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
6547
                            {
6548
                                (item.Markup as IPath).LineSize = undo.LineSize;
6549
                            }
6550
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
6551
                            {
6552
                                (item.Markup as UIElement).Opacity = undo.Opacity;
6553
                            }
6554
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
6555
                            {
6556
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
6557
                            }
6558
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
6559
                            {
6560
                                (item.Markup as LineControl).Interval = undo.Interval;
6561
                            }
6562
                            else if (item.Markup as IShapeControl != null)
6563
                            {
6564
                                (item.Markup as IShapeControl).Paint = undo.paint;
6565
                            }
6566
                            comment.Add(item.Markup);
6567
                        }
6568
                        final = new AdornerFinal(comment);
6569
                        SelectLayer.Children.Add(final);
6570
                    }
6571
                    break;
6572
            }
6573
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6574
            {
6575
                i.IsUndo = true;
6576
            });
6577
        }
6578

    
6579

    
6580

    
6581
        public void Redo()
6582
        {
6583
            //if (ViewerDataModel.Instance.IsPressCtrl)
6584
            //{
6585
            //    ViewerDataModel.Instance.IsPressCtrl = false;
6586
            //}
6587
            AdornerFinal final;
6588
            Undo_data redo = new Undo_data();
6589
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6590
            SelectionSet.Instance.UnSelect(this);
6591
            if (redo == null)
6592
                return;
6593

    
6594
            switch (redo.Event)
6595
            {
6596
                case (Event_Type.Create):
6597
                    {
6598
                        foreach (var item in redo.Markup_List)
6599
                        {
6600
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6601
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
6602
                        }
6603
                    }
6604
                    break;
6605
                case (Event_Type.Delete):
6606
                    {
6607
                        foreach (var item in redo.Markup_List)
6608
                        {
6609
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6610
                        }
6611
                    }
6612
                    break;
6613
                case (Event_Type.Thumb):
6614
                    {
6615
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6616

    
6617
                        foreach (var item in redo.Markup_List)
6618
                        {
6619
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6620

    
6621
                            if ((item.Markup as IViewBox) != null)
6622
                            {
6623
                                (item.Markup as IViewBox).Angle = item.Angle;
6624
                            }
6625
                            if ((item.Markup as TextControl) != null)
6626
                            {
6627
                                (item.Markup as TextControl).Angle = item.Angle;
6628

    
6629
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6630
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6631
                            }
6632
                            else
6633
                            {
6634
                                (item.Markup as IPath).PointSet = item.PointSet;
6635
                                (item.Markup as IPath).updateControl();
6636
                            }
6637
                            comment.Add(item.Markup);
6638
                        }
6639
                        final = new AdornerFinal(comment);
6640
                        SelectLayer.Children.Add(final);
6641
                        SelectionSet.Instance.UnSelect(this);
6642
                    }
6643
                    break;
6644
                case (Event_Type.Select):
6645
                    {
6646
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6647

    
6648
                        foreach (var item in redo.Markup_List)
6649
                        {
6650
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6651

    
6652
                            if ((item.Markup as IPath) != null)
6653
                            {
6654
                                (item.Markup as IPath).LineSize = item.LineSize;
6655
                            }
6656
                            if ((item.Markup as UIElement) != null)
6657
                            {
6658
                                (item.Markup as UIElement).Opacity = item.Opacity;
6659
                            }
6660
                            if ((item.Markup as IDashControl) != null)
6661
                            {
6662
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6663
                            }
6664
                            if ((item.Markup as IShapeControl) != null)
6665
                            {
6666
                                (item.Markup as IShapeControl).Paint = item.paint;
6667
                            }
6668

    
6669
                            comment.Add(item.Markup);
6670
                        }
6671
                        final = new AdornerFinal(comment);
6672
                        SelectLayer.Children.Add(final);
6673
                    }
6674
                    break;
6675
                case (Event_Type.Option):
6676
                    {
6677
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6678

    
6679
                        foreach (var item in redo.Markup_List)
6680
                        {
6681
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6682
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6683
                            {
6684
                                (item.Markup as IPath).LineSize = redo.LineSize;
6685
                            }
6686
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6687
                            {
6688
                                (item.Markup as UIElement).Opacity = redo.Opacity;
6689
                            }
6690
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
6691
                            {
6692
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
6693
                            }
6694
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
6695
                            {
6696
                                (item.Markup as LineControl).Interval = redo.Interval;
6697
                            }
6698
                            else if (item.Markup as IShapeControl != null)
6699
                            {
6700
                                (item.Markup as IShapeControl).Paint = redo.paint;
6701
                            }
6702
                            comment.Add(item.Markup);
6703
                        }
6704
                        final = new AdornerFinal(comment);
6705
                        SelectLayer.Children.Add(final);
6706
                    }
6707
                    break;
6708
            }
6709

    
6710
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6711
            {
6712
                i.IsUndo = false;
6713
            });
6714
        }
6715

    
6716
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6717
        {
6718
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6719
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6720
            {
6721
                if (items.UserID == Select_ID)
6722
                {
6723
                    foreach (var item in items.MarkupList)
6724
                    {
6725
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6726
                        {
6727
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6728
                                items.MarkupInfoID, Commons.shortGuid());
6729
                        }
6730
                    }
6731
                }
6732
            }
6733
        }
6734
        public void EmptyControlCheck()
6735
        {
6736
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
6737
            {
6738
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
6739
                {
6740
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
6741
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
6742
                    {
6743
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
6744
                    }
6745
                }
6746
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
6747
                {
6748
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
6749
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
6750
                    {
6751
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
6752
                    }
6753
                }
6754
            }
6755
        }
6756
        public void InkControl_Convert()
6757
        {
6758
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6759
            if (inkBoard.Strokes.Count > 0)
6760
            {
6761
                inkBoard.Strokes.ToList().ForEach(stroke =>
6762
                {
6763
                    List<Stroke> removingStroke = new List<Stroke>();
6764
                    StrokeCollection stC = new StrokeCollection();
6765

    
6766
                    removingStroke.Add(stroke);
6767

    
6768
                    InkToPath ip = new InkToPath();
6769
                    List<Point> inkPointSet = new List<Point>();
6770
                    PolygonControl pc = null;
6771
                    pc = new PolygonControl()
6772
                    {
6773
                        Angle = 0,
6774
                        PointSet = new List<Point>(),
6775
                        ControlType = ControlType.Ink
6776
                    };
6777
                    foreach (var item in removingStroke)
6778
                    {
6779
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6780
                        inkBoard.Strokes.Remove(item);
6781
                    }
6782
                    if (inkPointSet.Count != 0)
6783
                    {
6784
                        //강인구 추가(PenControl Undo Redo 추가)
6785
                        UndoData = new Undo_data()
6786
                        {
6787
                            IsUndo = false,
6788
                            Event = Event_Type.Create,
6789
                            EventTime = DateTime.Now,
6790
                            Markup_List = new List<Multi_Undo_data>()
6791
                        };
6792

    
6793
                        pc.StartPoint = inkPointSet[0];
6794
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6795
                        pc.PointSet = inkPointSet;
6796
                        pc.LineSize = 3;
6797
                        pc.CommentID = Commons.shortGuid();
6798
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6799
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6800
                        ///pc.SetPolyPath();
6801

    
6802
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6803
                        {
6804
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6805
                        });
6806
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6807
                        UndoData.Markup_List.Add(multi_Undo_Data);
6808
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6809
                    }
6810
                });
6811
            }
6812
        }
6813

    
6814
        /// <summary>
6815
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6816
        /// </summary>
6817
        /// <param name="StartP">StartPoint</param>
6818
        /// <param name="EndP">EndPoint</param>
6819
        /// <returns>Return_EndPoint</returns>
6820
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6821
        {
6822
            Point Return_Point = new Point();
6823

    
6824
            double dx = EndP.X - StartP.X;
6825
            double dy = EndP.Y - StartP.Y;
6826
            double length;
6827

    
6828
            switch (controlType)
6829
            {
6830
                case ControlType.Triangle:
6831
                    {
6832
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6833
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6834
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6835
                    }
6836
                    break;
6837
                default:
6838
                    {
6839
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6840
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6841
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6842
                    }
6843
                    break;
6844
            }
6845

    
6846
            return Return_Point;
6847
        }
6848

    
6849
        /// <summary>
6850
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6851
        /// </summary>
6852
        /// <author>humkyung</author>
6853
        /// <date>2018.04.26</date>
6854
        /// <param name="StartP"></param>
6855
        /// <param name="EndP"></param>
6856
        /// <returns></returns>
6857
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6858
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6859
        {
6860
            List<Point> res = new List<Point>();
6861

    
6862
            double dx = EndP.X - StartP.X;
6863
            double dy = EndP.Y - StartP.Y;
6864
            double length = Math.Sqrt(dx * dx + dy * dy);
6865
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6866
            dx /= length;
6867
            dy /= length;
6868
            double tmp = dx;
6869
            dx = -dy; dy = tmp; /// rotate by 90 degree
6870

    
6871
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6872
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6873

    
6874
            return res;
6875
        }
6876

    
6877
        /// <summary>
6878
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6879
        /// </summary>
6880
        /// <author>ingu</author>
6881
        /// <date>2018.06.05</date>
6882
        /// <param name="getPoint"></param>
6883
        /// <returns></returns>
6884
        private bool IsGetoutpoint(Point getPoint)
6885
        {
6886
            if (getPoint == new Point())
6887
            {
6888
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6889
                currentControl = null;
6890
                return true;
6891
            }
6892

    
6893
            return false;
6894
        }
6895

    
6896
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6897
        {
6898
            e.Effects = DragDropEffects.Copy;
6899
        }
6900

    
6901
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6902
        {
6903
            e.Effects = DragDropEffects.Copy;
6904
        }
6905

    
6906
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6907
        {
6908
            e.Effects = DragDropEffects.None;
6909
        }
6910

    
6911
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6912
        {
6913
            try
6914
            {
6915
                if (e.Data.GetDataPresent(typeof(string)))
6916
                {
6917
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6918
                    string dragData = e.Data.GetData(typeof(string)) as string;
6919
                    Move_Symbol(sender, dragData);
6920
                }
6921
            }
6922
            catch (Exception ex)
6923
            {
6924
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6925
            }            
6926
        }
6927

    
6928
        private void Move_Symbol(object sender, string dragData)
6929
        {
6930
            try
6931
            {
6932
                if (dragData.Contains("|DZ|"))
6933
                {
6934
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6935

    
6936
                    string[] delimiterChars = { "|DZ|" };
6937
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6938

    
6939
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6940

    
6941
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6942

    
6943
                    //강인구 Undo/Redo 보류
6944
                    UndoData = new Undo_data()
6945
                    {
6946
                        IsUndo = false,
6947
                        Event = Event_Type.Create,
6948
                        EventTime = DateTime.Now,
6949
                        Markup_List = new List<Multi_Undo_data>()
6950
                    };
6951

    
6952
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6953
                    {
6954
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6955
                    });
6956

    
6957
                    foreach (string parse in data)
6958
                    {
6959
                        if (parse != "")
6960
                        {
6961
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
6962
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
6963

    
6964
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6965
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6966

    
6967
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6968

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

    
6971
                            UndoData.Markup_List.Add(multi_Undo_Data);
6972
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6973
                        }
6974
                    }
6975
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6976

    
6977
                    /// move symbol to current mouse point
6978
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6979
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6980
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6981

    
6982
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6983
                    {
6984
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6985
                    }
6986
                    /// up to here
6987

    
6988
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6989
                }
6990
            }
6991
            catch (Exception ex)
6992
            {
6993
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
6994
            }            
6995
        }        
6996
    }
6997
}
클립보드 이미지 추가 (최대 크기: 500 MB)