프로젝트

일반

사용자정보

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

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

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

    
521
        bool ComingNewBieEnd = false;
522

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

    
534
            InkControl_Convert();
535

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

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

    
543

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

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

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

    
558
            #endregion
559

    
560
            ViewerDataModel.Instance.PageNumber = BalancePoint;
561

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

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

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

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

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

    
601

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

    
607

    
608

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

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

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

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

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

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

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

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

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

    
700
            this.pageNavigator.SetNextPage();
701

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

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

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

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

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

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

    
742

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

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

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

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

    
764

    
765
        
766

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

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

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

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

    
827
        #region ZoomIn & ZoomOut
828

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

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

    
841

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

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

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

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

    
877
        }
878

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

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

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

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

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

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

    
931
        #endregion
932

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

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

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

    
945
        }
946

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

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

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

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

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

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

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

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

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

    
1138
      
1139
            CreateDragDropWindow2(img);
1140
        }
1141

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

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

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

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

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

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

    
1182

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

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

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

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

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

    
1262
                //        default:
1263
                //            {
1264

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1428

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

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

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

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

    
1472

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

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

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

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

    
1516

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

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

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

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

    
1560

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

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

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

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

    
1604

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

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

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

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

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

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

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

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

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

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

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

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

    
1702
                            }
1703
                            break;
1704

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

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

    
1728

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

    
1737

    
1738
                            }
1739
                            break;
1740

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

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

    
1763

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

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

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

    
1796

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

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

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

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

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

    
1843
                                if (control != null)
1844
                                {
1845

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

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

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

    
1863
                                    ///control.SetPolyPath();
1864

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

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

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

    
1892

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

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

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

    
1926

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

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

    
1971
                                    }
1972

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

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

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

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

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

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

    
2021
                                }
2022
                            }
2023
                            break;
2024

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

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

    
2034
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2035

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

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

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

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

    
2066

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2318
                                var control = currentControl as PolygonControl;
2319

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

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

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

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

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

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

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

    
2413
                                if (control != null)
2414
                                {
2415

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

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

    
2423

    
2424
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2425

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

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

    
2436
                                        //control.ApplyTemplate();
2437

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

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

    
2449

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

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

    
2477

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

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

    
2507
                if (isDraggingSelectionRect)
2508
                {
2509
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2510

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

    
2518
                    if (dragDistance > DragThreshold)
2519
                    {
2520
                        isDraggingSelectionRect = true;
2521

    
2522
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2523
                    }
2524

    
2525
                    e.Handled = true;
2526
                }
2527

    
2528

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

    
2551

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

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

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

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

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

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

    
2611
                //if (hitList.Count > 0)
2612
                //{
2613

    
2614
                //}
2615

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

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

    
2638
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2639
                //hitResultsList.Clear();
2640

    
2641
                #endregion
2642
            }
2643
        }
2644

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

    
2653
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2654

    
2655
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2656
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2657

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

    
2666
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2667

    
2668
        private EllipseGeometry hitArea = new EllipseGeometry();
2669

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

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

    
2680
                    SetCursor();
2681

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

    
2689
                            }
2690
                            break;
2691
                        case ControlType.PenControl:
2692
                            {
2693

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

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

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

    
2741
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2742

    
2743
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2744
                            }
2745

    
2746
                            isDraggingSelectionRect = false;
2747
                            e.Handled = true;
2748
                            wasDragSelectionApplied = true;
2749
                        }
2750

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

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

    
2770
                zoomAndPanControl.ReleaseMouseCapture();
2771

    
2772

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

    
2782
            //controlType = ControlType.SingleLine;
2783
        }
2784

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

    
2795
            double width = dragCaptureBorder.Width;
2796
            double height = dragCaptureBorder.Height;
2797

    
2798
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2799

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

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

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

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

    
2841
            //GC.Collect();
2842

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

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

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

    
2866
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2867
        {
2868

    
2869
        }
2870

    
2871
        private void ApplyDragSelectionRect()
2872
        {
2873
            multi_Undo_Data = new Multi_Undo_data();
2874

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

    
2883
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2884

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
3026
                }
3027
            }
3028
            return result;
3029
        }
3030

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

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

    
3064
            zoomAndPanControl.RotationAngle = rotate.Angle;
3065

    
3066

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

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

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

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

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

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

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

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

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

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

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

    
3189
            InkControl_Convert();
3190

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

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

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

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

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

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

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

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

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

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

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

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

    
3271
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3272
                SetCursor();
3273

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

    
3298
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3299

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

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

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

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

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

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

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

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

    
3366
                        Control_Style(control);
3367
                        UndoData.Markup_List.Add(multi_Undo_Data);
3368

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

    
3394
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3395

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

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

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

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

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

    
3488
                        Control_Style(control);
3489
                        UndoData.Markup_List.Add(multi_Undo_Data);
3490

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

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

    
3500
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3501

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

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

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

    
3565
                                    CreateControl();
3566

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

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

    
3594
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3595

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

    
3613
                                    CreateControl();
3614

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

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

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

    
3648
                                    CreateControl();
3649

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

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

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

    
3683
                                    CreateControl();
3684

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

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

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

    
3721
                                        CreateControl();
3722

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

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

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

    
3761
                                        CreateControl();
3762

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

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

    
3798
                                        CreateControl();
3799

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

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

    
3840
                                            CreateControl();
3841

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

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

    
3877
                                        CreateControl();
3878

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

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

    
3914
                                        CreateControl();
3915

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

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

    
3951
                                        CreateControl();
3952

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

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

    
3988
                                        CreateControl();
3989

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

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

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

    
4059
                                    CreateControl();
4060

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

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

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

    
4119
                                        CreateControl();
4120

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

    
4164
                                    CreateControl();
4165

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

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

    
4224
                                            CreateControl();
4225

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

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

    
4270
                                    CreateControl();
4271

    
4272
                                    control.isTransOn = true;
4273
                                    var firstPoint = control.PointSet.First();
4274

    
4275
                                    control.PointSet.Add(firstPoint);
4276
                                    control.DrawingCloud();
4277
                                    control.ApplyOverViewData();
4278

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

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

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

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

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

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

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

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

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

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

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

    
4451
                                    CreateControl();
4452

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

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

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

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

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

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

    
4533
                                    CreateControl();
4534

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4845
                                    ///control.SetPolyPath();
4846

    
4847
                                    control.ApplyOverViewData();
4848

    
4849
                                    CreateControl();
4850

    
4851
                                    currentControl = null;
4852
                                }
4853
                            }
4854
                            else
4855
                            {
4856
                                if (mouseButtonDown == MouseButton.Left)
4857
                                {
4858
                                    currentControl = new PolygonControl
4859
                                    {
4860
                                        PointSet = new List<Point>(),
4861
                                        //PointC = new StylusPointSet()
4862
                                    };
4863

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

    
4888
                                    if (_sign == null)
4889
                                    {
4890
                                        txtBatch.Visibility = Visibility.Collapsed;
4891
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4892
                                        controlType = ControlType.None;
4893

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

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

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

    
4926
                                        currentControl.CommentID = Commons.shortGuid();
4927
                                        currentControl.IsNew = true;
4928
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4929
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4930

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

    
4952
                                        CreateControl();
4953
                                        (currentControl as RectangleControl).ApplyOverViewData();
4954
                                        currentControl = null;
4955
                                    
4956
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4957

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

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

    
5009
                                        currentControl.IsNew = true;
5010
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
5011
                                        currentControl.CommentID = Commons.shortGuid();
5012
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
5013

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

    
5035
                                        CreateControl();
5036
                                        currentControl = null;
5037
                                   
5038

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

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

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

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

    
5116
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
5117
        {
5118
            mouseButtonDown = e.ChangedButton;
5119
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
5120
        }
5121

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

    
5135

    
5136
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
5137
                UndoData.Markup_List.Add(multi_Undo_Data);
5138
                multi_Undo_Data = new Multi_Undo_data();
5139

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

    
5153
            }
5154
        }
5155

    
5156
        private void RemovePointStroke(Point P)
5157
        {
5158
            foreach (Stroke hits in inkBoard.Strokes)
5159
            {
5160
                foreach (StylusPoint sty in hits.StylusPoints)
5161
                {
5162

    
5163
                }
5164
                if (hits.HitTest(P))
5165
                {
5166
                    inkBoard.Strokes.Remove(hits);
5167
                    return;
5168
                }
5169
            }
5170
        }
5171

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

    
5179
            stroke.DrawingAttributes.Color = Colors.Red;
5180
            stroke.DrawingAttributes.Width = 4;
5181
            stroke.DrawingAttributes.Height = 4;
5182

    
5183
            inkBoard.Strokes.Add(stroke);
5184

    
5185
        }
5186

    
5187
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5188
        {
5189
            ConsolidationMethod();
5190
        }
5191

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

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

    
5225
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5226
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5227
            }
5228
        }
5229
        public void ConsolidationMethod()
5230
        {
5231
            ChangeCommentReact();
5232

    
5233
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5234
            {
5235
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5236
            }
5237
            else
5238
            {
5239
                ViewerDataModel.Instance.IsConsolidate = true;
5240
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5241
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5242

    
5243
                string project_no = App.ViewInfo.ProjectNO;
5244
                string doc_id = _DocInfo.ID;
5245
                string user_id = App.ViewInfo.UserID;
5246
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5247
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5248
                {
5249
                    markupInfoItems.Add(item);
5250
                }
5251
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5252
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5253
                //this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
5254

    
5255
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5256
                this.BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5257

    
5258
            }
5259
        }
5260

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

    
5273
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5274
        {
5275
            TeamConsolidationMethod();
5276
        }
5277

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

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

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

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

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

    
5333
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5334
        {
5335
            ChangeCommentReact();
5336

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

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

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

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

    
5375
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5376
        {
5377
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5378

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

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

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

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

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

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

    
5440
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5441
        {
5442

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

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

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

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

    
5480
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5481
                {
5482
                }
5483
                else
5484
                {
5485
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5486
                }
5487

    
5488
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5489
                {
5490

    
5491
                }
5492
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5493
                {
5494
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5495
                }
5496

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

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

    
5521
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5522
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5523
                        }
5524

    
5525
                    }
5526
                    else
5527
                    {
5528
                        string uri = "";
5529

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

    
5539
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5540

    
5541
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5542
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5543
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5544

    
5545
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5546
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5547

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

    
5556
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5557
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5558
                            };
5559
                        }
5560
                    }
5561

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

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

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

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

    
5585
                }
5586
            }
5587
        }
5588

    
5589
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5590
        {
5591
            if (MarkupMode.IsChecked)
5592
            {
5593
                IsSyncPDFMode = true;
5594

    
5595
                var uri = CurrentRev.TO_VENDOR;
5596

    
5597
                if (ViewerDataModel.Instance.PageNumber == 0)
5598
                {
5599
                    ViewerDataModel.Instance.PageNumber = 1;
5600
                }
5601

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

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

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

    
5640
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5641

    
5642
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5643
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5644
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5645

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

    
5662
        private void RadButton_Click(object sender, RoutedEventArgs e)
5663
        {
5664
            gridViewHistory_Busy.IsBusy = true;
5665

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

    
5676
                        ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5677
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5678

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

    
5689
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5690

    
5691
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5692

    
5693
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5694
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5695
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5696

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

    
5707
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5708
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5709
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5710
                        zoomAndPanControl2.ApplyTemplate();
5711
                        zoomAndPanControl2.UpdateLayout();
5712

    
5713
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5714
                        {
5715
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5716
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5717
                        }
5718

    
5719
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5720
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5721
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5722

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

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

    
5735
        public void Sync_Event(VPRevision Currnet_Rev)
5736
        {
5737
            CurrentRev = Currnet_Rev;
5738

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

    
5745
                    ViewerDataModel.Instance._markupInfoRevList = SetDisplayColor(ea.Result, _ViewInfo.UserID);
5746
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5747

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

    
5758
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5759

    
5760
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5761

    
5762
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5763
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5764
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5765

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

    
5776

    
5777
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5778
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5779
                    zoomAndPanControl2.ApplyTemplate();
5780
                    zoomAndPanControl2.UpdateLayout();
5781

    
5782
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5783
                    {
5784
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5785
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5786
                    }
5787
                    //}
5788

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

    
5795
            };
5796
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5797
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5798
        }
5799

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

    
5816
        private void Create_Symbol(object sender, RoutedEventArgs e)
5817
        {
5818
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5819

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

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

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

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

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

    
5905
                                    System.Drawing.Bitmap image;
5906

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

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

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

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

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

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

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

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

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

    
6053
                symbolPanel_Instance.deptlist.ItemsSource = client.GetPublicSymbolDeptList();
6054

    
6055
                List<SYMBOL_PUBLIC> symbol_Public;
6056

    
6057

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

    
6093
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
6094
                        _Encoder.Save(fs);
6095
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
6096

    
6097
                        byte[] Img_byte = fs.ToArray();
6098

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

    
6120
        public PngBitmapEncoder symImage(string data)
6121
        {
6122

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

    
6129
            BitmapEncoder encoder = new PngBitmapEncoder();
6130

    
6131

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

    
6134
            DrawingVisual dv = new DrawingVisual();
6135

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

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

    
6145
            try
6146
            {
6147
                renderBitmap.Render(dv);
6148

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

    
6159
            }
6160
            catch //(Exception ex)
6161
            {
6162
                return null;
6163
            }
6164

    
6165
        }
6166

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

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

    
6187
        #region 캡쳐 기능
6188

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

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

    
6212
            byte[] pixels = CopyPixels(x, y, width, height);
6213

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

    
6216
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6217
        }
6218

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

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

    
6227
            return pixels;
6228
        }
6229

    
6230
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6231
        {
6232
            DrawingVisual drawingVisual = new DrawingVisual();
6233
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6234

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

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

    
6245
            target.Render(drawingVisual);
6246
            return target;
6247
        }
6248

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

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

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

    
6277
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6278

    
6279
            RadWindow CheckPop = new RadWindow();
6280
            //Alert check = new Alert(Msg);
6281

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

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

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

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

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

    
6365
        }
6366

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

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

    
6383
        //MarkupInfoItem
6384
        public void CreateControl()
6385
        {
6386

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

    
6394
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6395

    
6396
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6397
        }
6398

    
6399
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6400
        {
6401
            multi_Undo_Data = new Multi_Undo_data();
6402

    
6403
            multi_Undo_Data.Markup = control;
6404

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

    
6422
            return multi_Undo_Data;
6423
        }
6424

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

    
6435
            undo = ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == false).ToList().OrderByDescending(order => order.EventTime).FirstOrDefault();
6436
            if (undo == null)
6437
                return;
6438

    
6439

    
6440

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

    
6463
                        foreach (var item in undo.Markup_List)
6464
                        {
6465
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6466

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

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

    
6495
                        foreach (var item in undo.Markup_List)
6496
                        {
6497
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup));
6498

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

    
6516
                            comment.Add(item.Markup);
6517
                        }
6518

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

    
6527
                        foreach (var item in undo.Markup_List)
6528
                        {
6529
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6530

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

    
6564

    
6565

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

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

    
6602
                        foreach (var item in redo.Markup_List)
6603
                        {
6604
                            ViewerDataModel.Instance.MarkupControls_USER.Remove((item.Markup as CommentUserInfo));
6605

    
6606
                            if ((item.Markup as IViewBox) != null)
6607
                            {
6608
                                (item.Markup as IViewBox).Angle = item.Angle;
6609
                            }
6610
                            if ((item.Markup as TextControl) != null)
6611
                            {
6612
                                (item.Markup as TextControl).Angle = item.Angle;
6613

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

    
6633
                        foreach (var item in redo.Markup_List)
6634
                        {
6635
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item.Markup);
6636

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

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

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

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

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

    
6751
                    removingStroke.Add(stroke);
6752

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

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

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

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

    
6809
            double dx = EndP.X - StartP.X;
6810
            double dy = EndP.Y - StartP.Y;
6811
            double length;
6812

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

    
6831
            return Return_Point;
6832
        }
6833

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

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

    
6856
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6857
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6858

    
6859
            return res;
6860
        }
6861

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

    
6878
            return false;
6879
        }
6880

    
6881
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6882
        {
6883
            e.Effects = DragDropEffects.Copy;
6884
        }
6885

    
6886
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6887
        {
6888
            e.Effects = DragDropEffects.Copy;
6889
        }
6890

    
6891
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6892
        {
6893
            e.Effects = DragDropEffects.None;
6894
        }
6895

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

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

    
6921
                    string[] delimiterChars = { "|DZ|" };
6922
                    string[] data = dragData.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
6923

    
6924
                    SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
6925

    
6926
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
6927

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

    
6937
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
6938
                    {
6939
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
6940
                    });
6941

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

    
6949
                            ViewerDataModel.Instance.MarkupControls.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6950
                            ViewerDataModel.Instance.MarkupControls_USER.Remove(item as MarkupToPDF.Common.CommentUserInfo);
6951

    
6952
                            adornerSet.Add(item as MarkupToPDF.Common.CommentUserInfo);
6953

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

    
6956
                            UndoData.Markup_List.Add(multi_Undo_Data);
6957
                            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6958
                        }
6959
                    }
6960
                    Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
6961

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

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

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