프로젝트

일반

사용자정보

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

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

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

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

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

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

    
373
            DeleteItem(item);
374
        }
375

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

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

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

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

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

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

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

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

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

    
444
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
445

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

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

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

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

    
506

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

    
521
        bool ComingNewBieEnd = false;
522

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

    
534
            InkControl_Convert();
535

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

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

    
543

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

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

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

    
558
            #endregion
559

    
560
            ViewerDataModel.Instance.PageNumber = BalancePoint;
561

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

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

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

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

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

    
601

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

    
607

    
608

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

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

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

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

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

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

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

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

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

    
700
            this.pageNavigator.SetNextPage();
701

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

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

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

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

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

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

    
742

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

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

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

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

    
764

    
765
        
766

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

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

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

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

    
827
        #region ZoomIn & ZoomOut
828

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

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

    
841

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

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

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

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

    
877
        }
878

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

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

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

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

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

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

    
931
        #endregion
932

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

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

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

    
945
        }
946

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

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

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

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

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

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

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

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

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

    
1138
      
1139
            CreateDragDropWindow2(img);
1140
        }
1141

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

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

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

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

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

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

    
1182

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

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

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

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

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

    
1262
                //        default:
1263
                //            {
1264

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1428

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

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

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

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

    
1472

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

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

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

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

    
1516

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

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

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

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

    
1560

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

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

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

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

    
1604

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

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

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

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

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

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

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

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

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

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

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

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

    
1702
                            }
1703
                            break;
1704

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

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

    
1728

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

    
1737

    
1738
                            }
1739
                            break;
1740

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

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

    
1763

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

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

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

    
1796

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

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

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

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

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

    
1843
                                if (control != null)
1844
                                {
1845

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

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

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

    
1863
                                    ///control.SetPolyPath();
1864

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

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

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

    
1892

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

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

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

    
1926

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

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

    
1971
                                    }
1972

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

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

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

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

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

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

    
2021
                                }
2022
                            }
2023
                            break;
2024

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

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

    
2034
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2035

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

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

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

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

    
2066

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2411
                                if (control != null)
2412
                                {
2413

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

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

    
2421

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

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

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

    
2434
                                        //control.ApplyTemplate();
2435

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

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

    
2447

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

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

    
2475

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

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

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

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

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

    
2520
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2521
                    }
2522

    
2523
                    e.Handled = true;
2524
                }
2525

    
2526

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

    
2549

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

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

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

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

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

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

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

    
2612
                //}
2613

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

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

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

    
2639
                #endregion
2640
            }
2641
        }
2642

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

    
2651
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2652

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

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

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

    
2666
        private EllipseGeometry hitArea = new EllipseGeometry();
2667

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

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

    
2678
                    SetCursor();
2679

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

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

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

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

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

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

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

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

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

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

    
2768
                zoomAndPanControl.ReleaseMouseCapture();
2769

    
2770

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

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

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

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

    
2796
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2797

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

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

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

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

    
2839
            //GC.Collect();
2840

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

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

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

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

    
2867
        }
2868

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

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

    
2884
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2885

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3044
            zoomAndPanControl.RotationAngle = rotate.Angle;
3045

    
3046

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

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

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

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

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

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

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

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

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

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

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

    
3169
            InkControl_Convert();
3170

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3545
                                    CreateControl();
3546

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

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

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

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

    
3593
                                    CreateControl();
3594

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

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

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

    
3628
                                    CreateControl();
3629

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

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

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

    
3663
                                    CreateControl();
3664

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

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

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

    
3701
                                        CreateControl();
3702

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

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

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

    
3741
                                        CreateControl();
3742

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

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

    
3778
                                        CreateControl();
3779

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

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

    
3820
                                            CreateControl();
3821

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

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

    
3857
                                        CreateControl();
3858

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

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

    
3894
                                        CreateControl();
3895

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

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

    
3931
                                        CreateControl();
3932

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

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

    
3968
                                        CreateControl();
3969

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

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

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

    
4039
                                    CreateControl();
4040

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

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

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

    
4099
                                        CreateControl();
4100

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

    
4144
                                    CreateControl();
4145

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

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

    
4204
                                            CreateControl();
4205

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

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

    
4250
                                    CreateControl();
4251

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4432
                                    CreateControl();
4433

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

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

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

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

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

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

    
4514
                                    CreateControl();
4515

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4826
                                    control.ApplyOverViewData();
4827

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5113

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

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

    
5131
            }
5132
        }
5133

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

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

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

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

    
5161
            inkBoard.Strokes.Add(stroke);
5162

    
5163
        }
5164

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5569
                }
5570
            }
5571
        }
5572

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

    
5579
                var uri = CurrentRev.TO_VENDOR;
5580

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5760

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

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

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

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

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

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

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

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

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

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

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

    
5889
                                    System.Drawing.Bitmap image;
5890

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

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

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

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

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

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

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

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

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

    
6037
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
6038

    
6039
                List<SYMBOL_PUBLIC> symbol_Public;
6040

    
6041
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
6042
                {
6043
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
6044
                }
6045
                else
6046
                {
6047
                    symbol_Public = BaseClient.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
                BaseClient.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)