프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 71d7e0bf

이력 | 보기 | 이력해설 | 다운로드 (310 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
using Telerik.Windows.Data;
43
using System.ComponentModel;
44

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

    
54
            T instance = Activator.CreateInstance<T>();
55

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

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

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

    
92
        public TextBox Gui { get; private set; }
93

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

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

    
115
            Gui.Text += line + Environment.NewLine;
116
        }
117
    }
118

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

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

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

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

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

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

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

    
271
            return false;
272
        }
273

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

    
297
            return false;
298
        }
299

    
300

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

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

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

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

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

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

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

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

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

    
374
            DeleteItem(item);
375
        }
376

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

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

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

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

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

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

    
423
            ////GC.Collect();
424
        }
425
        
426
        /// <summary>
427
        /// update my markuplist
428
        ///  - update existing markup data if already exist
429
        ///  - add new markup data if control is new
430
        /// </summary>
431
        public void UpdateMyMarkupList()
432
        {
433
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
434
            bool isComingNewBie = false;
435

    
436
            /// add or update markup list
437
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
438
            {
439
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
440

    
441
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
442
                if (exist != null) //신규 추가 된 코멘트
443
                {
444
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
445
                    {
446
                        exist.Data = root.ConvertData;
447
                        exist.IsUpdate = true;
448
                        ComingNewBieEnd = false;
449
                    }
450
                }
451
                else if (root.CommentID != null)
452
                {
453
                    isComingNewBie = true;
454
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
455
                    {
456
                        ID = control.CommentID,
457
                        Data = root.ConvertData,
458
                        Data_Type = root.DATA_TYPE,
459
                        MarkupInfoID = App.Custom_ViewInfoId,
460
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
461
                        Symbol_ID = control.SymbolID,
462
                        //Group_ID = control.GroupID,
463
                    });
464
                    ComingNewBieEnd = false;
465
                }
466
            }
467

    
468
            /// delete markup list
469
            int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
470
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
471
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
472
                          select markup).ToList();
473
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
474
            /// up to here
475

    
476
            if (PreviewUserMarkupInfoItem != null && isComingNewBie && !ComingNewBieEnd)
477
            {
478
                if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
479
                {
480
                    ComingNewBieEnd = true;
481
                    ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
482
                    PreviewUserMarkupInfoItem.IsPreviewUser = false;
483
                    gridViewMarkup.ItemsSource = null;
484
                    gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
485
                    gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
486

    
487
                    GroupDescriptor descriptor = new GroupDescriptor();
488
                    descriptor.Member = "Depatment";
489
                    descriptor.DisplayContent = "DEPT";
490
                    descriptor.SortDirection = ListSortDirection.Ascending;
491
                    gridViewMarkup.GroupDescriptors.Add(descriptor);
492
                }
493
            }
494
        }
495

    
496
        bool ComingNewBieEnd = false;
497

    
498
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
499
        {
500
            Logger.sendCheckLog("pageNavigator_PageChanging_Start", 1);
501
            if (ViewerDataModel.Instance.UndoDataList.Count > 0)
502
            {
503
                Logger.sendCheckLog("pageNavigator_PageChanging_이전페이지Save", 1);
504
                this.ParentOfType<MainWindow>().dzTopMenu.SaveEvent(null, null);
505
            }
506
            Logger.sendCheckLog("pageNavigator_PageChanging_UndoDataListClear", 1);
507
            ViewerDataModel.Instance.UndoDataList.Clear();
508

    
509
            InkControl_Convert();
510

    
511
            SelectionSet.Instance.UnSelect(this);
512
            UpdateMyMarkupList();
513

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

    
518

    
519
            #region 페이지가 벗어난 경우
520

    
521
            if (BalancePoint < 1)
522
            {
523
                BalancePoint = 1;
524
                ViewerDataModel.Instance.PageBalanceNumber = 0;
525
            }
526

    
527
            if (pageNavigator.PageCount < BalancePoint)
528
            {
529
                BalancePoint = pageNavigator.PageCount;
530
                ViewerDataModel.Instance.PageBalanceNumber = 0;
531
            }
532

    
533
            #endregion
534

    
535
            ViewerDataModel.Instance.PageNumber = BalancePoint;
536

    
537
            Logger.sendCheckLog("pageNavigator_PageChanging_페이지 Image url 설정", 1);
538
            string uri = "";
539
            if (userData.COMPANY != "EXT")
540
            {
541
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
542
            }
543
            else
544
            {
545
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
546
            }
547

    
548
            var defaultBitmapImage = new BitmapImage();
549
            defaultBitmapImage.BeginInit();
550
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
551
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
552
            defaultBitmapImage.UriSource = new Uri(uri);
553
            defaultBitmapImage.EndInit();
554

    
555
            ViewerDataModel.Instance.ImageViewPath = null;
556
            GC.Collect();
557

    
558
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
559
            if (defaultBitmapImage.IsDownloading)
560
            {
561
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
562
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
563
                {
564
                    defaultBitmapImage.Freeze();
565
                    mainPanel.UpdateLayout();
566
                    GC.Collect();
567
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
568
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
569
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
570
                };
571
            }
572

    
573
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
574
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
575

    
576

    
577
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
578
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
579
            inkBoard.Width = zoomAndPanCanvas.Width;
580
            inkBoard.Height = zoomAndPanCanvas.Height;
581

    
582

    
583

    
584
            if (!testPanel2.IsHidden)
585
            {
586
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
587
                //PDF모드일때 잠시 대기(강인구)
588
                if (IsSyncPDFMode)
589
                {
590
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
591
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
592

    
593
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
594
                    if (pdfpath.IsDownloading)
595
                    {
596
                        pdfpath.DownloadCompleted += (ex, arg) =>
597
                        {
598
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
599
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
600
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
601
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
602
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
603
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
604
                        };
605
                    }
606
                    else
607
                    {
608
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
609
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
610
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
611
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
612

    
613
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
614
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
615
                    }
616
                }
617
                else
618
                {
619
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
620
                    string uri2 = "";
621
                    if (userData.COMPANY != "EXT")
622
                    {
623
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
624
                    }
625
                    else
626
                    {
627
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
628
                    }
629

    
630
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
631
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri2));
632

    
633
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanCanvas2 Page Setting", 1);
634
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
635
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
636
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
637
                    zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
638
                    zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
639

    
640
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
641
                    zoomAndPanControl.ZoomTo(new Rect
642
                    {
643
                        X = 0,
644
                        Y = 0,
645
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
646
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
647
                    });
648

    
649
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
650
                    if (defaultBitmapImage_Compare.IsDownloading)
651
                    {
652
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
653
                        {
654
                            Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare DownloadCompleted", 1);
655
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
656
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
657
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
658

    
659
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
660
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
661

    
662
                            zoomAndPanControl.ZoomTo(new Rect
663
                            {
664
                                X = 0,
665
                                Y = 0,
666
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
667
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
668
                            });
669
                        };
670
                    }
671
                }
672
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
673
            }
674

    
675
            this.pageNavigator.SetNextPage();
676

    
677
            if (zoomAndPanCanvas2.Width.IsNaN())
678
            {
679
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
680
            }
681

    
682
            Logger.sendCheckLog("-- pageNavigator_PageChanging_ControlData Setting --", 1);
683
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
684
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
685

    
686
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
687
            foreach (var info in gridSelectionItem)
688
            {
689
                Logger.sendCheckLog(String.Format("==>{0}", info), 1);
690
            }
691
            /// fire selection event
692
            this.gridViewMarkup.UnselectAll();
693
            this.gridViewMarkup.Select(gridSelectionItem);
694

    
695
            if (!testPanel2.IsHidden)
696
            {
697
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
698
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
699
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
700

    
701
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
702
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
703

    
704

    
705
                foreach (var item in gridSelectionRevItem)
706
                {
707
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == BalancePoint).ToList().ForEach(delegate (MarkupItem markupitem)
708
                    {
709
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
710
                    });
711
                }
712
            }
713

    
714
            var instanceMain = this.ParentOfType<MainWindow>();
715
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
716
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
717

    
718
            instanceMain.dzTopMenu.rotateOffSet = 0;
719
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
720
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
721

    
722
            //}
723
            SetCommentPages(true);
724
        }
725

    
726

    
727
        
728

    
729
        private void SetCommentPages(bool onlyMe = false)
730
        {
731
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
732
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
733
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
734
            {
735
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
736
                instance.UserName = item.UserName;
737
                instance.Depart = item.Depatment;
738
                instance.MarkupInfoID = item.MarkupInfoID;
739
                instance.IsSelected = true;
740
                instance.isConSolidation = item.Consolidate;
741
                instance.SetColor = item.DisplayColor;
742
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
743
                {
744
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
745
                }
746
                else
747
                {
748
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
749
                }
750
                _pages.Add(instance);
751
            }
752
            this.pageNavigator.SetCommentList(_pages.ToList());
753
        }
754

    
755
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
756
        {
757
            if (e.MiddleButton == MouseButtonState.Pressed)
758
            {
759

    
760
            }
761
            e.Handled = true;
762
            if (e.Delta > 0)
763
            {
764
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
765
                ZoomIn(currentContentMousePoint);
766
            }
767
            else
768
            {
769
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
770
                ZoomOut(currentContentMousePoint);
771
            }
772
        }
773

    
774
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
775
        {
776
            e.Handled = true;
777
            if (e.Delta > 0)
778
            {
779
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
780
                ZoomIn_Sync(currentContentMousePoint);
781
            }
782
            else
783
            {
784
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
785
                ZoomOut_Sync(currentContentMousePoint);
786
            }
787
        }
788

    
789
        #region ZoomIn & ZoomOut
790

    
791
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
792
        {
793
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
794
                zoomAndPanControl.ContentZoomFocusY));
795
        }
796

    
797
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
798
        {
799
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
800
                zoomAndPanControl.ContentZoomFocusY));
801
        }
802

    
803

    
804
        //강인구 추가 (줌 인아웃 수치 변경)
805
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
806
        private void ZoomOut(Point contentZoomCenter)
807
        {
808
            if (zoomAndPanControl.ContentScale > 0.39)
809
            {
810
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
811
            }
812
            else
813
            {
814
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
815
            }
816

    
817
            if (zoomAndPanControl2 != null && Sync.IsChecked)
818
            {
819
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
820
            }
821
        }
822

    
823
        private void ZoomIn(Point contentZoomCenter)
824
        {
825
            if (zoomAndPanControl.ContentScale > 0.19)
826
            {
827
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
828
            }
829
            else
830
            {
831
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
832
            }
833

    
834
            if (zoomAndPanControl2 != null && Sync.IsChecked)
835
            {
836
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
837
            }
838

    
839
        }
840

    
841
        private void ZoomOut_Sync(Point contentZoomCenter)
842
        {
843
            if (zoomAndPanControl2.ContentScale > 0.39)
844
            {
845
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
846
            }
847
            else
848
            {
849
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
850
            }
851

    
852
            if (Sync.IsChecked)
853
            {
854
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
855
            }
856
        }
857

    
858
        private void ZoomIn_Sync(Point contentZoomCenter)
859
        {
860
            if (zoomAndPanControl2.ContentScale > 0.19)
861
            {
862
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
863
            }
864
            else
865
            {
866
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
867
            }
868

    
869
            if (Sync.IsChecked)
870
            {
871
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
872
            }
873
        }
874

    
875
        private void ZoomOut()
876
        {
877
            zoomAndPanControl.ContentScale -= 0.1;
878
            //if (zoomAndPanControl2 != null)
879
            //{
880
            //    zoomAndPanControl2.ContentScale -= 0.1;
881
            //}
882
        }
883

    
884
        private void ZoomIn()
885
        {
886
            zoomAndPanControl.ContentScale += 0.1;
887
            //if (zoomAndPanControl2 != null)
888
            //{
889
            //    zoomAndPanControl2.ContentScale += 0.1;
890
            //}
891
        }
892

    
893
        #endregion
894

    
895
        private void init()
896
        {
897
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
898
            {
899

    
900
                ControlList.Clear();
901
                listBox.Items.Clear();
902
                selected_item.Clear();
903

    
904
                (item as IMarkupCommonData).IsSelected = false;
905
            }
906

    
907
        }
908

    
909
        private HitTestResultBehavior MyCallback(HitTestResult result)
910
        {
911
            //this.cursor = Cursors.UpArrow;
912
            var element = result.VisualHit;
913
            while (element != null && !(element is CommentUserInfo))
914
                element = VisualTreeHelper.GetParent(element);
915

    
916
            if (element == null)
917
            {
918
                return HitTestResultBehavior.Stop;
919
            }
920
            else
921
            {
922
                if (element is CommentUserInfo)
923
                {
924
                    if (!hitList.Contains(element))
925
                    {
926
                        hitList.Add((CommentUserInfo)element);
927
                    }
928
                    else
929
                    {
930
                        return HitTestResultBehavior.Stop;
931
                    }
932
                    //IntersectionDetail intersectionDetail =
933
                    //((GeometryHitTestResult)result).IntersectionDetail;
934
                    //switch (intersectionDetail)
935
                    //{
936
                    //    case IntersectionDetail.FullyContains:
937
                    //        // Add the hit test result to the list:
938
                    //        hitList.Add((CommentUserInfo)result.VisualHit);
939
                    //        return HitTestResultBehavior.Continue;
940
                    //    case IntersectionDetail.Intersects:
941
                    //        // Set the behavior to return visuals at all z-order levels:
942
                    //        return HitTestResultBehavior.Continue;
943
                    //    case IntersectionDetail.FullyInside:
944
                    //        // Set the behavior to return visuals at all z-order levels:
945
                    //        return HitTestResultBehavior.Continue;
946
                    //    default:
947
                    //        return HitTestResultBehavior.Stop;
948
                    //}
949
                }
950
            }
951
            return HitTestResultBehavior.Continue;
952
        }
953

    
954
        public void ReleaseSelectPath()
955
        {
956
            if (SelectionPath == null)
957
            {
958
                SelectionPath = new Path();
959
                SelectionPath.Name = "";
960
            }
961
            if (SelectionPath.Name != "")
962
            {
963
                SelectionPath.Name = "None";
964
            }
965
            SelectionPath.Opacity = 0.01;
966
            SelectionPath.RenderTransform = null;
967
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
968
        }
969

    
970
        #region 컨트롤 초기화 
971
        public void Control_Init(object control)
972
        {
973
            if (L_Size != 0 && (control as IPath) != null)
974
            {
975
                (control as IPath).LineSize = L_Size;
976
                L_Size = 0;
977
            }
978

    
979
            switch (control.GetType().Name)
980
            {
981
                case "RectangleControl":
982
                    {
983
                        (control as RectangleControl).StrokeColor = Brushes.Red;
984
                    }
985
                    break;
986
                case "CircleControl":
987
                    {
988
                        (control as CircleControl).StrokeColor = Brushes.Red;
989
                    }
990
                    break;
991
                case "TriControl":
992
                    {
993
                        (control as TriControl).StrokeColor = Brushes.Red;
994
                    }
995
                    break;
996
                case "RectCloudControl":
997
                    {
998
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
999
                    }
1000
                    break;
1001
                case "CloudControl":
1002
                    {
1003
                        (control as CloudControl).StrokeColor = Brushes.Red;
1004
                    }
1005
                    break;
1006
                case "PolygonControl":
1007
                    {
1008
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1009
                    }
1010
                    break;
1011
                case "ArcControl":
1012
                    {
1013
                        (control as ArcControl).StrokeColor = Brushes.Red;
1014
                    }
1015
                    break;
1016
                case "ArrowArcControl":
1017
                    {
1018
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1019
                    }
1020
                    break;
1021
                case "LineControl":
1022
                    {
1023
                        (control as LineControl).StrokeColor = Brushes.Red;
1024
                    }
1025
                    break;
1026
                case "ArrowControl_Multi":
1027
                    {
1028
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1029
                    }
1030
                    break;
1031
                case "TextControl":
1032
                    {
1033
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1034
                    }
1035
                    break;
1036
                case "ArrowTextControl":
1037
                    {
1038
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1039
                    }
1040
                    break;
1041
                case "InsideWhiteControl":
1042
                    {
1043
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1044
                    }
1045
                    break;
1046
                case "OverlapWhiteControl":
1047
                    {
1048
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1049
                    }
1050
                    break;
1051
                case "ClipWhiteControl":
1052
                    {
1053
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1054
                    }
1055
                    break;
1056
                case "CoordinateControl":
1057
                    {
1058
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1059
                    }
1060
                    break;
1061
            }
1062
        }
1063
        #endregion
1064

    
1065
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1066
        {
1067
            //Control_Init(e.Source);
1068
        }
1069
        private Window _dragdropWindow = null;
1070

    
1071
        [DllImport("user32.dll")]
1072
        [return: MarshalAs(UnmanagedType.Bool)]
1073
        internal static extern bool GetCursorPos(ref Win32Point pt);
1074

    
1075
        [StructLayout(LayoutKind.Sequential)]
1076
        internal struct Win32Point
1077
        {
1078
            public Int32 X;
1079
            public Int32 Y;
1080
        };
1081
        public string symbol_id = null;
1082
        public long symbol_group_id;
1083
        public int symbol_SelectedIndex;
1084
        public ImageSource symbol_img;
1085
        public string symbol_Data = null;
1086
        public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1087
        {
1088
            if (this._dragdropWindow != null)
1089
            {
1090
                this._dragdropWindow.Close();
1091
                this._dragdropWindow = null;
1092
            }
1093

    
1094
            symbol_id = id;
1095
            symbol_group_id = group_id;
1096
            symbol_SelectedIndex = SelectedIndex;
1097
            symbol_Data = Data_;
1098
            symbol_img = img;
1099

    
1100
      
1101
            CreateDragDropWindow2(img);
1102
        }
1103

    
1104
        private void CreateDragDropWindow2(ImageSource image)
1105
        {
1106
            this._dragdropWindow = new Window();
1107
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1108
            _dragdropWindow.WindowStyle = WindowStyle.None;
1109
            _dragdropWindow.AllowsTransparency = true;           
1110
            _dragdropWindow.AllowDrop = false;
1111
            _dragdropWindow.Background = null;
1112
            _dragdropWindow.IsHitTestVisible = false;
1113
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1114
            _dragdropWindow.Topmost = true;
1115
            _dragdropWindow.ShowInTaskbar = false;
1116
            
1117
            Rectangle r = new Rectangle();
1118
            r.Width = image.Width;
1119
            r.Height = image.Height;
1120
            r.Opacity = 0.5;            
1121
            r.Fill = new ImageBrush(image);
1122
            this._dragdropWindow.Content = r;
1123

    
1124
            Win32Point w32Mouse = new Win32Point();
1125
            GetCursorPos(ref w32Mouse);
1126

    
1127
            //w32Mouse.X = getCurrentPoint.X;
1128
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1129
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1130
            this._dragdropWindow.Show();
1131
        }
1132

    
1133
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1134
        {
1135
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1136
            {
1137
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1138

    
1139
                Point currentPos = e.GetPosition(rect);
1140

    
1141
                floatingTip.HorizontalOffset = currentPos.X + 20;
1142
                floatingTip.VerticalOffset = currentPos.Y;
1143
            }
1144

    
1145
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1146
            
1147
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1148
            {
1149
                SetCursor();
1150
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1151
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1152

    
1153
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1154
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1155
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1156

    
1157
                if (Sync.IsChecked)
1158
                {
1159
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1160
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1161
                }
1162
            }
1163

    
1164
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1165
            {
1166
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1167
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1168
                SetCursor();
1169

    
1170
                if (currentControl != null)
1171
                {
1172
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1173
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1174
                    //강인구 추가
1175
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1176

    
1177
                    if ((currentControl as IPath) != null)
1178
                    {
1179
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1180
                    }
1181
                    if ((currentControl as LineControl) != null)
1182
                    {
1183
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1184
                    }
1185

    
1186
                    if ((currentControl as IShapeControl) != null)
1187
                    {
1188
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1189
                    }
1190
                    if ((currentControl as TextControl) != null)
1191
                    {
1192
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1193
                        {
1194
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1195
                        }
1196
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1197
                        {
1198
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1199
                        }
1200
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1201
                        {
1202
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1203
                        }
1204
                    }
1205
                    else if ((currentControl as ArrowTextControl) != null)
1206
                    {
1207
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1208
                        {
1209
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1210
                        }
1211
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1212
                        {
1213
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1214
                        }
1215
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1216
                        {
1217
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1218
                        }
1219
                    }
1220
                    else if ((currentControl as RectCloudControl) != null)
1221
                    {
1222
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1223
                    }
1224
                    else if ((currentControl as CloudControl) != null)
1225
                    {
1226
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1227
                    }
1228

    
1229
                    switch (controlType)
1230
                    {
1231
                        case (ControlType.Coordinate):
1232
                            {
1233
                                var control = currentControl as CoordinateControl;
1234

    
1235
                                if (control != null)
1236
                                {
1237
                                    if (move.mousemode == MouseMode.Drawing)
1238
                                    {
1239
                                        //move.control_Move(ControlList, true, moveX, moveY);
1240
                                    }
1241
                                    else
1242
                                    {
1243
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1244
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1245
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1246
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1247

    
1248

    
1249
                                        if (ViewerDataModel.Instance.IsPressShift)
1250
                                        {
1251
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1252
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1253
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1254
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1255
                                        }
1256

    
1257
                                        control.PointSet = new List<Point>
1258
                                        {
1259
                                            control.StartPoint,
1260
                                            control.LeftBottomPoint,
1261
                                            control.EndPoint,
1262
                                            control.TopRightPoint,
1263
                                        };
1264
                                        control.updateControl();
1265
                                    }
1266

    
1267
                                    //강인구 추가
1268
                                    control.ControlType = controlType;
1269
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1270
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1271
                                    //  control.Paint = PaintSet.Fill;
1272
                                }
1273
                            }
1274
                            break;
1275
                        case (ControlType.InsideWhite):
1276
                            {
1277
                                var control = currentControl as InsideWhiteControl;
1278

    
1279
                                if (control != null)
1280
                                {
1281
                                    if (move.mousemode == MouseMode.Drawing)
1282
                                    {
1283
                                        //move.control_Move(ControlList, true, moveX, moveY);
1284
                                    }
1285
                                    else
1286
                                    {
1287
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1288
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1289
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1290
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1291

    
1292

    
1293
                                        if (ViewerDataModel.Instance.IsPressShift)
1294
                                        {
1295
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1296
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1297
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1298
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1299
                                        }
1300

    
1301
                                        control.PointSet = new List<Point>
1302
                                        {
1303
                                            control.StartPoint,
1304
                                            control.LeftBottomPoint,
1305
                                            control.EndPoint,
1306
                                            control.TopRightPoint,
1307
                                        };
1308
                                        control.updateControl();
1309
                                    }
1310

    
1311
                                    //강인구 추가
1312
                                    control.ControlType = controlType;
1313
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1314
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1315
                                    control.Paint = PaintSet.Fill;
1316
                                }
1317
                            }
1318
                            break;
1319
                        case (ControlType.OverlapWhite):
1320
                            {
1321
                                var control = currentControl as OverlapWhiteControl;
1322

    
1323
                                if (control != null)
1324
                                {
1325
                                    if (move.mousemode == MouseMode.Drawing)
1326
                                    {
1327
                                        //move.control_Move(ControlList, true, moveX, moveY);
1328
                                    }
1329
                                    else
1330
                                    {
1331
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1332
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1333
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1334
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1335

    
1336

    
1337
                                        if (ViewerDataModel.Instance.IsPressShift)
1338
                                        {
1339
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1340
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1341
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1342
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1343
                                        }
1344

    
1345
                                        control.PointSet = new List<Point>
1346
                                        {
1347
                                            control.StartPoint,
1348
                                            control.LeftBottomPoint,
1349
                                            control.EndPoint,
1350
                                            control.TopRightPoint,
1351
                                        };
1352
                                        control.updateControl();
1353
                                    }
1354

    
1355
                                    //강인구 추가
1356
                                    control.ControlType = controlType;
1357
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1358
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1359
                                    control.Paint = PaintSet.Fill;
1360
                                }
1361
                            }
1362
                            break;
1363
                        case (ControlType.ClipWhite):
1364
                            {
1365
                                var control = currentControl as ClipWhiteControl;
1366

    
1367
                                if (control != null)
1368
                                {
1369
                                    if (move.mousemode == MouseMode.Drawing)
1370
                                    {
1371
                                        //move.control_Move(ControlList, true, moveX, moveY);
1372
                                    }
1373
                                    else
1374
                                    {
1375
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1376
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1377
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1378
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1379

    
1380

    
1381
                                        if (ViewerDataModel.Instance.IsPressShift)
1382
                                        {
1383
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1384
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1385
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1386
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1387
                                        }
1388

    
1389
                                        control.PointSet = new List<Point>
1390
                                        {
1391
                                            control.StartPoint,
1392
                                            control.LeftBottomPoint,
1393
                                            control.EndPoint,
1394
                                            control.TopRightPoint,
1395
                                        };
1396
                                        control.updateControl();
1397
                                    }
1398

    
1399
                                    //강인구 추가
1400
                                    control.ControlType = controlType;
1401
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1402
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1403
                                    control.Paint = PaintSet.Fill;
1404
                                }
1405
                            }
1406
                            break;
1407
                        case ControlType.Rectangle:
1408
                            {
1409
                                var control = currentControl as RectangleControl;
1410

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

    
1424

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

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

    
1443
                                    //강인구 추가
1444
                                    control.ControlType = controlType;
1445
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1446
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1447
                                }
1448
                            }
1449
                            break;
1450

    
1451
                        case ControlType.RectCloud:
1452
                            {
1453
                                var control = currentControl as RectCloudControl;
1454

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

    
1468
                                        if (ViewerDataModel.Instance.IsPressShift)
1469
                                        {
1470
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1471
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1472
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1473
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1474
                                        }
1475

    
1476
                                        control.PointSet = new List<Point>
1477
                                        {
1478
                                            control.StartPoint,
1479
                                            control.LeftBottomPoint,
1480
                                            control.EndPoint,
1481
                                            control.TopRightPoint,
1482
                                        };
1483
                                    }
1484

    
1485
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1486
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1487
                                }
1488
                            }
1489
                            break;
1490

    
1491
                        case ControlType.SingleLine:
1492
                            {
1493
                                var control = currentControl as LineControl;
1494
                                if (control != null)
1495
                                {
1496
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1497
                                    control.ControlType = controlType;
1498
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1499
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1500
                                    Point tempPoint = control.EndPoint;
1501

    
1502
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1503
                                    {
1504
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1505
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1506
                                        control.EndPoint = tempPoint;
1507
                                    }
1508
                                    else
1509
                                    {
1510
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1511
                                    }
1512

    
1513
                                    control.PointSet = new List<Point>
1514
                                        {
1515
                                            control.StartPoint,
1516
                                            control.EndPoint,
1517
                                        };
1518

    
1519
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1520
                                }
1521

    
1522
                            }
1523
                            break;
1524

    
1525
                        case ControlType.CancelLine:
1526
                            {
1527
                                var control = currentControl as LineControl;
1528
                                if (control != null)
1529
                                {
1530
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1531
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1532
                                    control.ControlType = controlType;
1533
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1534
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1535
                                    Point tempPoint = control.EndPoint;
1536

    
1537
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1538
                                    {
1539
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1540
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1541
                                        control.EndPoint = tempPoint;
1542
                                    }
1543
                                    else
1544
                                    {
1545
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1546
                                    }
1547

    
1548

    
1549
                                    control.PointSet = new List<Point>
1550
                                            {
1551
                                                control.StartPoint,
1552
                                                control.EndPoint,
1553
                                            };
1554
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1555
                                }
1556

    
1557

    
1558
                            }
1559
                            break;
1560

    
1561
                        case ControlType.ArrowLine:
1562
                            {
1563
                                var control = currentControl as LineControl;
1564
                                if (control != null)
1565
                                {
1566
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1567
                                    control.ControlType = controlType;
1568
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1569
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1570
                                    Point tempPoint = control.EndPoint;
1571

    
1572
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1573
                                    {
1574
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1575
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1576
                                        control.EndPoint = tempPoint;
1577
                                    }
1578
                                    else
1579
                                    {
1580
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1581
                                    }
1582

    
1583

    
1584
                                    control.PointSet = new List<Point>
1585
                                            {
1586
                                                control.StartPoint,
1587
                                                control.EndPoint,
1588
                                            };
1589
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1590
                                }
1591
                            }
1592
                            break;
1593

    
1594
                        case ControlType.TwinLine:
1595
                            {
1596
                                var control = currentControl as LineControl;
1597
                                if (control != null)
1598
                                {
1599
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1600
                                    control.ControlType = controlType;
1601
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1602
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1603
                                    Point tempPoint = control.EndPoint;
1604

    
1605
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1606
                                    {
1607
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1608
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1609
                                        control.EndPoint = tempPoint;
1610
                                    }
1611
                                    else
1612
                                    {
1613
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1614
                                    }
1615

    
1616

    
1617
                                    control.PointSet = new List<Point>
1618
                                            {
1619
                                                control.StartPoint,
1620
                                                control.EndPoint,
1621
                                            };
1622
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1623
                                }
1624
                            }
1625
                            break;
1626

    
1627
                        case ControlType.DimLine:
1628
                            {
1629
                                var control = currentControl as LineControl;
1630
                                if (control != null)
1631
                                {
1632
                                    control.LineStyleSet = LineStyleSet.DimLine;
1633
                                    control.ControlType = controlType;
1634
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1635
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1636
                                    Point tempPoint = control.EndPoint;
1637

    
1638
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1639
                                    {
1640
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1641
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1642
                                        control.EndPoint = tempPoint;
1643
                                    }
1644
                                    else
1645
                                    {
1646
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1647
                                    }
1648

    
1649
                                    control.PointSet = new List<Point>
1650
                                            {
1651
                                                control.StartPoint,
1652
                                                control.EndPoint,
1653
                                            };
1654
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1655
                                }
1656
                            }
1657
                            break;
1658

    
1659
                        case ControlType.ArcLine:
1660
                            {
1661
                                var control = currentControl as ArcControl;
1662
                                if (control != null)
1663
                                {
1664
                                    control.isTransOn = false;
1665
                                    control.ControlType = controlType;
1666
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1667
                                    control.MidPoint = new Point(0, 0);
1668
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1669
                                    Point tempPoint = control.EndPoint;
1670

    
1671
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1672
                                    {
1673
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1674
                                        control.EndPoint = tempPoint;
1675
                                    }
1676
                                    else
1677
                                    {
1678
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1679
                                    }
1680

    
1681

    
1682
                                    control.PointSet = new List<Point>
1683
                                            {
1684
                                                control.StartPoint,
1685
                                                control.MidPoint,
1686
                                                control.EndPoint,
1687
                                            };
1688
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1689
                                }
1690
                            }
1691
                            break;
1692

    
1693
                        case ControlType.ArcArrow:
1694
                            {
1695
                                var control = currentControl as ArrowArcControl;
1696
                                if (control != null)
1697
                                {
1698
                                    control.isTransOn = false;
1699
                                    control.ControlType = controlType;
1700
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1701
                                    control.MidPoint = new Point(0, 0);
1702
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1703
                                    Point tempPoint = control.EndPoint;
1704

    
1705
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1706
                                    {
1707
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1708
                                        control.EndPoint = tempPoint;
1709
                                    }
1710
                                    else
1711
                                    {
1712
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1713
                                    }
1714

    
1715

    
1716
                                    control.PointSet = new List<Point>
1717
                                            {
1718
                                                control.StartPoint,
1719
                                                control.MidPoint,
1720
                                                control.EndPoint,
1721
                                            };
1722
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1723
                                }
1724
                            }
1725
                            break;
1726

    
1727
                        case ControlType.ArrowMultiLine:
1728
                            {
1729
                                var control = currentControl as ArrowControl_Multi;
1730
                                if (control != null)
1731
                                {
1732
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1733
                                    Point tempPoint = control.EndPoint;
1734
                                    if (control.MiddlePoint == new Point(0, 0))
1735
                                    {
1736
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1737
                                        {
1738
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1739
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1740
                                            control.EndPoint = tempPoint;
1741
                                        }
1742
                                        else
1743
                                        {
1744
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1745
                                        }
1746
                                    }
1747
                                    else
1748
                                    {
1749
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1750
                                        {
1751
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1752
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1753
                                            control.EndPoint = tempPoint;
1754
                                        }
1755
                                        else
1756
                                        {
1757
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1758
                                        }
1759

    
1760
                                    }
1761

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

    
1773
                        case ControlType.Circle:
1774
                            {
1775
                                var control = currentControl as CircleControl;
1776

    
1777
                                if (control != null)
1778
                                {
1779
                                    if (move.mousemode == MouseMode.Drawing)
1780
                                    {
1781
                                        //move.control_Move(ControlList, true, moveX, moveY);
1782
                                    }
1783
                                    else
1784
                                    {
1785
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1786
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1787
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1788
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1789

    
1790
                                        if (ViewerDataModel.Instance.IsPressShift)
1791
                                        {
1792
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1793
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1794
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1795
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1796
                                        }
1797

    
1798
                                        control.PointSet = new List<Point>
1799
                                        {
1800
                                            control.StartPoint,
1801
                                            control.LeftBottomPoint,
1802
                                            control.EndPoint,
1803
                                            control.TopRightPoint,
1804
                                        };
1805
                                    }
1806

    
1807
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1808
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1809

    
1810
                                }
1811
                            }
1812
                            break;
1813

    
1814
                        case ControlType.PolygonCloud:
1815
                            {
1816
                                var control = currentControl as CloudControl;
1817

    
1818
                                if (control != null)
1819
                                {
1820
                                    control.isTransOn = true;
1821
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1822

    
1823
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1824

    
1825
                                    control.SetCloud();
1826
                                    //강인구 추가
1827
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1828
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1829
                                }
1830
                            }
1831
                            break;
1832

    
1833
                        case ControlType.Triangle:
1834
                            {
1835
                                var control = currentControl as TriControl;
1836

    
1837
                                if (control != null)
1838
                                {
1839
                                    if (move.mousemode == MouseMode.Drawing)
1840
                                    {
1841
                                        //move.control_Move(ControlList, true, moveX, moveY);
1842
                                    }
1843
                                    else
1844
                                    {
1845
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1846
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1847

    
1848
                                        if (ViewerDataModel.Instance.checkAxis)
1849
                                        {
1850
                                            Point tempPoint = control.EndPoint;
1851
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1852
                                            control.EndPoint = tempPoint;
1853
                                        }
1854

    
1855

    
1856
                                        if (ViewerDataModel.Instance.IsPressShift)
1857
                                        {
1858
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1859
                                            if (2 == Points.Count())
1860
                                            {
1861
                                                control.MidPoint = Points[0];
1862
                                                control.EndPoint = Points[1];
1863
                                            }
1864
                                        }
1865

    
1866
                                        control.PointSet = new List<Point>
1867
                                            {
1868
                                                control.StartPoint,
1869
                                                control.MidPoint,
1870
                                                control.EndPoint,
1871
                                            };
1872
                                    }
1873

    
1874
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1875
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1876
                                }
1877
                            }
1878
                            break;
1879

    
1880
                        case ControlType.ImgControl:
1881
                            {
1882
                                var control = currentControl as ImgControl;
1883

    
1884
                                if (control != null)
1885
                                {
1886
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1887
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1888
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1889
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1890

    
1891
                                    control.PointSet = new List<Point>
1892
                                        {
1893
                                            control.StartPoint,
1894
                                            control.LeftBottomPoint,
1895
                                            control.EndPoint,
1896
                                            control.TopRightPoint,
1897
                                        };
1898
                                }
1899
                            }
1900
                            break;
1901

    
1902
                        case ControlType.Date:
1903
                            {
1904
                                var control = currentControl as DateControl;
1905

    
1906
                                if (control != null)
1907
                                {
1908
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1909
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1910
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1911
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1912
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
1913

    
1914
                                    control.PointSet = new List<Point>
1915
                                        {
1916
                                            control.StartPoint,
1917
                                            control.LeftBottomPoint,
1918
                                            control.EndPoint,
1919
                                            control.TopRightPoint,
1920
                                        };
1921
                                }
1922
                            }
1923
                            break;
1924

    
1925
                        case ControlType.ArrowTextControl:
1926
                            {
1927
                                var control = currentControl as ArrowTextControl;
1928

    
1929
                                if (control != null)
1930
                                {
1931
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1932
                                    Point tempPoint = control.EndPoint;
1933

    
1934
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
1935

    
1936
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1937
                                    {
1938
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1939
                                        control.EndPoint = tempPoint;
1940
                                    }
1941
                                    else
1942
                                    {
1943
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1944
                                    }
1945
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1946

    
1947
                                    control.PointSet = new List<Point>
1948
                                            {
1949
                                                control.StartPoint,
1950
                                                control.MidPoint,
1951
                                                control.EndPoint,
1952
                                            };
1953
                                }
1954
                            }
1955
                            break;
1956

    
1957
                        case ControlType.ArrowTransTextControl:
1958
                            {
1959
                                var control = currentControl as ArrowTextControl;
1960

    
1961
                                if (control != null)
1962
                                {
1963
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1964
                                    Point tempPoint = control.EndPoint;
1965
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
1966

    
1967
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1968
                                    {
1969
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1970
                                        control.EndPoint = tempPoint;
1971
                                    }
1972
                                    else
1973
                                    {
1974
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1975
                                    }
1976
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
1977
                                    control.isFixed = true;
1978

    
1979
                                    control.PointSet = new List<Point>
1980
                                            {
1981
                                                control.StartPoint,
1982
                                                control.MidPoint,
1983
                                                control.EndPoint,
1984
                                            };
1985
                                }
1986
                            }
1987
                            break;
1988

    
1989
                        case ControlType.ArrowTextBorderControl:
1990
                            {
1991
                                var control = currentControl as ArrowTextControl;
1992

    
1993
                                if (control != null)
1994
                                {
1995
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
1996
                                    Point tempPoint = control.EndPoint;
1997
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1998
                                    {
1999
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2000
                                        control.EndPoint = tempPoint;
2001
                                    }
2002
                                    else
2003
                                    {
2004
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2005
                                    }
2006
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2007
                                    control.PointSet = new List<Point>
2008
                                            {
2009
                                                control.StartPoint,
2010
                                                control.MidPoint,
2011
                                                control.EndPoint,
2012
                                            };
2013
                                }
2014

    
2015
                            }
2016
                            break;
2017
                        case ControlType.ArrowTransTextBorderControl:
2018
                            {
2019
                                var control = currentControl as ArrowTextControl;
2020

    
2021
                                if (control != null)
2022
                                {
2023
                                    control.isFixed = true;
2024
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2025
                                    Point tempPoint = control.EndPoint;
2026
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2027
                                    {
2028
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2029
                                        control.EndPoint = tempPoint;
2030
                                    }
2031
                                    else
2032
                                    {
2033
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2034
                                    }
2035

    
2036
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2037
                                    control.PointSet = new List<Point>
2038
                                            {
2039
                                                control.StartPoint,
2040
                                                control.MidPoint,
2041
                                                control.EndPoint,
2042
                                            };
2043
                                }
2044

    
2045
                            }
2046
                            break;
2047
                        case ControlType.ArrowTextCloudControl:
2048
                            {
2049
                                var control = currentControl as ArrowTextControl;
2050

    
2051
                                if (control != null)
2052
                                {
2053
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2054
                                    Point tempPoint = control.EndPoint;
2055
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2056
                                    {
2057
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2058
                                        control.EndPoint = tempPoint;
2059
                                    }
2060
                                    else
2061
                                    {
2062
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2063
                                    }
2064
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2065
                                    control.PointSet = new List<Point>
2066
                                            {
2067
                                                control.StartPoint,
2068
                                                control.MidPoint,
2069
                                                control.EndPoint,
2070
                                            };
2071
                                }
2072

    
2073
                            }
2074
                            break;
2075
                        case ControlType.ArrowTransTextCloudControl:
2076
                            {
2077
                                var control = currentControl as ArrowTextControl;
2078

    
2079
                                if (control != null)
2080
                                {
2081
                                    control.isFixed = true;
2082
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2083
                                    Point tempPoint = control.EndPoint;
2084
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2085
                                    {
2086
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2087
                                        control.EndPoint = tempPoint;
2088
                                    }
2089
                                    else
2090
                                    {
2091
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2092
                                    }
2093
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2094
                                    control.PointSet = new List<Point>
2095
                                            {
2096
                                                control.StartPoint,
2097
                                                control.MidPoint,
2098
                                                control.EndPoint,
2099
                                            };
2100
                                }
2101

    
2102
                            }
2103
                            break;
2104
                        case ControlType.PolygonControl:
2105
                        case ControlType.ChainLine:
2106
                            {
2107
                                var control = currentControl as PolygonControl;
2108

    
2109
                                if (control != null)
2110
                                {
2111
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2112
                                    Point tempPoint = currentCanvasDrawingMouseMovePoint;
2113
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2114
                                    {
2115
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 1], ref tempPoint, true);
2116
                                    }
2117
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2118

    
2119
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2120
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2121
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2122
                                    control.updateControl();
2123
                                }
2124
                            }
2125
                            break;
2126
                        //강인구 추가
2127
                        case ControlType.Sign:
2128
                            {
2129
                                var control = currentControl as SignControl;
2130

    
2131
                                if (control != null)
2132
                                {
2133
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2134
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2135
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2136
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2137

    
2138
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2139
                                    {
2140
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2141
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2142
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2143
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2144
                                        stream.Position = 0;
2145
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2146
                                        BitmapImage returnImage = new BitmapImage();
2147
                                        returnImage.BeginInit();
2148
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2149
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2150
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2151
                                        returnImage.StreamSource = ms;
2152
                                        returnImage.EndInit();
2153
                                        stream.Close();
2154

    
2155
                                        control.SignImage = returnImage;
2156
                                    }
2157
                                    control.PointSet = new List<Point>
2158
                                        {
2159
                                            control.StartPoint,
2160
                                            control.LeftBottomPoint,
2161
                                            control.EndPoint,
2162
                                            control.TopRightPoint,
2163
                                        };
2164
                                }
2165
                            }
2166
                            break;
2167
                        //TODO: 강인구 추가
2168
                        case ControlType.Symbol:
2169
                            {
2170
                                var control = currentControl as SymControl;
2171

    
2172
                                if (control != null)
2173
                                {
2174
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2175
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2176
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2177
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2178
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2179
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2180

    
2181
                                    if (control.StartPoint != control.EndPoint)
2182
                                    {
2183
                                        if (control.PathData == null)
2184
                                        {
2185
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2186
                                            {
2187
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2188
                                            }
2189
                                        }
2190
                                    }
2191

    
2192
                                    control.PointSet = new List<Point>
2193
                                        {
2194
                                            control.StartPoint,
2195
                                            control.LeftBottomPoint,
2196
                                            control.EndPoint,
2197
                                            control.TopRightPoint,
2198
                                        };
2199
                                }
2200
                            }
2201
                            break;
2202
                        ///TODO: 
2203
                        case ControlType.Stamp:
2204
                            {
2205
                                var control = currentControl as SymControlN;
2206

    
2207
                                if (control != null)
2208
                                {
2209

    
2210
                                    if (control.StartPoint == control.EndPoint)
2211
                                    {
2212
                                        //string appovalData = "";
2213

    
2214
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2215
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2216

    
2217

    
2218
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2219

    
2220
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2221
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2222
                                        writer.Write(xamlData);
2223
                                        writer.Flush();
2224
                                        stream.Position = 0;
2225

    
2226
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2227
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2228
                                        UIElement ob = obj as UIElement;
2229

    
2230
                                        //control.ApplyTemplate();
2231

    
2232
                                        control.SetViewBox();
2233
                                        control.PathXathData = App.SystemInfo.STAMP;
2234
                                        control.Base_ViewBox.Child = ob;
2235
                                    }
2236

    
2237
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2238
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2239
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2240
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2241
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2242

    
2243

    
2244
                                    control.PointSet = new List<Point>
2245
                                    {
2246
                                        control.StartPoint,
2247
                                        control.LeftBottomPoint,
2248
                                        control.EndPoint,
2249
                                        control.TopRightPoint,
2250
                                    };
2251
                                }
2252
                            }
2253
                            break;
2254
                        case ControlType.Mark:
2255
                            {
2256
                                var control = currentControl as RectangleControl;
2257

    
2258
                                if (control != null)
2259
                                {
2260
                                    if (move.mousemode == MouseMode.Drawing)
2261
                                    {
2262
                                        //move.control_Move(ControlList, true, moveX, moveY);
2263
                                    }
2264
                                    else
2265
                                    {
2266
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2267
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2268
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2269
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2270

    
2271

    
2272
                                        control.PointSet = new List<Point>
2273
                                    {
2274
                                        control.StartPoint,
2275
                                        control.LeftBottomPoint,
2276
                                        control.EndPoint,
2277
                                        control.TopRightPoint,
2278
                                    };
2279
                                    }
2280

    
2281
                                    //강인구 추가
2282
                                    control.Paint = PaintSet.Fill;
2283
                                }
2284
                            }
2285
                            break;
2286
                        case ControlType.PenControl:
2287
                            {
2288
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2289
                                //inkBoard.Strokes.Add(stroke);
2290
                            }
2291
                            break;
2292
                        default:
2293
                            break;
2294
                    }
2295
                }
2296
            }
2297
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2298
            {
2299
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2300
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2301
                SetCursor();
2302
                if (currentControl == null)
2303
                {
2304
                    switch (controlType)
2305
                    {
2306
                        case ControlType.PenControl:
2307
                            {
2308
                                if (inkBoard.Tag.ToString() == "Ink")
2309
                                {
2310
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2311
                                }
2312
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2313
                                {
2314
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2315
                                }
2316
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2317
                                {
2318
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2319
                                }
2320

    
2321
                                //inkBoard.Strokes.Add(stroke);
2322
                            }
2323
                            break;
2324
                    }
2325
                    return;
2326
                }
2327
            }
2328
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
2329
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
2330
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2331
            {
2332
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2333

    
2334
                if (isDraggingSelectionRect)
2335
                {
2336
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2337
                    e.Handled = true;
2338
                }
2339
                else if (isLeftMouseButtonDownOnWindow)
2340
                {
2341
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2342
                    double dragDistance = Math.Abs(dragDelta.Length);
2343

    
2344
                    if (dragDistance > DragThreshold)
2345
                    {
2346
                        isDraggingSelectionRect = true;
2347
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2348
                    }
2349

    
2350
                    e.Handled = true;
2351
                }
2352

    
2353
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2354
                {
2355
                }
2356
                else
2357
                {
2358
                    e.Handled = true;
2359
                }
2360
            }
2361
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2362
            { //symbol      
2363
                if(_dragdropWindow != null)
2364
                {
2365
                    Win32Point w32Mouse = new Win32Point();
2366
                    GetCursorPos(ref w32Mouse);
2367

    
2368
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2369
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2370
                }                
2371
            }
2372
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
2373
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2374
            {
2375
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2376
                if(control != null)
2377
                {
2378
                    this.cursor = Cursors.Hand;
2379
                    SetCursor();
2380
                }
2381
                else
2382
                {
2383
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2384
                    SetCursor();
2385
                }
2386
            }
2387
            else
2388
            {
2389
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2390

    
2391
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2392
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2393

    
2394
                //if (hitList.Count > 0)
2395
                //{
2396

    
2397
                //}
2398

    
2399
                #region 조건 설정 : firstCondition
2400
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2401
                //pnts = generalTransform.Transform(pnts);
2402
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2403
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2404
                //                               this.DeepLayer._BaseLayer).ToObservable()
2405
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2406
                //                      select kkk).FirstOrDefault();
2407

    
2408
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2409
                //if (canvas !=null)
2410
                //{
2411
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2412
                //    {
2413
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2414
                //        if (uiElement!=null)
2415
                //        {
2416
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2417
                //        }
2418
                //    }
2419
                //}
2420

    
2421
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2422
                //hitResultsList.Clear();
2423

    
2424
                #endregion
2425
            }
2426
        }
2427

    
2428
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2429
        {
2430
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2431
            {
2432
                SetCursor();
2433
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2434
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2435

    
2436
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2437

    
2438
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2439
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2440

    
2441
                if (Sync.IsChecked)
2442
                {
2443
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2444
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2445
                }
2446
            }
2447
        }
2448

    
2449
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2450

    
2451
        private EllipseGeometry hitArea = new EllipseGeometry();
2452

    
2453
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2454
        {
2455
            IsDrawing = false;
2456

    
2457
            if (mouseHandlingMode != MouseHandlingMode.None)
2458
            {
2459
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2460
                {
2461
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2462

    
2463
                    SetCursor();
2464

    
2465
                    switch (controlType)
2466
                    {
2467
                        case ControlType.None:
2468
                            break;
2469
                        case ControlType.Rectangle:
2470
                            {
2471

    
2472
                            }
2473
                            break;
2474
                        case ControlType.PenControl:
2475
                            {
2476

    
2477
                            }
2478
                            break;
2479
                        default:
2480
                            break;
2481
                    }
2482
                }
2483
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2484
                {
2485
                    if (isLeftMouseButtonDownOnWindow)
2486
                    {
2487
                        bool wasDragSelectionApplied = false;
2488

    
2489
                        if (isDraggingSelectionRect)
2490
                        {
2491
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2492
                            {
2493
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2494
                                mouseHandlingMode = MouseHandlingMode.None;
2495
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2496
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2497
                                Set_Symbol_Capture(endPoint);
2498
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2499
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2500
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2501
                            }
2502
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2503
                            {
2504
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2505
                                mouseHandlingMode = MouseHandlingMode.None;
2506
                                Set_Capture();
2507

    
2508
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2509
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2510
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2511
                            }
2512
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2513
                            {
2514
                                ApplyDragSelectionRect();
2515
                            }
2516
                            else
2517
                            {
2518
                                double x = Canvas.GetLeft(dragZoomBorder);
2519
                                double y = Canvas.GetTop(dragZoomBorder);
2520
                                double width = dragZoomBorder.Width;
2521
                                double height = dragZoomBorder.Height;
2522
                                Rect dragRect = new Rect(x, y, width, height);
2523

    
2524
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2525

    
2526
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2527
                            }
2528

    
2529
                            isDraggingSelectionRect = false;
2530
                            e.Handled = true;
2531
                            wasDragSelectionApplied = true;
2532
                        }
2533

    
2534
                        if (isLeftMouseButtonDownOnWindow)
2535
                        {
2536
                            isLeftMouseButtonDownOnWindow = false;
2537
                            this.ReleaseMouseCapture();
2538
                            e.Handled = true;
2539
                        }
2540

    
2541
                        if (!wasDragSelectionApplied)
2542
                        {
2543
                            init();
2544
                        }
2545
                    }
2546
                }
2547
                else if (e.RightButton == MouseButtonState.Pressed)
2548
                {
2549
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2550
                    SetCursor();
2551
                }
2552

    
2553
                zoomAndPanControl.ReleaseMouseCapture();
2554

    
2555

    
2556
                e.Handled = true;
2557
            }
2558
            else
2559
            {
2560
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2561
                SetCursor();
2562
            }
2563

    
2564
            ///mouseButtonDown = MouseButton.Left;
2565
            //controlType = ControlType.SingleLine;
2566
        }
2567

    
2568
        public void Set_Symbol_Capture(Point endPoint)
2569
        {       
2570
            double x = canvasDrawingMouseDownPoint.X;
2571
            double y = canvasDrawingMouseDownPoint.Y;
2572
            if(x > endPoint.X)
2573
            {
2574
                x = endPoint.X;
2575
                y = endPoint.Y;
2576
            }
2577

    
2578
            double width = dragCaptureBorder.Width;
2579
            double height = dragCaptureBorder.Height;
2580

    
2581
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2582

    
2583
            if (x < 0)
2584
            {
2585
                width += x;
2586
                x = 0;
2587
            }
2588
            if (y < 0)
2589
            {
2590
                height += y;
2591
                y = 0;
2592

    
2593
                width = (int)canvasImage.PixelWidth - x;
2594
            }
2595
            if (x + width > canvasImage.PixelWidth)
2596
            {
2597
                width = (int)canvasImage.PixelWidth - x;
2598
            }
2599
            if (y + height > canvasImage.PixelHeight)
2600
            {
2601
                height = (int)canvasImage.PixelHeight - y;
2602
            }
2603
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2604

    
2605
            string uri = "";
2606
            if (userData.COMPANY != "EXT")
2607
            {
2608
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
2609
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2610
            }
2611
            else
2612
            {
2613
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2614
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2615
            }
2616

    
2617
            var defaultBitmapImage = new BitmapImage();
2618
            defaultBitmapImage.BeginInit();
2619
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2620
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2621
            defaultBitmapImage.UriSource = new Uri(uri);
2622
            defaultBitmapImage.EndInit();
2623

    
2624
            //GC.Collect();
2625

    
2626
            if (defaultBitmapImage.IsDownloading)
2627
            {
2628
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2629
                {
2630
                    defaultBitmapImage.Freeze();
2631
                    //GC.Collect();
2632
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2633
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2634
                };
2635
            }
2636
        }
2637

    
2638
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2639
        {
2640
            ///mouseButtonDown = MouseButton.Left;
2641
        }
2642

    
2643
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2644
        {
2645
            ///mouseButtonDown = MouseButton.Left;
2646
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2647
        }
2648

    
2649
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2650
        {
2651

    
2652
        }
2653

    
2654
        /// <summary>
2655
        /// select items by dragging
2656
        /// </summary>
2657
        private void ApplyDragSelectionRect()
2658
        {
2659
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2660

    
2661
            double x = Canvas.GetLeft(dragSelectionBorder);
2662
            double y = Canvas.GetTop(dragSelectionBorder);
2663
            double width = dragSelectionBorder.Width;
2664
            double height = dragSelectionBorder.Height;
2665
            Boolean Flag = false;
2666
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2667
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2668

    
2669
            Rect dragRect = new Rect(x, y, width, height);
2670
            ///dragRect.Inflate(width / 10, height / 10);
2671

    
2672
            foreach (var item in Items)
2673
            {
2674
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2675

    
2676
                if (Flag)
2677
                {
2678
                    adornerSet.Add(item);
2679
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2680
                    Control_Style(item);
2681
                }
2682
            }
2683
            if (adornerSet.Count > 0)
2684
            {
2685
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2686
                SelectLayer.Children.Add(final);
2687
            }
2688
        }
2689

    
2690
        private void InitDragSelectionRect(Point pt1, Point pt2)
2691
        {
2692
            //캡쳐 중
2693
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2694
            {
2695
                dragCaptureBorder.Visibility = Visibility.Visible;
2696
            }
2697
            //선택 중
2698
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2699
            {
2700

    
2701
                dragSelectionBorder.Visibility = Visibility.Visible;
2702
            }
2703
            else
2704
            {
2705
                dragZoomBorder.Visibility = Visibility.Visible;
2706
            }
2707
            UpdateDragSelectionRect(pt1, pt2);
2708
        }
2709

    
2710
        /// <summary>
2711
        /// Update the position and size of the rectangle used for drag selection.
2712
        /// </summary>
2713
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2714
        {
2715
            double x, y, width, height;
2716

    
2717
            //
2718
            // Determine x,y,width and height of the rect inverting the points if necessary.
2719
            // 
2720

    
2721
            if (pt2.X < pt1.X)
2722
            {
2723
                x = pt2.X;
2724
                width = pt1.X - pt2.X;
2725
            }
2726
            else
2727
            {
2728
                x = pt1.X;
2729
                width = pt2.X - pt1.X;
2730
            }
2731

    
2732
            if (pt2.Y < pt1.Y)
2733
            {
2734
                y = pt2.Y;
2735
                height = pt1.Y - pt2.Y;
2736
            }
2737
            else
2738
            {
2739
                y = pt1.Y;
2740
                height = pt2.Y - pt1.Y;
2741
            }
2742

    
2743
            //
2744
            // Update the coordinates of the rectangle used for drag selection.
2745
            //
2746
            //캡쳐 중
2747
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2748
            {
2749
                Canvas.SetLeft(dragCaptureBorder, x);
2750
                Canvas.SetTop(dragCaptureBorder, y);
2751
                dragCaptureBorder.Width = width;
2752
                dragCaptureBorder.Height = height;
2753
            }
2754
            //선택 중
2755
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2756
            {
2757
                Canvas.SetLeft(dragSelectionBorder, x);
2758
                Canvas.SetTop(dragSelectionBorder, y);
2759
                dragSelectionBorder.Width = width;
2760
                dragSelectionBorder.Height = height;
2761
            }
2762
            else
2763
            {
2764
                Canvas.SetLeft(dragZoomBorder, x);
2765
                Canvas.SetTop(dragZoomBorder, y);
2766
                dragZoomBorder.Width = width;
2767
                dragZoomBorder.Height = height;
2768
            }
2769
        }
2770

    
2771
        private void drawingPannelRotate(double angle)
2772
        {
2773
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2774
            rotate.Angle = angle;
2775
            var rotationNum = Math.Abs((rotate.Angle / 90));
2776

    
2777
            if (angle == 90 || angle == 270)
2778
            {
2779
                double emptySize = zoomAndPanCanvas.Width;
2780
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2781
                zoomAndPanCanvas.Height = emptySize;
2782
            }
2783
            if (angle == 0)
2784
            {
2785
                translate.X = 0;
2786
                translate.Y = 0;
2787
            }
2788
            else if (angle == 90)
2789
            {
2790
                translate.X = zoomAndPanCanvas.Width;
2791
                translate.Y = 0;
2792
            }
2793
            else if (angle == 180)
2794
            {
2795
                translate.X = zoomAndPanCanvas.Width;
2796
                translate.Y = zoomAndPanCanvas.Height;
2797
            }
2798
            else
2799
            {
2800
                translate.X = 0;
2801
                translate.Y = zoomAndPanCanvas.Height;
2802
            }
2803

    
2804
            zoomAndPanControl.RotationAngle = rotate.Angle;
2805

    
2806

    
2807
            if (!testPanel2.IsHidden)
2808
            {
2809
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2810
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2811
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2812
            }
2813

    
2814
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2815
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2816
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2817
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2818
            ViewerDataModel.Instance.Angle = rotate.Angle;
2819
        }
2820

    
2821
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2822
        {
2823
            string Data_ = "";
2824

    
2825
            try
2826
            {
2827
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2828
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2829
                if (Data_ != null || Data_ != "")
2830
                {
2831
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2832
                }
2833
                else
2834
                {
2835
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2836
                }
2837

    
2838
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2839
                //{
2840
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2841
                //    STATE = 0,
2842
                //};
2843
                if (Data_ != null)
2844
                {
2845
                    Image img = new Image();
2846
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2847
                    if (Data_.Contains(".svg"))
2848
                    {
2849
                        byte[] imageData = null;
2850
                        DrawingImage image = null;
2851
                        using (System.Net.WebClient web = new System.Net.WebClient())
2852
                        {
2853
                            imageData = web.DownloadData(new Uri(Data_));
2854
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2855
                            image = SvgReader.Load(stream);
2856
                        }
2857
                        img.Source = image;
2858
                    }
2859
                    else
2860
                    {
2861
                        img.Source = new BitmapImage(new Uri(Data_));
2862
                    }
2863

    
2864
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2865
                    {
2866
                        PointSet = new List<Point>(),
2867
                        FilePath = Data_,
2868
                        ImageData = img.Source,
2869
                        StartPoint = canvasZoomPanningMouseDownPoint,
2870
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2871
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2872
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2873
                        canvasZoomPanningMouseDownPoint.Y),
2874
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2875
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2876
                    };
2877

    
2878
                    currentControl.PointSet = new List<Point>
2879
                                        {
2880
                                            currentControl.StartPoint,
2881
                                            currentControl.LeftBottomPoint,
2882
                                            currentControl.EndPoint,
2883
                                            currentControl.TopRightPoint,
2884
                                        };
2885
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2886
                    UndoData = new Undo_data()
2887
                    {
2888
                        IsUndo = false,
2889
                        Event = Event_Type.Create,
2890
                        EventTime = DateTime.Now,
2891
                        Markup_List = new List<Multi_Undo_data>()
2892
                    };
2893
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2894
                    {
2895
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2896
                    });
2897

    
2898
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2899
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2900
                    UndoData.Markup_List.Add(multi_Undo_Data);
2901
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2902

    
2903
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2904
                    currentControl.CommentID = Commons.shortGuid();
2905
                    currentControl.SymbolID = id;
2906
                    currentControl.GroupID = group_id;
2907
                    currentControl.ApplyTemplate();
2908
                    currentControl.SetImage();
2909

    
2910
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2911
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2912
                    SelectLayer.Children.Add(final);
2913
                }
2914
            }
2915
            catch (Exception ex)
2916
            {
2917
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2918
            }
2919
        }
2920

    
2921
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2922
        {            
2923
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2924
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2925
            {
2926
                set_option.Value = double.Parse(set_option.ContentText);
2927
            }
2928

    
2929
            InkControl_Convert();
2930

    
2931
            ///TODO:
2932
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2933
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2934

    
2935
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2936
            {
2937
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2938
            }
2939
            /// up to here
2940

    
2941
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2942
            {
2943
                if (arrow_text as ArrowTextControl != null)
2944
                {
2945
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2946
                }
2947
            }
2948

    
2949
            //if (currentControl != null)
2950
            {
2951
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2952
                if (text_item_ != null)
2953
                {
2954
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2955
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2956
                    (text_item_ as TextControl).EnableEditing = false;
2957
                    currentControl = null;
2958
                }
2959

    
2960
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2961
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2962
                {
2963
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2964
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2965
                    currentControl = null;
2966
                }
2967
            }
2968

    
2969
            double Ang = 0;                                          
2970
            if (rotate.Angle != 0)
2971
            {
2972
                Ang = 360 - rotate.Angle;
2973
            }
2974

    
2975
            if (e.OriginalSource is System.Windows.Controls.Image)
2976
            {
2977
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2978
            }
2979

    
2980
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2981
            {                
2982
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2983
                if(symbol_id != null)
2984
                {
2985
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2986
                }                
2987
            }
2988

    
2989
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2990
            {
2991
                if (this._dragdropWindow != null)
2992
                {
2993
                    this._dragdropWindow.Close();
2994
                    this._dragdropWindow = null;
2995
                    symbol_id = null;
2996
                }
2997
            }
2998

    
2999
            if (e.LeftButton == MouseButtonState.Pressed)
3000
            {
3001
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3002
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3003

    
3004
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3005
                SetCursor();
3006

    
3007
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
3008
            }
3009

    
3010
            if (e.MiddleButton == MouseButtonState.Pressed)
3011
            {
3012
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3013
                cursor = Cursors.SizeAll;
3014
                SetCursor();
3015
            }
3016
            if (e.RightButton == MouseButtonState.Pressed)
3017
            {
3018
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3019
                cursor = Cursors.SizeAll;
3020
                SetCursor();
3021
            }
3022
            else if (e.XButton1 == MouseButtonState.Pressed)
3023
            {
3024
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3025
                {
3026
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3027
                }
3028

    
3029
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3030

    
3031
            }
3032
            else if (e.XButton2 == MouseButtonState.Pressed)
3033
            {
3034
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3035
                {
3036
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3037
                }
3038
            }
3039

    
3040
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3041
            {
3042
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3043
                {
3044
                    if (SelectLayer.Children.Count == 0)
3045
                    {
3046
                        isLeftMouseButtonDownOnWindow = true;
3047
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3048
                    }
3049

    
3050
                    if (controlType == ControlType.None)
3051
                    {
3052
                        isLeftMouseButtonDownOnWindow = true;
3053
                    }
3054
                }
3055

    
3056
                /// 캡쳐 모드 설정
3057
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3058
                {
3059
                    dragCaptureBorder.Visibility = Visibility.Visible;
3060
                    isLeftMouseButtonDownOnWindow = true;
3061
                }
3062

    
3063
                /// 줌 모드 설정
3064
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3065
                {
3066
                    isLeftMouseButtonDownOnWindow = true;
3067
                }
3068

    
3069
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3070
                if (control != null)
3071
                {
3072
                    AdornerFinal final = null;
3073

    
3074
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3075
                    {
3076
                        /// 기존 selection 해제
3077
                        SelectionSet.Instance.UnSelect(this);
3078

    
3079
                        final = new AdornerFinal(control);
3080

    
3081
                        this.Control_Style(control);
3082

    
3083
                        if ((control as IPath) != null)
3084
                        {
3085
                            if ((control as IPath).LineSize != 0)
3086
                            {
3087
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3088
                            }
3089
                        }
3090
                        if ((control as IShapeControl) != null)
3091
                        {
3092
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3093
                            {
3094
                                ViewerDataModel.Instance.checkHatchShape = true;
3095
                            }
3096
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3097
                            {
3098
                                ViewerDataModel.Instance.checkFillShape = true;
3099
                            }
3100
                            else
3101
                            {
3102
                                ViewerDataModel.Instance.checkHatchShape = false;
3103
                                ViewerDataModel.Instance.checkFillShape = false;
3104
                            }
3105
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3106
                        }
3107

    
3108
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3109

    
3110
                        if ((control as TextControl) != null)
3111
                        {
3112
                            if(!((control as TextControl).EnableEditing)) {
3113
                                (control as TextControl).EnableEditing = true;
3114
                            }
3115

    
3116
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3117
                            {
3118
                                ViewerDataModel.Instance.checkTextStyle = true;
3119
                            }
3120
                            else
3121
                            {
3122
                                ViewerDataModel.Instance.checkTextStyle = false;
3123
                            }
3124

    
3125
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3126
                            {
3127
                                ViewerDataModel.Instance.checkTextStyle = true;
3128
                            }
3129
                            else
3130
                            {
3131
                                ViewerDataModel.Instance.checkTextStyle = false;
3132
                            }
3133
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3134
                            {
3135
                                ViewerDataModel.Instance.checkTextWeight = true;
3136
                            }
3137
                            else
3138
                            {
3139
                                ViewerDataModel.Instance.checkTextWeight = false;
3140
                            }
3141
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3142
                            {
3143
                                ViewerDataModel.Instance.checkUnderLine = true;
3144
                            }
3145
                            else
3146
                            {
3147
                                ViewerDataModel.Instance.checkUnderLine = false;
3148
                            }
3149
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3150
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3151

    
3152
                        }
3153
                        else if ((control as ArrowTextControl) != null)
3154
                        {
3155
                            if (!((control as ArrowTextControl).EnableEditing)){
3156
                                (control as ArrowTextControl).EnableEditing = true;
3157
                            }
3158
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3159
                            {
3160
                                ViewerDataModel.Instance.checkTextStyle = true;
3161
                            }
3162
                            else
3163
                            {
3164
                                ViewerDataModel.Instance.checkTextStyle = false;
3165
                            }
3166

    
3167
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3168
                            {
3169
                                ViewerDataModel.Instance.checkTextStyle = true;
3170
                            }
3171
                            else
3172
                            {
3173
                                ViewerDataModel.Instance.checkTextStyle = false;
3174
                            }
3175
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3176
                            {
3177
                                ViewerDataModel.Instance.checkTextWeight = true;
3178
                            }
3179
                            else
3180
                            {
3181
                                ViewerDataModel.Instance.checkTextWeight = false;
3182
                            }
3183
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3184
                            {
3185
                                ViewerDataModel.Instance.checkUnderLine = true;
3186
                            }
3187
                            else
3188
                            {
3189
                                ViewerDataModel.Instance.checkUnderLine = false;
3190
                            }
3191
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3192
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3193
                        }
3194
                        else if ((control as RectCloudControl) != null)
3195
                        {
3196
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3197
                        }
3198
                        else if ((control as CloudControl) != null)
3199
                        {
3200
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3201
                        }
3202
                    }
3203
                    else
3204
                    {
3205
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3206
                        SelectionSet.Instance.UnSelect(this);
3207
                        comment.Add(control);
3208

    
3209
                        Control_Style(control);
3210

    
3211
                        final = new AdornerFinal(comment);
3212
                    }
3213

    
3214
                    if (final != null)
3215
                    {
3216
                        this.SelectLayer.Children.Add(final);
3217
                    }
3218
                }              
3219
            }
3220
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3221
            {               
3222
                init();
3223
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3224
                if (cursor != Cursors.SizeAll)
3225
                {
3226
                    cursor = Cursors.Cross;
3227
                    SetCursor();
3228
                }
3229
                bool init_user = false;
3230
                foreach (var user in gridViewMarkup.Items)
3231
                {
3232
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3233
                    {
3234
                        init_user = true;
3235
                    }
3236
                }
3237
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3238
                {
3239
                    RadWindow.Alert(new DialogParameters
3240
                    {
3241
                        Owner = Application.Current.MainWindow,
3242
                        Theme = new VisualStudio2013Theme(),
3243
                        Header = "안내",
3244
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3245
                    });
3246
                    return;
3247
                }
3248
                else
3249
                {
3250
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3251
                    if (item != null)
3252
                    {
3253
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3254
                    }
3255
                }
3256

    
3257
                switch (controlType)
3258
                {
3259
                    case ControlType.Coordinate:
3260
                        {
3261
                            if (e.LeftButton == MouseButtonState.Pressed)
3262
                            {
3263
                                if (currentControl is CoordinateControl)
3264
                                {
3265
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3266
                                    {
3267
                                        return;
3268
                                    }
3269

    
3270
                                    CreateCommand.Instance.Execute(currentControl);
3271

    
3272
                                    currentControl = null;
3273
                                    this.cursor = Cursors.Arrow;
3274
                                }
3275
                                else
3276
                                {
3277
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3278
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3279
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3280
                                    {
3281
                                        currentControl = null;
3282
                                        this.cursor = Cursors.Arrow;
3283
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3284
                                        return;
3285
                                    }
3286
                                    else
3287
                                    {
3288
                                        currentControl = new CoordinateControl
3289
                                        {
3290
                                            Background = new SolidColorBrush(Colors.Black),
3291
                                            ControlType = ControlType.Coordinate
3292
                                        };
3293

    
3294
                                        currentControl.CommentID = Commons.shortGuid();
3295
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3296
                                        currentControl.IsNew = true;
3297

    
3298
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3299

    
3300
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3301
                                    }
3302
                                }
3303
                            }
3304
                        }
3305
                        break;
3306
                    case ControlType.InsideWhite:
3307
                        {
3308
                            if (e.LeftButton == MouseButtonState.Pressed)
3309
                            {
3310
                                if (currentControl is InsideWhiteControl)
3311
                                {
3312
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3313
                                    {
3314
                                        return;
3315
                                    }
3316

    
3317
                                    CreateCommand.Instance.Execute(currentControl);
3318

    
3319
                                    currentControl = null;
3320
                                    this.cursor = Cursors.Arrow;
3321
                                }
3322
                                else
3323
                                {
3324
                                    currentControl = new InsideWhiteControl
3325
                                    {
3326
                                        Background = new SolidColorBrush(Colors.Black),
3327
                                        ControlType = ControlType.InsideWhite
3328
                                    };
3329

    
3330
                                    currentControl.CommentID = Commons.shortGuid();
3331
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3332
                                    currentControl.IsNew = true;
3333
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3334

    
3335
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3336
                                }
3337
                            }
3338
                        }
3339
                        break;
3340
                    case ControlType.OverlapWhite:
3341
                        {
3342
                            if (e.LeftButton == MouseButtonState.Pressed)
3343
                            {
3344
                                if (currentControl is OverlapWhiteControl)
3345
                                {
3346
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3347
                                    {
3348
                                        return;
3349
                                    }
3350

    
3351
                                    CreateCommand.Instance.Execute(currentControl);
3352

    
3353
                                    currentControl = null;
3354
                                    this.cursor = Cursors.Arrow;
3355
                                }
3356
                                else
3357
                                {
3358
                                    currentControl = new OverlapWhiteControl
3359
                                    {
3360
                                        Background = new SolidColorBrush(Colors.Black),
3361
                                        ControlType = ControlType.OverlapWhite
3362
                                    };
3363

    
3364
                                    currentControl.CommentID = Commons.shortGuid();
3365
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3366
                                    currentControl.IsNew = true;
3367
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3368

    
3369
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3370
                                }
3371
                            }
3372
                        }
3373
                        break;
3374
                    case ControlType.ClipWhite:
3375
                        {
3376
                            if (e.LeftButton == MouseButtonState.Pressed)
3377
                            {
3378
                                if (currentControl is ClipWhiteControl)
3379
                                {
3380
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3381
                                    {
3382
                                        return;
3383
                                    }
3384

    
3385
                                    CreateCommand.Instance.Execute(currentControl);
3386

    
3387
                                    currentControl = null;
3388
                                    this.cursor = Cursors.Arrow;
3389
                                }
3390
                                else
3391
                                {
3392
                                    currentControl = new ClipWhiteControl
3393
                                    {
3394
                                        Background = new SolidColorBrush(Colors.Black),
3395
                                        ControlType = ControlType.ClipWhite
3396
                                    };
3397

    
3398
                                    currentControl.CommentID = Commons.shortGuid();
3399
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3400
                                    currentControl.IsNew = true;
3401
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3402

    
3403
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3404
                                }
3405
                            }
3406
                        }
3407
                        break;
3408
                    case ControlType.Rectangle:
3409
                        {
3410
                            if (e.LeftButton == MouseButtonState.Pressed)
3411
                            {
3412
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3413
                                //{
3414
                                    if (currentControl is RectangleControl)
3415
                                    {
3416
                                        //20180906 LJY TEST IsRotationDrawingEnable
3417
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3418
                                        {
3419
                                            return;
3420
                                        }
3421

    
3422
                                        CreateCommand.Instance.Execute(currentControl);
3423

    
3424
                                        currentControl = null;
3425
                                    
3426
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3427
                                    }
3428
                                    else
3429
                                    {
3430
                                        currentControl = new RectangleControl
3431
                                        {
3432
                                            Background = new SolidColorBrush(Colors.Black),
3433
                                            ControlType = ControlType.Rectangle
3434
                                        };
3435

    
3436
                                        currentControl.CommentID = Commons.shortGuid();
3437
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3438
                                        currentControl.IsNew = true;
3439
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3440

    
3441
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3442
                                    }
3443
                                //}
3444
                            }
3445
                        }
3446
                        break;
3447
                    case ControlType.RectCloud:
3448
                        {
3449
                            if (e.LeftButton == MouseButtonState.Pressed)
3450
                            {
3451
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3452
                                //{
3453
                                    if (currentControl is RectCloudControl)
3454
                                    {
3455
                                        //20180906 LJY TEST IsRotationDrawingEnable
3456
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3457
                                        {
3458
                                            return;
3459
                                        }
3460

    
3461
                                        CreateCommand.Instance.Execute(currentControl);
3462

    
3463
                                        currentControl = null;
3464
                                    
3465
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3466
                                    }
3467
                                    else
3468
                                    {
3469
                                        currentControl = new RectCloudControl
3470
                                        {
3471
                                            Background = new SolidColorBrush(Colors.Black)
3472
                                        };
3473

    
3474
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3475
                                        currentControl.CommentID = Commons.shortGuid();
3476
                                        currentControl.IsNew = true;
3477
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3478
                                    }
3479
                                //}
3480
                            }
3481
                        }
3482
                        break;
3483
                    case ControlType.Circle:
3484
                        {
3485
                            if (e.LeftButton == MouseButtonState.Pressed)
3486
                            {
3487
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3488
                                //{
3489
                                    if (currentControl is CircleControl)
3490
                                    {
3491
                                        //20180906 LJY TEST IsRotationDrawingEnable
3492
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3493
                                        {
3494
                                            return;
3495
                                        }
3496

    
3497
                                        CreateCommand.Instance.Execute(currentControl);
3498

    
3499
                                        currentControl = null;
3500
                                    }
3501
                                    else
3502
                                    {
3503
                                        currentControl = new CircleControl
3504
                                        {
3505
                                            Background = new SolidColorBrush(Colors.Black)
3506
                                        };
3507

    
3508
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3509
                                        currentControl.CommentID = Commons.shortGuid();
3510
                                        currentControl.IsNew = true;
3511
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3512
                                    }
3513
                                //}
3514
                            }
3515
                        }
3516
                        break;
3517
                    case ControlType.Triangle:
3518
                        {
3519
                            if (e.LeftButton == MouseButtonState.Pressed)
3520
                            {
3521
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3522
                                //{
3523
                                    if (currentControl is TriControl)
3524
                                    {
3525
                                        var content = currentControl as TriControl;
3526
                                        if (content.MidPoint == new Point(0, 0))
3527
                                        {
3528
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3529
                                        }
3530
                                        else
3531
                                        {
3532
                                            //20180906 LJY TEST IsRotationDrawingEnable
3533
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3534
                                            {
3535
                                                return;
3536
                                            }
3537

    
3538
                                            CreateCommand.Instance.Execute(currentControl);
3539

    
3540
                                            currentControl = null;
3541
                                        }
3542
                                    }
3543
                                    else
3544
                                    {
3545
                                        currentControl = new TriControl
3546
                                        {
3547
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3548
                                            Background = new SolidColorBrush(Colors.Black),
3549
                                        };
3550

    
3551
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3552
                                        currentControl.CommentID = Commons.shortGuid();
3553
                                        currentControl.IsNew = true;
3554
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3555
                                    }
3556
                                //}
3557
                            }
3558
                        }
3559
                        break;
3560
                    case ControlType.SingleLine:
3561
                        {
3562
                            if (e.LeftButton == MouseButtonState.Pressed)
3563
                            {
3564
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3565
                                //{
3566
                                    if (currentControl is LineControl)
3567
                                    {
3568
                                        //20180906 LJY TEST IsRotationDrawingEnable
3569
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3570
                                        {
3571
                                            return;
3572
                                        }
3573

    
3574
                                        CreateCommand.Instance.Execute(currentControl);
3575

    
3576
                                        currentControl = null;
3577
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3578
                                    }
3579
                                    else
3580
                                    {
3581
                                        currentControl = new LineControl
3582
                                        {
3583
                                            Background = new SolidColorBrush(Colors.Black)
3584
                                        };
3585

    
3586
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3587
                                        currentControl.CommentID = Commons.shortGuid();
3588
                                        currentControl.IsNew = true;
3589
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3590
                                        this.MainAngle.Visibility = Visibility.Visible;
3591
                                    }
3592
                                //}
3593
                            }
3594
                        }
3595
                        break;
3596
                    case ControlType.CancelLine:
3597
                        {
3598
                            if (e.LeftButton == MouseButtonState.Pressed)
3599
                            {
3600
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3601
                                //{
3602
                                    if (currentControl is LineControl)
3603
                                    {
3604
                                        //20180906 LJY TEST IsRotationDrawingEnable
3605
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3606
                                        {
3607
                                            return;
3608
                                        }
3609

    
3610
                                        CreateCommand.Instance.Execute(currentControl);
3611

    
3612
                                        currentControl = null;
3613
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3614
                                    }
3615
                                    else
3616
                                    {
3617
                                        currentControl = new LineControl
3618
                                        {
3619
                                            Background = new SolidColorBrush(Colors.Black)
3620
                                        };
3621

    
3622
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3623
                                        currentControl.CommentID = Commons.shortGuid();
3624
                                        currentControl.IsNew = true;
3625
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3626
                                        this.MainAngle.Visibility = Visibility.Visible;
3627
                                    }
3628
                                //}
3629
                            }
3630
                        }
3631
                        break;
3632
                    case ControlType.ArrowLine:
3633
                        {
3634
                            if (e.LeftButton == MouseButtonState.Pressed)
3635
                            {
3636
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3637
                                //{
3638
                                    if (currentControl is LineControl)
3639
                                    {
3640
                                        //20180906 LJY TEST IsRotationDrawingEnable
3641
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3642
                                        {
3643
                                            return;
3644
                                        }
3645

    
3646
                                        CreateCommand.Instance.Execute(currentControl);
3647

    
3648
                                        currentControl = null;
3649
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3650
                                    }
3651
                                    else
3652
                                    {
3653
                                        currentControl = new LineControl
3654
                                        {
3655
                                            Background = new SolidColorBrush(Colors.Black)
3656
                                        };
3657

    
3658
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3659
                                        currentControl.CommentID = Commons.shortGuid();
3660
                                        currentControl.IsNew = true;
3661
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3662
                                        this.MainAngle.Visibility = Visibility.Visible;
3663
                                    }
3664
                                //}
3665
                            }
3666
                        }
3667
                        break;
3668
                    case ControlType.TwinLine:
3669
                        {
3670
                            if (e.LeftButton == MouseButtonState.Pressed)
3671
                            {
3672
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3673
                                //{
3674
                                    if (currentControl is LineControl)
3675
                                    {
3676
                                        //20180906 LJY TEST IsRotationDrawingEnable
3677
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3678
                                        {
3679
                                            return;
3680
                                        }
3681

    
3682
                                        CreateCommand.Instance.Execute(currentControl);
3683

    
3684
                                        currentControl = null;
3685
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3686
                                    }
3687
                                    else
3688
                                    {
3689
                                        currentControl = new LineControl
3690
                                        {
3691
                                            Background = new SolidColorBrush(Colors.Black)
3692
                                        };
3693
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3694
                                        currentControl.CommentID = Commons.shortGuid();
3695
                                        currentControl.IsNew = true;
3696
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3697
                                        this.MainAngle.Visibility = Visibility.Visible;
3698
                                    }
3699
                                //}
3700
                            }
3701
                        }
3702
                        break;
3703
                    case ControlType.DimLine:
3704
                        {
3705
                            if (e.LeftButton == MouseButtonState.Pressed)
3706
                            {
3707
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3708
                                //{
3709
                                    if (currentControl is LineControl)
3710
                                    {
3711
                                        //20180906 LJY TEST IsRotationDrawingEnable
3712
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3713
                                        {
3714
                                            return;
3715
                                        }
3716
                                        CreateCommand.Instance.Execute(currentControl);
3717

    
3718
                                        currentControl = null;
3719
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3720
                                    }
3721
                                    else
3722
                                    {
3723
                                        currentControl = new LineControl
3724
                                        {
3725
                                            Background = new SolidColorBrush(Colors.Black)
3726
                                        };
3727
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3728
                                        currentControl.CommentID = Commons.shortGuid();
3729
                                        currentControl.IsNew = true;
3730
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3731
                                        this.MainAngle.Visibility = Visibility.Visible;
3732
                                    }
3733
                                //}
3734
                            }
3735
                        }
3736
                        break;
3737
                    case ControlType.ChainLine:
3738
                        {
3739
                            if (currentControl is PolygonControl)
3740
                            {
3741
                                var control = currentControl as PolygonControl;
3742

    
3743
                                if (e.RightButton == MouseButtonState.Pressed)
3744
                                {
3745
                                    //20180906 LJY TEST IsRotationDrawingEnable
3746
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3747
                                    {
3748
                                        return;
3749
                                    }
3750

    
3751
                                    CreateCommand.Instance.Execute(currentControl);
3752

    
3753
                                    currentControl = null;
3754
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3755
                                    return;
3756
                                }
3757

    
3758
                                if (!control.IsCompleted)
3759
                                {
3760
                                    control.PointSet.Add(control.EndPoint);
3761
                                    this.MainAngle.Visibility = Visibility.Visible;
3762
                                }
3763
                            }
3764
                            else
3765
                            {
3766
                                if (e.LeftButton == MouseButtonState.Pressed)
3767
                                {
3768
                                    MainAngle.Visibility = Visibility.Visible;
3769
                                    currentControl = new PolygonControl
3770
                                    {
3771
                                        PointSet = new List<Point>(),
3772
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3773
                                        ControlType = ControlType.ChainLine,
3774
                                        DashSize = ViewerDataModel.Instance.DashSize,
3775
                                        LineSize = ViewerDataModel.Instance.LineSize,
3776
                                        //PointC = new StylusPointSet()
3777
                                    };
3778

    
3779
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3780
                                    //{
3781
                                        var polygonControl = (currentControl as PolygonControl);
3782
                                        currentControl.CommentID = Commons.shortGuid();
3783
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3784
                                        currentControl.IsNew = true;
3785
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3786
                                        //currentControl.OnApplyTemplate();
3787
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3788
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3789
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3790
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3791
                                    //}
3792
                                }
3793
                            }
3794
                        }
3795
                        break;
3796
                    case ControlType.ArcLine:
3797
                        {
3798
                            if (e.LeftButton == MouseButtonState.Pressed)
3799
                            {
3800
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3801
                                //{
3802
                                    if (currentControl is ArcControl)
3803
                                    {
3804
                                        //20180906 LJY TEST IsRotationDrawingEnable
3805
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3806
                                        {
3807
                                            return;
3808
                                        }
3809

    
3810
                                        CreateCommand.Instance.Execute(currentControl);
3811

    
3812
                                        currentControl = null;
3813
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3814
                                    }
3815
                                    else
3816
                                    {
3817
                                        currentControl = new ArcControl
3818
                                        {
3819
                                            Background = new SolidColorBrush(Colors.Black)
3820
                                        };
3821
                                        currentControl.CommentID = Commons.shortGuid();
3822
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3823
                                        currentControl.IsNew = true;
3824
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3825
                                        this.MainAngle.Visibility = Visibility.Visible;
3826
                                    }
3827
                                //}
3828
                            }
3829
                            else if (e.RightButton == MouseButtonState.Pressed)
3830
                            {
3831
                                if (currentControl != null)
3832
                                {
3833
                                    (currentControl as ArcControl).setClock();
3834
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3835
                                    //(currentControl as ArcControl).ApplyTemplate();
3836
                                }
3837
                            }
3838
                        }
3839
                        break;
3840
                    case ControlType.ArcArrow:
3841
                        {
3842
                            if (e.LeftButton == MouseButtonState.Pressed)
3843
                            {
3844
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3845
                                //{
3846
                                if (currentControl is ArrowArcControl)
3847
                                {
3848
                                    //20180906 LJY TEST IsRotationDrawingEnable
3849
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3850
                                    {
3851
                                        return;
3852
                                    }
3853

    
3854
                                    CreateCommand.Instance.Execute(currentControl);
3855

    
3856
                                    currentControl = null;
3857
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3858
                                }
3859
                                else
3860
                                {
3861
                                    currentControl = new ArrowArcControl
3862
                                    {
3863
                                        Background = new SolidColorBrush(Colors.Black)
3864
                                    };
3865
                                    currentControl.CommentID = Commons.shortGuid();
3866
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3867
                                    currentControl.IsNew = true;
3868
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3869
                                    this.MainAngle.Visibility = Visibility.Visible;
3870
                                }
3871
                                //}
3872
                            }
3873
                            else if (e.RightButton == MouseButtonState.Pressed)
3874
                            {
3875
                                if (currentControl != null)
3876
                                {
3877
                                    (currentControl as ArrowArcControl).setClock();
3878
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3879
                                    //(currentControl as ArcControl).ApplyTemplate();
3880
                                }
3881
                            }
3882
                        }
3883
                        break;
3884
                    case ControlType.ArrowMultiLine:
3885
                        {
3886
                            if (e.LeftButton == MouseButtonState.Pressed)
3887
                            {
3888
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3889
                                //{
3890

    
3891
                                    if (currentControl is ArrowControl_Multi)
3892
                                    {
3893
                                        var content = currentControl as ArrowControl_Multi;
3894
                                        if (content.MiddlePoint == new Point(0, 0))
3895
                                        {
3896
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3897
                                            {
3898
                                                content.MiddlePoint = content.EndPoint;
3899
                                            }
3900
                                            else
3901
                                            {
3902
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3903
                                            }
3904
                                        }
3905
                                        else
3906
                                        {
3907
                                            //20180906 LJY TEST IsRotationDrawingEnable
3908
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3909
                                            {
3910
                                                return;
3911
                                            }
3912

    
3913
                                            CreateCommand.Instance.Execute(currentControl);
3914

    
3915
                                            currentControl = null;
3916
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3917
                                        }
3918
                                    }
3919
                                    else
3920
                                    {
3921
                                        currentControl = new ArrowControl_Multi
3922
                                        {
3923
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3924
                                            Background = new SolidColorBrush(Colors.Black)
3925
                                        };
3926
                                        currentControl.CommentID = Commons.shortGuid();
3927
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3928
                                        currentControl.IsNew = true;
3929
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3930
                                        this.MainAngle.Visibility = Visibility.Visible;
3931
                                    }
3932
                                //}
3933
                            }
3934
                        }
3935
                        break;
3936
                    case ControlType.PolygonCloud:
3937
                        {
3938
                            if (currentControl is CloudControl)
3939
                            {
3940
                                var control = currentControl as CloudControl;
3941
                                if (e.RightButton == MouseButtonState.Pressed)
3942
                                {
3943
                                    control.IsCompleted = true;
3944
                                }
3945

    
3946
                                if (!control.IsCompleted)
3947
                                {
3948
                                    control.PointSet.Add(control.EndPoint);
3949
                                }
3950
                                else
3951
                                {
3952
                                    //20180906 LJY TEST IsRotationDrawingEnable
3953
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3954
                                    {
3955
                                        return;
3956
                                    }
3957

    
3958
                                    CreateCommand.Instance.Execute(currentControl);
3959

    
3960
                                    control.isTransOn = true;
3961
                                    var firstPoint = control.PointSet.First();
3962

    
3963
                                    control.PointSet.Add(firstPoint);
3964
                                    control.DrawingCloud();
3965
                                    control.ApplyOverViewData();
3966

    
3967
                                    currentControl = null;
3968
                                }
3969
                            }
3970
                            else
3971
                            {
3972
                                if (e.LeftButton == MouseButtonState.Pressed)
3973
                                {
3974
                                    currentControl = new CloudControl
3975
                                    {
3976
                                        PointSet = new List<Point>(),
3977
                                        PointC = new StylusPointSet()
3978
                                    };
3979

    
3980
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3981
                                    //{
3982
                                        var polygonControl = (currentControl as CloudControl);
3983
                                        currentControl.CommentID = Commons.shortGuid();
3984
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3985
                                        currentControl.IsNew = true;
3986
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3987

    
3988
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3989
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3990
                                    
3991
                                    //}
3992
                                }
3993
                            }
3994
                        }
3995
                        break;
3996
                    case ControlType.ImgControl:
3997
                        {
3998
                            if (e.LeftButton == MouseButtonState.Pressed)
3999
                            {
4000
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4001
                                //{
4002
                                    if (currentControl is ImgControl)
4003
                                    {
4004
                                        //20180906 LJY TEST IsRotationDrawingEnable
4005
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4006
                                        {
4007
                                            return;
4008
                                        }
4009

    
4010
                                        CreateCommand.Instance.Execute(currentControl);
4011
                                        controlType = ControlType.ImgControl;
4012
                                        currentControl = null;
4013
                                    }
4014
                                    else
4015
                                    {
4016
                                        
4017
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4018
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4019
                                        {
4020
                                            Image img = new Image();
4021
                                            //img.Source = new BitmapImage(new Uri(filename));
4022
                                            if (filename.Contains(".svg"))
4023
                                            {
4024
                                                byte[] imageData = null;
4025
                                                DrawingImage image = null;
4026
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4027
                                                {
4028
                                                    imageData = web.DownloadData(new Uri(filename));
4029
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4030
                                                    image = SvgReader.Load(stream);
4031
                                                }
4032
                                                img.Source = image;
4033
                                            }
4034
                                            else
4035
                                            {
4036
                                                img.Source = new BitmapImage(new Uri(filename));
4037
                                            }
4038

    
4039
                                            currentControl = new ImgControl
4040
                                            {
4041
                                                    Background = new SolidColorBrush(Colors.Black),
4042
                                                    PointSet = new List<Point>(),
4043
                                                    FilePath = filename,
4044
                                                    ImageData = img.Source,
4045
                                                    StartPoint = canvasDrawingMouseDownPoint,
4046
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4047
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4048
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4049
                                                    ControlType = ControlType.ImgControl
4050
                                                };
4051

    
4052
                                        
4053
                                                currentControl.CommentID = Commons.shortGuid();                                            
4054
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4055
                                                currentControl.IsNew = true;
4056
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4057

    
4058
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4059
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4060
                                        }
4061
                                    }
4062
                                //}
4063
                            }
4064
                        }
4065
                        break;
4066
                    case ControlType.Date:
4067
                        {
4068
                            if (e.LeftButton == MouseButtonState.Pressed)
4069
                            {
4070
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4071
                                //{
4072
                                    if (currentControl is DateControl)
4073
                                    {
4074
                                        //20180906 LJY TEST IsRotationDrawingEnable
4075
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4076
                                        {
4077
                                            return;
4078
                                        }
4079

    
4080
                                        CreateCommand.Instance.Execute(currentControl);
4081
                                        currentControl = null;
4082

    
4083
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4084
                                        {
4085
                                            controlType = ControlType.None;
4086
                                            IsSwingMode = false;
4087
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4088
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4089
                                            mouseHandlingMode = MouseHandlingMode.None;
4090
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4091
                                            txtBatch.Visibility = Visibility.Collapsed;
4092

    
4093
                                        }
4094
                                    }
4095
                                    else
4096
                                    {
4097
                                        currentControl = new DateControl
4098
                                        {
4099
                                            Background = new SolidColorBrush(Colors.Black)
4100
                                        };
4101
                                        currentControl.CommentID = Commons.shortGuid();
4102
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4103
                                        currentControl.IsNew = true;
4104
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4105

    
4106
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4107
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4108
                                }
4109
                                //}
4110
                            }
4111
                        }
4112
                        break;
4113
                    case ControlType.TextControl:
4114
                        {
4115
                            if (e.LeftButton == MouseButtonState.Pressed)
4116
                            {
4117
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4118
                                {
4119
                                    currentControl = new TextControl
4120
                                    {
4121
                                        ControlType = controlType
4122
                                    };
4123
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4124
                                    currentControl.CommentID = Commons.shortGuid();
4125
                                    currentControl.IsNew = true;
4126
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4127
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4128
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4129

    
4130
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4131
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4132
                                    
4133
                                    (currentControl as TextControl).ControlType_No = 0;
4134
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4135
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4136
                                    (currentControl as TextControl).ApplyTemplate();
4137
                                    (currentControl as TextControl).Base_TextBox.Focus();
4138

    
4139
                                    //System.Diagnostics.Debug.WriteLine("CanvasX" + (currentControl as TextControl).CanvasX);
4140
                                    //System.Diagnostics.Debug.WriteLine("CanvasY" + (currentControl as TextControl).CanvasY);
4141

    
4142
                                    CreateCommand.Instance.Execute(currentControl);
4143

    
4144
                                }
4145
                            }
4146
                        }
4147
                        break;
4148
                    case ControlType.TextBorder:
4149
                        {
4150
                            if (e.LeftButton == MouseButtonState.Pressed)
4151
                            {
4152
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4153
                                {
4154
                                    currentControl = new TextControl
4155
                                    {
4156
                                        ControlType = controlType
4157
                                    };
4158

    
4159
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4160
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4161
                                    currentControl.CommentID = Commons.shortGuid();
4162
                                    currentControl.IsNew = true;
4163
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4164
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4165
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4166
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4167
                                    
4168
                                    (currentControl as TextControl).ControlType_No = 1;
4169
                                    (currentControl as TextControl).Angle = Ang;
4170
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4171
                                    (currentControl as TextControl).ApplyTemplate();
4172
                                    (currentControl as TextControl).Base_TextBox.Focus();
4173
                                    CreateCommand.Instance.Execute(currentControl);
4174

    
4175
                                    //currentControl = null;
4176
                                }
4177
                            }
4178
                        }
4179
                        break;
4180
                    case ControlType.TextCloud:
4181
                        {
4182
                            if (e.LeftButton == MouseButtonState.Pressed)
4183
                            {
4184
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4185
                                {
4186
                                    currentControl = new TextControl
4187
                                    {
4188
                                        ControlType = controlType
4189
                                    };
4190

    
4191
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4192
                                    currentControl.CommentID = Commons.shortGuid();
4193
                                    currentControl.IsNew = true;
4194
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4195
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4196

    
4197
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4198
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4199
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4200

    
4201
                                    (currentControl as TextControl).Angle = Ang;
4202
                                    (currentControl as TextControl).ControlType_No = 2;
4203
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4204
                                    (currentControl as TextControl).ApplyTemplate();
4205
                                    (currentControl as TextControl).Base_TextBox.Focus();
4206
                                    CreateCommand.Instance.Execute(currentControl);
4207
                                    //currentControl = null;
4208
                                }
4209
                            }
4210
                        }
4211
                        break;
4212
                    case ControlType.ArrowTextControl:
4213
                         {
4214
                            if (e.LeftButton == MouseButtonState.Pressed)
4215
                            {
4216
                                if (currentControl is ArrowTextControl)
4217
                                {
4218
                                    //20180906 LJY TEST IsRotationDrawingEnable
4219
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4220
                                    {
4221
                                        return;
4222
                                    }
4223

    
4224
                                    CreateCommand.Instance.Execute(currentControl);
4225

    
4226
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4227
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4228
                                    (currentControl as ArrowTextControl).IsNew = false;
4229
                                    currentControl = null;
4230
                                }
4231
                                else
4232
                                {
4233
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4234
                                    //{
4235
                                        currentControl = new ArrowTextControl();
4236
                                        currentControl.CommentID = Commons.shortGuid();
4237
                                        currentControl.IsNew = true;
4238
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4239
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4240

    
4241
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4242
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4243
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4244
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4245
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4246

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

    
4250
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4251
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4252
                                        this.MainAngle.Visibility = Visibility.Visible;
4253

    
4254
                                    
4255
                                    //}
4256
                                }
4257
                            }
4258
                        }
4259
                        break;
4260
                    case ControlType.ArrowTransTextControl:
4261
                        {
4262
                            if (e.LeftButton == MouseButtonState.Pressed)
4263
                            {
4264
                                if (currentControl is ArrowTextControl)
4265
                                {
4266
                                    //20180906 LJY TEST IsRotationDrawingEnable
4267
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4268
                                    {
4269
                                        return;
4270
                                    }
4271

    
4272
                                    CreateCommand.Instance.Execute(currentControl);
4273
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4274
                                    currentControl.IsNew = false;
4275
                                    currentControl = null;
4276
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4277
                                }
4278
                                else
4279
                                {
4280
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4281
                                    //{
4282
                                         currentControl = new ArrowTextControl();
4283
                                        currentControl.CommentID = Commons.shortGuid();
4284
                                        currentControl.IsNew = true;
4285
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4286
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4287
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4288
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4289
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4290
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4291
                                        (currentControl as ArrowTextControl).isFixed = true;
4292
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4293

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

    
4297
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4298
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4299
                                        (currentControl as ArrowTextControl).isTrans = true;
4300
                                }
4301
                            }
4302
                        }
4303
                        break;
4304
                    case ControlType.ArrowTextBorderControl:
4305
                         {
4306
                            if (e.LeftButton == MouseButtonState.Pressed)
4307
                            {
4308
                                if (currentControl is ArrowTextControl)
4309
                                {
4310
                                    //20180906 LJY TEST IsRotationDrawingEnable
4311
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4312
                                    {
4313
                                        return;
4314
                                    }
4315

    
4316
                                    CreateCommand.Instance.Execute(currentControl);
4317
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4318
                                    currentControl.IsNew = false;
4319
                                    currentControl = null;
4320
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4321
                                }
4322
                                else
4323
                                {
4324
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4325
                                    //{
4326
                                        currentControl = new ArrowTextControl()
4327
                                        {
4328
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4329
                                        };
4330
                                        currentControl.CommentID = Commons.shortGuid();
4331
                                        currentControl.IsNew = true;
4332
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4333
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4334

    
4335
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4336

    
4337
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4338

    
4339
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4340
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4341
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4342

    
4343
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4344
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4345
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4346
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4347
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4348
                                    //}
4349
                                }
4350
                            }
4351
                        }
4352
                        break;
4353
                    case ControlType.ArrowTransTextBorderControl:
4354
                        {
4355
                            if (e.LeftButton == MouseButtonState.Pressed)
4356
                            {
4357
                                if (currentControl is ArrowTextControl)
4358
                                {
4359
                                    //20180906 LJY TEST IsRotationDrawingEnable
4360
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4361
                                    {
4362
                                        return;
4363
                                    }
4364
                                    CreateCommand.Instance.Execute(currentControl);
4365
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4366
                                    currentControl.IsNew = false;
4367
                                    currentControl = null;
4368
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4369
                                }
4370
                                else
4371
                                {
4372
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4373
                                    //{
4374
                                    
4375

    
4376
                                    currentControl = new ArrowTextControl()
4377
                                        {
4378
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4379
                                        };
4380
                                        currentControl.CommentID = Commons.shortGuid();
4381
                                        currentControl.IsNew = true;
4382
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4383
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4384

    
4385
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4386

    
4387
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4388
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4389
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4390
                                        (currentControl as ArrowTextControl).isFixed = true;
4391
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4392
                                     
4393
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4394
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4395
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4396

    
4397
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4398
                                        this.MainAngle.Visibility = Visibility.Visible;
4399
                                    
4400
                                    //20180911 LJY
4401
                                        (currentControl as ArrowTextControl).isTrans = true;
4402
                                    
4403

    
4404
                                    //}
4405
                                }
4406
                            }
4407
                        }
4408
                        break;
4409
                    case ControlType.ArrowTextCloudControl:
4410
                        {
4411
                            if (e.LeftButton == MouseButtonState.Pressed)
4412
                            {
4413
                                if (currentControl is ArrowTextControl)
4414
                                {
4415
                                    //20180906 LJY TEST IsRotationDrawingEnable
4416
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4417
                                    {
4418
                                        return;
4419
                                    }
4420
                                    CreateCommand.Instance.Execute(currentControl);
4421
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4422
                                    currentControl.IsNew = false;
4423
                                    currentControl = null;
4424
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4425
                                }
4426
                                else
4427
                                {
4428
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4429
                                    //{
4430
                                        currentControl = new ArrowTextControl()
4431
                                        {
4432
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4433
                                        };
4434
                                        currentControl.CommentID = Commons.shortGuid();
4435
                                        currentControl.IsNew = true;
4436
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4437
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4438

    
4439
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4440
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4441
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4442
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4443
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4444

    
4445
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4446
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4447
                                    
4448
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4449
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4450
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4451
                                    //}
4452
                                }
4453
                            }
4454
                        }
4455
                        break;
4456
                    case ControlType.ArrowTransTextCloudControl:
4457
                        {
4458
                            if (e.LeftButton == MouseButtonState.Pressed)
4459
                            {
4460
                                if (currentControl is ArrowTextControl)
4461
                                {
4462
                                    //20180906 LJY TEST IsRotationDrawingEnable
4463
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4464
                                    {
4465
                                        return;
4466
                                    }
4467
                                    CreateCommand.Instance.Execute(currentControl);
4468
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4469
                                    currentControl.IsNew = false;
4470
                                    currentControl = null;
4471
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4472
                                }
4473
                                else
4474
                                {
4475
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4476
                                    //{
4477
                                        currentControl = new ArrowTextControl()
4478
                                        {
4479
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4480
                                        };
4481
                                        currentControl.CommentID = Commons.shortGuid();
4482
                                        currentControl.IsNew = true; 
4483
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4484
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4485
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4486

    
4487
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4488
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4489
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4490
                                        (currentControl as ArrowTextControl).isFixed = true;
4491
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4492

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

    
4496
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4497
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4498
                                        this.MainAngle.Visibility = Visibility.Visible;  
4499
                                    
4500
                                    //20180911 LJY
4501
                                        (currentControl as ArrowTextControl).isTrans = true;
4502
                                    //}
4503
                                }
4504
                            }
4505
                        }
4506
                        break;
4507
                    case ControlType.PolygonControl:
4508
                        {
4509
                            if (currentControl is PolygonControl)
4510
                            {
4511
                                var control = currentControl as PolygonControl;
4512

    
4513
                                if (e.RightButton == MouseButtonState.Pressed)
4514
                                {
4515
                                    control.IsCompleted = true;
4516
                                }
4517

    
4518
                                if (!control.IsCompleted)
4519
                                {
4520
                                    control.PointSet.Add(control.EndPoint);
4521
                                }
4522
                                else
4523
                                {
4524
                                    //20180906 LJY TEST IsRotationDrawingEnable
4525
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4526
                                    {
4527
                                        return;
4528
                                    }
4529

    
4530
                                    var firstPoint = control.PointSet.First();
4531
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4532
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4533
                                    control.PointSet.Add(firstPoint);
4534

    
4535
                                    control.ApplyOverViewData();
4536

    
4537
                                    CreateCommand.Instance.Execute(currentControl);
4538
                                    control.updateControl();
4539
                                    currentControl = null;
4540
                                }
4541
                            }
4542
                            else
4543
                            {
4544
                                if (e.LeftButton == MouseButtonState.Pressed)
4545
                                {
4546
                                    currentControl = new PolygonControl
4547
                                    {
4548
                                        PointSet = new List<Point>(),
4549
                                    };
4550

    
4551
                                    var polygonControl = (currentControl as PolygonControl);
4552
                                    currentControl.CommentID = Commons.shortGuid();
4553
                                    currentControl.IsNew = true;
4554
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4555
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
4556
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
4557
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4558
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4559
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4560
                                    polygonControl.ApplyTemplate();
4561
                                    polygonControl.Visibility = Visibility.Visible;
4562
                                }
4563
                            }
4564
                        }
4565
                        break;
4566
                    //강인구 추가
4567
                    case ControlType.Sign:
4568
                        {
4569
                            if (e.LeftButton == MouseButtonState.Pressed)
4570
                            {
4571
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4572
                                //{
4573
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4574

    
4575
                                    if (_sign == null)
4576
                                    {
4577
                                        txtBatch.Visibility = Visibility.Collapsed;
4578
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4579
                                        controlType = ControlType.None;
4580

    
4581
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4582
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4583
                                        return;
4584
                                    }
4585

    
4586
                                    if (currentControl is SignControl)
4587
                                    {
4588
                                        //20180906 LJY TEST IsRotationDrawingEnable
4589
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4590
                                        {
4591
                                            return;
4592
                                        }
4593

    
4594
                                        CreateCommand.Instance.Execute(currentControl);
4595
                                        currentControl = null;
4596
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4597
                                        {
4598
                                            txtBatch.Text = "Place Date";
4599
                                            controlType = ControlType.Date;
4600
                                        }
4601
                                    }
4602
                                    else
4603
                                    {
4604
                                        currentControl = new SignControl
4605
                                        {
4606
                                            Background = new SolidColorBrush(Colors.Black),
4607
                                            UserNumber = App.ViewInfo.UserID,
4608
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4609
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4610
                                            ControlType = ControlType.Sign
4611
                                        };
4612

    
4613
                                        currentControl.CommentID = Commons.shortGuid();
4614
                                        currentControl.IsNew = true;
4615
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4616
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4617

    
4618
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4619
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4620
                                }
4621
                                //}
4622
                            }
4623
                        }
4624
                        break;
4625
                    case ControlType.Mark:
4626
                        {
4627
                            if (e.LeftButton == MouseButtonState.Pressed)
4628
                            {
4629
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4630
                                //{
4631
                                    if (currentControl is RectangleControl)
4632
                                    {
4633
                                        //20180906 LJY TEST IsRotationDrawingEnable
4634
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4635
                                        {
4636
                                            return;
4637
                                        }
4638

    
4639
                                        CreateCommand.Instance.Execute(currentControl);
4640
                                        (currentControl as RectangleControl).ApplyOverViewData();
4641
                                        currentControl = null;
4642
                                    
4643
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4644

    
4645
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4646
                                        {
4647
                                            txtBatch.Text = "Place Signature";
4648
                                            controlType = ControlType.Sign;
4649
                                        }
4650
                                    }
4651
                                    else
4652
                                    {
4653
                                        currentControl = new RectangleControl
4654
                                        {
4655
                                            Background = new SolidColorBrush(Colors.Black),
4656
                                            Paint = PaintSet.Fill
4657
                                        };
4658

    
4659
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4660
                                        currentControl.CommentID = Commons.shortGuid();
4661
                                        currentControl.IsNew = true;
4662
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4663
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4664
                                    }
4665
                                //}
4666
                            }
4667
                        }
4668
                        break;
4669
                    case ControlType.Symbol:
4670
                        {
4671
                            if (e.LeftButton == MouseButtonState.Pressed)
4672
                            {
4673
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4674
                                //{
4675
                                    if (currentControl is SymControl)
4676
                                    {
4677
                                        //20180906 LJY TEST IsRotationDrawingEnable
4678
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4679
                                        {
4680
                                            return;
4681
                                        }
4682
                                        CreateCommand.Instance.Execute(currentControl);
4683
                                        currentControl = null;
4684
                                    
4685
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4686
                                    }
4687
                                    else
4688
                                    {
4689
                                        currentControl = new SymControl
4690
                                        {
4691
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4692
                                            Background = new SolidColorBrush(Colors.Black),
4693
                                            ControlType = ControlType.Symbol
4694
                                        };
4695

    
4696
                                        currentControl.IsNew = true;
4697
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4698
                                        currentControl.CommentID = Commons.shortGuid();
4699
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4700

    
4701
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4702
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4703
                                }
4704
                                //}
4705
                            }
4706
                        }
4707
                        break;
4708
                    case ControlType.Stamp:
4709
                        {
4710
                            if (e.LeftButton == MouseButtonState.Pressed)
4711
                            {
4712
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4713
                                //{
4714
                                    if (currentControl is SymControlN)
4715
                                    {
4716
                                        //20180906 LJY TEST IsRotationDrawingEnable
4717
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4718
                                        {
4719
                                            return;
4720
                                        }
4721

    
4722
                                        CreateCommand.Instance.Execute(currentControl);
4723
                                        currentControl = null;
4724
                                   
4725

    
4726
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4727
                                    }
4728
                                    else
4729
                                    {
4730
                                        currentControl = new SymControlN
4731
                                        {
4732
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4733
                                            Background = new SolidColorBrush(Colors.Black),
4734
                                            ControlType = ControlType.Stamp
4735
                                        };
4736

    
4737
                                        currentControl.IsNew = true;
4738
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4739
                                        currentControl.CommentID = Commons.shortGuid();
4740
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4741
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4742
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4743
                                }                                    
4744
                                //}
4745
                            }
4746
                        }
4747
                        break;
4748
                    case ControlType.PenControl:
4749
                        {
4750
                            if (inkBoard.Tag.ToString() == "Ink")
4751
                            {
4752
                                inkBoard.IsEnabled = true;
4753
                                StartNewStroke(canvasDrawingMouseDownPoint);
4754
                            }
4755
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4756
                            {
4757
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4758
                            }
4759
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4760
                            {
4761
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4762
                            }
4763
                            IsDrawing = true;
4764
                            return;
4765
                        }
4766
                    default:
4767
                        if (currentControl != null)
4768
                        {
4769
                            currentControl.CommentID = null;
4770
                            currentControl.IsNew = false;
4771
                        }
4772
                        break;
4773
                }
4774
            }
4775
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4776
            {
4777
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4778
                {
4779
                    bool mouseOff = false;
4780
                    foreach (var item in SelectLayer.Children)
4781
                    {
4782
                        if (item is AdornerFinal)
4783
                        {
4784

    
4785
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4786
                            if (over != null)
4787
                            {
4788
                                mouseOff = true;
4789
                            }
4790
                        }
4791
                    }
4792

    
4793
                    if (!mouseOff)
4794
                    {
4795
                        SelectionSet.Instance.UnSelect(this);
4796
                    }
4797
                }
4798
                zoomAndPanControl.CaptureMouse();
4799
                e.Handled = true;
4800
            }
4801
        }
4802

    
4803
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4804
        {
4805
            ///mouseButtonDown = e.ChangedButton;
4806
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4807
        }
4808

    
4809
        private void RemoveLineStroke(Point P)
4810
        {
4811
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4812
            if (control != null)
4813
            {
4814
                UndoData = new Undo_data()
4815
                {
4816
                    IsUndo = false,
4817
                    Event = Event_Type.Delete,
4818
                    EventTime = DateTime.Now,
4819
                    Markup_List = new List<Multi_Undo_data>()
4820
                };
4821

    
4822

    
4823
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4824
                UndoData.Markup_List.Add(multi_Undo_Data);
4825
                multi_Undo_Data = new Multi_Undo_data();
4826

    
4827
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4828
                var Item_ = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4829
                ViewerDataModel.Instance.MyMarkupList.Remove(Item_);
4830
                
4831
                //임시파일에서도 삭제한다.
4832
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
4833
                
4834
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4835
                {
4836
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
4837
                });
4838
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
4839

    
4840
            }
4841
        }
4842

    
4843
        private void RemovePointStroke(Point P)
4844
        {
4845
            foreach (Stroke hits in inkBoard.Strokes)
4846
            {
4847
                foreach (StylusPoint sty in hits.StylusPoints)
4848
                {
4849

    
4850
                }
4851
                if (hits.HitTest(P))
4852
                {
4853
                    inkBoard.Strokes.Remove(hits);
4854
                    return;
4855
                }
4856
            }
4857
        }
4858

    
4859
        private void StartNewStroke(Point P)
4860
        {
4861
            strokePoints = new StylusPointCollection();
4862
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4863
            strokePoints.Add(segment1Start);
4864
            stroke = new Stroke(strokePoints);
4865

    
4866
            stroke.DrawingAttributes.Color = Colors.Red;
4867
            stroke.DrawingAttributes.Width = 4;
4868
            stroke.DrawingAttributes.Height = 4;
4869

    
4870
            inkBoard.Strokes.Add(stroke);
4871

    
4872
        }
4873

    
4874
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4875
        {
4876
            ConsolidationMethod();
4877
        }
4878

    
4879
        /// <summary>
4880
        /// execute TeamConsolidationCommand
4881
        /// </summary>
4882
        public void TeamConsolidationMethod()
4883
        {
4884
            this.UpdateMyMarkupList();
4885
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4886
            {
4887
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4888
            }
4889
            else
4890
            {
4891

    
4892
                ViewerDataModel.Instance.IsConsolidate = true;
4893
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4894

    
4895
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4896
                {
4897
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4898
                    {
4899
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4900
                        return;
4901
                    }                    
4902
                }
4903
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4904
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4905
                {
4906
                    MarkupInfoList.Add(item);
4907
                }
4908
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4909
            }
4910
        }
4911

    
4912
        public void ConsolidationMethod()
4913
        {
4914
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4915
            {
4916
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4917
            }
4918
            else
4919
            {
4920
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4921
                foreach (var item in this.gridViewMarkup.SelectedItems)
4922
                {
4923
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4924
                }
4925
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4926
                
4927
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4928
            }
4929
        }
4930

    
4931
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4932
        {
4933
            if (App.ViewInfo != null)
4934
            {
4935
                btnConsolidate = (sender as RadRibbonButton);
4936
                if (!App.ViewInfo.NewCommentPermission)
4937
                {
4938
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4939
                }
4940
            }
4941
        }
4942

    
4943
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4944
        {
4945
            TeamConsolidationMethod();
4946
        }
4947

    
4948
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4949
        {
4950
            btnTeamConsolidate = sender as RadRibbonButton;
4951
            if (App.ViewInfo != null)
4952
            {
4953
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4954
                {
4955
                    if (btnConsolidate != null)
4956
                    {
4957
                        btnConsolidate.Visibility = Visibility.Collapsed;
4958
                    }
4959

    
4960
                    if (!App.ViewInfo.NewCommentPermission)
4961
                    {
4962
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4963
                    }
4964
                }
4965
                else
4966
                {
4967
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4968
                }
4969
            }
4970
        }
4971

    
4972
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4973
        {
4974
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4975
            if (item != null)
4976
            {
4977
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4978

    
4979
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4980
            }
4981
            else
4982
            {
4983
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4984
            }
4985
        }
4986

    
4987
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4988
        {
4989
            btnFinalPDF = sender as RadRibbonButton;
4990
            if (App.ViewInfo != null)
4991
            {
4992
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4993
                {
4994
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4995
                    if (btnConsolidate != null)
4996
                    {
4997
                        btnConsolidate.Visibility = Visibility.Collapsed;
4998
                    }
4999
                }
5000
            }
5001
        }
5002

    
5003
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5004
        {
5005
            UpdateMyMarkupList();
5006

    
5007
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5008
            {
5009
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5010
            }
5011
            else
5012
            {
5013
                ViewerDataModel.Instance.IsConsolidate = true;
5014
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5015
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5016

    
5017
                string project_no = App.ViewInfo.ProjectNO;
5018
                string doc_id = _DocInfo.ID;
5019
                string user_id = App.ViewInfo.UserID;
5020
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5021
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5022
                {
5023
                    markupInfoItems.Add(item);
5024
                }
5025
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5026
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5027
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5028
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5029

    
5030
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5031
                if (item2 != null)
5032
                {
5033
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5034

    
5035
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5036
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5037
                }
5038
                else
5039
                {
5040
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5041
                }
5042
            }
5043
        }
5044

    
5045
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5046
        {
5047
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5048

    
5049
            if (App.ViewInfo != null)
5050
            {
5051
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5052
                {
5053
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5054
                }
5055
            }
5056
        }
5057

    
5058
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5059
        {
5060
            if (CompareMode.IsChecked)
5061
            {
5062
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5063
                {
5064
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5065
                }
5066
                if (ViewerDataModel.Instance.PageNumber == 0)
5067
                {
5068
                    ViewerDataModel.Instance.PageNumber = 1;
5069
                }
5070

    
5071
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5072
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5073
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5074

    
5075
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5076
            }
5077
            else
5078
            {
5079
                da.From = 1;
5080
                da.To = 1;
5081
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5082
                da.AutoReverse = false;
5083
                canvas_compareBorder.Children.Clear();
5084
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5085
            }
5086
        }
5087

    
5088
        private void Sync_Click(object sender, RoutedEventArgs e)
5089
        {
5090
            if (Sync.IsChecked)
5091
            {
5092
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5093
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5094
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5095
            }
5096
        }
5097

    
5098
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5099
        {
5100
            if (UserList.IsChecked)
5101
            {
5102
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5103
            }
5104
            else
5105
            {
5106
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5107
            }
5108
        }
5109

    
5110
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5111
        {
5112

    
5113
            if (BalanceMode.IsChecked)
5114
            {
5115
                ViewerDataModel.Instance.PageBalanceMode = true;
5116
            }
5117
            else
5118
            {
5119
                ViewerDataModel.Instance.PageBalanceMode = false;
5120
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5121
            }
5122
        }
5123

    
5124
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5125
        {
5126
            //초기화
5127
            testPanel2.IsHidden = true;
5128
            ViewerDataModel.Instance.PageBalanceMode = false;
5129
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5130
            ViewerDataModel.Instance.PageNumber = 0;
5131
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5132
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5133
            UserList.IsChecked = false;
5134
            BalanceMode.IsChecked = false;
5135
        }
5136

    
5137
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5138
        {
5139
            if ((sender as System.Windows.Controls.Control).Tag != null)
5140
            {
5141
                //Compare 초기화
5142
                CompareMode.IsChecked = false;
5143
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5144

    
5145
                if (ViewerDataModel.Instance.PageNumber == 0)
5146
                {
5147
                    ViewerDataModel.Instance.PageNumber = 1;
5148
                }
5149

    
5150
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5151
                {
5152
                }
5153
                else
5154
                {
5155
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5156
                }
5157

    
5158
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5159
                {
5160

    
5161
                }
5162
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5163
                {
5164
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5165
                }
5166

    
5167
                if (!testPanel2.IsHidden)
5168
                {
5169
                    if (IsSyncPDFMode)
5170
                    {
5171
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5172
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5173

    
5174
                        if (pdfpath.IsDownloading)
5175
                        {
5176
                            pdfpath.DownloadCompleted += (ex, arg) =>
5177
                            {
5178
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5179
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5180
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5181
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5182
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5183
                            };
5184
                        }
5185
                        else
5186
                        {
5187
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5188
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5189
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5190

    
5191
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5192
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5193
                        }
5194

    
5195
                    }
5196
                    else
5197
                    {
5198
                        string uri = "";
5199

    
5200
                        if (userData.COMPANY != "EXT")
5201
                        {
5202
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5203
                        }
5204
                        else
5205
                        {
5206
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5207
                        }
5208

    
5209
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5210

    
5211
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5212
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5213
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5214

    
5215
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5216
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5217

    
5218
                        if (defaultBitmapImage_Compare.IsDownloading)
5219
                        {
5220
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5221
                            {
5222
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5223
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5224
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5225

    
5226
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5227
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5228
                            };
5229
                        }
5230
                    }
5231

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

    
5236
                    foreach (var item in gridSelectionRevItem)
5237
                    {
5238
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5239
                        {
5240
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5241
                        });
5242
                    }
5243

    
5244
                    //강인구 추가
5245
                    zoomAndPanControl2.ZoomTo(new Rect
5246
                    {
5247
                        X = 0,
5248
                        Y = 0,
5249
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5250
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5251
                    });
5252

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

    
5255
                }
5256
            }
5257
        }
5258

    
5259
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5260
        {
5261
            if (MarkupMode.IsChecked)
5262
            {
5263
                IsSyncPDFMode = true;
5264

    
5265
                var uri = CurrentRev.TO_VENDOR;
5266

    
5267
                if (ViewerDataModel.Instance.PageNumber == 0)
5268
                {
5269
                    ViewerDataModel.Instance.PageNumber = 1;
5270
                }
5271

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

    
5276
                if (pdfpath.IsDownloading)
5277
                {
5278
                    pdfpath.DownloadCompleted += (ex, arg) =>
5279
                    {
5280
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5281
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5282
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5283
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5284
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5285
                    };
5286
                }
5287
                else
5288
                {
5289
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5290
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5291
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5292

    
5293
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5294
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5295
                }
5296
            }
5297
            else
5298
            {
5299
                IsSyncPDFMode = false;
5300
                string uri = "";
5301
                if (userData.COMPANY != "EXT")
5302
                {
5303
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5304
                }
5305
                else
5306
                {
5307
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5308
                }
5309

    
5310
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5311

    
5312
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5313
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5314
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5315

    
5316
                if (defaultBitmapImage_Compare.IsDownloading)
5317
                {
5318
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5319
                    {
5320
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5321
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5322
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5323
                    };
5324
                }
5325
                zoomAndPanControl2.ApplyTemplate();
5326
                zoomAndPanControl2.UpdateLayout();
5327
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5328
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5329
            }
5330
        }
5331

    
5332
        private void RadButton_Click(object sender, RoutedEventArgs e)
5333
        {
5334
            gridViewHistory_Busy.IsBusy = true;
5335

    
5336
            RadButton instance = sender as RadButton;
5337
            if (instance.CommandParameter != null)
5338
            {
5339
                CurrentRev = instance.CommandParameter as VPRevision;
5340
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5341
                {
5342
                    if (ea.Error == null && ea.Result != null)
5343
                    {
5344
                        testPanel2.IsHidden = false;
5345

    
5346
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5347
                        foreach(var info in ea.Result)
5348
                        {
5349
                            if(info.UserID == App.ViewInfo.UserID)
5350
                            {
5351
                                info.userDelete = true;
5352
                                info.DisplayColor = "FFFF0000";
5353
                            }
5354
                            else
5355
                            {
5356
                                info.userDelete = false;
5357
                            }
5358
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5359
                        }
5360
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5361

    
5362
                        string uri = "";
5363
                        if (userData.COMPANY != "EXT")
5364
                        {
5365
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5366
                        }
5367
                        else
5368
                        {
5369
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5370
                        }
5371

    
5372
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5373

    
5374
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5375

    
5376
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5377
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5378
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5379

    
5380
                        if (defaultBitmapImage_Compare.IsDownloading)
5381
                        {
5382
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5383
                            {
5384
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5385
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5386
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5387
                            };
5388
                        }
5389

    
5390
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5391
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5392
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5393
                        zoomAndPanControl2.ApplyTemplate();
5394
                        zoomAndPanControl2.UpdateLayout();
5395

    
5396
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5397
                        {
5398
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5399
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5400
                        }
5401

    
5402
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5403
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5404
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5405

    
5406
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5407
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5408
                        gridViewHistory_Busy.IsBusy = false;
5409
                    }
5410

    
5411
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5412
                };
5413
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5414
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5415
            }
5416
        }
5417

    
5418
        public void Sync_Event(VPRevision Currnet_Rev)
5419
        {
5420
            CurrentRev = Currnet_Rev;
5421

    
5422
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5423
            {
5424
                if (ea.Error == null && ea.Result != null)
5425
                {
5426
                    testPanel2.IsHidden = false;
5427

    
5428
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5429
                    foreach(var info in ea.Result)
5430
                    {
5431
                        if(info.UserID == App.ViewInfo.UserID)
5432
                        {
5433
                            info.userDelete = true;
5434
                            info.DisplayColor = "FFFF0000";
5435
                        }
5436
                        else
5437
                        {
5438
                            info.userDelete = false;
5439
                        }
5440
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5441
                    }
5442
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5443

    
5444
                    string uri = "";
5445
                    if (userData.COMPANY != "EXT")
5446
                    {
5447
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5448
                    }
5449
                    else
5450
                    {
5451
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5452
                    }
5453

    
5454
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5455

    
5456
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5457

    
5458
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5459
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5460
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5461

    
5462
                    if (defaultBitmapImage_Compare.IsDownloading)
5463
                    {
5464
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5465
                        {
5466
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5467
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5468
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5469
                        };
5470
                    }
5471

    
5472

    
5473
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5474
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5475
                    zoomAndPanControl2.ApplyTemplate();
5476
                    zoomAndPanControl2.UpdateLayout();
5477

    
5478
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5479
                    {
5480
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5481
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5482
                    }
5483
                    //}
5484

    
5485
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5486
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5487
                    gridViewHistory_Busy.IsBusy = false;
5488
                }
5489
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5490

    
5491
            };
5492
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5493
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5494
        }
5495

    
5496
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5497
        {
5498
            if (sender is Image)
5499
            {
5500
                if ((sender as Image).Tag != null)
5501
                {
5502
                    var pdfUrl = (sender as Image).Tag.ToString();
5503
                    System.Diagnostics.Process.Start(pdfUrl);
5504
                }
5505
                else
5506
                {
5507
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5508
                }
5509
            }
5510
        }
5511

    
5512
        private void Create_Symbol(object sender, RoutedEventArgs e)
5513
        {
5514
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5515

    
5516
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5517
            {
5518
                DialogMessage_Alert("Please Select Controls", "Alert");
5519
            }
5520
            else //선택된 것이 있으면
5521
            {
5522
                string MarkupData = "";
5523
                adorner_ = new AdornerFinal();
5524

    
5525
                foreach (var item in SelectLayer.Children)
5526
                {
5527
                    if (item.GetType().Name == "AdornerFinal")
5528
                    {
5529
                        adorner_ = (item as Controls.AdornerFinal);
5530
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5531
                        {
5532
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5533
                            {
5534
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5535
                                MarkupData += markupReturn.ConvertData;
5536
                            }
5537
                        }
5538
                    }
5539
                }
5540
                DialogParameters parameters = new DialogParameters()
5541
                {
5542
                    Owner = Application.Current.MainWindow,
5543
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5544
                    DefaultPromptResultValue = "Custom State",
5545
                    Content = "Name :",
5546
                    Header = "Insert Custom Symbol Name",
5547
                    Theme = new VisualStudio2013Theme(),
5548
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5549
                };
5550
                RadWindow.Prompt(parameters);
5551
            }
5552

    
5553
        }
5554
        public int symbolselectindex = 0;
5555
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5556
        {
5557
            //Save save = new Save();
5558
            try
5559
            {
5560
                string svgfilename = null;
5561
                if (symbolname != null)
5562
                {
5563
                    if (symbolpng == true || symbolsvg == true)
5564
                    {
5565
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5566
                        string guid = Commons.shortGuid();
5567

    
5568
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5569
                        //Check_Uri.UriCheck();
5570
                        fileUploader.RunCompleted += (ex, arg) =>
5571
                        {
5572
                            filename = arg.Result;
5573
                            if (symbolpng == true)
5574
                            {
5575
                                if (filename != null)
5576
                                { 
5577
                                    if (symbolselectindex == 0)
5578
                                    {
5579
                                        SymbolSave(symbolname, filename, data);
5580
                                    }
5581
                                    else
5582
                                    {
5583
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5584
                                    }
5585
                                    DataBind();
5586
                                }                                
5587
                            }
5588

    
5589
                            if (symbolsvg == true)
5590
                            {
5591
                                try
5592
                                {
5593
                                    var defaultBitmapImage = new BitmapImage();
5594
                                    defaultBitmapImage.BeginInit();
5595
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5596
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5597
                                    Check_Uri.UriCheck(filename);
5598
                                    defaultBitmapImage.UriSource = new Uri(filename);
5599
                                    defaultBitmapImage.EndInit();
5600

    
5601
                                    System.Drawing.Bitmap image;
5602

    
5603
                                    if (defaultBitmapImage.IsDownloading)
5604
                                    {
5605
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5606
                                        {
5607
                                            defaultBitmapImage.Freeze();
5608
                                            image = GetBitmap(defaultBitmapImage);
5609
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5610
                                            Process potrace = new Process
5611
                                            {
5612
                                                StartInfo = new ProcessStartInfo
5613
                                                {
5614
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5615
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5616
                                                    RedirectStandardInput = true,
5617
                                                    RedirectStandardOutput = true,
5618
                                                    RedirectStandardError = true,
5619
                                                    UseShellExecute = false,
5620
                                                    CreateNoWindow = true,
5621
                                                    WindowStyle = ProcessWindowStyle.Hidden
5622
                                                },
5623
                                            };
5624

    
5625
                                            StringBuilder svgBuilder = new StringBuilder();
5626
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5627
                                            {
5628
                                                svgBuilder.AppendLine(e2.Data);
5629
                                            };
5630

    
5631
                                            potrace.EnableRaisingEvents = true;
5632
                                            potrace.Start();
5633
                                            potrace.Exited += (sender, e) =>
5634
                                            {
5635
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5636
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5637
                                                Check_Uri.UriCheck(svgfilename);
5638
                                                if (symbolselectindex == 0)
5639
                                                {
5640
                                                    SymbolSave(symbolname, svgfilename, data);
5641
                                                }
5642
                                                else
5643
                                                {
5644
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5645
                                                }
5646

    
5647
                                                DataBind();
5648
                                            };
5649
                                            potrace.WaitForExit();
5650
                                        };
5651
                                    }
5652
                                    else
5653
                                    {
5654
                                        //GC.Collect();
5655
                                    }
5656
                                }
5657
                                catch(Exception ee)
5658
                                {
5659
                                    DialogMessage_Alert("" + ee, "Alert");
5660
                                }
5661
                            }
5662
                        };                                             
5663
                    }
5664
                }
5665
            }
5666
            catch (Exception e)
5667
            {
5668
                //DialogMessage_Alert(e + "", "Alert");
5669
            }            
5670
        }
5671

    
5672
        public void SymbolSave(string Name, string Url, string Data)
5673
        {
5674
            try
5675
            {
5676
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5677
                {
5678
                    ID = Commons.shortGuid(),
5679
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5680
                    NAME = Name,
5681
                    IMAGE_URL = Url,
5682
                    DATA = Data
5683
                };
5684

    
5685
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5686
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5687
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5688
            }
5689
            catch (Exception)
5690
            {
5691
                throw;
5692
            }
5693
        }
5694

    
5695
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5696
        {
5697
            try
5698
            {
5699
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5700
                {
5701
                    ID = Commons.shortGuid(),
5702
                    DEPARTMENT = Department,
5703
                    NAME = Name,
5704
                    IMAGE_URL = Url,
5705
                    DATA = Data
5706
                };
5707
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5708
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5709
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5710
            }
5711
            catch (Exception)
5712
            {
5713
                throw;
5714
            }
5715
        }
5716

    
5717
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5718
        {           
5719
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5720
            DataBind();
5721
        }
5722

    
5723
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5724
        {
5725
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5726
            DataBind();
5727
        }
5728
        private void DataBind()
5729
        {
5730
            try
5731
            {
5732
                Symbol_Custom Custom = new Symbol_Custom();
5733
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5734
                
5735
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5736
                foreach (var item in symbol_Private)
5737
                {
5738
                    Custom.Name = item.NAME;
5739
                    Custom.ImageUri = item.IMAGE_URL;
5740
                    Custom.ID = item.ID;
5741
                    Custom_List.Add(Custom);
5742
                    Custom = new Symbol_Custom();
5743
                }
5744
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5745
                
5746
                Custom = new Symbol_Custom();
5747
                Custom_List = new List<Symbol_Custom>();
5748

    
5749
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5750

    
5751
                List<SYMBOL_PUBLIC> symbol_Public;
5752

    
5753
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5754
                {
5755
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5756
                }
5757
                else
5758
                {
5759
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5760
                }
5761
                foreach (var item in symbol_Public)
5762
                {
5763
                    Custom.Name = item.NAME;
5764
                    Custom.ImageUri = item.IMAGE_URL;
5765
                    Custom.ID = item.ID;
5766
                    Custom_List.Add(Custom);
5767
                    Custom = new Symbol_Custom();
5768
                }
5769
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5770
                BaseClient.Close();                
5771
            }
5772
            catch(Exception e)
5773
            {
5774
                //DialogMessage_Alert("DataBind", "Alert");
5775
            }
5776
            
5777
        }
5778
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5779
        {
5780
            try
5781
            {
5782
                if (args.PromptResult != null)
5783
                {
5784
                    if (args.DialogResult.Value)
5785
                    {
5786
                        PngBitmapEncoder _Encoder = symImage(data);
5787

    
5788
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5789
                        _Encoder.Save(fs);
5790
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5791

    
5792
                        byte[] Img_byte = fs.ToArray();
5793

    
5794
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5795
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5796
                        Check_Uri.UriCheck(filename);
5797
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5798
                        {
5799
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5800
                        }
5801
                        else
5802
                        {
5803
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5804
                        }
5805
                        DataBind();
5806
                    }
5807
                }
5808
            }
5809
            catch(Exception ex)
5810
            {
5811
                DialogMessage_Alert("" + ex, "Alert");
5812
            }
5813
        }
5814

    
5815
        public PngBitmapEncoder symImage(string data)
5816
        {
5817

    
5818
            Canvas _canvas = new Canvas();
5819
            _canvas.Background = Brushes.White;
5820
            _canvas.Width = adorner_.BorderSize.Width;
5821
            _canvas.Height = adorner_.BorderSize.Height;
5822
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5823

    
5824
            BitmapEncoder encoder = new PngBitmapEncoder();
5825

    
5826

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

    
5829
            DrawingVisual dv = new DrawingVisual();
5830

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

    
5834
            using (DrawingContext ctx = dv.RenderOpen())
5835
            {
5836
                VisualBrush vb = new VisualBrush(_canvas);
5837
                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)));
5838
            }
5839

    
5840
            try
5841
            {
5842
                renderBitmap.Render(dv);
5843

    
5844
                //GC.Collect();
5845
                GC.WaitForPendingFinalizers();
5846
                //GC.Collect();
5847
                // encode png data
5848
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5849
                // puch rendered bitmap into it
5850
                pngEncoder.Interlace = PngInterlaceOption.Off;
5851
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5852
                return pngEncoder;
5853

    
5854
            }
5855
            catch //(Exception ex)
5856
            {
5857
                return null;
5858
            }
5859

    
5860
        }
5861

    
5862
        public void DialogMessage_Alert(string content, string header)
5863
        {
5864
            var box = new TextBlock();
5865
            box.MinWidth = 400;
5866
            box.FontSize = 11;
5867
            //box.FontSize = 12;
5868
            box.Text = content;
5869
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
5870

    
5871
            DialogParameters parameters = new DialogParameters()
5872
            {
5873
                Owner = Application.Current.MainWindow,
5874
                Content = box,
5875
                Header = header,
5876
                Theme = new VisualStudio2013Theme(),
5877
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5878
            };            
5879
            RadWindow.Alert(parameters);
5880
        }
5881

    
5882
        #region 캡쳐 기능
5883

    
5884
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5885
        {
5886
            if (x < 0)
5887
            {
5888
                width += x;
5889
                x = 0;
5890
            }
5891
            if (y < 0)
5892
            {
5893
                height += y;
5894
                y = 0;
5895

    
5896
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5897
            }
5898
            if (x + width > zoomAndPanCanvas.ActualWidth)
5899
            {
5900
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5901
            }
5902
            if (y + height > zoomAndPanCanvas.ActualHeight)
5903
            {
5904
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5905
            }
5906

    
5907
            byte[] pixels = CopyPixels(x, y, width, height);
5908

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

    
5911
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5912
        }
5913

    
5914
        public byte[] CopyPixels(int x, int y, int width, int height)
5915
        {
5916
            byte[] pixels = new byte[width * height * 4];
5917
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5918

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

    
5922
            return pixels;
5923
        }
5924

    
5925
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5926
        {
5927
            DrawingVisual drawingVisual = new DrawingVisual();
5928
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5929

    
5930
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5931
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5932
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5933
            drawingContext.Close();
5934

    
5935
            // 비트맵으로 변환합니다.
5936
            RenderTargetBitmap target =
5937
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5938
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5939

    
5940
            target.Render(drawingVisual);
5941
            return target;
5942
        }
5943

    
5944
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5945
        {
5946
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5947
            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);
5948
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5949
            bmp.UnlockBits(data);
5950
            return bmp;
5951
        }
5952
        public string symbolname = null;
5953
        public bool symbolsvg = true;
5954
        public bool symbolpng = true;
5955

    
5956
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5957
        {
5958
            System.Drawing.Bitmap image = GetBitmap(source);
5959
            //흰색 제거
5960
            //image.MakeTransparent(System.Drawing.Color.White);
5961

    
5962
            var imageStream = new System.IO.MemoryStream();
5963
            byte[] imageBytes = null;
5964
            using (imageStream)
5965
            {
5966
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5967
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5968
                imageStream.Position = 0;
5969
                imageBytes = imageStream.ToArray();
5970
            }
5971

    
5972
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5973

    
5974
            RadWindow CheckPop = new RadWindow();
5975
            //Alert check = new Alert(Msg);
5976

    
5977
            CheckPop = new RadWindow
5978
            {
5979
                MinWidth = 400,
5980
                MinHeight = 100,
5981
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5982
                Header = "Alert",
5983
                Content = symbolPrompt,
5984
                //DialogResult = 
5985
                ResizeMode = System.Windows.ResizeMode.NoResize,
5986
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5987
                IsTopmost = true,
5988
            };
5989
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5990
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5991
            CheckPop.ShowDialog();
5992

    
5993
            /*
5994
            DialogParameters parameters = new DialogParameters()
5995
            {
5996
                Owner = Application.Current.MainWindow,
5997
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5998
                DefaultPromptResultValue = "Custom State",
5999
                Content = "Name :",
6000
                Header = "Insert Custom Symbol Name",
6001
                Theme = new VisualStudio2013Theme(),
6002
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6003
            };            
6004
            RadWindow.Prompt(parameters);
6005
            */
6006
        }
6007

    
6008
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6009
        {
6010
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6011
            KCOMDataModel.DataModel.CHECK_LIST check_;
6012
            string Result = streamToBase64.ImageToBase64(source);
6013
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6014
            string projectno = App.ViewInfo.ProjectNO;
6015
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6016

    
6017
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6018
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6019
            if (Item != null)
6020
            {
6021
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6022
            }
6023
            else
6024
            {
6025
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6026
            }
6027

    
6028
            if (Item == null)
6029
            {
6030
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6031
                {
6032
                    ID = Commons.shortGuid(),
6033
                    USER_ID = App.ViewInfo.UserID,
6034
                    IMAGE_URL = Result,
6035
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6036
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6037
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6038
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6039
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6040
                    STATUS = "False",
6041
                    CREATE_TIME = DateTime.Now,
6042
                    UPDATE_TIME = DateTime.Now,
6043
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6044
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6045
                };
6046
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6047
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6048
                //this.BaseClient.AddCheckList(projectno, check_);
6049
            }
6050
            else
6051
            {
6052
                Item.IMAGE_URL = Result;
6053
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6054
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6055
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6056
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6057
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6058
            }
6059

    
6060
        }
6061

    
6062
        public void Set_Capture()
6063
        {
6064
            double x = canvasDrawingMouseDownPoint.X;
6065
            double y = canvasDrawingMouseDownPoint.Y;
6066
            double width = dragCaptureBorder.Width;
6067
            double height = dragCaptureBorder.Height;
6068

    
6069
            if (width > 5 || height > 5)
6070
            {
6071
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6072
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6073
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6074
            }
6075
        }
6076
        #endregion
6077

    
6078
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6079
        {
6080
            multi_Undo_Data = new Multi_Undo_data();
6081

    
6082
            multi_Undo_Data.Markup = control;
6083

    
6084
            if ((control as IShapeControl) != null)
6085
            {
6086
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6087
            }
6088
            if ((control as IDashControl) != null)
6089
            {
6090
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6091
            }
6092
            if ((control as IPath) != null)
6093
            {
6094
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6095
            }
6096
            if ((control as UIElement) != null)
6097
            {
6098
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6099
            }
6100

    
6101
            return multi_Undo_Data;
6102
        }
6103

    
6104
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6105
        {
6106
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6107
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6108
            {
6109
                if (items.UserID == Select_ID)
6110
                {
6111
                    foreach (var item in items.MarkupList)
6112
                    {
6113
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6114
                        {
6115
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6116
                                items.MarkupInfoID, Commons.shortGuid());
6117
                        }
6118
                    }
6119
                }
6120
            }
6121
        }
6122

    
6123
        public void InkControl_Convert()
6124
        {
6125
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6126
            if (inkBoard.Strokes.Count > 0)
6127
            {
6128
                inkBoard.Strokes.ToList().ForEach(stroke =>
6129
                {
6130
                    List<Stroke> removingStroke = new List<Stroke>();
6131
                    StrokeCollection stC = new StrokeCollection();
6132

    
6133
                    removingStroke.Add(stroke);
6134

    
6135
                    InkToPath ip = new InkToPath();
6136
                    List<Point> inkPointSet = new List<Point>();
6137
                    PolygonControl pc = null;
6138
                    pc = new PolygonControl()
6139
                    {
6140
                        Angle = 0,
6141
                        PointSet = new List<Point>(),
6142
                        ControlType = ControlType.Ink
6143
                    };
6144
                    foreach (var item in removingStroke)
6145
                    {
6146
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6147
                        inkBoard.Strokes.Remove(item);
6148
                    }
6149
                    if (inkPointSet.Count != 0)
6150
                    {
6151
                        //강인구 추가(PenControl Undo Redo 추가)
6152
                        UndoData = new Undo_data()
6153
                        {
6154
                            IsUndo = false,
6155
                            Event = Event_Type.Create,
6156
                            EventTime = DateTime.Now,
6157
                            Markup_List = new List<Multi_Undo_data>()
6158
                        };
6159

    
6160
                        pc.StartPoint = inkPointSet[0];
6161
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6162
                        pc.PointSet = inkPointSet;
6163
                        pc.LineSize = 3;
6164
                        pc.CommentID = Commons.shortGuid();
6165
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6166
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6167
                        ///pc.SetPolyPath();
6168

    
6169
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6170
                        {
6171
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6172
                        });
6173
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6174
                        UndoData.Markup_List.Add(multi_Undo_Data);
6175
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6176
                    }
6177
                });
6178
            }
6179
        }
6180

    
6181
        /// <summary>
6182
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6183
        /// </summary>
6184
        /// <param name="StartP">StartPoint</param>
6185
        /// <param name="EndP">EndPoint</param>
6186
        /// <returns>Return_EndPoint</returns>
6187
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6188
        {
6189
            Point Return_Point = new Point();
6190

    
6191
            double dx = EndP.X - StartP.X;
6192
            double dy = EndP.Y - StartP.Y;
6193
            double length;
6194

    
6195
            switch (controlType)
6196
            {
6197
                case ControlType.Triangle:
6198
                    {
6199
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6200
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6201
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6202
                    }
6203
                    break;
6204
                default:
6205
                    {
6206
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6207
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6208
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6209
                    }
6210
                    break;
6211
            }
6212

    
6213
            return Return_Point;
6214
        }
6215

    
6216
        /// <summary>
6217
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6218
        /// </summary>
6219
        /// <author>humkyung</author>
6220
        /// <date>2018.04.26</date>
6221
        /// <param name="StartP"></param>
6222
        /// <param name="EndP"></param>
6223
        /// <returns></returns>
6224
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6225
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6226
        {
6227
            List<Point> res = new List<Point>();
6228

    
6229
            double dx = EndP.X - StartP.X;
6230
            double dy = EndP.Y - StartP.Y;
6231
            double length = Math.Sqrt(dx * dx + dy * dy);
6232
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6233
            dx /= length;
6234
            dy /= length;
6235
            double tmp = dx;
6236
            dx = -dy; dy = tmp; /// rotate by 90 degree
6237

    
6238
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6239
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6240

    
6241
            return res;
6242
        }
6243

    
6244
        /// <summary>
6245
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6246
        /// </summary>
6247
        /// <author>ingu</author>
6248
        /// <date>2018.06.05</date>
6249
        /// <param name="getPoint"></param>
6250
        /// <returns></returns>
6251
        private bool IsGetoutpoint(Point getPoint)
6252
        {
6253
            if (getPoint == new Point())
6254
            {
6255
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6256
                currentControl = null;
6257
                return true;
6258
            }
6259

    
6260
            return false;
6261
        }
6262

    
6263
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6264
        {
6265
            e.Effects = DragDropEffects.Copy;
6266
        }
6267

    
6268
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6269
        {
6270
            e.Effects = DragDropEffects.Copy;
6271
        }
6272

    
6273
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6274
        {
6275
            e.Effects = DragDropEffects.None;
6276
        }
6277

    
6278
        /*
6279
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6280
        {
6281
            try
6282
            {
6283
                if (e.Data.GetDataPresent(typeof(string)))
6284
                {
6285
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6286
                    string dragData = e.Data.GetData(typeof(string)) as string;
6287
                    Move_Symbol(sender, dragData);
6288
                }
6289
            }
6290
            catch (Exception ex)
6291
            {
6292
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6293
            }            
6294
        }
6295
        */
6296
    }
6297
}
클립보드 이미지 추가 (최대 크기: 500 MB)