프로젝트

일반

사용자정보

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

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

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

1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

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

    
235
        #endregion
236

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

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

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

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

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

    
270
            return false;
271
        }
272

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

    
296
            return false;
297
        }
298

    
299

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

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

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

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

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

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

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

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

    
372
            DeleteItem(item);
373
        }
374

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

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

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

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

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

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

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

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

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

    
443
                            Control_Style(InnerItem.DrawingData as CommentUserInfo);
444

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

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

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

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

    
505

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

    
520
        bool ComingNewBieEnd = false;
521

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

    
533
            InkControl_Convert();
534

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

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

    
542

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

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

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

    
557
            #endregion
558

    
559
            ViewerDataModel.Instance.PageNumber = BalancePoint;
560

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

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

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

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

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

    
600

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

    
606

    
607

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

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

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

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

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

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

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

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

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

    
699
            this.pageNavigator.SetNextPage();
700

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

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

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

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

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

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

    
741

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

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

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

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

    
763

    
764
        
765

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

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

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

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

    
826
        #region ZoomIn & ZoomOut
827

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

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

    
840

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

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

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

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

    
876
        }
877

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

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

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

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

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

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

    
930
        #endregion
931

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

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

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

    
944
        }
945

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

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

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

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

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

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

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

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

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

    
1137
      
1138
            CreateDragDropWindow2(img);
1139
        }
1140

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

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

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

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

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

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

    
1181

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

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

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

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

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

    
1261
                //        default:
1262
                //            {
1263

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1427

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

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

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

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

    
1471

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

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

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

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

    
1515

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

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

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

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

    
1559

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

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

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

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

    
1603

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

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

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

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

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

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

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

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

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

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

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

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

    
1701
                            }
1702
                            break;
1703

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

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

    
1727

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

    
1736

    
1737
                            }
1738
                            break;
1739

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

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

    
1762

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

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

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

    
1795

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

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

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

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

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

    
1842
                                if (control != null)
1843
                                {
1844

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

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

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

    
1862
                                    ///control.SetPolyPath();
1863

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

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

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

    
1891

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

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

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

    
1925

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

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

    
1970
                                    }
1971

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

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

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

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

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

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

    
2020
                                }
2021
                            }
2022
                            break;
2023

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

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

    
2033
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2034

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

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

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

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

    
2065

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2312
                            }
2313
                            break;
2314
                        case ControlType.PolygonControl:
2315
                            {
2316

    
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
        private void ApplyDragSelectionRect()
2870
        {
2871
            multi_Undo_Data = new Multi_Undo_data();
2872

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

    
2881
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2882

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3008
        public bool IsSelectionControl(Rect dragRect, Rect controlRect, Geometry OverViewPathData, ControlType type)
3009
        {
3010
            //// X, Y, WIDTH, HEIGHT 형태로 RECT를 만든다.
3011

    
3012
            bool result = false;
3013
            if (dragRect.Contains(controlRect))
3014
            {
3015
                result = true;
3016
                //잡은 객체들을 담은 리스트
3017
                try
3018
                {
3019
                    selected_item.Add(OverViewPathData, type.ToString());
3020
                }
3021
                catch (Exception)
3022
                {
3023

    
3024
                }
3025
            }
3026
            return result;
3027
        }
3028

    
3029
        private void drawingPannelRotate(double angle)
3030
        {
3031
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
3032
            rotate.Angle = angle;
3033
            var rotationNum = Math.Abs((rotate.Angle / 90));
3034

    
3035
            if (angle == 90 || angle == 270)
3036
            {
3037
                double emptySize = zoomAndPanCanvas.Width;
3038
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
3039
                zoomAndPanCanvas.Height = emptySize;
3040
            }
3041
            if (angle == 0)
3042
            {
3043
                translate.X = 0;
3044
                translate.Y = 0;
3045
            }
3046
            else if (angle == 90)
3047
            {
3048
                translate.X = zoomAndPanCanvas.Width;
3049
                translate.Y = 0;
3050
            }
3051
            else if (angle == 180)
3052
            {
3053
                translate.X = zoomAndPanCanvas.Width;
3054
                translate.Y = zoomAndPanCanvas.Height;
3055
            }
3056
            else
3057
            {
3058
                translate.X = 0;
3059
                translate.Y = zoomAndPanCanvas.Height;
3060
            }
3061

    
3062
            zoomAndPanControl.RotationAngle = rotate.Angle;
3063

    
3064

    
3065
            if (!testPanel2.IsHidden)
3066
            {
3067
                zoomAndPanControl2.RotationAngle = rotate.Angle;
3068
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
3069
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
3070
            }
3071

    
3072
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
3073
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
3074
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
3075
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
3076
            ViewerDataModel.Instance.Angle = rotate.Angle;
3077
        }
3078

    
3079
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
3080
        {
3081
            string Data_ = "";
3082

    
3083
            try
3084
            {
3085
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
3086
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
3087
                if (Data_ != null || Data_ != "")
3088
                {
3089
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
3090
                }
3091
                else
3092
                {
3093
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
3094
                }
3095

    
3096
                MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
3097
                {
3098
                    SYMBOL_ID = id,//InnerItem.Symbol_ID
3099
                    STATE = 0,
3100
                };
3101
                if (Data_ != null)
3102
                {
3103
                    Image img = new Image();
3104
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
3105
                    if (Data_.Contains(".svg"))
3106
                    {
3107
                        byte[] imageData = null;
3108
                        DrawingImage image = null;
3109
                        using (System.Net.WebClient web = new System.Net.WebClient())
3110
                        {
3111
                            imageData = web.DownloadData(new Uri(Data_));
3112
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3113
                            image = SvgReader.Load(stream);
3114
                        }
3115
                        img.Source = image;
3116
                    }
3117
                    else
3118
                    {
3119
                        img.Source = new BitmapImage(new Uri(Data_));
3120
                    }
3121

    
3122
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3123
                    {
3124
                        PointSet = new List<Point>(),
3125
                        FilePath = Data_,
3126
                        ImageData = img.Source,
3127
                        StartPoint = canvasZoomPanningMouseDownPoint,
3128
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3129
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3130
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3131
                        canvasZoomPanningMouseDownPoint.Y),
3132
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3133
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3134
                    };
3135

    
3136
                    currentControl.PointSet = new List<Point>
3137
                                        {
3138
                                            currentControl.StartPoint,
3139
                                            currentControl.LeftBottomPoint,
3140
                                            currentControl.EndPoint,
3141
                                            currentControl.TopRightPoint,
3142
                                        };
3143
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3144
                    UndoData = new Undo_data()
3145
                    {
3146
                        IsUndo = false,
3147
                        Event = Event_Type.Create,
3148
                        EventTime = DateTime.Now,
3149
                        Markup_List = new List<Multi_Undo_data>()
3150
                    };
3151
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3152
                    {
3153
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3154
                    });
3155

    
3156
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3157
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3158
                    UndoData.Markup_List.Add(multi_Undo_Data);
3159
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3160

    
3161
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3162
                    currentControl.CommentID = Commons.shortGuid();
3163
                    currentControl.SymbolID = id;
3164
                    currentControl.GroupID = group_id;
3165
                    currentControl.ApplyTemplate();
3166
                    currentControl.SetImage();
3167

    
3168
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3169
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3170
                    SelectLayer.Children.Add(final);
3171
                }
3172
            }
3173
            catch (Exception ex)
3174
            {
3175
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3176
            }
3177
        }
3178

    
3179
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3180
        {            
3181
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3182
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3183
            {
3184
                set_option.Value = double.Parse(set_option.ContentText);
3185
            }
3186

    
3187
            InkControl_Convert();
3188

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

    
3192
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3193
            {
3194
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3195
            }
3196

    
3197
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3198
            {
3199
                if (arrow_text as ArrowTextControl != null)
3200
                {
3201
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3202
                }
3203
            }
3204

    
3205
            mouseButtonDown = e.ChangedButton;
3206
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3207

    
3208
            //if (currentControl != null)
3209
            {
3210
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3211
                if (text_item_ != null)
3212
                {
3213
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3214
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3215
                    (text_item_ as TextControl).IsEditing = false;
3216
                    (text_item_ as TextControl).EnableEditing = false;
3217
                    currentControl = null;
3218
                }
3219

    
3220
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3221
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3222
                {
3223
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3224
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3225
                    currentControl = null;
3226
                }
3227
            }
3228

    
3229
            double Ang = 0;                                          
3230
            if (rotate.Angle != 0)
3231
            {
3232
                Ang = 360 - rotate.Angle;
3233
            }
3234
            move = new Move();
3235

    
3236
            if (e.OriginalSource is System.Windows.Controls.Image)
3237
            {
3238
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3239
            }
3240

    
3241
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Left)
3242
            {                
3243
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3244
                //SetCursor();
3245

    
3246
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3247
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3248
                if(symbol_id != null)
3249
                {
3250
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3251
                }                
3252
            }
3253

    
3254
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && mouseButtonDown == MouseButton.Right)
3255
            {
3256
                if (this._dragdropWindow != null)
3257
                {
3258
                    this._dragdropWindow.Close();
3259
                    this._dragdropWindow = null;
3260
                    symbol_id = null;
3261
                }
3262
            }
3263

    
3264
            if (mouseButtonDown == MouseButton.Left)
3265
            {
3266
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3267
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3268

    
3269
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3270
                SetCursor();
3271

    
3272
                if (!ViewerDataModel.Instance.IsPressCtrl)
3273
                {
3274
                    SelectionSet.Instance.UnSelect(this);
3275
                }
3276
            }
3277
            if (mouseButtonDown == MouseButton.Middle)
3278
            {
3279
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3280
                cursor = Cursors.SizeAll;
3281
                SetCursor();
3282
            }
3283
            if (mouseButtonDown == MouseButton.Right)
3284
            {
3285
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3286
                cursor = Cursors.SizeAll;
3287
                SetCursor();
3288
            }
3289
            else if (mouseButtonDown == MouseButton.XButton1)
3290
            {
3291
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3292
                {
3293
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3294
                }
3295

    
3296
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3297

    
3298
            }
3299
            else if (mouseButtonDown == MouseButton.XButton2)
3300
            {
3301
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3302
                {
3303
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3304
                }
3305
            }
3306

    
3307
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3308
            if (mouseButtonDown == MouseButton.Left && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3309
            {
3310
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3311
                {
3312
                    if (SelectLayer.Children.Count == 0)
3313
                    {
3314
                        isLeftMouseButtonDownOnWindow = true;
3315
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3316
                    }
3317

    
3318
                    if (controlType == ControlType.None)
3319
                    {
3320
                        isLeftMouseButtonDownOnWindow = true;
3321
                    }
3322
                }
3323

    
3324
                //캡쳐 모드 설정
3325
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3326
                {
3327
                    dragCaptureBorder.Visibility = Visibility.Visible;
3328
                    isLeftMouseButtonDownOnWindow = true;
3329
                }
3330

    
3331
                //줌 모드 설정
3332
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3333
                {
3334
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3335
                    isLeftMouseButtonDownOnWindow = true;
3336
                }               
3337

    
3338
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3339
                if (control != null)
3340
                {
3341
                    //강인구 추가 컨트롤 누르고 멀티 선택(다시확인필요)
3342
                    AdornerFinal final;
3343
                    List<Point> p_set = new List<Point>();
3344
                    List<CommentUserInfo> comment = new List<CommentUserInfo>();
3345
                    ViewerDataModel.Instance.MarkupControls.Remove(control);
3346
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
3347
                    multi_Undo_Data = new Multi_Undo_data();
3348

    
3349
                    //강인구 Undo/Redo 보류
3350
                    UndoData = new Undo_data()
3351
                    {
3352
                        IsUndo = false,
3353
                        Event = Event_Type.Select,
3354
                        EventTime = DateTime.Now,
3355
                        Markup_List = new List<Multi_Undo_data>()
3356
                    };
3357

    
3358
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3359
                    {
3360
                        SelectionSet.Instance.UnSelect(this);
3361
                        final = new AdornerFinal(control);
3362
                        //단일 컨트롤 언두 저장
3363

    
3364
                        Control_Style(control);
3365
                        UndoData.Markup_List.Add(multi_Undo_Data);
3366

    
3367
                        if ((control as IPath) != null)
3368
                        {
3369
                            if ((control as IPath).LineSize != 0)
3370
                            {
3371
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3372
                            }
3373
                        }
3374
                        if ((control as IShapeControl) != null)
3375
                        {
3376
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3377
                            {
3378
                                ViewerDataModel.Instance.checkHatchShape = true;
3379
                            }
3380
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3381
                            {
3382
                                ViewerDataModel.Instance.checkFillShape = true;
3383
                            }
3384
                            else
3385
                            {
3386
                                ViewerDataModel.Instance.checkHatchShape = false;
3387
                                ViewerDataModel.Instance.checkFillShape = false;
3388
                            }
3389
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3390
                        }
3391

    
3392
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3393

    
3394
                        if ((control as TextControl) != null)
3395
                        {
3396
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3397
                            {
3398
                                ViewerDataModel.Instance.checkTextStyle = true;
3399
                            }
3400
                            else
3401
                            {
3402
                                ViewerDataModel.Instance.checkTextStyle = false;
3403
                            }
3404

    
3405
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3406
                            {
3407
                                ViewerDataModel.Instance.checkTextStyle = true;
3408
                            }
3409
                            else
3410
                            {
3411
                                ViewerDataModel.Instance.checkTextStyle = false;
3412
                            }
3413
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3414
                            {
3415
                                ViewerDataModel.Instance.checkTextWeight = true;
3416
                            }
3417
                            else
3418
                            {
3419
                                ViewerDataModel.Instance.checkTextWeight = false;
3420
                            }
3421
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3422
                            {
3423
                                ViewerDataModel.Instance.checkUnderLine = true;
3424
                            }
3425
                            else
3426
                            {
3427
                                ViewerDataModel.Instance.checkUnderLine = false;
3428
                            }
3429
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3430
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3431

    
3432
                        }
3433
                        else if ((control as ArrowTextControl) != null)
3434
                        {
3435
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3436
                            {
3437
                                ViewerDataModel.Instance.checkTextStyle = true;
3438
                            }
3439
                            else
3440
                            {
3441
                                ViewerDataModel.Instance.checkTextStyle = false;
3442
                            }
3443

    
3444
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3445
                            {
3446
                                ViewerDataModel.Instance.checkTextStyle = true;
3447
                            }
3448
                            else
3449
                            {
3450
                                ViewerDataModel.Instance.checkTextStyle = false;
3451
                            }
3452
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3453
                            {
3454
                                ViewerDataModel.Instance.checkTextWeight = true;
3455
                            }
3456
                            else
3457
                            {
3458
                                ViewerDataModel.Instance.checkTextWeight = false;
3459
                            }
3460
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3461
                            {
3462
                                ViewerDataModel.Instance.checkUnderLine = true;
3463
                            }
3464
                            else
3465
                            {
3466
                                ViewerDataModel.Instance.checkUnderLine = false;
3467
                            }
3468
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3469
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3470
                        }
3471
                        else if ((control as RectCloudControl) != null)
3472
                        {
3473
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3474
                        }
3475
                        else if ((control as CloudControl) != null)
3476
                        {
3477
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3478
                        }
3479

    
3480
                    }
3481
                    else
3482
                    {
3483
                        comment = AddAdorner();
3484
                        comment.Add(control);
3485

    
3486
                        Control_Style(control);
3487
                        UndoData.Markup_List.Add(multi_Undo_Data);
3488

    
3489
                        final = new AdornerFinal(comment);
3490
                        //다중 컨트롤 언두 저장
3491
                    }
3492

    
3493
                    ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
3494
                    {
3495
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3496
                    });
3497

    
3498
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3499

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

    
3540
                multi_Undo_Data = new Multi_Undo_data();
3541
                //강인구 Undo/Redo 보류
3542
                UndoData = new Undo_data()
3543
                {
3544
                    IsUndo = false,
3545
                    Event = Event_Type.Create,
3546
                    EventTime = DateTime.Now,
3547
                    Markup_List = new List<Multi_Undo_data>()
3548
                };
3549

    
3550
                switch (controlType)
3551
                {
3552
                    case ControlType.Coordinate:
3553
                        {
3554
                            if (mouseButtonDown == MouseButton.Left)
3555
                            {
3556
                                if (currentControl is CoordinateControl)
3557
                                {
3558
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3559
                                    {
3560
                                        return;
3561
                                    }
3562

    
3563
                                    CreateControl();
3564

    
3565
                                    (currentControl as CoordinateControl).ApplyOverViewData();
3566
                                    currentControl = null;
3567
                                    this.cursor = Cursors.Arrow;
3568
                                }
3569
                                else
3570
                                {
3571
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3572
                                    if (ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3573
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3574
                                    {
3575
                                        currentControl = null;
3576
                                        this.cursor = Cursors.Arrow;
3577
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3578
                                        return;
3579
                                    }
3580
                                    else
3581
                                    {
3582
                                        currentControl = new CoordinateControl
3583
                                        {
3584
                                            Background = new SolidColorBrush(Colors.Black),
3585
                                            ControlType = ControlType.Coordinate
3586
                                        };
3587

    
3588
                                        currentControl.CommentID = Commons.shortGuid();
3589
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3590
                                        currentControl.IsNew = true;
3591

    
3592
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3593

    
3594
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3595
                                    }
3596
                                }
3597
                            }
3598
                        }
3599
                        break;
3600
                    case ControlType.InsideWhite:
3601
                        {
3602
                            if (mouseButtonDown == MouseButton.Left)
3603
                            {
3604
                                if (currentControl is InsideWhiteControl)
3605
                                {
3606
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3607
                                    {
3608
                                        return;
3609
                                    }
3610

    
3611
                                    CreateControl();
3612

    
3613
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3614
                                    currentControl = null;
3615
                                    this.cursor = Cursors.Arrow;
3616
                                }
3617
                                else
3618
                                {
3619
                                    currentControl = new InsideWhiteControl
3620
                                    {
3621
                                        Background = new SolidColorBrush(Colors.Black),
3622
                                        ControlType = ControlType.InsideWhite
3623
                                    };
3624

    
3625
                                    currentControl.CommentID = Commons.shortGuid();
3626
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3627
                                    currentControl.IsNew = true;
3628
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3629

    
3630
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3631
                                }
3632
                            }
3633
                        }
3634
                        break;
3635
                    case ControlType.OverlapWhite:
3636
                        {
3637
                            if (mouseButtonDown == MouseButton.Left)
3638
                            {
3639
                                if (currentControl is OverlapWhiteControl)
3640
                                {
3641
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3642
                                    {
3643
                                        return;
3644
                                    }
3645

    
3646
                                    CreateControl();
3647

    
3648
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3649
                                    currentControl = null;
3650
                                    this.cursor = Cursors.Arrow;
3651
                                }
3652
                                else
3653
                                {
3654
                                    currentControl = new OverlapWhiteControl
3655
                                    {
3656
                                        Background = new SolidColorBrush(Colors.Black),
3657
                                        ControlType = ControlType.OverlapWhite
3658
                                    };
3659

    
3660
                                    currentControl.CommentID = Commons.shortGuid();
3661
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3662
                                    currentControl.IsNew = true;
3663
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3664

    
3665
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3666
                                }
3667
                            }
3668
                        }
3669
                        break;
3670
                    case ControlType.ClipWhite:
3671
                        {
3672
                            if (mouseButtonDown == MouseButton.Left)
3673
                            {
3674
                                if (currentControl is ClipWhiteControl)
3675
                                {
3676
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3677
                                    {
3678
                                        return;
3679
                                    }
3680

    
3681
                                    CreateControl();
3682

    
3683
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
3684
                                    currentControl = null;
3685
                                    this.cursor = Cursors.Arrow;
3686
                                }
3687
                                else
3688
                                {
3689
                                    currentControl = new ClipWhiteControl
3690
                                    {
3691
                                        Background = new SolidColorBrush(Colors.Black),
3692
                                        ControlType = ControlType.ClipWhite
3693
                                    };
3694

    
3695
                                    currentControl.CommentID = Commons.shortGuid();
3696
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3697
                                    currentControl.IsNew = true;
3698
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3699

    
3700
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3701
                                }
3702
                            }
3703
                        }
3704
                        break;
3705
                    case ControlType.Rectangle:
3706
                        {
3707
                            if (mouseButtonDown == MouseButton.Left)
3708
                            {
3709
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3710
                                //{
3711
                                    if (currentControl is RectangleControl)
3712
                                    {
3713
                                        //20180906 LJY TEST IsRotationDrawingEnable
3714
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3715
                                        {
3716
                                            return;
3717
                                        }
3718

    
3719
                                        CreateControl();
3720

    
3721
                                        (currentControl as RectangleControl).ApplyOverViewData();
3722
                                        currentControl = null;
3723
                                    
3724
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3725
                                    }
3726
                                    else
3727
                                    {
3728
                                        currentControl = new RectangleControl
3729
                                        {
3730
                                            Background = new SolidColorBrush(Colors.Black),
3731
                                            ControlType = ControlType.Rectangle
3732
                                        };
3733

    
3734
                                        currentControl.CommentID = Commons.shortGuid();
3735
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3736
                                        currentControl.IsNew = true;
3737
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3738

    
3739
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3740
                                    }
3741
                                //}
3742
                            }
3743
                        }
3744
                        break;
3745
                    case ControlType.RectCloud:
3746
                        {
3747
                            if (mouseButtonDown == MouseButton.Left)
3748
                            {
3749
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3750
                                //{
3751
                                    if (currentControl is RectCloudControl)
3752
                                    {
3753
                                        //20180906 LJY TEST IsRotationDrawingEnable
3754
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3755
                                        {
3756
                                            return;
3757
                                        }
3758

    
3759
                                        CreateControl();
3760

    
3761
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3762
                                        currentControl = null;
3763
                                    
3764
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3765
                                    }
3766
                                    else
3767
                                    {
3768
                                        currentControl = new RectCloudControl
3769
                                        {
3770
                                            Background = new SolidColorBrush(Colors.Black)
3771
                                        };
3772

    
3773
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3774
                                        currentControl.CommentID = Commons.shortGuid();
3775
                                        currentControl.IsNew = true;
3776
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3777
                                    }
3778
                                //}
3779
                            }
3780
                        }
3781
                        break;
3782
                    case ControlType.Circle:
3783
                        {
3784
                            if (mouseButtonDown == MouseButton.Left)
3785
                            {
3786
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3787
                                //{
3788
                                    if (currentControl is CircleControl)
3789
                                    {
3790
                                        //20180906 LJY TEST IsRotationDrawingEnable
3791
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3792
                                        {
3793
                                            return;
3794
                                        }
3795

    
3796
                                        CreateControl();
3797

    
3798
                                        (currentControl as CircleControl).ApplyOverViewData();
3799
                                        currentControl = null;
3800
                                    }
3801
                                    else
3802
                                    {
3803
                                        currentControl = new CircleControl
3804
                                        {
3805
                                            Background = new SolidColorBrush(Colors.Black)
3806
                                        };
3807

    
3808
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3809
                                        currentControl.CommentID = Commons.shortGuid();
3810
                                        currentControl.IsNew = true;
3811
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3812
                                    }
3813
                                //}
3814
                            }
3815
                        }
3816
                        break;
3817
                    case ControlType.Triangle:
3818
                        {
3819
                            if (mouseButtonDown == MouseButton.Left)
3820
                            {
3821
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3822
                                //{
3823
                                    if (currentControl is TriControl)
3824
                                    {
3825
                                        var content = currentControl as TriControl;
3826
                                        if (content.MidPoint == new Point(0, 0))
3827
                                        {
3828
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3829
                                        }
3830
                                        else
3831
                                        {
3832
                                            //20180906 LJY TEST IsRotationDrawingEnable
3833
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3834
                                            {
3835
                                                return;
3836
                                            }
3837

    
3838
                                            CreateControl();
3839

    
3840
                                            (currentControl as TriControl).ApplyOverViewData();
3841
                                            currentControl = null;
3842
                                        }
3843
                                    }
3844
                                    else
3845
                                    {
3846
                                        currentControl = new TriControl
3847
                                        {
3848
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3849
                                            Background = new SolidColorBrush(Colors.Black),
3850
                                        };
3851

    
3852
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3853
                                        currentControl.CommentID = Commons.shortGuid();
3854
                                        currentControl.IsNew = true;
3855
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3856
                                    }
3857
                                //}
3858
                            }
3859
                        }
3860
                        break;
3861
                    case ControlType.SingleLine:
3862
                        {
3863
                            if (mouseButtonDown == MouseButton.Left)
3864
                            {
3865
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3866
                                //{
3867
                                    if (currentControl is LineControl)
3868
                                    {
3869
                                        //20180906 LJY TEST IsRotationDrawingEnable
3870
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3871
                                        {
3872
                                            return;
3873
                                        }
3874

    
3875
                                        CreateControl();
3876

    
3877
                                        (currentControl as LineControl).ApplyOverViewData();
3878
                                        currentControl = null;
3879
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3880
                                    }
3881
                                    else
3882
                                    {
3883
                                        currentControl = new LineControl
3884
                                        {
3885
                                            Background = new SolidColorBrush(Colors.Black)
3886
                                        };
3887

    
3888
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3889
                                        currentControl.CommentID = Commons.shortGuid();
3890
                                        currentControl.IsNew = true;
3891
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3892
                                        this.MainAngle.Visibility = Visibility.Visible;
3893
                                    }
3894
                                //}
3895
                            }
3896
                        }
3897
                        break;
3898
                    case ControlType.CancelLine:
3899
                        {
3900
                            if (mouseButtonDown == MouseButton.Left)
3901
                            {
3902
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3903
                                //{
3904
                                    if (currentControl is LineControl)
3905
                                    {
3906
                                        //20180906 LJY TEST IsRotationDrawingEnable
3907
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3908
                                        {
3909
                                            return;
3910
                                        }
3911

    
3912
                                        CreateControl();
3913

    
3914
                                        (currentControl as LineControl).ApplyOverViewData();
3915
                                        currentControl = null;
3916
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3917
                                    }
3918
                                    else
3919
                                    {
3920
                                        currentControl = new LineControl
3921
                                        {
3922
                                            Background = new SolidColorBrush(Colors.Black)
3923
                                        };
3924

    
3925
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3926
                                        currentControl.CommentID = Commons.shortGuid();
3927
                                        currentControl.IsNew = true;
3928
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3929
                                        this.MainAngle.Visibility = Visibility.Visible;
3930
                                    }
3931
                                //}
3932
                            }
3933
                        }
3934
                        break;
3935
                    case ControlType.ArrowLine:
3936
                        {
3937
                            if (mouseButtonDown == MouseButton.Left)
3938
                            {
3939
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3940
                                //{
3941
                                    if (currentControl is LineControl)
3942
                                    {
3943
                                        //20180906 LJY TEST IsRotationDrawingEnable
3944
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3945
                                        {
3946
                                            return;
3947
                                        }
3948

    
3949
                                        CreateControl();
3950

    
3951
                                        (currentControl as LineControl).ApplyOverViewData();
3952
                                        currentControl = null;
3953
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3954
                                    }
3955
                                    else
3956
                                    {
3957
                                        currentControl = new LineControl
3958
                                        {
3959
                                            Background = new SolidColorBrush(Colors.Black)
3960
                                        };
3961

    
3962
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3963
                                        currentControl.CommentID = Commons.shortGuid();
3964
                                        currentControl.IsNew = true;
3965
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3966
                                        this.MainAngle.Visibility = Visibility.Visible;
3967
                                    }
3968
                                //}
3969
                            }
3970
                        }
3971
                        break;
3972
                    case ControlType.TwinLine:
3973
                        {
3974
                            if (mouseButtonDown == MouseButton.Left)
3975
                            {
3976
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3977
                                //{
3978
                                    if (currentControl is LineControl)
3979
                                    {
3980
                                        //20180906 LJY TEST IsRotationDrawingEnable
3981
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3982
                                        {
3983
                                            return;
3984
                                        }
3985

    
3986
                                        CreateControl();
3987

    
3988
                                        (currentControl as LineControl).ApplyOverViewData();
3989
                                        currentControl = null;
3990
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3991
                                    }
3992
                                    else
3993
                                    {
3994
                                        currentControl = new LineControl
3995
                                        {
3996
                                            Background = new SolidColorBrush(Colors.Black)
3997
                                        };
3998
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3999
                                        currentControl.CommentID = Commons.shortGuid();
4000
                                        currentControl.IsNew = true;
4001
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4002
                                        this.MainAngle.Visibility = Visibility.Visible;
4003
                                    }
4004
                                //}
4005
                            }
4006
                        }
4007
                        break;
4008
                    case ControlType.DimLine:
4009
                        {
4010
                            if (mouseButtonDown == MouseButton.Left)
4011
                            {
4012
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4013
                                //{
4014
                                    if (currentControl is LineControl)
4015
                                    {
4016
                                        //20180906 LJY TEST IsRotationDrawingEnable
4017
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4018
                                        {
4019
                                            return;
4020
                                        }
4021
                                        CreateControl();
4022

    
4023
                                        (currentControl as LineControl).ApplyOverViewData();
4024
                                        currentControl = null;
4025
                                        this.MainAngle.Visibility = Visibility.Collapsed;
4026
                                    }
4027
                                    else
4028
                                    {
4029
                                        currentControl = new LineControl
4030
                                        {
4031
                                            Background = new SolidColorBrush(Colors.Black)
4032
                                        };
4033
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4034
                                        currentControl.CommentID = Commons.shortGuid();
4035
                                        currentControl.IsNew = true;
4036
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4037
                                        this.MainAngle.Visibility = Visibility.Visible;
4038
                                    }
4039
                                //}
4040
                            }
4041
                        }
4042
                        break;
4043
                    case ControlType.ChainLine:
4044
                        {
4045
                            if (currentControl is PolygonControl)
4046
                            {
4047
                                var control = currentControl as PolygonControl;
4048

    
4049
                                if (mouseButtonDown == MouseButton.Right)
4050
                                {
4051
                                    //20180906 LJY TEST IsRotationDrawingEnable
4052
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4053
                                    {
4054
                                        return;
4055
                                    }
4056

    
4057
                                    CreateControl();
4058

    
4059
                                    (currentControl as PolygonControl).ApplyOverViewData();
4060
                                    currentControl = null;
4061
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4062
                                    return;
4063
                                }
4064

    
4065
                                if (!control.IsCompleted)
4066
                                {
4067
                                    control.PointSet.Add(control.EndPoint);
4068
                                    this.MainAngle.Visibility = Visibility.Visible;
4069
                                }
4070
                            }
4071
                            else
4072
                            {
4073
                                if (mouseButtonDown == MouseButton.Left)
4074
                                {
4075
                                    MainAngle.Visibility = Visibility.Visible;
4076
                                    currentControl = new PolygonControl
4077
                                    {
4078
                                        PointSet = new List<Point>(),
4079
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
4080
                                        ControlType = ControlType.ChainLine,
4081
                                        DashSize = ViewerDataModel.Instance.DashSize,
4082
                                        LineSize = ViewerDataModel.Instance.LineSize,
4083
                                        //PointC = new StylusPointSet()
4084
                                    };
4085

    
4086
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4087
                                    //{
4088
                                        var polygonControl = (currentControl as PolygonControl);
4089
                                        currentControl.CommentID = Commons.shortGuid();
4090
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4091
                                        currentControl.IsNew = true;
4092
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4093
                                        //currentControl.OnApplyTemplate();
4094
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
4095
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
4096
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4097
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4098
                                    //}
4099
                                }
4100
                            }
4101
                        }
4102
                        break;
4103
                    case ControlType.ArcLine:
4104
                        {
4105
                            if (mouseButtonDown == MouseButton.Left)
4106
                            {
4107
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4108
                                //{
4109
                                    if (currentControl is ArcControl)
4110
                                    {
4111
                                        //20180906 LJY TEST IsRotationDrawingEnable
4112
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4113
                                        {
4114
                                            return;
4115
                                        }
4116

    
4117
                                        CreateControl();
4118

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

    
4162
                                    CreateControl();
4163

    
4164
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
4165
                                    currentControl = null;
4166
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4167
                                }
4168
                                else
4169
                                {
4170
                                    currentControl = new ArrowArcControl
4171
                                    {
4172
                                        Background = new SolidColorBrush(Colors.Black)
4173
                                    };
4174
                                    currentControl.CommentID = Commons.shortGuid();
4175
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4176
                                    currentControl.IsNew = true;
4177
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4178
                                    this.MainAngle.Visibility = Visibility.Visible;
4179
                                }
4180
                                //}
4181
                            }
4182
                            else if (mouseButtonDown == MouseButton.Right)
4183
                            {
4184
                                if (currentControl != null)
4185
                                {
4186
                                    (currentControl as ArrowArcControl).setClock();
4187
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
4188
                                    //(currentControl as ArcControl).ApplyTemplate();
4189
                                }
4190
                            }
4191
                        }
4192
                        break;
4193
                    case ControlType.ArrowMultiLine:
4194
                        {
4195
                            if (mouseButtonDown == MouseButton.Left)
4196
                            {
4197
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4198
                                //{
4199

    
4200
                                    if (currentControl is ArrowControl_Multi)
4201
                                    {
4202
                                        var content = currentControl as ArrowControl_Multi;
4203
                                        if (content.MiddlePoint == new Point(0, 0))
4204
                                        {
4205
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
4206
                                            {
4207
                                                content.MiddlePoint = content.EndPoint;
4208
                                            }
4209
                                            else
4210
                                            {
4211
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4212
                                            }
4213
                                        }
4214
                                        else
4215
                                        {
4216
                                            //20180906 LJY TEST IsRotationDrawingEnable
4217
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4218
                                            {
4219
                                                return;
4220
                                            }
4221

    
4222
                                            CreateControl();
4223

    
4224
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
4225
                                            currentControl = null;
4226
                                            this.MainAngle.Visibility = Visibility.Collapsed;
4227
                                        }
4228
                                    }
4229
                                    else
4230
                                    {
4231
                                        currentControl = new ArrowControl_Multi
4232
                                        {
4233
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4234
                                            Background = new SolidColorBrush(Colors.Black)
4235
                                        };
4236
                                        currentControl.CommentID = Commons.shortGuid();
4237
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4238
                                        currentControl.IsNew = true;
4239
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4240
                                        this.MainAngle.Visibility = Visibility.Visible;
4241
                                    }
4242
                                //}
4243
                            }
4244
                        }
4245
                        break;
4246
                    case ControlType.PolygonCloud:
4247
                        {
4248
                            if (currentControl is CloudControl)
4249
                            {
4250
                                var control = currentControl as CloudControl;
4251
                                if (mouseButtonDown == MouseButton.Right)
4252
                                {
4253
                                    control.IsCompleted = true;
4254
                                }
4255

    
4256
                                if (!control.IsCompleted)
4257
                                {
4258
                                    control.PointSet.Add(control.EndPoint);
4259
                                }
4260
                                else
4261
                                {
4262
                                    //20180906 LJY TEST IsRotationDrawingEnable
4263
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4264
                                    {
4265
                                        return;
4266
                                    }
4267

    
4268
                                    CreateControl();
4269

    
4270
                                    control.isTransOn = true;
4271
                                    var firstPoint = control.PointSet.First();
4272

    
4273
                                    control.PointSet.Add(firstPoint);
4274
                                    control.DrawingCloud();
4275
                                    control.ApplyOverViewData();
4276

    
4277
                                    currentControl = null;
4278
                                }
4279
                            }
4280
                            else
4281
                            {
4282
                                if (mouseButtonDown == MouseButton.Left)
4283
                                {
4284
                                    currentControl = new CloudControl
4285
                                    {
4286
                                        PointSet = new List<Point>(),
4287
                                        PointC = new StylusPointSet()
4288
                                    };
4289

    
4290
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4291
                                    //{
4292
                                        var polygonControl = (currentControl as CloudControl);
4293
                                        currentControl.CommentID = Commons.shortGuid();
4294
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4295
                                        currentControl.IsNew = true;
4296
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4297

    
4298
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4299
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4300
                                    
4301
                                    //}
4302
                                }
4303
                            }
4304
                        }
4305
                        break;
4306
                    case ControlType.ImgControl:
4307
                        {
4308
                            if (mouseButtonDown == MouseButton.Left)
4309
                            {
4310
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4311
                                //{
4312
                                    if (currentControl is ImgControl)
4313
                                    {
4314
                                        //20180906 LJY TEST IsRotationDrawingEnable
4315
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4316
                                        {
4317
                                            return;
4318
                                        }
4319

    
4320
                                        CreateControl();
4321
                                        (currentControl as ImgControl).ApplyOverViewData();
4322
                                        controlType = ControlType.ImgControl;
4323
                                        currentControl = null;
4324
                                    }
4325
                                    else
4326
                                    {
4327
                                        
4328
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4329
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4330
                                        {
4331
                                            Image img = new Image();
4332
                                            //img.Source = new BitmapImage(new Uri(filename));
4333
                                            if (filename.Contains(".svg"))
4334
                                            {
4335
                                                byte[] imageData = null;
4336
                                                DrawingImage image = null;
4337
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4338
                                                {
4339
                                                    imageData = web.DownloadData(new Uri(filename));
4340
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4341
                                                    image = SvgReader.Load(stream);
4342
                                                }
4343
                                                img.Source = image;
4344
                                            }
4345
                                            else
4346
                                            {
4347
                                                img.Source = new BitmapImage(new Uri(filename));
4348
                                            }
4349

    
4350
                                            currentControl = new ImgControl
4351
                                            {
4352
                                                    Background = new SolidColorBrush(Colors.Black),
4353
                                                    PointSet = new List<Point>(),
4354
                                                    FilePath = filename,
4355
                                                    ImageData = img.Source,
4356
                                                    StartPoint = canvasDrawingMouseDownPoint,
4357
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4358
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4359
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4360
                                                    ControlType = ControlType.ImgControl
4361
                                                };
4362

    
4363
                                        
4364
                                                currentControl.CommentID = Commons.shortGuid();                                            
4365
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4366
                                                currentControl.IsNew = true;
4367
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4368

    
4369
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4370
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4371
                                        }
4372
                                    }
4373
                                //}
4374
                            }
4375
                        }
4376
                        break;
4377
                    case ControlType.Date:
4378
                        {
4379
                            if (mouseButtonDown == MouseButton.Left)
4380
                            {
4381
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4382
                                //{
4383
                                    if (currentControl is DateControl)
4384
                                    {
4385
                                        //20180906 LJY TEST IsRotationDrawingEnable
4386
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4387
                                        {
4388
                                            return;
4389
                                        }
4390

    
4391
                                        CreateControl();
4392
                                        (currentControl as DateControl).ApplyOverViewData();
4393
                                        currentControl = null;
4394

    
4395
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4396
                                        {
4397
                                            controlType = ControlType.None;
4398
                                            IsSwingMode = false;
4399
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4400
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4401
                                            mouseHandlingMode = MouseHandlingMode.None;
4402
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4403
                                            txtBatch.Visibility = Visibility.Collapsed;
4404

    
4405
                                        }
4406
                                    }
4407
                                    else
4408
                                    {
4409
                                        currentControl = new DateControl
4410
                                        {
4411
                                            Background = new SolidColorBrush(Colors.Black)
4412
                                        };
4413
                                        currentControl.CommentID = Commons.shortGuid();
4414
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4415
                                        currentControl.IsNew = true;
4416
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4417

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

    
4450
                                    CreateControl();
4451

    
4452
                                }
4453
                            }
4454
                        }
4455
                        break;
4456
                    case ControlType.TextBorder:
4457
                        {
4458
                            if (mouseButtonDown == MouseButton.Left)
4459
                            {
4460
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4461
                                {
4462
                                    currentControl = new TextControl
4463
                                    {
4464
                                        ControlType = controlType
4465
                                    };
4466

    
4467
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4468
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4469
                                    currentControl.CommentID = Commons.shortGuid();
4470
                                    currentControl.IsNew = true;
4471
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4472
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4473
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4474
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4475
                                    
4476
                                    (currentControl as TextControl).ControlType_No = 1;
4477
                                    (currentControl as TextControl).Angle = Ang;
4478
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4479
                                    (currentControl as TextControl).ApplyTemplate();
4480
                                    (currentControl as TextControl).Base_TextBox.Focus();
4481
                                    CreateControl();
4482

    
4483
                                    //currentControl = null;
4484
                                }
4485
                            }
4486
                        }
4487
                        break;
4488
                    case ControlType.TextCloud:
4489
                        {
4490
                            if (mouseButtonDown == MouseButton.Left)
4491
                            {
4492
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4493
                                {
4494
                                    currentControl = new TextControl
4495
                                    {
4496
                                        ControlType = controlType
4497
                                    };
4498

    
4499
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4500
                                    currentControl.CommentID = Commons.shortGuid();
4501
                                    currentControl.IsNew = true;
4502
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4503
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4504

    
4505
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4506
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4507
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4508

    
4509
                                    (currentControl as TextControl).Angle = Ang;
4510
                                    (currentControl as TextControl).ControlType_No = 2;
4511
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4512
                                    (currentControl as TextControl).ApplyTemplate();
4513
                                    (currentControl as TextControl).Base_TextBox.Focus();
4514
                                    CreateControl();
4515
                                    //currentControl = null;
4516
                                }
4517
                            }
4518
                        }
4519
                        break;
4520
                    case ControlType.ArrowTextControl:
4521
                         {
4522
                            if (mouseButtonDown == MouseButton.Left)
4523
                            {
4524
                                if (currentControl is ArrowTextControl)
4525
                                {
4526
                                    //20180906 LJY TEST IsRotationDrawingEnable
4527
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4528
                                    {
4529
                                        return;
4530
                                    }                                    
4531

    
4532
                                    CreateControl();
4533

    
4534
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4535
                                    (currentControl as ArrowTextControl).IsEditing = false;
4536
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4537
                                    (currentControl as ArrowTextControl).IsNew = false;
4538
                                    currentControl = null;
4539
                                }
4540
                                else
4541
                                {
4542
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4543
                                    //{
4544
                                        currentControl = new ArrowTextControl();
4545
                                        currentControl.CommentID = Commons.shortGuid();
4546
                                        currentControl.IsNew = true;
4547
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4548
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4549

    
4550
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4551
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4552
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4553
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4554
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4555

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

    
4559
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4560
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4561
                                        this.MainAngle.Visibility = Visibility.Visible;
4562

    
4563
                                    
4564
                                    //}
4565
                                }
4566
                            }
4567
                        }
4568
                        break;
4569
                    case ControlType.ArrowTransTextControl:
4570
                        {
4571
                            if (mouseButtonDown == MouseButton.Left)
4572
                            {
4573
                                if (currentControl is ArrowTextControl)
4574
                                {
4575
                                    //20180906 LJY TEST IsRotationDrawingEnable
4576
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4577
                                    {
4578
                                        return;
4579
                                    }                                    
4580

    
4581
                                    CreateControl();
4582
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4583
                                    currentControl.IsNew = false;
4584
                                    currentControl = null;
4585
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4586
                                }
4587
                                else
4588
                                {
4589
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4590
                                    //{
4591
                                         currentControl = new ArrowTextControl();
4592
                                        currentControl.CommentID = Commons.shortGuid();
4593
                                        currentControl.IsNew = true;
4594
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4595
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4596
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4597
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4598
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4599
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4600
                                        (currentControl as ArrowTextControl).isFixed = true;
4601
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4602

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

    
4606
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4607
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4608
                                        (currentControl as ArrowTextControl).isTrans = true;
4609
                                }
4610
                            }
4611
                        }
4612
                        break;
4613
                    case ControlType.ArrowTextBorderControl:
4614
                         {
4615
                            if (mouseButtonDown == MouseButton.Left)
4616
                            {
4617
                                if (currentControl is ArrowTextControl)
4618
                                {
4619
                                    //20180906 LJY TEST IsRotationDrawingEnable
4620
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4621
                                    {
4622
                                        return;
4623
                                    }
4624

    
4625
                                    CreateControl();
4626
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4627
                                    currentControl.IsNew = false;
4628
                                    currentControl = null;
4629
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4630
                                }
4631
                                else
4632
                                {
4633
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4634
                                    //{
4635
                                        currentControl = new ArrowTextControl()
4636
                                        {
4637
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4638
                                        };
4639
                                        currentControl.CommentID = Commons.shortGuid();
4640
                                        currentControl.IsNew = true;
4641
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4642
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4643

    
4644
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4645

    
4646
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4647

    
4648
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4649
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4650
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4651

    
4652
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4653
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4654
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4655
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4656
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4657
                                    //}
4658
                                }
4659
                            }
4660
                        }
4661
                        break;
4662
                    case ControlType.ArrowTransTextBorderControl:
4663
                        {
4664
                            if (mouseButtonDown == MouseButton.Left)
4665
                            {
4666
                                if (currentControl is ArrowTextControl)
4667
                                {
4668
                                    //20180906 LJY TEST IsRotationDrawingEnable
4669
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4670
                                    {
4671
                                        return;
4672
                                    }
4673
                                    CreateControl();
4674
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4675
                                    currentControl.IsNew = false;
4676
                                    currentControl = null;
4677
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4678
                                }
4679
                                else
4680
                                {
4681
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4682
                                    //{
4683
                                    
4684

    
4685
                                    currentControl = new ArrowTextControl()
4686
                                        {
4687
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4688
                                        };
4689
                                        currentControl.CommentID = Commons.shortGuid();
4690
                                        currentControl.IsNew = true;
4691
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4692
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4693

    
4694
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4695

    
4696
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4697
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4698
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4699
                                        (currentControl as ArrowTextControl).isFixed = true;
4700
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4701
                                     
4702
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4703
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4704
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4705

    
4706
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4707
                                        this.MainAngle.Visibility = Visibility.Visible;
4708
                                    
4709
                                    //20180911 LJY
4710
                                        (currentControl as ArrowTextControl).isTrans = true;
4711
                                    
4712

    
4713
                                    //}
4714
                                }
4715
                            }
4716
                        }
4717
                        break;
4718
                    case ControlType.ArrowTextCloudControl:
4719
                        {
4720
                            if (mouseButtonDown == MouseButton.Left)
4721
                            {
4722
                                if (currentControl is ArrowTextControl)
4723
                                {
4724
                                    //20180906 LJY TEST IsRotationDrawingEnable
4725
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4726
                                    {
4727
                                        return;
4728
                                    }
4729
                                    CreateControl();
4730
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4731
                                    currentControl.IsNew = false;
4732
                                    currentControl = null;
4733
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4734
                                }
4735
                                else
4736
                                {
4737
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4738
                                    //{
4739
                                        currentControl = new ArrowTextControl()
4740
                                        {
4741
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4742
                                        };
4743
                                        currentControl.CommentID = Commons.shortGuid();
4744
                                        currentControl.IsNew = true;
4745
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4746
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4747

    
4748
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4749
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4750
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4751
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4752
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4753

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

    
4796
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4797
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4798
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4799
                                        (currentControl as ArrowTextControl).isFixed = true;
4800
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4801

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

    
4805
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4806
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4807
                                        this.MainAngle.Visibility = Visibility.Visible;  
4808
                                    
4809
                                    //20180911 LJY
4810
                                        (currentControl as ArrowTextControl).isTrans = true;
4811
                                    //}
4812
                                }
4813
                            }
4814
                        }
4815
                        break;
4816
                    case ControlType.PolygonControl:
4817
                        {
4818
                            if (currentControl is PolygonControl)
4819
                            {
4820
                                var control = currentControl as PolygonControl;
4821

    
4822
                                if (mouseButtonDown == MouseButton.Right)
4823
                                {
4824
                                    control.IsCompleted = true;
4825
                                }
4826

    
4827
                                if (!control.IsCompleted)
4828
                                {
4829
                                    control.PointSet.Add(control.EndPoint);
4830
                                }
4831
                                else
4832
                                {
4833
                                    //20180906 LJY TEST IsRotationDrawingEnable
4834
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4835
                                    {
4836
                                        return;
4837
                                    }
4838

    
4839
                                    var firstPoint = control.PointSet.First();
4840
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4841
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4842
                                    control.PointSet.Add(firstPoint);
4843

    
4844
                                    ///control.SetPolyPath();
4845

    
4846
                                    control.ApplyOverViewData();
4847

    
4848
                                    CreateControl();
4849
                                    control.updateControl();
4850
                                    currentControl = null;
4851
                                }
4852
                            }
4853
                            else
4854
                            {
4855
                                if (mouseButtonDown == MouseButton.Left)
4856
                                {
4857
                                    currentControl = new PolygonControl
4858
                                    {
4859
                                        PointSet = new List<Point>(),
4860
                                    };
4861

    
4862
                                    var polygonControl = (currentControl as PolygonControl);
4863
                                    currentControl.CommentID = Commons.shortGuid();
4864
                                    currentControl.IsNew = true;
4865
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4866
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4867
                                    //currentControl.OnApplyTemplate();
4868
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4869
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4870
                                    polygonControl.ApplyTemplate();
4871
                                    polygonControl.Visibility = Visibility.Visible;
4872
                                }
4873
                            }
4874
                        }
4875
                        break;
4876
                    //강인구 추가
4877
                    case ControlType.Sign:
4878
                        {
4879
                            if (mouseButtonDown == MouseButton.Left)
4880
                            {
4881
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4882
                                //{
4883
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4884

    
4885
                                    if (_sign == null)
4886
                                    {
4887
                                        txtBatch.Visibility = Visibility.Collapsed;
4888
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4889
                                        controlType = ControlType.None;
4890

    
4891
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4892
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4893
                                        return;
4894
                                    }
4895

    
4896
                                    if (currentControl is SignControl)
4897
                                    {
4898
                                        //20180906 LJY TEST IsRotationDrawingEnable
4899
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4900
                                        {
4901
                                            return;
4902
                                        }
4903

    
4904
                                        CreateControl();
4905
                                        currentControl = null;
4906
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4907
                                        {
4908
                                            txtBatch.Text = "Place Date";
4909
                                            controlType = ControlType.Date;
4910
                                        }
4911
                                    }
4912
                                    else
4913
                                    {
4914
                                        currentControl = new SignControl
4915
                                        {
4916
                                            Background = new SolidColorBrush(Colors.Black),
4917
                                            UserNumber = App.ViewInfo.UserID,
4918
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4919
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4920
                                            ControlType = ControlType.Sign
4921
                                        };
4922

    
4923
                                        currentControl.CommentID = Commons.shortGuid();
4924
                                        currentControl.IsNew = true;
4925
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4926
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4927

    
4928
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4929
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4930
                                }
4931
                                //}
4932
                            }
4933
                        }
4934
                        break;
4935
                    case ControlType.Mark:
4936
                        {
4937
                            if (mouseButtonDown == MouseButton.Left)
4938
                            {
4939
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4940
                                //{
4941
                                    if (currentControl is RectangleControl)
4942
                                    {
4943
                                        //20180906 LJY TEST IsRotationDrawingEnable
4944
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4945
                                        {
4946
                                            return;
4947
                                        }
4948

    
4949
                                        CreateControl();
4950
                                        (currentControl as RectangleControl).ApplyOverViewData();
4951
                                        currentControl = null;
4952
                                    
4953
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4954

    
4955
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4956
                                        {
4957
                                            txtBatch.Text = "Place Signature";
4958
                                            controlType = ControlType.Sign;
4959
                                        }
4960
                                    }
4961
                                    else
4962
                                    {
4963
                                        currentControl = new RectangleControl
4964
                                        {
4965
                                            Background = new SolidColorBrush(Colors.Black),
4966
                                            Paint = PaintSet.Fill
4967
                                        };
4968

    
4969
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4970
                                        currentControl.CommentID = Commons.shortGuid();
4971
                                        currentControl.IsNew = true;
4972
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4973
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4974
                                    }
4975
                                //}
4976
                            }
4977
                        }
4978
                        break;
4979
                    case ControlType.Symbol:
4980
                        {
4981
                            if (mouseButtonDown == MouseButton.Left)
4982
                            {
4983
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4984
                                //{
4985
                                    if (currentControl is SymControl)
4986
                                    {
4987
                                        //20180906 LJY TEST IsRotationDrawingEnable
4988
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4989
                                        {
4990
                                            return;
4991
                                        }
4992
                                        CreateControl();
4993
                                        currentControl = null;
4994
                                    
4995
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4996
                                    }
4997
                                    else
4998
                                    {
4999
                                        currentControl = new SymControl
5000
                                        {
5001
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5002
                                            Background = new SolidColorBrush(Colors.Black),
5003
                                            ControlType = ControlType.Symbol
5004
                                        };
5005

    
5006
                                        currentControl.IsNew = true;
5007
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5008
                                        currentControl.CommentID = Commons.shortGuid();
5009
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5010

    
5011
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
5012
                                        (currentControl as SymControl).Angle -= rotate.Angle;
5013
                                }
5014
                                //}
5015
                            }
5016
                        }
5017
                        break;
5018
                    case ControlType.Stamp:
5019
                        {
5020
                            if (mouseButtonDown == MouseButton.Left)
5021
                            {
5022
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
5023
                                //{
5024
                                    if (currentControl is SymControlN)
5025
                                    {
5026
                                        //20180906 LJY TEST IsRotationDrawingEnable
5027
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
5028
                                        {
5029
                                            return;
5030
                                        }
5031

    
5032
                                        CreateControl();
5033
                                        currentControl = null;
5034
                                   
5035

    
5036
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
5037
                                    }
5038
                                    else
5039
                                    {
5040
                                        currentControl = new SymControlN
5041
                                        {
5042
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
5043
                                            Background = new SolidColorBrush(Colors.Black),
5044
                                            ControlType = ControlType.Stamp
5045
                                        };
5046

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

    
5095
                            var over = (item as AdornerFinal).MemberSet.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
5096
                            if (over != null)
5097
                            {
5098
                                mouseOff = true;
5099
                            }
5100
                        }
5101
                    }
5102

    
5103
                    if (!mouseOff)
5104
                    {
5105
                        SelectionSet.Instance.UnSelect(this);
5106
                    }
5107
                }
5108
                zoomAndPanControl.CaptureMouse();
5109
                e.Handled = true;
5110
            }
5111
        }
5112

    
5113
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5114
        {
5115
            mouseButtonDown = e.ChangedButton;
5116
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5117
        }
5118

    
5119
        private void RemoveLineStroke(Point P)
5120
        {
5121
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
5122
            if (control != null)
5123
            {
5124
                UndoData = new Undo_data()
5125
                {
5126
                    IsUndo = false,
5127
                    Event = Event_Type.Delete,
5128
                    EventTime = DateTime.Now,
5129
                    Markup_List = new List<Multi_Undo_data>()
5130
                };
5131

    
5132

    
5133
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5134
                UndoData.Markup_List.Add(multi_Undo_Data);
5135
                multi_Undo_Data = new Multi_Undo_data();
5136

    
5137
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
5138
                var Item_ = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
5139
                ViewerDataModel.Instance.MarkupList_USER.Remove(Item_);
5140
                
5141
                //임시파일에서도 삭제한다.
5142
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
5143
                
5144
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
5145
                {
5146
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5147
                });
5148
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5149

    
5150
            }
5151
        }
5152

    
5153
        private void RemovePointStroke(Point P)
5154
        {
5155
            foreach (Stroke hits in inkBoard.Strokes)
5156
            {
5157
                foreach (StylusPoint sty in hits.StylusPoints)
5158
                {
5159

    
5160
                }
5161
                if (hits.HitTest(P))
5162
                {
5163
                    inkBoard.Strokes.Remove(hits);
5164
                    return;
5165
                }
5166
            }
5167
        }
5168

    
5169
        private void StartNewStroke(Point P)
5170
        {
5171
            strokePoints = new StylusPointCollection();
5172
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5173
            strokePoints.Add(segment1Start);
5174
            stroke = new Stroke(strokePoints);
5175

    
5176
            stroke.DrawingAttributes.Color = Colors.Red;
5177
            stroke.DrawingAttributes.Width = 4;
5178
            stroke.DrawingAttributes.Height = 4;
5179

    
5180
            inkBoard.Strokes.Add(stroke);
5181

    
5182
        }
5183

    
5184
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5185
        {
5186
            ConsolidationMethod();
5187
        }
5188

    
5189
        public void TeamConsolidationMethod()
5190
        {
5191
            ChangeCommentReact();
5192
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5193
            {
5194
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5195
            }
5196
            else
5197
            {
5198
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5199
                {
5200
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
5201
                    {
5202
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
5203
                        return;
5204
                    }                    
5205
                }
5206
                ViewerDataModel.Instance.IsConsolidate = true;
5207
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5208
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5209

    
5210
                string project_no = App.ViewInfo.ProjectNO;
5211
                string doc_id = _DocInfo.ID;
5212
                string user_id = App.ViewInfo.UserID;
5213
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5214
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5215
                {
5216
                    markupInfoItems.Add(item);
5217
                }
5218
                Logger.sendReqLog("TeamConsolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5219
                Logger.sendResLog("TeamConsolidate", this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5220
                //this.BaseClient.TeamConsolidate(project_no, user_id, doc_id, markupInfoItems);
5221

    
5222
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5223
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5224
            }
5225
        }
5226
        public void ConsolidationMethod()
5227
        {
5228
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5229
            {
5230
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5231
            }
5232
            else
5233
            {
5234
                /*
5235
                ViewerDataModel.Instance.IsConsolidate = true;
5236
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5237

    
5238
                string project_no = App.ViewInfo.ProjectNO;
5239
                string doc_id = _DocInfo.ID;
5240
                string user_id = App.ViewInfo.UserID;
5241
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5242
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5243
                {
5244
                    markupInfoItems.Add(item);
5245
                }
5246
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5247
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5248

    
5249
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5250
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5251
                */
5252
                
5253
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
5254
                foreach (var item in this.gridViewMarkup.SelectedItems)
5255
                {
5256
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
5257
                }
5258
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
5259

    
5260
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
5261
            }
5262
        }
5263

    
5264
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5265
        {
5266
            if (App.ViewInfo != null)
5267
            {
5268
                btnConsolidate = (sender as RadRibbonButton);
5269
                if (!App.ViewInfo.NewCommentPermission)
5270
                {
5271
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5272
                }
5273
            }
5274
        }
5275

    
5276
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5277
        {
5278
            TeamConsolidationMethod();
5279
        }
5280

    
5281
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5282
        {
5283
            btnTeamConsolidate = sender as RadRibbonButton;
5284
            if (App.ViewInfo != null)
5285
            {
5286
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5287
                {
5288
                    if (btnConsolidate != null)
5289
                    {
5290
                        btnConsolidate.Visibility = Visibility.Collapsed;
5291
                    }
5292

    
5293
                    if (!App.ViewInfo.NewCommentPermission)
5294
                    {
5295
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5296
                    }
5297
                }
5298
                else
5299
                {
5300
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5301
                }
5302
            }
5303
        }
5304

    
5305
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5306
        {
5307
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5308
            if (item != null)
5309
            {
5310
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5311

    
5312
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5313
            }
5314
            else
5315
            {
5316
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5317
            }
5318
        }
5319

    
5320
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5321
        {
5322
            btnFinalPDF = sender as RadRibbonButton;
5323
            if (App.ViewInfo != null)
5324
            {
5325
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5326
                {
5327
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5328
                    if (btnConsolidate != null)
5329
                    {
5330
                        btnConsolidate.Visibility = Visibility.Collapsed;
5331
                    }
5332
                }
5333
            }
5334
        }
5335

    
5336
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5337
        {
5338
            ChangeCommentReact();
5339

    
5340
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5341
            {
5342
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5343
            }
5344
            else
5345
            {
5346
                ViewerDataModel.Instance.IsConsolidate = true;
5347
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5348
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5349

    
5350
                string project_no = App.ViewInfo.ProjectNO;
5351
                string doc_id = _DocInfo.ID;
5352
                string user_id = App.ViewInfo.UserID;
5353
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5354
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5355
                {
5356
                    markupInfoItems.Add(item);
5357
                }
5358
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5359
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5360
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5361
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5362

    
5363
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5364
                if (item2 != null)
5365
                {
5366
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5367

    
5368
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5369
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5370
                }
5371
                else
5372
                {
5373
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5374
                }
5375
            }
5376
        }
5377

    
5378
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5379
        {
5380
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5381

    
5382
            if (App.ViewInfo != null)
5383
            {
5384
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5385
                {
5386
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5387
                }
5388
            }
5389
        }
5390

    
5391
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5392
        {
5393
            if (CompareMode.IsChecked)
5394
            {
5395
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5396
                {
5397
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5398
                }
5399
                if (ViewerDataModel.Instance.PageNumber == 0)
5400
                {
5401
                    ViewerDataModel.Instance.PageNumber = 1;
5402
                }
5403

    
5404
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5405
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5406
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5407

    
5408
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5409
            }
5410
            else
5411
            {
5412
                da.From = 1;
5413
                da.To = 1;
5414
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5415
                da.AutoReverse = false;
5416
                canvas_compareBorder.Children.Clear();
5417
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5418
            }
5419
        }
5420

    
5421
        private void Sync_Click(object sender, RoutedEventArgs e)
5422
        {
5423
            if (Sync.IsChecked)
5424
            {
5425
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5426
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5427
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5428
            }
5429
        }
5430

    
5431
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5432
        {
5433
            if (UserList.IsChecked)
5434
            {
5435
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5436
            }
5437
            else
5438
            {
5439
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5440
            }
5441
        }
5442

    
5443
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5444
        {
5445

    
5446
            if (BalanceMode.IsChecked)
5447
            {
5448
                ViewerDataModel.Instance.PageBalanceMode = true;
5449
            }
5450
            else
5451
            {
5452
                ViewerDataModel.Instance.PageBalanceMode = false;
5453
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5454
            }
5455
        }
5456

    
5457
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5458
        {
5459
            //초기화
5460
            testPanel2.IsHidden = true;
5461
            ViewerDataModel.Instance.PageBalanceMode = false;
5462
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5463
            ViewerDataModel.Instance.PageNumber = 0;
5464
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5465
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5466
            UserList.IsChecked = false;
5467
            BalanceMode.IsChecked = false;
5468
        }
5469

    
5470
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5471
        {
5472
            if ((sender as System.Windows.Controls.Control).Tag != null)
5473
            {
5474
                //Compare 초기화
5475
                CompareMode.IsChecked = false;
5476
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5477

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

    
5483
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5484
                {
5485
                }
5486
                else
5487
                {
5488
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5489
                }
5490

    
5491
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5492
                {
5493

    
5494
                }
5495
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5496
                {
5497
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5498
                }
5499

    
5500
                if (!testPanel2.IsHidden)
5501
                {
5502
                    if (IsSyncPDFMode)
5503
                    {
5504
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5505
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5506

    
5507
                        if (pdfpath.IsDownloading)
5508
                        {
5509
                            pdfpath.DownloadCompleted += (ex, arg) =>
5510
                            {
5511
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5512
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5513
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5514
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5515
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5516
                            };
5517
                        }
5518
                        else
5519
                        {
5520
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5521
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5522
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5523

    
5524
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5525
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5526
                        }
5527

    
5528
                    }
5529
                    else
5530
                    {
5531
                        string uri = "";
5532

    
5533
                        if (userData.COMPANY != "EXT")
5534
                        {
5535
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5536
                        }
5537
                        else
5538
                        {
5539
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5540
                        }
5541

    
5542
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5543

    
5544
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5545
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5546
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5547

    
5548
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5549
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5550

    
5551
                        if (defaultBitmapImage_Compare.IsDownloading)
5552
                        {
5553
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5554
                            {
5555
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5556
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5557
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5558

    
5559
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5560
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5561
                            };
5562
                        }
5563
                    }
5564

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

    
5569
                    foreach (var item in gridSelectionRevItem)
5570
                    {
5571
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5572
                        {
5573
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5574
                        });
5575
                    }
5576

    
5577
                    //강인구 추가
5578
                    zoomAndPanControl2.ZoomTo(new Rect
5579
                    {
5580
                        X = 0,
5581
                        Y = 0,
5582
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5583
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5584
                    });
5585

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

    
5588
                }
5589
            }
5590
        }
5591

    
5592
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5593
        {
5594
            if (MarkupMode.IsChecked)
5595
            {
5596
                IsSyncPDFMode = true;
5597

    
5598
                var uri = CurrentRev.TO_VENDOR;
5599

    
5600
                if (ViewerDataModel.Instance.PageNumber == 0)
5601
                {
5602
                    ViewerDataModel.Instance.PageNumber = 1;
5603
                }
5604

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

    
5609
                if (pdfpath.IsDownloading)
5610
                {
5611
                    pdfpath.DownloadCompleted += (ex, arg) =>
5612
                    {
5613
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5614
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5615
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5616
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5617
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5618
                    };
5619
                }
5620
                else
5621
                {
5622
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5623
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5624
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5625

    
5626
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5627
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5628
                }
5629
            }
5630
            else
5631
            {
5632
                IsSyncPDFMode = false;
5633
                string uri = "";
5634
                if (userData.COMPANY != "EXT")
5635
                {
5636
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5637
                }
5638
                else
5639
                {
5640
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5641
                }
5642

    
5643
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5644

    
5645
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5646
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5647
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5648

    
5649
                if (defaultBitmapImage_Compare.IsDownloading)
5650
                {
5651
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5652
                    {
5653
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5654
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5655
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5656
                    };
5657
                }
5658
                zoomAndPanControl2.ApplyTemplate();
5659
                zoomAndPanControl2.UpdateLayout();
5660
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5661
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5662
            }
5663
        }
5664

    
5665
        private void RadButton_Click(object sender, RoutedEventArgs e)
5666
        {
5667
            gridViewHistory_Busy.IsBusy = true;
5668

    
5669
            RadButton instance = sender as RadButton;
5670
            if (instance.CommandParameter != null)
5671
            {
5672
                CurrentRev = instance.CommandParameter as VPRevision;
5673
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5674
                {
5675
                    if (ea.Error == null && ea.Result != null)
5676
                    {
5677
                        testPanel2.IsHidden = false;
5678

    
5679
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5680
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5681

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

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

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

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

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

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

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

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

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

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

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

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

    
5748
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5749
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5750

    
5751
                    string uri = "";
5752
                    if (userData.COMPANY != "EXT")
5753
                    {
5754
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5755
                    }
5756
                    else
5757
                    {
5758
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5759
                    }
5760

    
5761
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5762

    
5763
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5764

    
5765
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5766
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5767
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5768

    
5769
                    if (defaultBitmapImage_Compare.IsDownloading)
5770
                    {
5771
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5772
                        {
5773
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5774
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5775
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5776
                        };
5777
                    }
5778

    
5779

    
5780
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5781
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5782
                    zoomAndPanControl2.ApplyTemplate();
5783
                    zoomAndPanControl2.UpdateLayout();
5784

    
5785
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5786
                    {
5787
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5788
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5789
                    }
5790
                    //}
5791

    
5792
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5793
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5794
                    gridViewHistory_Busy.IsBusy = false;
5795
                }
5796
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5797

    
5798
            };
5799
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5800
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5801
        }
5802

    
5803
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5804
        {
5805
            if (sender is Image)
5806
            {
5807
                if ((sender as Image).Tag != null)
5808
                {
5809
                    var pdfUrl = (sender as Image).Tag.ToString();
5810
                    System.Diagnostics.Process.Start(pdfUrl);
5811
                }
5812
                else
5813
                {
5814
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5815
                }
5816
            }
5817
        }
5818

    
5819
        private void Create_Symbol(object sender, RoutedEventArgs e)
5820
        {
5821
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5822

    
5823
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5824
            {
5825
                DialogMessage_Alert("Please Select Controls", "Alert");
5826
            }
5827
            else //선택된 것이 있으면
5828
            {
5829
                string MarkupData = "";
5830
                adorner_ = new AdornerFinal();
5831

    
5832
                foreach (var item in SelectLayer.Children)
5833
                {
5834
                    if (item.GetType().Name == "AdornerFinal")
5835
                    {
5836
                        adorner_ = (item as Controls.AdornerFinal);
5837
                        foreach (var InnerItem in (item as Controls.AdornerFinal).MemberSet.Cast<Controls.AdornerMember>())
5838
                        {
5839
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5840
                            {
5841
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5842
                                MarkupData += markupReturn.ConvertData;
5843
                            }
5844
                        }
5845
                    }
5846
                }
5847
                DialogParameters parameters = new DialogParameters()
5848
                {
5849
                    Owner = Application.Current.MainWindow,
5850
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5851
                    DefaultPromptResultValue = "Custom State",
5852
                    Content = "Name :",
5853
                    Header = "Insert Custom Symbol Name",
5854
                    Theme = new VisualStudio2013Theme(),
5855
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5856
                };
5857
                RadWindow.Prompt(parameters);
5858
            }
5859

    
5860
        }
5861
        public int symbolselectindex = 0;
5862
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5863
        {
5864
            //Save save = new Save();
5865
            try
5866
            {
5867
                string svgfilename = null;
5868
                if (symbolname != null)
5869
                {
5870
                    if (symbolpng == true || symbolsvg == true)
5871
                    {
5872
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5873
                        string guid = Commons.shortGuid();
5874

    
5875
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5876
                        //Check_Uri.UriCheck();
5877
                        fileUploader.RunCompleted += (ex, arg) =>
5878
                        {
5879
                            filename = arg.Result;
5880
                            if (symbolpng == true)
5881
                            {
5882
                                if (filename != null)
5883
                                { 
5884
                                    if (symbolselectindex == 0)
5885
                                    {
5886
                                        SymbolSave(symbolname, filename, data);
5887
                                    }
5888
                                    else
5889
                                    {
5890
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5891
                                    }
5892
                                    DataBind();
5893
                                }                                
5894
                            }
5895

    
5896
                            if (symbolsvg == true)
5897
                            {
5898
                                try
5899
                                {
5900
                                    var defaultBitmapImage = new BitmapImage();
5901
                                    defaultBitmapImage.BeginInit();
5902
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5903
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5904
                                    Check_Uri.UriCheck(filename);
5905
                                    defaultBitmapImage.UriSource = new Uri(filename);
5906
                                    defaultBitmapImage.EndInit();
5907

    
5908
                                    System.Drawing.Bitmap image;
5909

    
5910
                                    if (defaultBitmapImage.IsDownloading)
5911
                                    {
5912
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5913
                                        {
5914
                                            defaultBitmapImage.Freeze();
5915
                                            image = GetBitmap(defaultBitmapImage);
5916
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5917
                                            Process potrace = new Process
5918
                                            {
5919
                                                StartInfo = new ProcessStartInfo
5920
                                                {
5921
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5922
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5923
                                                    RedirectStandardInput = true,
5924
                                                    RedirectStandardOutput = true,
5925
                                                    RedirectStandardError = true,
5926
                                                    UseShellExecute = false,
5927
                                                    CreateNoWindow = true,
5928
                                                    WindowStyle = ProcessWindowStyle.Hidden
5929
                                                },
5930
                                            };
5931

    
5932
                                            StringBuilder svgBuilder = new StringBuilder();
5933
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5934
                                            {
5935
                                                svgBuilder.AppendLine(e2.Data);
5936
                                            };
5937

    
5938
                                            potrace.EnableRaisingEvents = true;
5939
                                            potrace.Start();
5940
                                            potrace.Exited += (sender, e) =>
5941
                                            {
5942
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5943
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5944
                                                Check_Uri.UriCheck(svgfilename);
5945
                                                if (symbolselectindex == 0)
5946
                                                {
5947
                                                    SymbolSave(symbolname, svgfilename, data);
5948
                                                }
5949
                                                else
5950
                                                {
5951
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5952
                                                }
5953

    
5954
                                                DataBind();
5955
                                            };
5956
                                            potrace.WaitForExit();
5957
                                        };
5958
                                    }
5959
                                    else
5960
                                    {
5961
                                        //GC.Collect();
5962
                                    }
5963
                                }
5964
                                catch(Exception ee)
5965
                                {
5966
                                    DialogMessage_Alert("" + ee, "Alert");
5967
                                }
5968
                            }
5969
                        };                                             
5970
                    }
5971
                }
5972
            }
5973
            catch (Exception e)
5974
            {
5975
                //DialogMessage_Alert(e + "", "Alert");
5976
            }            
5977
        }
5978

    
5979
        public void SymbolSave(string Name, string Url, string Data)
5980
        {
5981
            try
5982
            {
5983
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5984
                {
5985
                    ID = Commons.shortGuid(),
5986
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5987
                    NAME = Name,
5988
                    IMAGE_URL = Url,
5989
                    DATA = Data
5990
                };
5991

    
5992
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5993
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5994
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5995
            }
5996
            catch (Exception)
5997
            {
5998
                throw;
5999
            }
6000
        }
6001

    
6002
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
6003
        {
6004
            try
6005
            {
6006
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
6007
                {
6008
                    ID = Commons.shortGuid(),
6009
                    DEPARTMENT = Department,
6010
                    NAME = Name,
6011
                    IMAGE_URL = Url,
6012
                    DATA = Data
6013
                };
6014
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
6015
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
6016
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
6017
            }
6018
            catch (Exception)
6019
            {
6020
                throw;
6021
            }
6022
        }
6023

    
6024
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
6025
        {           
6026
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6027
            DataBind();
6028
        }
6029

    
6030
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
6031
        {
6032
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
6033
            DataBind();
6034
        }
6035
        private void DataBind()
6036
        {
6037
            try
6038
            {
6039
                Symbol_Custom Custom = new Symbol_Custom();
6040
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
6041
                ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
6042
                var symbol_Private = client.GetSymbolList(App.ViewInfo.UserID);
6043
                foreach (var item in symbol_Private)
6044
                {
6045
                    Custom.Name = item.NAME;
6046
                    Custom.ImageUri = item.IMAGE_URL;
6047
                    Custom.ID = item.ID;
6048
                    Custom_List.Add(Custom);
6049
                    Custom = new Symbol_Custom();
6050
                }
6051
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
6052
                
6053
                Custom = new Symbol_Custom();
6054
                Custom_List = new List<Symbol_Custom>();
6055

    
6056
                symbolPanel_Instance.deptlist.ItemsSource = client.GetPublicSymbolDeptList();
6057

    
6058
                List<SYMBOL_PUBLIC> symbol_Public;
6059

    
6060

    
6061
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
6062
                {
6063
                    symbol_Public = client.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
6064
                }
6065
                else
6066
                {
6067
                    symbol_Public = client.GetPublicSymbolList(null);
6068
                }
6069
                foreach (var item in symbol_Public)
6070
                {
6071
                    Custom.Name = item.NAME;
6072
                    Custom.ImageUri = item.IMAGE_URL;
6073
                    Custom.ID = item.ID;
6074
                    Custom_List.Add(Custom);
6075
                    Custom = new Symbol_Custom();
6076
                }
6077
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
6078
                client.Close();                
6079
            }
6080
            catch(Exception e)
6081
            {
6082
                //DialogMessage_Alert("DataBind", "Alert");
6083
            }
6084
            
6085
        }
6086
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
6087
        {
6088
            try
6089
            {
6090
                if (args.PromptResult != null)
6091
                {
6092
                    if (args.DialogResult.Value)
6093
                    {
6094
                        PngBitmapEncoder _Encoder = symImage(data);
6095

    
6096
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6097
                        _Encoder.Save(fs);
6098
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6099

    
6100
                        byte[] Img_byte = fs.ToArray();
6101

    
6102
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
6103
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
6104
                        Check_Uri.UriCheck(filename);
6105
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
6106
                        {
6107
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
6108
                        }
6109
                        else
6110
                        {
6111
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
6112
                        }
6113
                        DataBind();
6114
                    }
6115
                }
6116
            }
6117
            catch(Exception ex)
6118
            {
6119
                DialogMessage_Alert("" + ex, "Alert");
6120
            }
6121
        }
6122

    
6123
        public PngBitmapEncoder symImage(string data)
6124
        {
6125

    
6126
            Canvas _canvas = new Canvas();
6127
            _canvas.Background = Brushes.White;
6128
            _canvas.Width = adorner_.BorderSize.Width;
6129
            _canvas.Height = adorner_.BorderSize.Height;
6130
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
6131

    
6132
            BitmapEncoder encoder = new PngBitmapEncoder();
6133

    
6134

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

    
6137
            DrawingVisual dv = new DrawingVisual();
6138

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

    
6142
            using (DrawingContext ctx = dv.RenderOpen())
6143
            {
6144
                VisualBrush vb = new VisualBrush(_canvas);
6145
                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)));
6146
            }
6147

    
6148
            try
6149
            {
6150
                renderBitmap.Render(dv);
6151

    
6152
                //GC.Collect();
6153
                GC.WaitForPendingFinalizers();
6154
                //GC.Collect();
6155
                // encode png data
6156
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6157
                // puch rendered bitmap into it
6158
                pngEncoder.Interlace = PngInterlaceOption.Off;
6159
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6160
                return pngEncoder;
6161

    
6162
            }
6163
            catch //(Exception ex)
6164
            {
6165
                return null;
6166
            }
6167

    
6168
        }
6169

    
6170
        public void DialogMessage_Alert(string content, string header)
6171
        {
6172
            var box = new TextBlock();
6173
            box.MinWidth = 400;
6174
            box.FontSize = 11;
6175
            //box.FontSize = 12;
6176
            box.Text = content;
6177
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6178

    
6179
            DialogParameters parameters = new DialogParameters()
6180
            {
6181
                Owner = Application.Current.MainWindow,
6182
                Content = box,
6183
                Header = header,
6184
                Theme = new VisualStudio2013Theme(),
6185
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6186
            };            
6187
            RadWindow.Alert(parameters);
6188
        }
6189

    
6190
        #region 캡쳐 기능
6191

    
6192
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6193
        {
6194
            if (x < 0)
6195
            {
6196
                width += x;
6197
                x = 0;
6198
            }
6199
            if (y < 0)
6200
            {
6201
                height += y;
6202
                y = 0;
6203

    
6204
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6205
            }
6206
            if (x + width > zoomAndPanCanvas.ActualWidth)
6207
            {
6208
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6209
            }
6210
            if (y + height > zoomAndPanCanvas.ActualHeight)
6211
            {
6212
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6213
            }
6214

    
6215
            byte[] pixels = CopyPixels(x, y, width, height);
6216

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

    
6219
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6220
        }
6221

    
6222
        public byte[] CopyPixels(int x, int y, int width, int height)
6223
        {
6224
            byte[] pixels = new byte[width * height * 4];
6225
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6226

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

    
6230
            return pixels;
6231
        }
6232

    
6233
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6234
        {
6235
            DrawingVisual drawingVisual = new DrawingVisual();
6236
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6237

    
6238
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6239
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6240
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6241
            drawingContext.Close();
6242

    
6243
            // 비트맵으로 변환합니다.
6244
            RenderTargetBitmap target =
6245
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6246
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6247

    
6248
            target.Render(drawingVisual);
6249
            return target;
6250
        }
6251

    
6252
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6253
        {
6254
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6255
            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);
6256
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6257
            bmp.UnlockBits(data);
6258
            return bmp;
6259
        }
6260
        public string symbolname = null;
6261
        public bool symbolsvg = true;
6262
        public bool symbolpng = true;
6263

    
6264
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6265
        {
6266
            System.Drawing.Bitmap image = GetBitmap(source);
6267
            //흰색 제거
6268
            //image.MakeTransparent(System.Drawing.Color.White);
6269

    
6270
            var imageStream = new System.IO.MemoryStream();
6271
            byte[] imageBytes = null;
6272
            using (imageStream)
6273
            {
6274
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6275
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6276
                imageStream.Position = 0;
6277
                imageBytes = imageStream.ToArray();
6278
            }
6279

    
6280
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6281

    
6282
            RadWindow CheckPop = new RadWindow();
6283
            //Alert check = new Alert(Msg);
6284

    
6285
            CheckPop = new RadWindow
6286
            {
6287
                MinWidth = 400,
6288
                MinHeight = 100,
6289
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6290
                Header = "Alert",
6291
                Content = symbolPrompt,
6292
                //DialogResult = 
6293
                ResizeMode = System.Windows.ResizeMode.NoResize,
6294
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6295
                IsTopmost = true,
6296
            };
6297
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6298
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6299
            CheckPop.ShowDialog();
6300

    
6301
            /*
6302
            DialogParameters parameters = new DialogParameters()
6303
            {
6304
                Owner = Application.Current.MainWindow,
6305
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6306
                DefaultPromptResultValue = "Custom State",
6307
                Content = "Name :",
6308
                Header = "Insert Custom Symbol Name",
6309
                Theme = new VisualStudio2013Theme(),
6310
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6311
            };            
6312
            RadWindow.Prompt(parameters);
6313
            */
6314
        }
6315

    
6316
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6317
        {
6318
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6319
            KCOMDataModel.DataModel.CHECK_LIST check_;
6320
            string Result = streamToBase64.ImageToBase64(source);
6321
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6322
            string projectno = App.ViewInfo.ProjectNO;
6323
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6324

    
6325
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6326
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6327
            if (Item != null)
6328
            {
6329
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6330
            }
6331
            else
6332
            {
6333
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6334
            }
6335

    
6336
            if (Item == null)
6337
            {
6338
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6339
                {
6340
                    ID = Commons.shortGuid(),
6341
                    USER_ID = App.ViewInfo.UserID,
6342
                    IMAGE_URL = Result,
6343
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6344
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6345
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6346
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6347
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6348
                    STATUS = "False",
6349
                    CREATE_TIME = DateTime.Now,
6350
                    UPDATE_TIME = DateTime.Now,
6351
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6352
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6353
                };
6354
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6355
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6356
                //this.BaseClient.AddCheckList(projectno, check_);
6357
            }
6358
            else
6359
            {
6360
                Item.IMAGE_URL = Result;
6361
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6362
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6363
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6364
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6365
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6366
            }
6367

    
6368
        }
6369

    
6370
        public void Set_Capture()
6371
        {
6372
            double x = canvasDrawingMouseDownPoint.X;
6373
            double y = canvasDrawingMouseDownPoint.Y;
6374
            double width = dragCaptureBorder.Width;
6375
            double height = dragCaptureBorder.Height;
6376

    
6377
            if (width > 5 || height > 5)
6378
            {
6379
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6380
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6381
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6382
            }
6383
        }
6384
        #endregion
6385

    
6386
        //MarkupInfoItem
6387
        public void CreateControl()
6388
        {
6389

    
6390
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6391
            {
6392
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6393
            });
6394
            multi_Undo_Data.Markup = currentControl;
6395
            UndoData.Markup_List.Add(multi_Undo_Data);
6396

    
6397
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6398

    
6399
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6400
        }
6401

    
6402
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6403
        {
6404
            multi_Undo_Data = new Multi_Undo_data();
6405

    
6406
            multi_Undo_Data.Markup = control;
6407

    
6408
            if ((control as IShapeControl) != null)
6409
            {
6410
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6411
            }
6412
            if ((control as IDashControl) != null)
6413
            {
6414
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6415
            }
6416
            if ((control as IPath) != null)
6417
            {
6418
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6419
            }
6420
            if ((control as UIElement) != null)
6421
            {
6422
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6423
            }
6424

    
6425
            return multi_Undo_Data;
6426
        }
6427

    
6428
        public void Undo()
6429
        {
6430
            // if (ViewerDataModel.Instance.IsPressCtrl)
6431
            //   {
6432
            //      ViewerDataModel.Instance.IsPressCtrl = false;
6433
            //   }
6434
            Undo_data undo = new Undo_data();
6435
            AdornerFinal final;
6436
            SelectionSet.Instance.UnSelect(this);
6437

    
6438
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6439
            if (undo == null)
6440
                return;
6441

    
6442

    
6443

    
6444
            switch (undo.Event)
6445
            {
6446
                case (Event_Type.Create):
6447
                    {
6448
                        foreach (var item in undo.Markup_List)
6449
                        {
6450
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6451
                        }
6452
                    }
6453
                    break;
6454
                case (Event_Type.Delete):
6455
                    {
6456
                        foreach (var item in undo.Markup_List)
6457
                        {
6458
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6459
                        }
6460
                    }
6461
                    break;
6462
                case (Event_Type.Thumb):
6463
                    {
6464
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6465

    
6466
                        foreach (var item in undo.Markup_List)
6467
                        {
6468
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6469

    
6470
                            if ((item.Markup as IViewBox) != null)
6471
                            {
6472
                                (item.Markup as IViewBox).Angle = item.Angle;
6473
                            }
6474
                            if ((item.Markup as TextControl) != null)
6475
                            {
6476
                                (item.Markup as TextControl).Angle = item.Angle;
6477
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6478
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6479
                            }
6480
                            else
6481
                            {
6482
                                (item.Markup as IPath).PointSet = item.PointSet;
6483
                                (item.Markup as IPath).updateControl();
6484
                            }
6485

    
6486
                            comment.Add(item.Markup);
6487
                        }
6488
                        final = new AdornerFinal(comment);
6489
                        SelectLayer.Children.Add(final);
6490
                        SelectionSet.Instance.UnSelect(this);
6491
                    }
6492
                    break;
6493
                case (Event_Type.Select):
6494
                    {
6495
                        SelectionSet.Instance.UnSelect(this);
6496
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6497

    
6498
                        foreach (var item in undo.Markup_List)
6499
                        {
6500
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6501

    
6502
                            if ((item.Markup as IPath) != null)
6503
                            {
6504
                                (item.Markup as IPath).LineSize = item.LineSize;
6505
                            }
6506
                            if ((item.Markup as UIElement) != null)
6507
                            {
6508
                                (item.Markup as UIElement).Opacity = item.Opacity;
6509
                            }
6510
                            if ((item.Markup as IDashControl) != null)
6511
                            {
6512
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6513
                            }
6514
                            if ((item.Markup as IShapeControl) != null)
6515
                            {
6516
                                (item.Markup as IShapeControl).Paint = item.paint;
6517
                            }
6518

    
6519
                            comment.Add(item.Markup);
6520
                        }
6521

    
6522
                        final = new AdornerFinal(comment);
6523
                        SelectLayer.Children.Add(final);
6524
                    }
6525
                    break;
6526
                case (Event_Type.Option):
6527
                    {
6528
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6529

    
6530
                        foreach (var item in undo.Markup_List)
6531
                        {
6532
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6533

    
6534
                            if (undo.LineSize != 0 && item.Markup as IPath != null)
6535
                            {
6536
                                (item.Markup as IPath).LineSize = undo.LineSize;
6537
                            }
6538
                            else if (undo.Opacity != 0 && item.Markup as UIElement != null)
6539
                            {
6540
                                (item.Markup as UIElement).Opacity = undo.Opacity;
6541
                            }
6542
                            else if (undo.DashSize != null && item.Markup as IDashControl != null)
6543
                            {
6544
                                (item.Markup as IDashControl).DashSize = undo.DashSize;
6545
                            }
6546
                            else if (undo.Interval != 0 && item.Markup as LineControl != null)
6547
                            {
6548
                                (item.Markup as LineControl).Interval = undo.Interval;
6549
                            }
6550
                            else if (item.Markup as IShapeControl != null)
6551
                            {
6552
                                (item.Markup as IShapeControl).Paint = undo.paint;
6553
                            }
6554
                            comment.Add(item.Markup);
6555
                        }
6556
                        final = new AdornerFinal(comment);
6557
                        SelectLayer.Children.Add(final);
6558
                    }
6559
                    break;
6560
            }
6561
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == undo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6562
            {
6563
                i.IsUndo = true;
6564
            });
6565
        }
6566

    
6567

    
6568

    
6569
        public void Redo()
6570
        {
6571
            //if (ViewerDataModel.Instance.IsPressCtrl)
6572
            //{
6573
            //    ViewerDataModel.Instance.IsPressCtrl = false;
6574
            //}
6575
            AdornerFinal final;
6576
            Undo_data redo = new Undo_data();
6577
            redo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().OrderBy(order => order.EventTime).FirstOrDefault();
6578
            SelectionSet.Instance.UnSelect(this);
6579
            if (redo == null)
6580
                return;
6581

    
6582
            switch (redo.Event)
6583
            {
6584
                case (Event_Type.Create):
6585
                    {
6586
                        foreach (var item in redo.Markup_List)
6587
                        {
6588
                            ViewerDataModel.Instance.MarkupControls_USER.Add(item.Markup);
6589
                            //temp.AddTemp(redo, pageNavigator.CurrentPage.PageNumber, 0, 0);
6590
                        }
6591
                    }
6592
                    break;
6593
                case (Event_Type.Delete):
6594
                    {
6595
                        foreach (var item in redo.Markup_List)
6596
                        {
6597
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6598
                        }
6599
                    }
6600
                    break;
6601
                case (Event_Type.Thumb):
6602
                    {
6603
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6604

    
6605
                        foreach (var item in redo.Markup_List)
6606
                        {
6607
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6608

    
6609
                            if ((item.Markup as IViewBox) != null)
6610
                            {
6611
                                (item.Markup as IViewBox).Angle = item.Angle;
6612
                            }
6613
                            if ((item.Markup as TextControl) != null)
6614
                            {
6615
                                (item.Markup as TextControl).Angle = item.Angle;
6616

    
6617
                                Canvas.SetLeft((item.Markup as TextControl), item.PointSet[0].X);
6618
                                Canvas.SetTop((item.Markup as TextControl), item.PointSet[0].Y);
6619
                            }
6620
                            else
6621
                            {
6622
                                (item.Markup as IPath).PointSet = item.PointSet;
6623
                                (item.Markup as IPath).updateControl();
6624
                            }
6625
                            comment.Add(item.Markup);
6626
                        }
6627
                        final = new AdornerFinal(comment);
6628
                        SelectLayer.Children.Add(final);
6629
                        SelectionSet.Instance.UnSelect(this);
6630
                    }
6631
                    break;
6632
                case (Event_Type.Select):
6633
                    {
6634
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6635

    
6636
                        foreach (var item in redo.Markup_List)
6637
                        {
6638
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6639

    
6640
                            if ((item.Markup as IPath) != null)
6641
                            {
6642
                                (item.Markup as IPath).LineSize = item.LineSize;
6643
                            }
6644
                            if ((item.Markup as UIElement) != null)
6645
                            {
6646
                                (item.Markup as UIElement).Opacity = item.Opacity;
6647
                            }
6648
                            if ((item.Markup as IDashControl) != null)
6649
                            {
6650
                                (item.Markup as IDashControl).DashSize = item.DashSize;
6651
                            }
6652
                            if ((item.Markup as IShapeControl) != null)
6653
                            {
6654
                                (item.Markup as IShapeControl).Paint = item.paint;
6655
                            }
6656

    
6657
                            comment.Add(item.Markup);
6658
                        }
6659
                        final = new AdornerFinal(comment);
6660
                        SelectLayer.Children.Add(final);
6661
                    }
6662
                    break;
6663
                case (Event_Type.Option):
6664
                    {
6665
                        List<CommentUserInfo> comment = new List<CommentUserInfo>();
6666

    
6667
                        foreach (var item in redo.Markup_List)
6668
                        {
6669
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6670
                            if (redo.LineSize != 0 && item.Markup as IPath != null)
6671
                            {
6672
                                (item.Markup as IPath).LineSize = redo.LineSize;
6673
                            }
6674
                            else if (redo.Opacity != 0 && item.Markup as UIElement != null)
6675
                            {
6676
                                (item.Markup as UIElement).Opacity = redo.Opacity;
6677
                            }
6678
                            else if (redo.DashSize != null && item.Markup as IDashControl != null)
6679
                            {
6680
                                (item.Markup as IDashControl).DashSize = redo.DashSize;
6681
                            }
6682
                            else if (redo.Interval != 0 && item.Markup as LineControl != null)
6683
                            {
6684
                                (item.Markup as LineControl).Interval = redo.Interval;
6685
                            }
6686
                            else if (item.Markup as IShapeControl != null)
6687
                            {
6688
                                (item.Markup as IShapeControl).Paint = redo.paint;
6689
                            }
6690
                            comment.Add(item.Markup);
6691
                        }
6692
                        final = new AdornerFinal(comment);
6693
                        SelectLayer.Children.Add(final);
6694
                    }
6695
                    break;
6696
            }
6697

    
6698
            ViewerDataModel.Instance.UndoDataList.Where(data => data.EventTime == redo.EventTime).ToList().OrderByDescending(order => order.EventTime).ToList().ForEach(i =>
6699
            {
6700
                i.IsUndo = false;
6701
            });
6702
        }
6703

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

    
6754
                    removingStroke.Add(stroke);
6755

    
6756
                    InkToPath ip = new InkToPath();
6757
                    List<Point> inkPointSet = new List<Point>();
6758
                    PolygonControl pc = null;
6759
                    pc = new PolygonControl()
6760
                    {
6761
                        Angle = 0,
6762
                        PointSet = new List<Point>(),
6763
                        ControlType = ControlType.Ink
6764
                    };
6765
                    foreach (var item in removingStroke)
6766
                    {
6767
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6768
                        inkBoard.Strokes.Remove(item);
6769
                    }
6770
                    if (inkPointSet.Count != 0)
6771
                    {
6772
                        //강인구 추가(PenControl Undo Redo 추가)
6773
                        UndoData = new Undo_data()
6774
                        {
6775
                            IsUndo = false,
6776
                            Event = Event_Type.Create,
6777
                            EventTime = DateTime.Now,
6778
                            Markup_List = new List<Multi_Undo_data>()
6779
                        };
6780

    
6781
                        pc.StartPoint = inkPointSet[0];
6782
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6783
                        pc.PointSet = inkPointSet;
6784
                        pc.LineSize = 3;
6785
                        pc.CommentID = Commons.shortGuid();
6786
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6787
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6788
                        ///pc.SetPolyPath();
6789

    
6790
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6791
                        {
6792
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6793
                        });
6794
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6795
                        UndoData.Markup_List.Add(multi_Undo_Data);
6796
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6797
                    }
6798
                });
6799
            }
6800
        }
6801

    
6802
        /// <summary>
6803
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6804
        /// </summary>
6805
        /// <param name="StartP">StartPoint</param>
6806
        /// <param name="EndP">EndPoint</param>
6807
        /// <returns>Return_EndPoint</returns>
6808
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6809
        {
6810
            Point Return_Point = new Point();
6811

    
6812
            double dx = EndP.X - StartP.X;
6813
            double dy = EndP.Y - StartP.Y;
6814
            double length;
6815

    
6816
            switch (controlType)
6817
            {
6818
                case ControlType.Triangle:
6819
                    {
6820
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6821
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6822
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6823
                    }
6824
                    break;
6825
                default:
6826
                    {
6827
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6828
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6829
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6830
                    }
6831
                    break;
6832
            }
6833

    
6834
            return Return_Point;
6835
        }
6836

    
6837
        /// <summary>
6838
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6839
        /// </summary>
6840
        /// <author>humkyung</author>
6841
        /// <date>2018.04.26</date>
6842
        /// <param name="StartP"></param>
6843
        /// <param name="EndP"></param>
6844
        /// <returns></returns>
6845
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6846
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6847
        {
6848
            List<Point> res = new List<Point>();
6849

    
6850
            double dx = EndP.X - StartP.X;
6851
            double dy = EndP.Y - StartP.Y;
6852
            double length = Math.Sqrt(dx * dx + dy * dy);
6853
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6854
            dx /= length;
6855
            dy /= length;
6856
            double tmp = dx;
6857
            dx = -dy; dy = tmp; /// rotate by 90 degree
6858

    
6859
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6860
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6861

    
6862
            return res;
6863
        }
6864

    
6865
        /// <summary>
6866
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6867
        /// </summary>
6868
        /// <author>ingu</author>
6869
        /// <date>2018.06.05</date>
6870
        /// <param name="getPoint"></param>
6871
        /// <returns></returns>
6872
        private bool IsGetoutpoint(Point getPoint)
6873
        {
6874
            if (getPoint == new Point())
6875
            {
6876
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6877
                currentControl = null;
6878
                return true;
6879
            }
6880

    
6881
            return false;
6882
        }
6883

    
6884
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6885
        {
6886
            e.Effects = DragDropEffects.Copy;
6887
        }
6888

    
6889
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6890
        {
6891
            e.Effects = DragDropEffects.Copy;
6892
        }
6893

    
6894
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6895
        {
6896
            e.Effects = DragDropEffects.None;
6897
        }
6898

    
6899
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6900
        {
6901
            try
6902
            {
6903
                if (e.Data.GetDataPresent(typeof(string)))
6904
                {
6905
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6906
                    string dragData = e.Data.GetData(typeof(string)) as string;
6907
                    Move_Symbol(sender, dragData);
6908
                }
6909
            }
6910
            catch (Exception ex)
6911
            {
6912
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6913
            }            
6914
        }
6915

    
6916
        private void Move_Symbol(object sender, string dragData)
6917
        {
6918
            try
6919
            {
6920
                if (dragData.Contains("|DZ|"))
6921
                {
6922
                    List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
6923

    
6924
                    string[] delimiterChars = { "|DZ|" };
6925
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6926

    
6927
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6928

    
6929
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6930

    
6931
                    //강인구 Undo/Redo 보류
6932
                    UndoData = new Undo_data()
6933
                    {
6934
                        IsUndo = false,
6935
                        Event = Event_Type.Create,
6936
                        EventTime = DateTime.Now,
6937
                        Markup_List = new List<Multi_Undo_data>()
6938
                    };
6939

    
6940
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6941
                    {
6942
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6943
                    });
6944

    
6945
                    foreach (string parse in data)
6946
                    {
6947
                        if (parse != "")
6948
                        {
6949
                            System.Windows.Controls.Control item = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, parse, ViewerDataModel.Instance.MarkupControls_USER, string.Empty, string.Empty);
6950
                            (item as MarkupToPDF.Common.CommentUserInfo).CommentID = Commons.shortGuid();
6951

    
6952
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6953
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6954

    
6955
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6956

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

    
6959
                            UndoData.Markup_List.Add(multi_Undo_Data);
6960
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6961
                        }
6962
                    }
6963
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6964

    
6965
                    /// move symbol to current mouse point
6966
                    double realPointX = this.getCurrentPoint.X - final.BorderSize.X - (final.BorderSize.Width / 2);
6967
                    double realPointY = this.getCurrentPoint.Y - final.BorderSize.Y - (final.BorderSize.Height / 2);
6968
                    final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(realPointX, realPointY));
6969

    
6970
                    if (final.MemberSet.Where(type => type.Drawingtype == MarkupToPDF.Controls.Common.ControlType.TextControl).FirstOrDefault() != null)
6971
                    {
6972
                        final.MoveAdorner(new System.Windows.Controls.Primitives.DragDeltaEventArgs(0.001, 0.001)); //dummy
6973
                    }
6974
                    /// up to here
6975

    
6976
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Add(final);
6977
                }
6978
            }
6979
            catch (Exception ex)
6980
            {
6981
                Logger.sendResLog("Move_Symbol", ex.ToString(), 0);
6982
            }            
6983
        }        
6984
    }
6985
}
클립보드 이미지 추가 (최대 크기: 500 MB)