프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 4804a4fb

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

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

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

    
372
            DeleteItem(item);
373
        }
374

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

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

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

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

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

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

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

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

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

    
443
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
444

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

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

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

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

    
505

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

    
520
        bool ComingNewBieEnd = false;
521

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

    
533
            InkControl_Convert();
534

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

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

    
542

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

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

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

    
557
            #endregion
558

    
559
            ViewerDataModel.Instance.PageNumber = BalancePoint;
560

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

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

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

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

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

    
600

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

    
606

    
607

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

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

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

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

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

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

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

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

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

    
699
            this.pageNavigator.SetNextPage();
700

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

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

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

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

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

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

    
741

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

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

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

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

    
763

    
764
        
765

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

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

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

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

    
826
        #region ZoomIn & ZoomOut
827

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

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

    
840

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

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

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

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

    
876
        }
877

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

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

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

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

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

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

    
930
        #endregion
931

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

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

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

    
944
        }
945

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

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

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

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

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

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

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

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

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

    
1137
      
1138
            CreateDragDropWindow2(img);
1139
        }
1140

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

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

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

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

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

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

    
1181

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

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

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

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

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

    
1261
                //        default:
1262
                //            {
1263

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1427

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

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

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

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

    
1471

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

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

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

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

    
1515

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

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

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

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

    
1559

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

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

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

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

    
1603

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

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

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

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

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

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

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

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

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

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

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

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

    
1701
                            }
1702
                            break;
1703

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

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

    
1727

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

    
1736

    
1737
                            }
1738
                            break;
1739

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

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

    
1762

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

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

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

    
1795

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

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

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

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

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

    
1842
                                if (control != null)
1843
                                {
1844

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

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

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

    
1862
                                    ///control.SetPolyPath();
1863

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

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

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

    
1891

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

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

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

    
1925

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

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

    
1970
                                    }
1971

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

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

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

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

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

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

    
2020
                                }
2021
                            }
2022
                            break;
2023

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

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

    
2033
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2034

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

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

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

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

    
2065

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2410
                                if (control != null)
2411
                                {
2412

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

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

    
2420

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

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

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

    
2433
                                        //control.ApplyTemplate();
2434

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

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

    
2446

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

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

    
2474

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

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

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

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

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

    
2519
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2520
                    }
2521

    
2522
                    e.Handled = true;
2523
                }
2524

    
2525

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

    
2548

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

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

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

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

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

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

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

    
2611
                //}
2612

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

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

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

    
2638
                #endregion
2639
            }
2640
        }
2641

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

    
2650
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2651

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

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

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

    
2665
        private EllipseGeometry hitArea = new EllipseGeometry();
2666

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

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

    
2677
                    SetCursor();
2678

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

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

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

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

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

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

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

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

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

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

    
2767
                zoomAndPanControl.ReleaseMouseCapture();
2768

    
2769

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

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

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

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

    
2795
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2796

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

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

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

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

    
2838
            //GC.Collect();
2839

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

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

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

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

    
2866
        }
2867

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

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

    
2883
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2884

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

    
2895
            dragRect = new Rect(x, y, width, height);
2896
            dragRect.Inflate(width / 10, height / 10);
2897

    
2898
            foreach (var item in Items)
2899
            {
2900
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2901

    
2902
                if (Flag)
2903
                {
2904
                    adornerSet.Add(item);
2905
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2906

    
2907
                    Control_Style(item);
2908
                    UndoData.Markup_List.Add(multi_Undo_Data);
2909
                    multi_Undo_Data = new Multi_Undo_data();
2910
                    if (item.GroupID > 0)
2911
                    {
2912

    
2913
                    }
2914
                }
2915
            }
2916
            if (adornerSet.Count > 0)
2917
            {
2918
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2919
                {
2920
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
2921
                });
2922
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2923

    
2924
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2925
                SelectLayer.Children.Add(final);
2926
            }
2927
        }
2928

    
2929
        private void InitDragSelectionRect(Point pt1, Point pt2)
2930
        {
2931
            //캡쳐 중
2932
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2933
            {
2934
                dragCaptureBorder.Visibility = Visibility.Visible;
2935
            }
2936
            //선택 중
2937
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2938
            {
2939

    
2940
                dragSelectionBorder.Visibility = Visibility.Visible;
2941
            }
2942
            else
2943
            {
2944
                dragZoomBorder.Visibility = Visibility.Visible;
2945
            }
2946
            UpdateDragSelectionRect(pt1, pt2);
2947
        }
2948

    
2949
        /// <summary>
2950
        /// Update the position and size of the rectangle used for drag selection.
2951
        /// </summary>
2952
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2953
        {
2954
            double x, y, width, height;
2955

    
2956
            //
2957
            // Determine x,y,width and height of the rect inverting the points if necessary.
2958
            // 
2959

    
2960
            if (pt2.X < pt1.X)
2961
            {
2962
                x = pt2.X;
2963
                width = pt1.X - pt2.X;
2964
            }
2965
            else
2966
            {
2967
                x = pt1.X;
2968
                width = pt2.X - pt1.X;
2969
            }
2970

    
2971
            if (pt2.Y < pt1.Y)
2972
            {
2973
                y = pt2.Y;
2974
                height = pt1.Y - pt2.Y;
2975
            }
2976
            else
2977
            {
2978
                y = pt1.Y;
2979
                height = pt2.Y - pt1.Y;
2980
            }
2981

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

    
3010
        private void drawingPannelRotate(double angle)
3011
        {
3012
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
3013
            rotate.Angle = angle;
3014
            var rotationNum = Math.Abs((rotate.Angle / 90));
3015

    
3016
            if (angle == 90 || angle == 270)
3017
            {
3018
                double emptySize = zoomAndPanCanvas.Width;
3019
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
3020
                zoomAndPanCanvas.Height = emptySize;
3021
            }
3022
            if (angle == 0)
3023
            {
3024
                translate.X = 0;
3025
                translate.Y = 0;
3026
            }
3027
            else if (angle == 90)
3028
            {
3029
                translate.X = zoomAndPanCanvas.Width;
3030
                translate.Y = 0;
3031
            }
3032
            else if (angle == 180)
3033
            {
3034
                translate.X = zoomAndPanCanvas.Width;
3035
                translate.Y = zoomAndPanCanvas.Height;
3036
            }
3037
            else
3038
            {
3039
                translate.X = 0;
3040
                translate.Y = zoomAndPanCanvas.Height;
3041
            }
3042

    
3043
            zoomAndPanControl.RotationAngle = rotate.Angle;
3044

    
3045

    
3046
            if (!testPanel2.IsHidden)
3047
            {
3048
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3049
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3050
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3051
            }
3052

    
3053
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3054
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3055
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3056
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3057
            ViewerDataModel.Instance.Angle = rotate.Angle;
3058
        }
3059

    
3060
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3061
        {
3062
            string Data_ = "";
3063

    
3064
            try
3065
            {
3066
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3067
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3068
                if (Data_ != null || Data_ != "")
3069
                {
3070
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3071
                }
3072
                else
3073
                {
3074
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3075
                }
3076

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

    
3103
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3104
                    {
3105
                        PointSet = new List<Point>(),
3106
                        FilePath = Data_,
3107
                        ImageData = img.Source,
3108
                        StartPoint = canvasZoomPanningMouseDownPoint,
3109
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3110
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3111
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3112
                        canvasZoomPanningMouseDownPoint.Y),
3113
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3114
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3115
                    };
3116

    
3117
                    currentControl.PointSet = new List<Point>
3118
                                        {
3119
                                            currentControl.StartPoint,
3120
                                            currentControl.LeftBottomPoint,
3121
                                            currentControl.EndPoint,
3122
                                            currentControl.TopRightPoint,
3123
                                        };
3124
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3125
                    UndoData = new Undo_data()
3126
                    {
3127
                        IsUndo = false,
3128
                        Event = Event_Type.Create,
3129
                        EventTime = DateTime.Now,
3130
                        Markup_List = new List<Multi_Undo_data>()
3131
                    };
3132
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3133
                    {
3134
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3135
                    });
3136

    
3137
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3138
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3139
                    UndoData.Markup_List.Add(multi_Undo_Data);
3140
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3141

    
3142
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3143
                    currentControl.CommentID = Commons.shortGuid();
3144
                    currentControl.SymbolID = id;
3145
                    currentControl.GroupID = group_id;
3146
                    currentControl.ApplyTemplate();
3147
                    currentControl.SetImage();
3148

    
3149
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3150
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3151
                    SelectLayer.Children.Add(final);
3152
                }
3153
            }
3154
            catch (Exception ex)
3155
            {
3156
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3157
            }
3158
        }
3159

    
3160
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3161
        {            
3162
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3163
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3164
            {
3165
                set_option.Value = double.Parse(set_option.ContentText);
3166
            }
3167

    
3168
            InkControl_Convert();
3169

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

    
3173
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3174
            {
3175
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3176
            }
3177

    
3178
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3179
            {
3180
                if (arrow_text as ArrowTextControl != null)
3181
                {
3182
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3183
                }
3184
            }
3185

    
3186
            mouseButtonDown = e.ChangedButton;
3187
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3188

    
3189
            //if (currentControl != null)
3190
            {
3191
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3192
                if (text_item_ != null)
3193
                {
3194
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3195
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3196
                    (text_item_ as TextControl).IsEditing = false;
3197
                    (text_item_ as TextControl).EnableEditing = false;
3198
                    currentControl = null;
3199
                }
3200

    
3201
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3202
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3203
                {
3204
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3205
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3206
                    currentControl = null;
3207
                }
3208
            }
3209

    
3210
            double Ang = 0;                                          
3211
            if (rotate.Angle != 0)
3212
            {
3213
                Ang = 360 - rotate.Angle;
3214
            }
3215
            move = new Move();
3216

    
3217
            if (e.OriginalSource is System.Windows.Controls.Image)
3218
            {
3219
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3220
            }
3221

    
3222
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3223
            {                
3224
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3225
                //SetCursor();
3226

    
3227
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3228
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3229
                if(symbol_id != null)
3230
                {
3231
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3232
                }                
3233
            }
3234

    
3235
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3236
            {
3237
                if (this._dragdropWindow != null)
3238
                {
3239
                    this._dragdropWindow.Close();
3240
                    this._dragdropWindow = null;
3241
                    symbol_id = null;
3242
                }
3243
            }
3244

    
3245
            if (mouseButtonDown == MouseButton.Left)
3246
            {
3247
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3248
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3249

    
3250
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3251
                SetCursor();
3252

    
3253
                if (!ViewerDataModel.Instance.IsPressCtrl)
3254
                {
3255
                    SelectionSet.Instance.UnSelect(this);
3256
                }
3257
            }
3258
            if (mouseButtonDown == MouseButton.Middle)
3259
            {
3260
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3261
                cursor = Cursors.SizeAll;
3262
                SetCursor();
3263
            }
3264
            if (mouseButtonDown == MouseButton.Right)
3265
            {
3266
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3267
                cursor = Cursors.SizeAll;
3268
                SetCursor();
3269
            }
3270
            else if (mouseButtonDown == MouseButton.XButton1)
3271
            {
3272
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3273
                {
3274
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3275
                }
3276

    
3277
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3278

    
3279
            }
3280
            else if (mouseButtonDown == MouseButton.XButton2)
3281
            {
3282
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3283
                {
3284
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3285
                }
3286
            }
3287

    
3288
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3289
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3290
            {
3291
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3292
                {
3293
                    if (SelectLayer.Children.Count == 0)
3294
                    {
3295
                        isLeftMouseButtonDownOnWindow = true;
3296
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3297
                    }
3298

    
3299
                    if (controlType == ControlType.None)
3300
                    {
3301
                        isLeftMouseButtonDownOnWindow = true;
3302
                    }
3303
                }
3304

    
3305
                //캡쳐 모드 설정
3306
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3307
                {
3308
                    dragCaptureBorder.Visibility = Visibility.Visible;
3309
                    isLeftMouseButtonDownOnWindow = true;
3310
                }
3311

    
3312
                //줌 모드 설정
3313
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3314
                {
3315
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3316
                    isLeftMouseButtonDownOnWindow = true;
3317
                }               
3318

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

    
3330
                    //강인구 Undo/Redo 보류
3331
                    UndoData = new Undo_data()
3332
                    {
3333
                        IsUndo = false,
3334
                        Event = Event_Type.Select,
3335
                        EventTime = DateTime.Now,
3336
                        Markup_List = new List<Multi_Undo_data>()
3337
                    };
3338

    
3339
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3340
                    {
3341
                        SelectionSet.Instance.UnSelect(this);
3342
                        final = new AdornerFinal(control);
3343
                        //단일 컨트롤 언두 저장
3344

    
3345
                        Control_Style(control);
3346
                        UndoData.Markup_List.Add(multi_Undo_Data);
3347

    
3348
                        if ((control as IPath) != null)
3349
                        {
3350
                            if ((control as IPath).LineSize != 0)
3351
                            {
3352
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3353
                            }
3354
                        }
3355
                        if ((control as IShapeControl) != null)
3356
                        {
3357
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3358
                            {
3359
                                ViewerDataModel.Instance.checkHatchShape = true;
3360
                            }
3361
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3362
                            {
3363
                                ViewerDataModel.Instance.checkFillShape = true;
3364
                            }
3365
                            else
3366
                            {
3367
                                ViewerDataModel.Instance.checkHatchShape = false;
3368
                                ViewerDataModel.Instance.checkFillShape = false;
3369
                            }
3370
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3371
                        }
3372

    
3373
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3374

    
3375
                        if ((control as TextControl) != null)
3376
                        {
3377
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3378
                            {
3379
                                ViewerDataModel.Instance.checkTextStyle = true;
3380
                            }
3381
                            else
3382
                            {
3383
                                ViewerDataModel.Instance.checkTextStyle = false;
3384
                            }
3385

    
3386
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3387
                            {
3388
                                ViewerDataModel.Instance.checkTextStyle = true;
3389
                            }
3390
                            else
3391
                            {
3392
                                ViewerDataModel.Instance.checkTextStyle = false;
3393
                            }
3394
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3395
                            {
3396
                                ViewerDataModel.Instance.checkTextWeight = true;
3397
                            }
3398
                            else
3399
                            {
3400
                                ViewerDataModel.Instance.checkTextWeight = false;
3401
                            }
3402
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3403
                            {
3404
                                ViewerDataModel.Instance.checkUnderLine = true;
3405
                            }
3406
                            else
3407
                            {
3408
                                ViewerDataModel.Instance.checkUnderLine = false;
3409
                            }
3410
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3411
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3412

    
3413
                        }
3414
                        else if ((control as ArrowTextControl) != null)
3415
                        {
3416
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3417
                            {
3418
                                ViewerDataModel.Instance.checkTextStyle = true;
3419
                            }
3420
                            else
3421
                            {
3422
                                ViewerDataModel.Instance.checkTextStyle = false;
3423
                            }
3424

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

    
3461
                    }
3462
                    else
3463
                    {
3464
                        comment = AddAdorner();
3465
                        comment.Add(control);
3466

    
3467
                        Control_Style(control);
3468
                        UndoData.Markup_List.Add(multi_Undo_Data);
3469

    
3470
                        final = new AdornerFinal(comment);
3471
                        //다중 컨트롤 언두 저장
3472
                    }
3473

    
3474
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3475
                    {
3476
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3477
                    });
3478

    
3479
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3480

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

    
3521
                multi_Undo_Data = new Multi_Undo_data();
3522
                //강인구 Undo/Redo 보류
3523
                UndoData = new Undo_data()
3524
                {
3525
                    IsUndo = false,
3526
                    Event = Event_Type.Create,
3527
                    EventTime = DateTime.Now,
3528
                    Markup_List = new List<Multi_Undo_data>()
3529
                };
3530

    
3531
                switch (controlType)
3532
                {
3533
                    case ControlType.Coordinate:
3534
                        {
3535
                            if (mouseButtonDown == MouseButton.Left)
3536
                            {
3537
                                if (currentControl is CoordinateControl)
3538
                                {
3539
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3540
                                    {
3541
                                        return;
3542
                                    }
3543

    
3544
                                    CreateControl();
3545

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

    
3569
                                        currentControl.CommentID = Commons.shortGuid();
3570
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3571
                                        currentControl.IsNew = true;
3572

    
3573
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3574

    
3575
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3576
                                    }
3577
                                }
3578
                            }
3579
                        }
3580
                        break;
3581
                    case ControlType.InsideWhite:
3582
                        {
3583
                            if (mouseButtonDown == MouseButton.Left)
3584
                            {
3585
                                if (currentControl is InsideWhiteControl)
3586
                                {
3587
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3588
                                    {
3589
                                        return;
3590
                                    }
3591

    
3592
                                    CreateControl();
3593

    
3594
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3595
                                    currentControl = null;
3596
                                    this.cursor = Cursors.Arrow;
3597
                                }
3598
                                else
3599
                                {
3600
                                    currentControl = new InsideWhiteControl
3601
                                    {
3602
                                        Background = new SolidColorBrush(Colors.Black),
3603
                                        ControlType = ControlType.InsideWhite
3604
                                    };
3605

    
3606
                                    currentControl.CommentID = Commons.shortGuid();
3607
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3608
                                    currentControl.IsNew = true;
3609
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3610

    
3611
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3612
                                }
3613
                            }
3614
                        }
3615
                        break;
3616
                    case ControlType.OverlapWhite:
3617
                        {
3618
                            if (mouseButtonDown == MouseButton.Left)
3619
                            {
3620
                                if (currentControl is OverlapWhiteControl)
3621
                                {
3622
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3623
                                    {
3624
                                        return;
3625
                                    }
3626

    
3627
                                    CreateControl();
3628

    
3629
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3630
                                    currentControl = null;
3631
                                    this.cursor = Cursors.Arrow;
3632
                                }
3633
                                else
3634
                                {
3635
                                    currentControl = new OverlapWhiteControl
3636
                                    {
3637
                                        Background = new SolidColorBrush(Colors.Black),
3638
                                        ControlType = ControlType.OverlapWhite
3639
                                    };
3640

    
3641
                                    currentControl.CommentID = Commons.shortGuid();
3642
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3643
                                    currentControl.IsNew = true;
3644
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3645

    
3646
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3647
                                }
3648
                            }
3649
                        }
3650
                        break;
3651
                    case ControlType.ClipWhite:
3652
                        {
3653
                            if (mouseButtonDown == MouseButton.Left)
3654
                            {
3655
                                if (currentControl is ClipWhiteControl)
3656
                                {
3657
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3658
                                    {
3659
                                        return;
3660
                                    }
3661

    
3662
                                    CreateControl();
3663

    
3664
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
3665
                                    currentControl = null;
3666
                                    this.cursor = Cursors.Arrow;
3667
                                }
3668
                                else
3669
                                {
3670
                                    currentControl = new ClipWhiteControl
3671
                                    {
3672
                                        Background = new SolidColorBrush(Colors.Black),
3673
                                        ControlType = ControlType.ClipWhite
3674
                                    };
3675

    
3676
                                    currentControl.CommentID = Commons.shortGuid();
3677
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3678
                                    currentControl.IsNew = true;
3679
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3680

    
3681
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3682
                                }
3683
                            }
3684
                        }
3685
                        break;
3686
                    case ControlType.Rectangle:
3687
                        {
3688
                            if (mouseButtonDown == MouseButton.Left)
3689
                            {
3690
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3691
                                //{
3692
                                    if (currentControl is RectangleControl)
3693
                                    {
3694
                                        //20180906 LJY TEST IsRotationDrawingEnable
3695
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3696
                                        {
3697
                                            return;
3698
                                        }
3699

    
3700
                                        CreateControl();
3701

    
3702
                                        (currentControl as RectangleControl).ApplyOverViewData();
3703
                                        currentControl = null;
3704
                                    
3705
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3706
                                    }
3707
                                    else
3708
                                    {
3709
                                        currentControl = new RectangleControl
3710
                                        {
3711
                                            Background = new SolidColorBrush(Colors.Black),
3712
                                            ControlType = ControlType.Rectangle
3713
                                        };
3714

    
3715
                                        currentControl.CommentID = Commons.shortGuid();
3716
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3717
                                        currentControl.IsNew = true;
3718
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3719

    
3720
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3721
                                    }
3722
                                //}
3723
                            }
3724
                        }
3725
                        break;
3726
                    case ControlType.RectCloud:
3727
                        {
3728
                            if (mouseButtonDown == MouseButton.Left)
3729
                            {
3730
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3731
                                //{
3732
                                    if (currentControl is RectCloudControl)
3733
                                    {
3734
                                        //20180906 LJY TEST IsRotationDrawingEnable
3735
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3736
                                        {
3737
                                            return;
3738
                                        }
3739

    
3740
                                        CreateControl();
3741

    
3742
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3743
                                        currentControl = null;
3744
                                    
3745
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3746
                                    }
3747
                                    else
3748
                                    {
3749
                                        currentControl = new RectCloudControl
3750
                                        {
3751
                                            Background = new SolidColorBrush(Colors.Black)
3752
                                        };
3753

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

    
3777
                                        CreateControl();
3778

    
3779
                                        (currentControl as CircleControl).ApplyOverViewData();
3780
                                        currentControl = null;
3781
                                    }
3782
                                    else
3783
                                    {
3784
                                        currentControl = new CircleControl
3785
                                        {
3786
                                            Background = new SolidColorBrush(Colors.Black)
3787
                                        };
3788

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

    
3819
                                            CreateControl();
3820

    
3821
                                            (currentControl as TriControl).ApplyOverViewData();
3822
                                            currentControl = null;
3823
                                        }
3824
                                    }
3825
                                    else
3826
                                    {
3827
                                        currentControl = new TriControl
3828
                                        {
3829
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3830
                                            Background = new SolidColorBrush(Colors.Black),
3831
                                        };
3832

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

    
3856
                                        CreateControl();
3857

    
3858
                                        (currentControl as LineControl).ApplyOverViewData();
3859
                                        currentControl = null;
3860
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3861
                                    }
3862
                                    else
3863
                                    {
3864
                                        currentControl = new LineControl
3865
                                        {
3866
                                            Background = new SolidColorBrush(Colors.Black)
3867
                                        };
3868

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

    
3893
                                        CreateControl();
3894

    
3895
                                        (currentControl as LineControl).ApplyOverViewData();
3896
                                        currentControl = null;
3897
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3898
                                    }
3899
                                    else
3900
                                    {
3901
                                        currentControl = new LineControl
3902
                                        {
3903
                                            Background = new SolidColorBrush(Colors.Black)
3904
                                        };
3905

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

    
3930
                                        CreateControl();
3931

    
3932
                                        (currentControl as LineControl).ApplyOverViewData();
3933
                                        currentControl = null;
3934
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3935
                                    }
3936
                                    else
3937
                                    {
3938
                                        currentControl = new LineControl
3939
                                        {
3940
                                            Background = new SolidColorBrush(Colors.Black)
3941
                                        };
3942

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

    
3967
                                        CreateControl();
3968

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

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

    
4030
                                if (mouseButtonDown == MouseButton.Right)
4031
                                {
4032
                                    //20180906 LJY TEST IsRotationDrawingEnable
4033
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4034
                                    {
4035
                                        return;
4036
                                    }
4037

    
4038
                                    CreateControl();
4039

    
4040
                                    (currentControl as PolygonControl).ApplyOverViewData();
4041
                                    currentControl = null;
4042
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4043
                                    return;
4044
                                }
4045

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

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

    
4098
                                        CreateControl();
4099

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

    
4143
                                    CreateControl();
4144

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

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

    
4203
                                            CreateControl();
4204

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

    
4237
                                if (!control.IsCompleted)
4238
                                {
4239
                                    control.PointSet.Add(control.EndPoint);
4240
                                }
4241
                                else
4242
                                {
4243
                                    //20180906 LJY TEST IsRotationDrawingEnable
4244
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4245
                                    {
4246
                                        return;
4247
                                    }
4248

    
4249
                                    CreateControl();
4250

    
4251
                                    control.isTransOn = true;
4252
                                    var firstPoint = control.PointSet.First();
4253

    
4254
                                    control.PointSet.Add(firstPoint);
4255
                                    control.DrawingCloud();
4256
                                    control.ApplyOverViewData();
4257

    
4258
                                    currentControl = null;
4259
                                }
4260
                            }
4261
                            else
4262
                            {
4263
                                if (mouseButtonDown == MouseButton.Left)
4264
                                {
4265
                                    currentControl = new CloudControl
4266
                                    {
4267
                                        PointSet = new List<Point>(),
4268
                                        PointC = new StylusPointSet()
4269
                                    };
4270

    
4271
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4272
                                    //{
4273
                                        var polygonControl = (currentControl as CloudControl);
4274
                                        currentControl.CommentID = Commons.shortGuid();
4275
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4276
                                        currentControl.IsNew = true;
4277
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4278

    
4279
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4280
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4281
                                    
4282
                                    //}
4283
                                }
4284
                            }
4285
                        }
4286
                        break;
4287
                    case ControlType.ImgControl:
4288
                        {
4289
                            if (mouseButtonDown == MouseButton.Left)
4290
                            {
4291
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4292
                                //{
4293
                                    if (currentControl is ImgControl)
4294
                                    {
4295
                                        //20180906 LJY TEST IsRotationDrawingEnable
4296
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4297
                                        {
4298
                                            return;
4299
                                        }
4300

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

    
4331
                                            currentControl = new ImgControl
4332
                                            {
4333
                                                    Background = new SolidColorBrush(Colors.Black),
4334
                                                    PointSet = new List<Point>(),
4335
                                                    FilePath = filename,
4336
                                                    ImageData = img.Source,
4337
                                                    StartPoint = canvasDrawingMouseDownPoint,
4338
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4339
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4340
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4341
                                                    ControlType = ControlType.ImgControl
4342
                                                };
4343

    
4344
                                        
4345
                                                currentControl.CommentID = Commons.shortGuid();                                            
4346
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4347
                                                currentControl.IsNew = true;
4348
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4349

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

    
4372
                                        CreateControl();
4373
                                        (currentControl as DateControl).ApplyOverViewData();
4374
                                        currentControl = null;
4375

    
4376
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4377
                                        {
4378
                                            controlType = ControlType.None;
4379
                                            IsSwingMode = false;
4380
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4381
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4382
                                            mouseHandlingMode = MouseHandlingMode.None;
4383
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4384
                                            txtBatch.Visibility = Visibility.Collapsed;
4385

    
4386
                                        }
4387
                                    }
4388
                                    else
4389
                                    {
4390
                                        currentControl = new DateControl
4391
                                        {
4392
                                            Background = new SolidColorBrush(Colors.Black)
4393
                                        };
4394
                                        currentControl.CommentID = Commons.shortGuid();
4395
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4396
                                        currentControl.IsNew = true;
4397
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4398

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

    
4431
                                    CreateControl();
4432

    
4433
                                }
4434
                            }
4435
                        }
4436
                        break;
4437
                    case ControlType.TextBorder:
4438
                        {
4439
                            if (mouseButtonDown == MouseButton.Left)
4440
                            {
4441
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4442
                                {
4443
                                    currentControl = new TextControl
4444
                                    {
4445
                                        ControlType = controlType
4446
                                    };
4447

    
4448
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4449
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4450
                                    currentControl.CommentID = Commons.shortGuid();
4451
                                    currentControl.IsNew = true;
4452
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4453
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4454
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4455
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4456
                                    
4457
                                    (currentControl as TextControl).ControlType_No = 1;
4458
                                    (currentControl as TextControl).Angle = Ang;
4459
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4460
                                    (currentControl as TextControl).ApplyTemplate();
4461
                                    (currentControl as TextControl).Base_TextBox.Focus();
4462
                                    CreateControl();
4463

    
4464
                                    //currentControl = null;
4465
                                }
4466
                            }
4467
                        }
4468
                        break;
4469
                    case ControlType.TextCloud:
4470
                        {
4471
                            if (mouseButtonDown == MouseButton.Left)
4472
                            {
4473
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4474
                                {
4475
                                    currentControl = new TextControl
4476
                                    {
4477
                                        ControlType = controlType
4478
                                    };
4479

    
4480
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4481
                                    currentControl.CommentID = Commons.shortGuid();
4482
                                    currentControl.IsNew = true;
4483
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4484
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4485

    
4486
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4487
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4488
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4489

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

    
4513
                                    CreateControl();
4514

    
4515
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4516
                                    (currentControl as ArrowTextControl).IsEditing = false;
4517
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4518
                                    (currentControl as ArrowTextControl).IsNew = false;
4519
                                    currentControl = null;
4520
                                }
4521
                                else
4522
                                {
4523
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4524
                                    //{
4525
                                        currentControl = new ArrowTextControl();
4526
                                        currentControl.CommentID = Commons.shortGuid();
4527
                                        currentControl.IsNew = true;
4528
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4529
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4530

    
4531
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4532
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4533
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4534
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4535
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4536

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

    
4540
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4541
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4542
                                        this.MainAngle.Visibility = Visibility.Visible;
4543

    
4544
                                    
4545
                                    //}
4546
                                }
4547
                            }
4548
                        }
4549
                        break;
4550
                    case ControlType.ArrowTransTextControl:
4551
                        {
4552
                            if (mouseButtonDown == MouseButton.Left)
4553
                            {
4554
                                if (currentControl is ArrowTextControl)
4555
                                {
4556
                                    //20180906 LJY TEST IsRotationDrawingEnable
4557
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4558
                                    {
4559
                                        return;
4560
                                    }                                    
4561

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

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

    
4587
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4588
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4589
                                        (currentControl as ArrowTextControl).isTrans = true;
4590
                                }
4591
                            }
4592
                        }
4593
                        break;
4594
                    case ControlType.ArrowTextBorderControl:
4595
                         {
4596
                            if (mouseButtonDown == MouseButton.Left)
4597
                            {
4598
                                if (currentControl is ArrowTextControl)
4599
                                {
4600
                                    //20180906 LJY TEST IsRotationDrawingEnable
4601
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4602
                                    {
4603
                                        return;
4604
                                    }
4605

    
4606
                                    CreateControl();
4607
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4608
                                    currentControl.IsNew = false;
4609
                                    currentControl = null;
4610
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4611
                                }
4612
                                else
4613
                                {
4614
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4615
                                    //{
4616
                                        currentControl = new ArrowTextControl()
4617
                                        {
4618
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4619
                                        };
4620
                                        currentControl.CommentID = Commons.shortGuid();
4621
                                        currentControl.IsNew = true;
4622
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4623
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4624

    
4625
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4626

    
4627
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4628

    
4629
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4630
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4631
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4632

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

    
4666
                                    currentControl = new ArrowTextControl()
4667
                                        {
4668
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4669
                                        };
4670
                                        currentControl.CommentID = Commons.shortGuid();
4671
                                        currentControl.IsNew = true;
4672
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4673
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4674

    
4675
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4676

    
4677
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4678
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4679
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4680
                                        (currentControl as ArrowTextControl).isFixed = true;
4681
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4682
                                     
4683
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4684
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4685
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4686

    
4687
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4688
                                        this.MainAngle.Visibility = Visibility.Visible;
4689
                                    
4690
                                    //20180911 LJY
4691
                                        (currentControl as ArrowTextControl).isTrans = true;
4692
                                    
4693

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

    
4729
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4730
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4731
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4732
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4733
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4734

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

    
4777
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4778
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4779
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4780
                                        (currentControl as ArrowTextControl).isFixed = true;
4781
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4782

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

    
4786
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4787
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4788
                                        this.MainAngle.Visibility = Visibility.Visible;  
4789
                                    
4790
                                    //20180911 LJY
4791
                                        (currentControl as ArrowTextControl).isTrans = true;
4792
                                    //}
4793
                                }
4794
                            }
4795
                        }
4796
                        break;
4797
                    case ControlType.PolygonControl:
4798
                        {
4799
                            if (currentControl is PolygonControl)
4800
                            {
4801
                                var control = currentControl as PolygonControl;
4802

    
4803
                                if (mouseButtonDown == MouseButton.Right)
4804
                                {
4805
                                    control.IsCompleted = true;
4806
                                }
4807

    
4808
                                if (!control.IsCompleted)
4809
                                {
4810
                                    control.PointSet.Add(control.EndPoint);
4811
                                }
4812
                                else
4813
                                {
4814
                                    //20180906 LJY TEST IsRotationDrawingEnable
4815
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4816
                                    {
4817
                                        return;
4818
                                    }
4819

    
4820
                                    var firstPoint = control.PointSet.First();
4821
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4822
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4823
                                    control.PointSet.Add(firstPoint);
4824

    
4825
                                    control.ApplyOverViewData();
4826

    
4827
                                    CreateControl();
4828
                                    control.updateControl();
4829
                                    currentControl = null;
4830
                                }
4831
                            }
4832
                            else
4833
                            {
4834
                                if (mouseButtonDown == MouseButton.Left)
4835
                                {
4836
                                    currentControl = new PolygonControl
4837
                                    {
4838
                                        PointSet = new List<Point>(),
4839
                                    };
4840

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

    
4865
                                    if (_sign == null)
4866
                                    {
4867
                                        txtBatch.Visibility = Visibility.Collapsed;
4868
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4869
                                        controlType = ControlType.None;
4870

    
4871
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4872
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4873
                                        return;
4874
                                    }
4875

    
4876
                                    if (currentControl is SignControl)
4877
                                    {
4878
                                        //20180906 LJY TEST IsRotationDrawingEnable
4879
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4880
                                        {
4881
                                            return;
4882
                                        }
4883

    
4884
                                        CreateControl();
4885
                                        currentControl = null;
4886
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4887
                                        {
4888
                                            txtBatch.Text = "Place Date";
4889
                                            controlType = ControlType.Date;
4890
                                        }
4891
                                    }
4892
                                    else
4893
                                    {
4894
                                        currentControl = new SignControl
4895
                                        {
4896
                                            Background = new SolidColorBrush(Colors.Black),
4897
                                            UserNumber = App.ViewInfo.UserID,
4898
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4899
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4900
                                            ControlType = ControlType.Sign
4901
                                        };
4902

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

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

    
4929
                                        CreateControl();
4930
                                        (currentControl as RectangleControl).ApplyOverViewData();
4931
                                        currentControl = null;
4932
                                    
4933
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4934

    
4935
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4936
                                        {
4937
                                            txtBatch.Text = "Place Signature";
4938
                                            controlType = ControlType.Sign;
4939
                                        }
4940
                                    }
4941
                                    else
4942
                                    {
4943
                                        currentControl = new RectangleControl
4944
                                        {
4945
                                            Background = new SolidColorBrush(Colors.Black),
4946
                                            Paint = PaintSet.Fill
4947
                                        };
4948

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

    
4986
                                        currentControl.IsNew = true;
4987
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4988
                                        currentControl.CommentID = Commons.shortGuid();
4989
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4990

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

    
5012
                                        CreateControl();
5013
                                        currentControl = null;
5014
                                   
5015

    
5016
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5017
                                    }
5018
                                    else
5019
                                    {
5020
                                        currentControl = new SymControlN
5021
                                        {
5022
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5023
                                            Background = new SolidColorBrush(Colors.Black),
5024
                                            ControlType = ControlType.Stamp
5025
                                        };
5026

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

    
5075
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
5076
                            if (over != null)
5077
                            {
5078
                                mouseOff = true;
5079
                            }
5080
                        }
5081
                    }
5082

    
5083
                    if (!mouseOff)
5084
                    {
5085
                        SelectionSet.Instance.UnSelect(this);
5086
                    }
5087
                }
5088
                zoomAndPanControl.CaptureMouse();
5089
                e.Handled = true;
5090
            }
5091
        }
5092

    
5093
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5094
        {
5095
            mouseButtonDown = e.ChangedButton;
5096
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5097
        }
5098

    
5099
        private void RemoveLineStroke(Point P)
5100
        {
5101
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
5102
            if (control != null)
5103
            {
5104
                UndoData = new Undo_data()
5105
                {
5106
                    IsUndo = false,
5107
                    Event = Event_Type.Delete,
5108
                    EventTime = DateTime.Now,
5109
                    Markup_List = new List<Multi_Undo_data>()
5110
                };
5111

    
5112

    
5113
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5114
                UndoData.Markup_List.Add(multi_Undo_Data);
5115
                multi_Undo_Data = new Multi_Undo_data();
5116

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

    
5130
            }
5131
        }
5132

    
5133
        private void RemovePointStroke(Point P)
5134
        {
5135
            foreach (Stroke hits in inkBoard.Strokes)
5136
            {
5137
                foreach (StylusPoint sty in hits.StylusPoints)
5138
                {
5139

    
5140
                }
5141
                if (hits.HitTest(P))
5142
                {
5143
                    inkBoard.Strokes.Remove(hits);
5144
                    return;
5145
                }
5146
            }
5147
        }
5148

    
5149
        private void StartNewStroke(Point P)
5150
        {
5151
            strokePoints = new StylusPointCollection();
5152
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5153
            strokePoints.Add(segment1Start);
5154
            stroke = new Stroke(strokePoints);
5155

    
5156
            stroke.DrawingAttributes.Color = Colors.Red;
5157
            stroke.DrawingAttributes.Width = 4;
5158
            stroke.DrawingAttributes.Height = 4;
5159

    
5160
            inkBoard.Strokes.Add(stroke);
5161

    
5162
        }
5163

    
5164
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5165
        {
5166
            ConsolidationMethod();
5167
        }
5168

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

    
5190
                string project_no = App.ViewInfo.ProjectNO;
5191
                string doc_id = _DocInfo.ID;
5192
                string user_id = App.ViewInfo.UserID;
5193
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5194
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5195
                {
5196
                    markupInfoItems.Add(item);
5197
                }
5198
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5199
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5200
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
5201

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

    
5218
                string project_no = App.ViewInfo.ProjectNO;
5219
                string doc_id = _DocInfo.ID;
5220
                string user_id = App.ViewInfo.UserID;
5221
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5222
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5223
                {
5224
                    markupInfoItems.Add(item);
5225
                }
5226
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5227
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5228

    
5229
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5230
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5231
                */
5232
                
5233
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
5234
                foreach (var item in this.gridViewMarkup.SelectedItems)
5235
                {
5236
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
5237
                }
5238
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
5239

    
5240
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
5241
            }
5242
        }
5243

    
5244
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5245
        {
5246
            if (App.ViewInfo != null)
5247
            {
5248
                btnConsolidate = (sender as RadRibbonButton);
5249
                if (!App.ViewInfo.NewCommentPermission)
5250
                {
5251
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5252
                }
5253
            }
5254
        }
5255

    
5256
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5257
        {
5258
            TeamConsolidationMethod();
5259
        }
5260

    
5261
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5262
        {
5263
            btnTeamConsolidate = sender as RadRibbonButton;
5264
            if (App.ViewInfo != null)
5265
            {
5266
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5267
                {
5268
                    if (btnConsolidate != null)
5269
                    {
5270
                        btnConsolidate.Visibility = Visibility.Collapsed;
5271
                    }
5272

    
5273
                    if (!App.ViewInfo.NewCommentPermission)
5274
                    {
5275
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5276
                    }
5277
                }
5278
                else
5279
                {
5280
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5281
                }
5282
            }
5283
        }
5284

    
5285
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5286
        {
5287
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5288
            if (item != null)
5289
            {
5290
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5291

    
5292
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5293
            }
5294
            else
5295
            {
5296
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5297
            }
5298
        }
5299

    
5300
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5301
        {
5302
            btnFinalPDF = sender as RadRibbonButton;
5303
            if (App.ViewInfo != null)
5304
            {
5305
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5306
                {
5307
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5308
                    if (btnConsolidate != null)
5309
                    {
5310
                        btnConsolidate.Visibility = Visibility.Collapsed;
5311
                    }
5312
                }
5313
            }
5314
        }
5315

    
5316
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5317
        {
5318
            ChangeCommentReact();
5319

    
5320
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5321
            {
5322
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5323
            }
5324
            else
5325
            {
5326
                ViewerDataModel.Instance.IsConsolidate = true;
5327
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5328
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5329

    
5330
                string project_no = App.ViewInfo.ProjectNO;
5331
                string doc_id = _DocInfo.ID;
5332
                string user_id = App.ViewInfo.UserID;
5333
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5334
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5335
                {
5336
                    markupInfoItems.Add(item);
5337
                }
5338
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5339
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5340
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5341
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5342

    
5343
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5344
                if (item2 != null)
5345
                {
5346
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5347

    
5348
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5349
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5350
                }
5351
                else
5352
                {
5353
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5354
                }
5355
            }
5356
        }
5357

    
5358
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5359
        {
5360
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5361

    
5362
            if (App.ViewInfo != null)
5363
            {
5364
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5365
                {
5366
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5367
                }
5368
            }
5369
        }
5370

    
5371
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5372
        {
5373
            if (CompareMode.IsChecked)
5374
            {
5375
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5376
                {
5377
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5378
                }
5379
                if (ViewerDataModel.Instance.PageNumber == 0)
5380
                {
5381
                    ViewerDataModel.Instance.PageNumber = 1;
5382
                }
5383

    
5384
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5385
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5386
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5387

    
5388
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5389
            }
5390
            else
5391
            {
5392
                da.From = 1;
5393
                da.To = 1;
5394
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5395
                da.AutoReverse = false;
5396
                canvas_compareBorder.Children.Clear();
5397
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5398
            }
5399
        }
5400

    
5401
        private void Sync_Click(object sender, RoutedEventArgs e)
5402
        {
5403
            if (Sync.IsChecked)
5404
            {
5405
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5406
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5407
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5408
            }
5409
        }
5410

    
5411
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5412
        {
5413
            if (UserList.IsChecked)
5414
            {
5415
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5416
            }
5417
            else
5418
            {
5419
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5420
            }
5421
        }
5422

    
5423
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5424
        {
5425

    
5426
            if (BalanceMode.IsChecked)
5427
            {
5428
                ViewerDataModel.Instance.PageBalanceMode = true;
5429
            }
5430
            else
5431
            {
5432
                ViewerDataModel.Instance.PageBalanceMode = false;
5433
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5434
            }
5435
        }
5436

    
5437
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5438
        {
5439
            //초기화
5440
            testPanel2.IsHidden = true;
5441
            ViewerDataModel.Instance.PageBalanceMode = false;
5442
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5443
            ViewerDataModel.Instance.PageNumber = 0;
5444
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5445
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5446
            UserList.IsChecked = false;
5447
            BalanceMode.IsChecked = false;
5448
        }
5449

    
5450
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5451
        {
5452
            if ((sender as System.Windows.Controls.Control).Tag != null)
5453
            {
5454
                //Compare 초기화
5455
                CompareMode.IsChecked = false;
5456
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5457

    
5458
                if (ViewerDataModel.Instance.PageNumber == 0)
5459
                {
5460
                    ViewerDataModel.Instance.PageNumber = 1;
5461
                }
5462

    
5463
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5464
                {
5465
                }
5466
                else
5467
                {
5468
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5469
                }
5470

    
5471
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5472
                {
5473

    
5474
                }
5475
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5476
                {
5477
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5478
                }
5479

    
5480
                if (!testPanel2.IsHidden)
5481
                {
5482
                    if (IsSyncPDFMode)
5483
                    {
5484
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5485
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5486

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

    
5504
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5505
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5506
                        }
5507

    
5508
                    }
5509
                    else
5510
                    {
5511
                        string uri = "";
5512

    
5513
                        if (userData.COMPANY != "EXT")
5514
                        {
5515
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5516
                        }
5517
                        else
5518
                        {
5519
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5520
                        }
5521

    
5522
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5523

    
5524
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5525
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5526
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5527

    
5528
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5529
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5530

    
5531
                        if (defaultBitmapImage_Compare.IsDownloading)
5532
                        {
5533
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5534
                            {
5535
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5536
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5537
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5538

    
5539
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5540
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5541
                            };
5542
                        }
5543
                    }
5544

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

    
5549
                    foreach (var item in gridSelectionRevItem)
5550
                    {
5551
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5552
                        {
5553
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5554
                        });
5555
                    }
5556

    
5557
                    //강인구 추가
5558
                    zoomAndPanControl2.ZoomTo(new Rect
5559
                    {
5560
                        X = 0,
5561
                        Y = 0,
5562
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5563
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5564
                    });
5565

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

    
5568
                }
5569
            }
5570
        }
5571

    
5572
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5573
        {
5574
            if (MarkupMode.IsChecked)
5575
            {
5576
                IsSyncPDFMode = true;
5577

    
5578
                var uri = CurrentRev.TO_VENDOR;
5579

    
5580
                if (ViewerDataModel.Instance.PageNumber == 0)
5581
                {
5582
                    ViewerDataModel.Instance.PageNumber = 1;
5583
                }
5584

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

    
5589
                if (pdfpath.IsDownloading)
5590
                {
5591
                    pdfpath.DownloadCompleted += (ex, arg) =>
5592
                    {
5593
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5594
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5595
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5596
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5597
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5598
                    };
5599
                }
5600
                else
5601
                {
5602
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5603
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5604
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5605

    
5606
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5607
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5608
                }
5609
            }
5610
            else
5611
            {
5612
                IsSyncPDFMode = false;
5613
                string uri = "";
5614
                if (userData.COMPANY != "EXT")
5615
                {
5616
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5617
                }
5618
                else
5619
                {
5620
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5621
                }
5622

    
5623
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5624

    
5625
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5626
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5627
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5628

    
5629
                if (defaultBitmapImage_Compare.IsDownloading)
5630
                {
5631
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5632
                    {
5633
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5634
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5635
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5636
                    };
5637
                }
5638
                zoomAndPanControl2.ApplyTemplate();
5639
                zoomAndPanControl2.UpdateLayout();
5640
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5641
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5642
            }
5643
        }
5644

    
5645
        private void RadButton_Click(object sender, RoutedEventArgs e)
5646
        {
5647
            gridViewHistory_Busy.IsBusy = true;
5648

    
5649
            RadButton instance = sender as RadButton;
5650
            if (instance.CommandParameter != null)
5651
            {
5652
                CurrentRev = instance.CommandParameter as VPRevision;
5653
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5654
                {
5655
                    if (ea.Error == null && ea.Result != null)
5656
                    {
5657
                        testPanel2.IsHidden = false;
5658

    
5659
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5660
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5661

    
5662
                        string uri = "";
5663
                        if (userData.COMPANY != "EXT")
5664
                        {
5665
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5666
                        }
5667
                        else
5668
                        {
5669
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5670
                        }
5671

    
5672
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5673

    
5674
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5675

    
5676
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5677
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5678
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5679

    
5680
                        if (defaultBitmapImage_Compare.IsDownloading)
5681
                        {
5682
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5683
                            {
5684
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5685
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5686
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5687
                            };
5688
                        }
5689

    
5690
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5691
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5692
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5693
                        zoomAndPanControl2.ApplyTemplate();
5694
                        zoomAndPanControl2.UpdateLayout();
5695

    
5696
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5697
                        {
5698
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5699
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5700
                        }
5701

    
5702
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5703
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5704
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5705

    
5706
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5707
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5708
                        gridViewHistory_Busy.IsBusy = false;
5709
                    }
5710

    
5711
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5712
                };
5713
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5714
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5715
            }
5716
        }
5717

    
5718
        public void Sync_Event(VPRevision Currnet_Rev)
5719
        {
5720
            CurrentRev = Currnet_Rev;
5721

    
5722
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5723
            {
5724
                if (ea.Error == null && ea.Result != null)
5725
                {
5726
                    testPanel2.IsHidden = false;
5727

    
5728
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5729
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5730

    
5731
                    string uri = "";
5732
                    if (userData.COMPANY != "EXT")
5733
                    {
5734
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5735
                    }
5736
                    else
5737
                    {
5738
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5739
                    }
5740

    
5741
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5742

    
5743
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5744

    
5745
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5746
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5747
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5748

    
5749
                    if (defaultBitmapImage_Compare.IsDownloading)
5750
                    {
5751
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5752
                        {
5753
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5754
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5755
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5756
                        };
5757
                    }
5758

    
5759

    
5760
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5761
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5762
                    zoomAndPanControl2.ApplyTemplate();
5763
                    zoomAndPanControl2.UpdateLayout();
5764

    
5765
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5766
                    {
5767
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5768
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5769
                    }
5770
                    //}
5771

    
5772
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5773
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5774
                    gridViewHistory_Busy.IsBusy = false;
5775
                }
5776
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5777

    
5778
            };
5779
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5780
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5781
        }
5782

    
5783
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5784
        {
5785
            if (sender is Image)
5786
            {
5787
                if ((sender as Image).Tag != null)
5788
                {
5789
                    var pdfUrl = (sender as Image).Tag.ToString();
5790
                    System.Diagnostics.Process.Start(pdfUrl);
5791
                }
5792
                else
5793
                {
5794
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5795
                }
5796
            }
5797
        }
5798

    
5799
        private void Create_Symbol(object sender, RoutedEventArgs e)
5800
        {
5801
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5802

    
5803
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5804
            {
5805
                DialogMessage_Alert("Please Select Controls", "Alert");
5806
            }
5807
            else //선택된 것이 있으면
5808
            {
5809
                string MarkupData = "";
5810
                adorner_ = new AdornerFinal();
5811

    
5812
                foreach (var item in SelectLayer.Children)
5813
                {
5814
                    if (item.GetType().Name == "AdornerFinal")
5815
                    {
5816
                        adorner_ = (item as Controls.AdornerFinal);
5817
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5818
                        {
5819
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5820
                            {
5821
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5822
                                MarkupData += markupReturn.ConvertData;
5823
                            }
5824
                        }
5825
                    }
5826
                }
5827
                DialogParameters parameters = new DialogParameters()
5828
                {
5829
                    Owner = Application.Current.MainWindow,
5830
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5831
                    DefaultPromptResultValue = "Custom State",
5832
                    Content = "Name :",
5833
                    Header = "Insert Custom Symbol Name",
5834
                    Theme = new VisualStudio2013Theme(),
5835
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5836
                };
5837
                RadWindow.Prompt(parameters);
5838
            }
5839

    
5840
        }
5841
        public int symbolselectindex = 0;
5842
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5843
        {
5844
            //Save save = new Save();
5845
            try
5846
            {
5847
                string svgfilename = null;
5848
                if (symbolname != null)
5849
                {
5850
                    if (symbolpng == true || symbolsvg == true)
5851
                    {
5852
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5853
                        string guid = Commons.shortGuid();
5854

    
5855
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5856
                        //Check_Uri.UriCheck();
5857
                        fileUploader.RunCompleted += (ex, arg) =>
5858
                        {
5859
                            filename = arg.Result;
5860
                            if (symbolpng == true)
5861
                            {
5862
                                if (filename != null)
5863
                                { 
5864
                                    if (symbolselectindex == 0)
5865
                                    {
5866
                                        SymbolSave(symbolname, filename, data);
5867
                                    }
5868
                                    else
5869
                                    {
5870
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5871
                                    }
5872
                                    DataBind();
5873
                                }                                
5874
                            }
5875

    
5876
                            if (symbolsvg == true)
5877
                            {
5878
                                try
5879
                                {
5880
                                    var defaultBitmapImage = new BitmapImage();
5881
                                    defaultBitmapImage.BeginInit();
5882
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5883
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5884
                                    Check_Uri.UriCheck(filename);
5885
                                    defaultBitmapImage.UriSource = new Uri(filename);
5886
                                    defaultBitmapImage.EndInit();
5887

    
5888
                                    System.Drawing.Bitmap image;
5889

    
5890
                                    if (defaultBitmapImage.IsDownloading)
5891
                                    {
5892
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5893
                                        {
5894
                                            defaultBitmapImage.Freeze();
5895
                                            image = GetBitmap(defaultBitmapImage);
5896
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5897
                                            Process potrace = new Process
5898
                                            {
5899
                                                StartInfo = new ProcessStartInfo
5900
                                                {
5901
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5902
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5903
                                                    RedirectStandardInput = true,
5904
                                                    RedirectStandardOutput = true,
5905
                                                    RedirectStandardError = true,
5906
                                                    UseShellExecute = false,
5907
                                                    CreateNoWindow = true,
5908
                                                    WindowStyle = ProcessWindowStyle.Hidden
5909
                                                },
5910
                                            };
5911

    
5912
                                            StringBuilder svgBuilder = new StringBuilder();
5913
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5914
                                            {
5915
                                                svgBuilder.AppendLine(e2.Data);
5916
                                            };
5917

    
5918
                                            potrace.EnableRaisingEvents = true;
5919
                                            potrace.Start();
5920
                                            potrace.Exited += (sender, e) =>
5921
                                            {
5922
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5923
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5924
                                                Check_Uri.UriCheck(svgfilename);
5925
                                                if (symbolselectindex == 0)
5926
                                                {
5927
                                                    SymbolSave(symbolname, svgfilename, data);
5928
                                                }
5929
                                                else
5930
                                                {
5931
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5932
                                                }
5933

    
5934
                                                DataBind();
5935
                                            };
5936
                                            potrace.WaitForExit();
5937
                                        };
5938
                                    }
5939
                                    else
5940
                                    {
5941
                                        //GC.Collect();
5942
                                    }
5943
                                }
5944
                                catch(Exception ee)
5945
                                {
5946
                                    DialogMessage_Alert("" + ee, "Alert");
5947
                                }
5948
                            }
5949
                        };                                             
5950
                    }
5951
                }
5952
            }
5953
            catch (Exception e)
5954
            {
5955
                //DialogMessage_Alert(e + "", "Alert");
5956
            }            
5957
        }
5958

    
5959
        public void SymbolSave(string Name, string Url, string Data)
5960
        {
5961
            try
5962
            {
5963
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5964
                {
5965
                    ID = Commons.shortGuid(),
5966
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5967
                    NAME = Name,
5968
                    IMAGE_URL = Url,
5969
                    DATA = Data
5970
                };
5971

    
5972
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5973
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5974
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5975
            }
5976
            catch (Exception)
5977
            {
5978
                throw;
5979
            }
5980
        }
5981

    
5982
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5983
        {
5984
            try
5985
            {
5986
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5987
                {
5988
                    ID = Commons.shortGuid(),
5989
                    DEPARTMENT = Department,
5990
                    NAME = Name,
5991
                    IMAGE_URL = Url,
5992
                    DATA = Data
5993
                };
5994
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5995
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5996
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5997
            }
5998
            catch (Exception)
5999
            {
6000
                throw;
6001
            }
6002
        }
6003

    
6004
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
6005
        {           
6006
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6007
            DataBind();
6008
        }
6009

    
6010
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
6011
        {
6012
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6013
            DataBind();
6014
        }
6015
        private void DataBind()
6016
        {
6017
            try
6018
            {
6019
                Symbol_Custom Custom = new Symbol_Custom();
6020
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
6021
                ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
6022
                var symbol_Private = client.GetSymbolList(App.ViewInfo.UserID);
6023
                foreach (var item in symbol_Private)
6024
                {
6025
                    Custom.Name = item.NAME;
6026
                    Custom.ImageUri = item.IMAGE_URL;
6027
                    Custom.ID = item.ID;
6028
                    Custom_List.Add(Custom);
6029
                    Custom = new Symbol_Custom();
6030
                }
6031
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
6032
                
6033
                Custom = new Symbol_Custom();
6034
                Custom_List = new List<Symbol_Custom>();
6035

    
6036
                symbolPanel_Instance.deptlist.ItemsSource = client.GetPublicSymbolDeptList();
6037

    
6038
                List<SYMBOL_PUBLIC> symbol_Public;
6039

    
6040

    
6041
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
6042
                {
6043
                    symbol_Public = client.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
6044
                }
6045
                else
6046
                {
6047
                    symbol_Public = client.GetPublicSymbolList(null);
6048
                }
6049
                foreach (var item in symbol_Public)
6050
                {
6051
                    Custom.Name = item.NAME;
6052
                    Custom.ImageUri = item.IMAGE_URL;
6053
                    Custom.ID = item.ID;
6054
                    Custom_List.Add(Custom);
6055
                    Custom = new Symbol_Custom();
6056
                }
6057
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
6058
                client.Close();                
6059
            }
6060
            catch(Exception e)
6061
            {
6062
                //DialogMessage_Alert("DataBind", "Alert");
6063
            }
6064
            
6065
        }
6066
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
6067
        {
6068
            try
6069
            {
6070
                if (args.PromptResult != null)
6071
                {
6072
                    if (args.DialogResult.Value)
6073
                    {
6074
                        PngBitmapEncoder _Encoder = symImage(data);
6075

    
6076
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6077
                        _Encoder.Save(fs);
6078
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6079

    
6080
                        byte[] Img_byte = fs.ToArray();
6081

    
6082
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6083
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
6084
                        Check_Uri.UriCheck(filename);
6085
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6086
                        {
6087
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
6088
                        }
6089
                        else
6090
                        {
6091
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6092
                        }
6093
                        DataBind();
6094
                    }
6095
                }
6096
            }
6097
            catch(Exception ex)
6098
            {
6099
                DialogMessage_Alert("" + ex, "Alert");
6100
            }
6101
        }
6102

    
6103
        public PngBitmapEncoder symImage(string data)
6104
        {
6105

    
6106
            Canvas _canvas = new Canvas();
6107
            _canvas.Background = Brushes.White;
6108
            _canvas.Width = adorner_.BorderSize.Width;
6109
            _canvas.Height = adorner_.BorderSize.Height;
6110
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
6111

    
6112
            BitmapEncoder encoder = new PngBitmapEncoder();
6113

    
6114

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

    
6117
            DrawingVisual dv = new DrawingVisual();
6118

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

    
6122
            using (DrawingContext ctx = dv.RenderOpen())
6123
            {
6124
                VisualBrush vb = new VisualBrush(_canvas);
6125
                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)));
6126
            }
6127

    
6128
            try
6129
            {
6130
                renderBitmap.Render(dv);
6131

    
6132
                //GC.Collect();
6133
                GC.WaitForPendingFinalizers();
6134
                //GC.Collect();
6135
                // encode png data
6136
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6137
                // puch rendered bitmap into it
6138
                pngEncoder.Interlace = PngInterlaceOption.Off;
6139
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6140
                return pngEncoder;
6141

    
6142
            }
6143
            catch //(Exception ex)
6144
            {
6145
                return null;
6146
            }
6147

    
6148
        }
6149

    
6150
        public void DialogMessage_Alert(string content, string header)
6151
        {
6152
            var box = new TextBlock();
6153
            box.MinWidth = 400;
6154
            box.FontSize = 11;
6155
            //box.FontSize = 12;
6156
            box.Text = content;
6157
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6158

    
6159
            DialogParameters parameters = new DialogParameters()
6160
            {
6161
                Owner = Application.Current.MainWindow,
6162
                Content = box,
6163
                Header = header,
6164
                Theme = new VisualStudio2013Theme(),
6165
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6166
            };            
6167
            RadWindow.Alert(parameters);
6168
        }
6169

    
6170
        #region 캡쳐 기능
6171

    
6172
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6173
        {
6174
            if (x < 0)
6175
            {
6176
                width += x;
6177
                x = 0;
6178
            }
6179
            if (y < 0)
6180
            {
6181
                height += y;
6182
                y = 0;
6183

    
6184
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6185
            }
6186
            if (x + width > zoomAndPanCanvas.ActualWidth)
6187
            {
6188
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6189
            }
6190
            if (y + height > zoomAndPanCanvas.ActualHeight)
6191
            {
6192
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6193
            }
6194

    
6195
            byte[] pixels = CopyPixels(x, y, width, height);
6196

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

    
6199
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6200
        }
6201

    
6202
        public byte[] CopyPixels(int x, int y, int width, int height)
6203
        {
6204
            byte[] pixels = new byte[width * height * 4];
6205
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6206

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

    
6210
            return pixels;
6211
        }
6212

    
6213
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6214
        {
6215
            DrawingVisual drawingVisual = new DrawingVisual();
6216
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6217

    
6218
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6219
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6220
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6221
            drawingContext.Close();
6222

    
6223
            // 비트맵으로 변환합니다.
6224
            RenderTargetBitmap target =
6225
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6226
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6227

    
6228
            target.Render(drawingVisual);
6229
            return target;
6230
        }
6231

    
6232
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6233
        {
6234
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6235
            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);
6236
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6237
            bmp.UnlockBits(data);
6238
            return bmp;
6239
        }
6240
        public string symbolname = null;
6241
        public bool symbolsvg = true;
6242
        public bool symbolpng = true;
6243

    
6244
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6245
        {
6246
            System.Drawing.Bitmap image = GetBitmap(source);
6247
            //흰색 제거
6248
            //image.MakeTransparent(System.Drawing.Color.White);
6249

    
6250
            var imageStream = new System.IO.MemoryStream();
6251
            byte[] imageBytes = null;
6252
            using (imageStream)
6253
            {
6254
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6255
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6256
                imageStream.Position = 0;
6257
                imageBytes = imageStream.ToArray();
6258
            }
6259

    
6260
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6261

    
6262
            RadWindow CheckPop = new RadWindow();
6263
            //Alert check = new Alert(Msg);
6264

    
6265
            CheckPop = new RadWindow
6266
            {
6267
                MinWidth = 400,
6268
                MinHeight = 100,
6269
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6270
                Header = "Alert",
6271
                Content = symbolPrompt,
6272
                //DialogResult = 
6273
                ResizeMode = System.Windows.ResizeMode.NoResize,
6274
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6275
                IsTopmost = true,
6276
            };
6277
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6278
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6279
            CheckPop.ShowDialog();
6280

    
6281
            /*
6282
            DialogParameters parameters = new DialogParameters()
6283
            {
6284
                Owner = Application.Current.MainWindow,
6285
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6286
                DefaultPromptResultValue = "Custom State",
6287
                Content = "Name :",
6288
                Header = "Insert Custom Symbol Name",
6289
                Theme = new VisualStudio2013Theme(),
6290
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6291
            };            
6292
            RadWindow.Prompt(parameters);
6293
            */
6294
        }
6295

    
6296
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6297
        {
6298
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6299
            KCOMDataModel.DataModel.CHECK_LIST check_;
6300
            string Result = streamToBase64.ImageToBase64(source);
6301
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6302
            string projectno = App.ViewInfo.ProjectNO;
6303
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6304

    
6305
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6306
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6307
            if (Item != null)
6308
            {
6309
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6310
            }
6311
            else
6312
            {
6313
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6314
            }
6315

    
6316
            if (Item == null)
6317
            {
6318
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6319
                {
6320
                    ID = Commons.shortGuid(),
6321
                    USER_ID = App.ViewInfo.UserID,
6322
                    IMAGE_URL = Result,
6323
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6324
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6325
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6326
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6327
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6328
                    STATUS = "False",
6329
                    CREATE_TIME = DateTime.Now,
6330
                    UPDATE_TIME = DateTime.Now,
6331
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6332
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6333
                };
6334
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6335
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6336
                //this.BaseClient.AddCheckList(projectno, check_);
6337
            }
6338
            else
6339
            {
6340
                Item.IMAGE_URL = Result;
6341
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6342
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6343
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6344
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6345
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6346
            }
6347

    
6348
        }
6349

    
6350
        public void Set_Capture()
6351
        {
6352
            double x = canvasDrawingMouseDownPoint.X;
6353
            double y = canvasDrawingMouseDownPoint.Y;
6354
            double width = dragCaptureBorder.Width;
6355
            double height = dragCaptureBorder.Height;
6356

    
6357
            if (width > 5 || height > 5)
6358
            {
6359
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6360
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6361
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6362
            }
6363
        }
6364
        #endregion
6365

    
6366
        //MarkupInfoItem
6367
        public void CreateControl()
6368
        {
6369

    
6370
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6371
            {
6372
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6373
            });
6374
            multi_Undo_Data.Markup = currentControl;
6375
            UndoData.Markup_List.Add(multi_Undo_Data);
6376

    
6377
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6378

    
6379
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6380
        }
6381

    
6382
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6383
        {
6384
            multi_Undo_Data = new Multi_Undo_data();
6385

    
6386
            multi_Undo_Data.Markup = control;
6387

    
6388
            if ((control as IShapeControl) != null)
6389
            {
6390
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6391
            }
6392
            if ((control as IDashControl) != null)
6393
            {
6394
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6395
            }
6396
            if ((control as IPath) != null)
6397
            {
6398
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6399
            }
6400
            if ((control as UIElement) != null)
6401
            {
6402
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6403
            }
6404

    
6405
            return multi_Undo_Data;
6406
        }
6407

    
6408
        public void Undo()
6409
        {
6410
            // if (ViewerDataModel.Instance.IsPressCtrl)
6411
            //   {
6412
            //      ViewerDataModel.Instance.IsPressCtrl = false;
6413
            //   }
6414
            Undo_data undo = new Undo_data();
6415
            AdornerFinal final;
6416
            SelectionSet.Instance.UnSelect(this);
6417

    
6418
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6419
            if (undo == null)
6420
                return;
6421

    
6422

    
6423

    
6424
            switch (undo.Event)
6425
            {
6426
                case (Event_Type.Create):
6427
                    {
6428
                        foreach (var item in undo.Markup_List)
6429
                        {
6430
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6431
                        }
6432
                    }
6433
                    break;
6434
                case (Event_Type.Delete):
6435
                    {
6436
                        foreach (var item in undo.Markup_List)
6437
                        {
6438
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6439
                        }
6440
                    }
6441
                    break;
6442
                case (Event_Type.Thumb):
6443
                    {
6444
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6445

    
6446
                        foreach (var item in undo.Markup_List)
6447
                        {
6448
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6449

    
6450
                            if ((item.Markup as IViewBox) != null)
6451
                            {
6452
                                (item.Markup as IViewBox).Angle = item.Angle;
6453
                            }
6454
                            if ((item.Markup as TextControl) != null)
6455
                            {
6456
                                (item.Markup as TextControl).Angle = item.Angle;
6457
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6458
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6459
                            }
6460
                            else
6461
                            {
6462
                                (item.Markup as IPath).PointSet = item.PointSet;
6463
                                (item.Markup as IPath).updateControl();
6464
                            }
6465

    
6466
                            comment.Add(item.Markup);
6467
                        }
6468
                        final = new AdornerFinal(comment);
6469
                        SelectLayer.Children.Add(final);
6470
                        SelectionSet.Instance.UnSelect(this);
6471
                    }
6472
                    break;
6473
                case (Event_Type.Select):
6474
                    {
6475
                        SelectionSet.Instance.UnSelect(this);
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 IPath) != null)
6483
                            {
6484
                                (item.Markup as IPath).LineSize = item.LineSize;
6485
                            }
6486
                            if ((item.Markup as UIElement) != null)
6487
                            {
6488
                                (item.Markup as UIElement).Opacity = item.Opacity;
6489
                            }
6490
                            if ((item.Markup as IDashControl) != null)
6491
                            {
6492
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6493
                            }
6494
                            if ((item.Markup as IShapeControl) != null)
6495
                            {
6496
                                (item.Markup as IShapeControl).Paint = item.paint;
6497
                            }
6498

    
6499
                            comment.Add(item.Markup);
6500
                        }
6501

    
6502
                        final = new AdornerFinal(comment);
6503
                        SelectLayer.Children.Add(final);
6504
                    }
6505
                    break;
6506
                case (Event_Type.Option):
6507
                    {
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 (undo.LineSize != 0 && item.Markup as IPath != null)
6515
                            {
6516
                                (item.Markup as IPath).LineSize = undo.LineSize;
6517
                            }
6518
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
6519
                            {
6520
                                (item.Markup as UIElement).Opacity = undo.Opacity;
6521
                            }
6522
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
6523
                            {
6524
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
6525
                            }
6526
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
6527
                            {
6528
                                (item.Markup as LineControl).Interval = undo.Interval;
6529
                            }
6530
                            else if (item.Markup as IShapeControl != null)
6531
                            {
6532
                                (item.Markup as IShapeControl).Paint = undo.paint;
6533
                            }
6534
                            comment.Add(item.Markup);
6535
                        }
6536
                        final = new AdornerFinal(comment);
6537
                        SelectLayer.Children.Add(final);
6538
                    }
6539
                    break;
6540
            }
6541
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6542
            {
6543
                i.IsUndo = true;
6544
            });
6545
        }
6546

    
6547

    
6548

    
6549
        public void Redo()
6550
        {
6551
            //if (ViewerDataModel.Instance.IsPressCtrl)
6552
            //{
6553
            //    ViewerDataModel.Instance.IsPressCtrl = false;
6554
            //}
6555
            AdornerFinal final;
6556
            Undo_data redo = new Undo_data();
6557
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6558
            SelectionSet.Instance.UnSelect(this);
6559
            if (redo == null)
6560
                return;
6561

    
6562
            switch (redo.Event)
6563
            {
6564
                case (Event_Type.Create):
6565
                    {
6566
                        foreach (var item in redo.Markup_List)
6567
                        {
6568
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6569
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
6570
                        }
6571
                    }
6572
                    break;
6573
                case (Event_Type.Delete):
6574
                    {
6575
                        foreach (var item in redo.Markup_List)
6576
                        {
6577
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6578
                        }
6579
                    }
6580
                    break;
6581
                case (Event_Type.Thumb):
6582
                    {
6583
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6584

    
6585
                        foreach (var item in redo.Markup_List)
6586
                        {
6587
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6588

    
6589
                            if ((item.Markup as IViewBox) != null)
6590
                            {
6591
                                (item.Markup as IViewBox).Angle = item.Angle;
6592
                            }
6593
                            if ((item.Markup as TextControl) != null)
6594
                            {
6595
                                (item.Markup as TextControl).Angle = item.Angle;
6596

    
6597
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6598
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6599
                            }
6600
                            else
6601
                            {
6602
                                (item.Markup as IPath).PointSet = item.PointSet;
6603
                                (item.Markup as IPath).updateControl();
6604
                            }
6605
                            comment.Add(item.Markup);
6606
                        }
6607
                        final = new AdornerFinal(comment);
6608
                        SelectLayer.Children.Add(final);
6609
                        SelectionSet.Instance.UnSelect(this);
6610
                    }
6611
                    break;
6612
                case (Event_Type.Select):
6613
                    {
6614
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6615

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

    
6620
                            if ((item.Markup as IPath) != null)
6621
                            {
6622
                                (item.Markup as IPath).LineSize = item.LineSize;
6623
                            }
6624
                            if ((item.Markup as UIElement) != null)
6625
                            {
6626
                                (item.Markup as UIElement).Opacity = item.Opacity;
6627
                            }
6628
                            if ((item.Markup as IDashControl) != null)
6629
                            {
6630
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6631
                            }
6632
                            if ((item.Markup as IShapeControl) != null)
6633
                            {
6634
                                (item.Markup as IShapeControl).Paint = item.paint;
6635
                            }
6636

    
6637
                            comment.Add(item.Markup);
6638
                        }
6639
                        final = new AdornerFinal(comment);
6640
                        SelectLayer.Children.Add(final);
6641
                    }
6642
                    break;
6643
                case (Event_Type.Option):
6644
                    {
6645
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6646

    
6647
                        foreach (var item in redo.Markup_List)
6648
                        {
6649
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6650
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6651
                            {
6652
                                (item.Markup as IPath).LineSize = redo.LineSize;
6653
                            }
6654
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6655
                            {
6656
                                (item.Markup as UIElement).Opacity = redo.Opacity;
6657
                            }
6658
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
6659
                            {
6660
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
6661
                            }
6662
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
6663
                            {
6664
                                (item.Markup as LineControl).Interval = redo.Interval;
6665
                            }
6666
                            else if (item.Markup as IShapeControl != null)
6667
                            {
6668
                                (item.Markup as IShapeControl).Paint = redo.paint;
6669
                            }
6670
                            comment.Add(item.Markup);
6671
                        }
6672
                        final = new AdornerFinal(comment);
6673
                        SelectLayer.Children.Add(final);
6674
                    }
6675
                    break;
6676
            }
6677

    
6678
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6679
            {
6680
                i.IsUndo = false;
6681
            });
6682
        }
6683

    
6684
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6685
        {
6686
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6687
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6688
            {
6689
                if (items.UserID == Select_ID)
6690
                {
6691
                    foreach (var item in items.MarkupList)
6692
                    {
6693
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6694
                        {
6695
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6696
                                items.MarkupInfoID, Commons.shortGuid());
6697
                        }
6698
                    }
6699
                }
6700
            }
6701
        }
6702
        public void EmptyControlCheck()
6703
        {
6704
            for (var j = 0; j < (Common.ViewerDataModel.Instance.MarkupControls_USER).Count; j++)
6705
            {
6706
                if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "TextControl")
6707
                {
6708
                    if (((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == null
6709
                    || ((MarkupToPDF.Controls.Text.TextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Text == "")
6710
                    {
6711
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
6712
                    }
6713
                }
6714
                else if (((Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).GetType().Name == "ArrowTextControl")
6715
                {
6716
                    if (((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == null
6717
                    || ((MarkupToPDF.Controls.Text.ArrowTextControl)(Common.ViewerDataModel.Instance.MarkupControls_USER)[j]).Base_TextBox.Text == "")
6718
                    {
6719
                        Common.ViewerDataModel.Instance.MarkupControls_USER.RemoveAt(j);
6720
                    }
6721
                }
6722
            }
6723
        }
6724
        public void InkControl_Convert()
6725
        {
6726
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6727
            if (inkBoard.Strokes.Count > 0)
6728
            {
6729
                inkBoard.Strokes.ToList().ForEach(stroke =>
6730
                {
6731
                    List<Stroke> removingStroke = new List<Stroke>();
6732
                    StrokeCollection stC = new StrokeCollection();
6733

    
6734
                    removingStroke.Add(stroke);
6735

    
6736
                    InkToPath ip = new InkToPath();
6737
                    List<Point> inkPointSet = new List<Point>();
6738
                    PolygonControl pc = null;
6739
                    pc = new PolygonControl()
6740
                    {
6741
                        Angle = 0,
6742
                        PointSet = new List<Point>(),
6743
                        ControlType = ControlType.Ink
6744
                    };
6745
                    foreach (var item in removingStroke)
6746
                    {
6747
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6748
                        inkBoard.Strokes.Remove(item);
6749
                    }
6750
                    if (inkPointSet.Count != 0)
6751
                    {
6752
                        //강인구 추가(PenControl Undo Redo 추가)
6753
                        UndoData = new Undo_data()
6754
                        {
6755
                            IsUndo = false,
6756
                            Event = Event_Type.Create,
6757
                            EventTime = DateTime.Now,
6758
                            Markup_List = new List<Multi_Undo_data>()
6759
                        };
6760

    
6761
                        pc.StartPoint = inkPointSet[0];
6762
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6763
                        pc.PointSet = inkPointSet;
6764
                        pc.LineSize = 3;
6765
                        pc.CommentID = Commons.shortGuid();
6766
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6767
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6768
                        ///pc.SetPolyPath();
6769

    
6770
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6771
                        {
6772
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6773
                        });
6774
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6775
                        UndoData.Markup_List.Add(multi_Undo_Data);
6776
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6777
                    }
6778
                });
6779
            }
6780
        }
6781

    
6782
        /// <summary>
6783
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6784
        /// </summary>
6785
        /// <param name="StartP">StartPoint</param>
6786
        /// <param name="EndP">EndPoint</param>
6787
        /// <returns>Return_EndPoint</returns>
6788
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6789
        {
6790
            Point Return_Point = new Point();
6791

    
6792
            double dx = EndP.X - StartP.X;
6793
            double dy = EndP.Y - StartP.Y;
6794
            double length;
6795

    
6796
            switch (controlType)
6797
            {
6798
                case ControlType.Triangle:
6799
                    {
6800
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6801
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6802
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6803
                    }
6804
                    break;
6805
                default:
6806
                    {
6807
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6808
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6809
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6810
                    }
6811
                    break;
6812
            }
6813

    
6814
            return Return_Point;
6815
        }
6816

    
6817
        /// <summary>
6818
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6819
        /// </summary>
6820
        /// <author>humkyung</author>
6821
        /// <date>2018.04.26</date>
6822
        /// <param name="StartP"></param>
6823
        /// <param name="EndP"></param>
6824
        /// <returns></returns>
6825
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6826
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6827
        {
6828
            List<Point> res = new List<Point>();
6829

    
6830
            double dx = EndP.X - StartP.X;
6831
            double dy = EndP.Y - StartP.Y;
6832
            double length = Math.Sqrt(dx * dx + dy * dy);
6833
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6834
            dx /= length;
6835
            dy /= length;
6836
            double tmp = dx;
6837
            dx = -dy; dy = tmp; /// rotate by 90 degree
6838

    
6839
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6840
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6841

    
6842
            return res;
6843
        }
6844

    
6845
        /// <summary>
6846
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6847
        /// </summary>
6848
        /// <author>ingu</author>
6849
        /// <date>2018.06.05</date>
6850
        /// <param name="getPoint"></param>
6851
        /// <returns></returns>
6852
        private bool IsGetoutpoint(Point getPoint)
6853
        {
6854
            if (getPoint == new Point())
6855
            {
6856
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6857
                currentControl = null;
6858
                return true;
6859
            }
6860

    
6861
            return false;
6862
        }
6863

    
6864
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6865
        {
6866
            e.Effects = DragDropEffects.Copy;
6867
        }
6868

    
6869
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6870
        {
6871
            e.Effects = DragDropEffects.Copy;
6872
        }
6873

    
6874
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6875
        {
6876
            e.Effects = DragDropEffects.None;
6877
        }
6878

    
6879
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6880
        {
6881
            try
6882
            {
6883
                if (e.Data.GetDataPresent(typeof(string)))
6884
                {
6885
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6886
                    string dragData = e.Data.GetData(typeof(string)) as string;
6887
                    Move_Symbol(sender, dragData);
6888
                }
6889
            }
6890
            catch (Exception ex)
6891
            {
6892
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6893
            }            
6894
        }
6895

    
6896
        private void Move_Symbol(object sender, string dragData)
6897
        {
6898
            try
6899
            {
6900
                if (dragData.Contains("|DZ|"))
6901
                {
6902
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6903

    
6904
                    string[] delimiterChars = { "|DZ|" };
6905
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6906

    
6907
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6908

    
6909
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6910

    
6911
                    //강인구 Undo/Redo 보류
6912
                    UndoData = new Undo_data()
6913
                    {
6914
                        IsUndo = false,
6915
                        Event = Event_Type.Create,
6916
                        EventTime = DateTime.Now,
6917
                        Markup_List = new List<Multi_Undo_data>()
6918
                    };
6919

    
6920
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6921
                    {
6922
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6923
                    });
6924

    
6925
                    foreach (string parse in data)
6926
                    {
6927
                        if (parse != "")
6928
                        {
6929
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
6930
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
6931

    
6932
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6933
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6934

    
6935
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6936

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

    
6939
                            UndoData.Markup_List.Add(multi_Undo_Data);
6940
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6941
                        }
6942
                    }
6943
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6944

    
6945
                    /// move symbol to current mouse point
6946
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6947
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6948
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6949

    
6950
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6951
                    {
6952
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6953
                    }
6954
                    /// up to here
6955

    
6956
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6957
                }
6958
            }
6959
            catch (Exception ex)
6960
            {
6961
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
6962
            }            
6963
        }        
6964
    }
6965
}
클립보드 이미지 추가 (최대 크기: 500 MB)