프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 4913851c

이력 | 보기 | 이력해설 | 다운로드 (317 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(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
542
            }
543
            else
544
            {
545
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _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(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
624
                    }
625
                    else
626
                    {
627
                        uri2 = String.Format(Properties.Settings.Default.subServerImageWebPath, _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
                //ToolTip tool = new System.Windows.Controls.ToolTip();
1146
                //tool.Content = "ToolTip";
1147
                //panel.ToolTip = tool;
1148
            }
1149

    
1150
            if (mouseHandlingMode != MouseHandlingMode.Drawing)
1151
            {
1152
                #region 마우스 오버 시 색상 변경
1153
                /*
1154
                var firstCondition = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1155
                Color TempColor = MarkupToPDF.Controls.Common.ValueConverter.StringToColorConverter.Parse("FF07B4FF");
1156

    
1157
                if (firstCondition != null)
1158
                {
1159
                    firstCondition.MouseLeave += new System.Windows.Input.MouseEventHandler(firstCondition_MouseLeave);
1160

    
1161
                    if (firstCondition.GetType().Name == "TextControl")
1162
                    {
1163
                        (firstCondition as TextControl).BackInnerColor = new SolidColorBrush(TempColor);
1164
                        return;
1165
                    }
1166
                    else if (firstCondition.GetType().Name == "ArrowTextControl")
1167
                    {
1168
                        (firstCondition as ArrowTextControl).BackInnerColor = new SolidColorBrush(TempColor);
1169
                        return;
1170
                    }
1171

    
1172
                    if (L_Size == 0)
1173
                    {
1174
                        L_Size = (firstCondition as IPath).LineSize;
1175
                        (firstCondition as IPath).LineSize *= 4;
1176
                    }
1177
                    switch (firstCondition.GetType().Name)
1178
                    {
1179
                        case "RectangleControl":
1180
                            {
1181
                                (firstCondition as RectangleControl).StrokeColor = new SolidColorBrush(TempColor);
1182
                            }
1183
                            break;
1184
                        case "CircleControl":
1185
                            {
1186
                                (firstCondition as CircleControl).StrokeColor = new SolidColorBrush(TempColor);
1187
                            }
1188
                            break;
1189
                        case "TriControl":
1190
                            {
1191
                                (firstCondition as TriControl).StrokeColor = new SolidColorBrush(TempColor);
1192
                            }
1193
                            break;
1194
                        case "RectCloudControl":
1195
                            {
1196
                                (firstCondition as RectCloudControl).StrokeColor = new SolidColorBrush(TempColor);
1197
                            }
1198
                            break;
1199
                        case "CloudControl":
1200
                            {
1201
                                (firstCondition as CloudControl).StrokeColor = new SolidColorBrush(TempColor);
1202
                            }
1203
                            break;
1204
                        case "PolygonControl":
1205
                            {
1206
                                (firstCondition as PolygonControl).StrokeColor = new SolidColorBrush(TempColor);
1207
                            }
1208
                            break;
1209
                        case "ArcControl":
1210
                            {
1211
                                (firstCondition as ArcControl).StrokeColor = new SolidColorBrush(TempColor);
1212
                            }
1213
                            break;
1214
                        case "LineControl":
1215
                            {
1216
                                (firstCondition as LineControl).StrokeColor = new SolidColorBrush(TempColor);
1217
                            }
1218
                            break;
1219
                        case "ArrowControl_Multi":
1220
                            {
1221
                                (firstCondition as ArrowControl_Multi).StrokeColor = new SolidColorBrush(TempColor);
1222
                            }
1223
                            break;
1224

    
1225
                        default:
1226
                            {
1227

    
1228
                            }
1229
                            break;
1230
                    }
1231
                }
1232
                */
1233
                #endregion
1234
            }
1235

    
1236
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1237
            
1238
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1239
            {
1240
                SetCursor();
1241
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1242
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1243

    
1244
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1245
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1246
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1247

    
1248
                if (Sync.IsChecked)
1249
                {
1250
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1251
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1252
                }
1253
            }
1254

    
1255
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1256
            {
1257
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1258
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1259
                SetCursor();
1260

    
1261
                if (currentControl != null)
1262
                {
1263
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1264
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1265
                    //강인구 추가
1266
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1267

    
1268
                    if ((currentControl as IPath) != null)
1269
                    {
1270
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1271
                    }
1272
                    if ((currentControl as LineControl) != null)
1273
                    {
1274
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1275
                    }
1276

    
1277
                    if ((currentControl as IShapeControl) != null)
1278
                    {
1279
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1280
                    }
1281
                    if ((currentControl as TextControl) != null)
1282
                    {
1283
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1284
                        {
1285
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1286
                        }
1287
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1288
                        {
1289
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1290
                        }
1291
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1292
                        {
1293
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1294
                        }
1295
                    }
1296
                    else if ((currentControl as ArrowTextControl) != null)
1297
                    {
1298
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1299
                        {
1300
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1301
                        }
1302
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1303
                        {
1304
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1305
                        }
1306
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1307
                        {
1308
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1309
                        }
1310
                    }
1311
                    else if ((currentControl as RectCloudControl) != null)
1312
                    {
1313
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1314
                    }
1315
                    else if ((currentControl as CloudControl) != null)
1316
                    {
1317
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1318
                    }
1319

    
1320
                    switch (controlType)
1321
                    {
1322
                        case (ControlType.Coordinate):
1323
                            {
1324
                                var control = currentControl as CoordinateControl;
1325

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

    
1339

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

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

    
1358
                                    //강인구 추가
1359
                                    control.ControlType = controlType;
1360
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1361
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1362
                                    //  control.Paint = PaintSet.Fill;
1363
                                }
1364
                            }
1365
                            break;
1366
                        case (ControlType.InsideWhite):
1367
                            {
1368
                                var control = currentControl as InsideWhiteControl;
1369

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

    
1383

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

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

    
1402
                                    //강인구 추가
1403
                                    control.ControlType = controlType;
1404
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1405
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1406
                                    control.Paint = PaintSet.Fill;
1407
                                }
1408
                            }
1409
                            break;
1410
                        case (ControlType.OverlapWhite):
1411
                            {
1412
                                var control = currentControl as OverlapWhiteControl;
1413

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

    
1427

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

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

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

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

    
1471

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

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

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

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

    
1515

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

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

    
1534
                                    //강인구 추가
1535
                                    control.ControlType = controlType;
1536
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1537
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1538
                                }
1539
                            }
1540
                            break;
1541

    
1542
                        case ControlType.RectCloud:
1543
                            {
1544
                                var control = currentControl as RectCloudControl;
1545

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

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

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

    
1576
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1577
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1578
                                }
1579
                            }
1580
                            break;
1581

    
1582
                        case ControlType.SingleLine:
1583
                            {
1584
                                var control = currentControl as LineControl;
1585
                                if (control != null)
1586
                                {
1587
                                    control.LineStyleSet = LineStyleSet.SingleLine;
1588
                                    control.ControlType = controlType;
1589
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1590
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1591
                                    Point tempPoint = control.EndPoint;
1592

    
1593
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1594
                                    {
1595
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1596
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1597
                                        control.EndPoint = tempPoint;
1598
                                    }
1599
                                    else
1600
                                    {
1601
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1602
                                    }
1603

    
1604
                                    control.PointSet = new List<Point>
1605
                                        {
1606
                                            control.StartPoint,
1607
                                            control.EndPoint,
1608
                                        };
1609

    
1610
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1611
                                }
1612

    
1613
                            }
1614
                            break;
1615

    
1616
                        case ControlType.CancelLine:
1617
                            {
1618
                                var control = currentControl as LineControl;
1619
                                if (control != null)
1620
                                {
1621
                                    control.LineStyleSet = LineStyleSet.CancelLine;
1622
                                    //control.LineStyle = LineControl.LineStyleSet.MultiLine;
1623
                                    control.ControlType = controlType;
1624
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1625
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1626
                                    Point tempPoint = control.EndPoint;
1627

    
1628
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1629
                                    {
1630
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1631
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1632
                                        control.EndPoint = tempPoint;
1633
                                    }
1634
                                    else
1635
                                    {
1636
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1637
                                    }
1638

    
1639

    
1640
                                    control.PointSet = new List<Point>
1641
                                            {
1642
                                                control.StartPoint,
1643
                                                control.EndPoint,
1644
                                            };
1645
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1646
                                }
1647

    
1648

    
1649
                            }
1650
                            break;
1651

    
1652
                        case ControlType.ArrowLine:
1653
                            {
1654
                                var control = currentControl as LineControl;
1655
                                if (control != null)
1656
                                {
1657
                                    control.LineStyleSet = LineStyleSet.ArrowLine;
1658
                                    control.ControlType = controlType;
1659
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1660
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1661
                                    Point tempPoint = control.EndPoint;
1662

    
1663
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1664
                                    {
1665
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1666
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1667
                                        control.EndPoint = tempPoint;
1668
                                    }
1669
                                    else
1670
                                    {
1671
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1672
                                    }
1673

    
1674

    
1675
                                    control.PointSet = new List<Point>
1676
                                            {
1677
                                                control.StartPoint,
1678
                                                control.EndPoint,
1679
                                            };
1680
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1681
                                }
1682
                            }
1683
                            break;
1684

    
1685
                        case ControlType.TwinLine:
1686
                            {
1687
                                var control = currentControl as LineControl;
1688
                                if (control != null)
1689
                                {
1690
                                    control.LineStyleSet = LineStyleSet.TwinLine;
1691
                                    control.ControlType = controlType;
1692
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1693
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1694
                                    Point tempPoint = control.EndPoint;
1695

    
1696
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1697
                                    {
1698
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1699
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1700
                                        control.EndPoint = tempPoint;
1701
                                    }
1702
                                    else
1703
                                    {
1704
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1705
                                    }
1706

    
1707

    
1708
                                    control.PointSet = new List<Point>
1709
                                            {
1710
                                                control.StartPoint,
1711
                                                control.EndPoint,
1712
                                            };
1713
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1714
                                }
1715
                            }
1716
                            break;
1717

    
1718
                        case ControlType.DimLine:
1719
                            {
1720
                                var control = currentControl as LineControl;
1721
                                if (control != null)
1722
                                {
1723
                                    control.LineStyleSet = LineStyleSet.DimLine;
1724
                                    control.ControlType = controlType;
1725
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1726
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1727
                                    Point tempPoint = control.EndPoint;
1728

    
1729
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1730
                                    {
1731
                                        //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1732
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1733
                                        control.EndPoint = tempPoint;
1734
                                    }
1735
                                    else
1736
                                    {
1737
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1738
                                    }
1739

    
1740
                                    control.PointSet = new List<Point>
1741
                                            {
1742
                                                control.StartPoint,
1743
                                                control.EndPoint,
1744
                                            };
1745
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1746
                                }
1747
                            }
1748
                            break;
1749

    
1750
                        case ControlType.ArcLine:
1751
                            {
1752
                                var control = currentControl as ArcControl;
1753
                                if (control != null)
1754
                                {
1755
                                    control.isTransOn = false;
1756
                                    control.ControlType = controlType;
1757
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1758
                                    control.MidPoint = new Point(0, 0);
1759
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1760
                                    Point tempPoint = control.EndPoint;
1761

    
1762
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1763
                                    {
1764
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1765
                                        control.EndPoint = tempPoint;
1766
                                    }
1767
                                    else
1768
                                    {
1769
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1770
                                    }
1771

    
1772

    
1773
                                    control.PointSet = new List<Point>
1774
                                            {
1775
                                                control.StartPoint,
1776
                                                control.MidPoint,
1777
                                                control.EndPoint,
1778
                                            };
1779
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1780
                                }
1781
                            }
1782
                            break;
1783

    
1784
                        case ControlType.ArcArrow:
1785
                            {
1786
                                var control = currentControl as ArrowArcControl;
1787
                                if (control != null)
1788
                                {
1789
                                    control.isTransOn = false;
1790
                                    control.ControlType = controlType;
1791
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1792
                                    control.MidPoint = new Point(0, 0);
1793
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1794
                                    Point tempPoint = control.EndPoint;
1795

    
1796
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1797
                                    {
1798
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1799
                                        control.EndPoint = tempPoint;
1800
                                    }
1801
                                    else
1802
                                    {
1803
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1804
                                    }
1805

    
1806

    
1807
                                    control.PointSet = new List<Point>
1808
                                            {
1809
                                                control.StartPoint,
1810
                                                control.MidPoint,
1811
                                                control.EndPoint,
1812
                                            };
1813
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1814
                                }
1815
                            }
1816
                            break;
1817

    
1818
                        case ControlType.ArrowMultiLine:
1819
                            {
1820
                                var control = currentControl as ArrowControl_Multi;
1821
                                if (control != null)
1822
                                {
1823
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1824
                                    Point tempPoint = control.EndPoint;
1825
                                    if (control.MiddlePoint == new Point(0, 0))
1826
                                    {
1827
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1828
                                        {
1829
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1830
                                            //var AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1831
                                            control.EndPoint = tempPoint;
1832
                                        }
1833
                                        else
1834
                                        {
1835
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
1836
                                        }
1837
                                    }
1838
                                    else
1839
                                    {
1840
                                        if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
1841
                                        {
1842
                                            //var AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1843
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, true);
1844
                                            control.EndPoint = tempPoint;
1845
                                        }
1846
                                        else
1847
                                        {
1848
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.MiddlePoint, ref tempPoint, false);
1849
                                        }
1850

    
1851
                                    }
1852

    
1853
                                    control.PointSet = new List<Point>
1854
                                            {
1855
                                                control.StartPoint,
1856
                                                control.MiddlePoint,
1857
                                                control.EndPoint,
1858
                                            };
1859
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1860
                                }
1861
                            }
1862
                            break;
1863

    
1864
                        case ControlType.Circle:
1865
                            {
1866
                                var control = currentControl as CircleControl;
1867

    
1868
                                if (control != null)
1869
                                {
1870
                                    if (move.mousemode == MouseMode.Drawing)
1871
                                    {
1872
                                        //move.control_Move(ControlList, true, moveX, moveY);
1873
                                    }
1874
                                    else
1875
                                    {
1876
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1877
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1878
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1879
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1880

    
1881
                                        if (ViewerDataModel.Instance.IsPressShift)
1882
                                        {
1883
                                            Point setpoint = GetSquareEndPoint(control.StartPoint, control.EndPoint);
1884
                                            control.LeftBottomPoint = new Point(control.LeftBottomPoint.X, setpoint.Y);
1885
                                            control.TopRightPoint = new Point(setpoint.X, control.TopRightPoint.Y);
1886
                                            control.EndPoint = new Point(setpoint.X, setpoint.Y);
1887
                                        }
1888

    
1889
                                        control.PointSet = new List<Point>
1890
                                        {
1891
                                            control.StartPoint,
1892
                                            control.LeftBottomPoint,
1893
                                            control.EndPoint,
1894
                                            control.TopRightPoint,
1895
                                        };
1896
                                    }
1897

    
1898
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1899
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1900

    
1901
                                }
1902
                            }
1903
                            break;
1904

    
1905
                        case ControlType.PolygonCloud:
1906
                            {
1907
                                var control = currentControl as CloudControl;
1908

    
1909
                                if (control != null)
1910
                                {
1911
                                    control.isTransOn = true;
1912
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
1913

    
1914
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
1915

    
1916
                                    control.SetCloud();
1917
                                    //강인구 추가
1918
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1919
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1920
                                }
1921
                            }
1922
                            break;
1923

    
1924
                        case ControlType.Triangle:
1925
                            {
1926
                                var control = currentControl as TriControl;
1927

    
1928
                                if (control != null)
1929
                                {
1930
                                    if (move.mousemode == MouseMode.Drawing)
1931
                                    {
1932
                                        //move.control_Move(ControlList, true, moveX, moveY);
1933
                                    }
1934
                                    else
1935
                                    {
1936
                                        control.Paint = ViewerDataModel.Instance.paintSet;
1937
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1938

    
1939
                                        if (ViewerDataModel.Instance.checkAxis)
1940
                                        {
1941
                                            Point tempPoint = control.EndPoint;
1942
                                            ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
1943
                                            control.EndPoint = tempPoint;
1944
                                        }
1945

    
1946

    
1947
                                        if (ViewerDataModel.Instance.IsPressShift)
1948
                                        {
1949
                                            List<Point> Points = GetRegularTrianglePoints(control.StartPoint, control.EndPoint);
1950
                                            if (2 == Points.Count())
1951
                                            {
1952
                                                control.MidPoint = Points[0];
1953
                                                control.EndPoint = Points[1];
1954
                                            }
1955
                                        }
1956

    
1957
                                        control.PointSet = new List<Point>
1958
                                            {
1959
                                                control.StartPoint,
1960
                                                control.MidPoint,
1961
                                                control.EndPoint,
1962
                                            };
1963
                                    }
1964

    
1965
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1966
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1967
                                }
1968
                            }
1969
                            break;
1970

    
1971
                        case ControlType.ImgControl:
1972
                            {
1973
                                var control = currentControl as ImgControl;
1974

    
1975
                                if (control != null)
1976
                                {
1977
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
1978
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
1979
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
1980
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
1981

    
1982
                                    control.PointSet = new List<Point>
1983
                                        {
1984
                                            control.StartPoint,
1985
                                            control.LeftBottomPoint,
1986
                                            control.EndPoint,
1987
                                            control.TopRightPoint,
1988
                                        };
1989
                                }
1990
                            }
1991
                            break;
1992

    
1993
                        case ControlType.Date:
1994
                            {
1995
                                var control = currentControl as DateControl;
1996

    
1997
                                if (control != null)
1998
                                {
1999
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2000
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2001
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2002
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2003
                                    //control.Text = DateTime.Now.ToString("yyyy-MM-dd");
2004

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

    
2016
                        case ControlType.ArrowTextControl:
2017
                            {
2018
                                var control = currentControl as ArrowTextControl;
2019

    
2020
                                if (control != null)
2021
                                {
2022
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2023
                                    Point tempPoint = control.EndPoint;
2024

    
2025
                                    control.MidPoint = new Point(control.EndPoint.X - 100, control.EndPoint.Y - 100);
2026

    
2027
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2028
                                    {
2029
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2030
                                        control.EndPoint = tempPoint;
2031
                                    }
2032
                                    else
2033
                                    {
2034
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2035
                                    }
2036
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2037

    
2038
                                    control.PointSet = new List<Point>
2039
                                            {
2040
                                                control.StartPoint,
2041
                                                control.MidPoint,
2042
                                                control.EndPoint,
2043
                                            };
2044
                                }
2045
                            }
2046
                            break;
2047

    
2048
                        case ControlType.ArrowTransTextControl:
2049
                            {
2050
                                var control = currentControl as ArrowTextControl;
2051

    
2052
                                if (control != null)
2053
                                {
2054
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2055
                                    Point tempPoint = control.EndPoint;
2056
                                    //control.MidPoint = currentCanvasDrawingMouseMovePoint;
2057

    
2058
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2059
                                    {
2060
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2061
                                        control.EndPoint = tempPoint;
2062
                                    }
2063
                                    else
2064
                                    {
2065
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2066
                                    }
2067
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2068
                                    control.isFixed = true;
2069

    
2070
                                    control.PointSet = new List<Point>
2071
                                            {
2072
                                                control.StartPoint,
2073
                                                control.MidPoint,
2074
                                                control.EndPoint,
2075
                                            };
2076
                                }
2077
                            }
2078
                            break;
2079

    
2080
                        case ControlType.ArrowTextBorderControl:
2081
                            {
2082
                                var control = currentControl as ArrowTextControl;
2083

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

    
2106
                            }
2107
                            break;
2108
                        case ControlType.ArrowTransTextBorderControl:
2109
                            {
2110
                                var control = currentControl as ArrowTextControl;
2111

    
2112
                                if (control != null)
2113
                                {
2114
                                    control.isFixed = true;
2115
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2116
                                    Point tempPoint = control.EndPoint;
2117
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2118
                                    {
2119
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2120
                                        control.EndPoint = tempPoint;
2121
                                    }
2122
                                    else
2123
                                    {
2124
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2125
                                    }
2126

    
2127
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2128
                                    control.PointSet = new List<Point>
2129
                                            {
2130
                                                control.StartPoint,
2131
                                                control.MidPoint,
2132
                                                control.EndPoint,
2133
                                            };
2134
                                }
2135

    
2136
                            }
2137
                            break;
2138
                        case ControlType.ArrowTextCloudControl:
2139
                            {
2140
                                var control = currentControl as ArrowTextControl;
2141

    
2142
                                if (control != null)
2143
                                {
2144
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2145
                                    Point tempPoint = control.EndPoint;
2146
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2147
                                    {
2148
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2149
                                        control.EndPoint = tempPoint;
2150
                                    }
2151
                                    else
2152
                                    {
2153
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2154
                                    }
2155
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2156
                                    control.PointSet = new List<Point>
2157
                                            {
2158
                                                control.StartPoint,
2159
                                                control.MidPoint,
2160
                                                control.EndPoint,
2161
                                            };
2162
                                }
2163

    
2164
                            }
2165
                            break;
2166
                        case ControlType.ArrowTransTextCloudControl:
2167
                            {
2168
                                var control = currentControl as ArrowTextControl;
2169

    
2170
                                if (control != null)
2171
                                {
2172
                                    control.isFixed = true;
2173
                                    control.EndPoint = currentCanvasDrawingMouseMovePoint;
2174
                                    Point tempPoint = control.EndPoint;
2175
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2176
                                    {
2177
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, true);
2178
                                        control.EndPoint = tempPoint;
2179
                                    }
2180
                                    else
2181
                                    {
2182
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.StartPoint, ref tempPoint, false);
2183
                                    }
2184
                                    control.MidPoint = MathSet.getMiddlePoint(control.StartPoint, control.EndPoint);
2185
                                    control.PointSet = new List<Point>
2186
                                            {
2187
                                                control.StartPoint,
2188
                                                control.MidPoint,
2189
                                                control.EndPoint,
2190
                                            };
2191
                                }
2192

    
2193
                            }
2194
                            break;
2195
                        case ControlType.PolygonControl:
2196
                        case ControlType.ChainLine:
2197
                            {
2198
                                var control = currentControl as PolygonControl;
2199

    
2200
                                if (control != null)
2201
                                {
2202
                                    control.PointSet.RemoveAt(control.PointSet.Count - 1);
2203
                                    Point tempPoint = currentCanvasDrawingMouseMovePoint;
2204
                                    if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2205
                                    {
2206
                                        ViewerDataModel.Instance.AngleValue = MathSet.returnAngleString(control.PointSet[control.PointSet.Count - 1], ref tempPoint, true);
2207
                                    }
2208
                                    control.PointSet.Add(currentCanvasDrawingMouseMovePoint);
2209

    
2210
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2211
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2212
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2213
                                    control.updateControl();
2214
                                }
2215
                            }
2216
                            break;
2217
                        //강인구 추가
2218
                        case ControlType.Sign:
2219
                            {
2220
                                var control = currentControl as SignControl;
2221

    
2222
                                if (control != null)
2223
                                {
2224
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2225
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2226
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2227
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2228

    
2229
                                    if (control.StartPoint != control.EndPoint && control.SignImage == null)
2230
                                    {
2231
                                        var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
2232
                                        byte[] imageBytes = System.Convert.FromBase64String(_sign);
2233
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2234
                                        stream.Write(imageBytes, 0, imageBytes.Length);
2235
                                        stream.Position = 0;
2236
                                        System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
2237
                                        BitmapImage returnImage = new BitmapImage();
2238
                                        returnImage.BeginInit();
2239
                                        System.IO.MemoryStream ms = new System.IO.MemoryStream();
2240
                                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
2241
                                        ms.Seek(0, System.IO.SeekOrigin.Begin);
2242
                                        returnImage.StreamSource = ms;
2243
                                        returnImage.EndInit();
2244
                                        stream.Close();
2245

    
2246
                                        control.SignImage = returnImage;
2247
                                    }
2248
                                    control.PointSet = new List<Point>
2249
                                        {
2250
                                            control.StartPoint,
2251
                                            control.LeftBottomPoint,
2252
                                            control.EndPoint,
2253
                                            control.TopRightPoint,
2254
                                        };
2255
                                }
2256
                            }
2257
                            break;
2258
                        //TODO: 강인구 추가
2259
                        case ControlType.Symbol:
2260
                            {
2261
                                var control = currentControl as SymControl;
2262

    
2263
                                if (control != null)
2264
                                {
2265
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2266
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2267
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2268
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2269
                                    control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2270
                                    control.StrokeColor = new SolidColorBrush(Colors.Red);
2271

    
2272
                                    if (control.StartPoint != control.EndPoint)
2273
                                    {
2274
                                        if (control.PathData == null)
2275
                                        {
2276
                                            using (StringToPathConverter Convert = new StringToPathConverter())
2277
                                            {
2278
                                                control.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 ");
2279
                                            }
2280
                                        }
2281
                                    }
2282

    
2283
                                    control.PointSet = new List<Point>
2284
                                        {
2285
                                            control.StartPoint,
2286
                                            control.LeftBottomPoint,
2287
                                            control.EndPoint,
2288
                                            control.TopRightPoint,
2289
                                        };
2290
                                }
2291
                            }
2292
                            break;
2293
                        ///TODO: 
2294
                        case ControlType.Stamp:
2295
                            {
2296
                                var control = currentControl as SymControlN;
2297

    
2298
                                if (control != null)
2299
                                {
2300

    
2301
                                    if (control.StartPoint == control.EndPoint)
2302
                                    {
2303
                                        //string appovalData = "";
2304

    
2305
                                        var xamlData = MarkupToPDF.Serialize.Core.JsonSerializerHelper.UnCompressString_NonPrefix(App.SystemInfo.STAMP);
2306
                                        xamlData = xamlData.Replace("daelim", "DAELIM");
2307

    
2308

    
2309
                                        //object obj = System.Windows.Markup.XamlReader.Load(xamlData);
2310

    
2311
                                        System.IO.MemoryStream stream = new System.IO.MemoryStream();
2312
                                        System.IO.StreamWriter writer = new System.IO.StreamWriter(stream);
2313
                                        writer.Write(xamlData);
2314
                                        writer.Flush();
2315
                                        stream.Position = 0;
2316

    
2317
                                        control.StrokeColor = new SolidColorBrush(Colors.Red);
2318
                                        object obj = System.Windows.Markup.XamlReader.Load(stream);
2319
                                        UIElement ob = obj as UIElement;
2320

    
2321
                                        //control.ApplyTemplate();
2322

    
2323
                                        control.SetViewBox();
2324
                                        control.PathXathData = App.SystemInfo.STAMP;
2325
                                        control.Base_ViewBox.Child = ob;
2326
                                    }
2327

    
2328
                                    control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2329
                                    control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2330
                                    control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2331
                                    control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2332
                                    //control.LineSize = ViewerDataModel.Instance.LineSize + 3;
2333

    
2334

    
2335
                                    control.PointSet = new List<Point>
2336
                                    {
2337
                                        control.StartPoint,
2338
                                        control.LeftBottomPoint,
2339
                                        control.EndPoint,
2340
                                        control.TopRightPoint,
2341
                                    };
2342
                                }
2343
                            }
2344
                            break;
2345
                        case ControlType.Mark:
2346
                            {
2347
                                var control = currentControl as RectangleControl;
2348

    
2349
                                if (control != null)
2350
                                {
2351
                                    if (move.mousemode == MouseMode.Drawing)
2352
                                    {
2353
                                        //move.control_Move(ControlList, true, moveX, moveY);
2354
                                    }
2355
                                    else
2356
                                    {
2357
                                        control.StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2358
                                        control.LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X, currentCanvasDrawingMouseMovePoint.Y);
2359
                                        control.TopRightPoint = new Point(currentCanvasDrawingMouseMovePoint.X, canvasDrawingMouseDownPoint.Y);
2360
                                        control.EndPoint = new Point(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y);
2361

    
2362

    
2363
                                        control.PointSet = new List<Point>
2364
                                    {
2365
                                        control.StartPoint,
2366
                                        control.LeftBottomPoint,
2367
                                        control.EndPoint,
2368
                                        control.TopRightPoint,
2369
                                    };
2370
                                    }
2371

    
2372
                                    //강인구 추가
2373
                                    control.Paint = PaintSet.Fill;
2374
                                }
2375
                            }
2376
                            break;
2377
                        case ControlType.PenControl:
2378
                            {
2379
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2380
                                //inkBoard.Strokes.Add(stroke);
2381
                            }
2382
                            break;
2383
                        default:
2384
                            break;
2385
                    }
2386
                }
2387
            }
2388
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2389
            {
2390
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2391
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2392
                SetCursor();
2393
                if (currentControl == null)
2394
                {
2395
                    switch (controlType)
2396
                    {
2397
                        case ControlType.PenControl:
2398
                            {
2399
                                if (inkBoard.Tag.ToString() == "Ink")
2400
                                {
2401
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2402
                                }
2403
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2404
                                {
2405
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2406
                                }
2407
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2408
                                {
2409
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2410
                                }
2411

    
2412
                                //inkBoard.Strokes.Add(stroke);
2413
                            }
2414
                            break;
2415
                    }
2416
                    return;
2417
                }
2418
            }
2419
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
2420
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
2421
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2422
            {
2423
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2424

    
2425
                if (isDraggingSelectionRect)
2426
                {
2427
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2428

    
2429
                    e.Handled = true;
2430
                }
2431
                else if (isLeftMouseButtonDownOnWindow)
2432
                {
2433
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
2434
                    double dragDistance = Math.Abs(dragDelta.Length);
2435

    
2436
                    if (dragDistance > DragThreshold)
2437
                    {
2438
                        isDraggingSelectionRect = true;
2439

    
2440
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2441
                    }
2442

    
2443
                    e.Handled = true;
2444
                }
2445

    
2446

    
2447
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
2448
                {
2449
                    //SelectionPath = new Path();
2450
                    //PathFigure pathFigure = new PathFigure();
2451
                    //SelectionPath.Fill = new SolidColorBrush(Colors.Yellow);
2452
                    //SelectionPath.Opacity = 0.5;
2453
                    //SelectionPath.StrokeDashArray = new DoubleCollection() { 1 };
2454
                    //SelectionPath.StrokeDashCap = PenLineCap.Round;
2455
                    //SelectionPath.Stroke = new SolidColorBrush(Colors.Black);
2456
                }
2457
                else
2458
                {
2459
                    //List<Stroke> removingStroke = new List<Stroke>();
2460
                    //Rect p1 = new Rect(canvasDrawingMouseDownPoint, curMouseDownPoint);
2461
                    //StrokeCollection stC = new StrokeCollection();
2462
                    //for (int i = 0; i <= inkBoard.Strokes.Count - 1; i++)
2463
                    //{
2464
                    //    Rect p2 = inkBoard.Strokes[i].GetBounds();
2465
                    //    p1.Intersect(p2);
2466
                    //    if (p1.IsEmpty)
2467
                    //    {
2468

    
2469

    
2470
                    //        p1 = SelectionPath.Data.Bounds;
2471
                    //        bool intersectCheck = false;
2472
                    //        foreach (var T in inkBoard.Strokes[i].StylusPoints)
2473
                    //        {
2474
                    //            Rect p3 = new Rect(new Point(T.X, T.Y), new Size(10, 10));
2475
                    //            p1.Intersect(p3);
2476
                    //            if (!p1.IsEmpty)
2477
                    //            {
2478
                    //                intersectCheck = true;
2479
                    //            }
2480
                    //        }
2481
                    //        if (intersectCheck)
2482
                    //        {
2483
                    //            removingStroke.Add(inkBoard.Strokes[i]);
2484
                    //        }
2485

    
2486
                    //    }
2487
                    //    else
2488
                    //    {
2489
                    //        removingStroke.Add(inkBoard.Strokes[i]);
2490
                    //    }
2491
                    //}
2492

    
2493
                    e.Handled = true;
2494
                }
2495
            }
2496
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2497
            { //symbol      
2498
                if(_dragdropWindow != null)
2499
                {
2500
                    Win32Point w32Mouse = new Win32Point();
2501
                    GetCursorPos(ref w32Mouse);
2502

    
2503
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2504
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2505
                }                
2506
            }
2507
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
2508
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2509
            {
2510
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2511
                if(control != null)
2512
                {
2513
                    this.cursor = Cursors.Hand;
2514
                    SetCursor();
2515
                }
2516
                else
2517
                {
2518
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2519
                    SetCursor();
2520
                }
2521
            }
2522
            else
2523
            {
2524
                //var hitRect = new Rect(currentCanvasDrawingMouseMovePoint.X - 10, currentCanvasDrawingMouseMovePoint.Y - 10, 20, 20);
2525

    
2526
                //VisualTreeHelper.HitTest(this.drawingRotateCanvas, null, MyCallback,
2527
                //    new GeometryHitTestParameters(new RectangleGeometry(hitRect)));
2528

    
2529
                //if (hitList.Count > 0)
2530
                //{
2531

    
2532
                //}
2533

    
2534
                #region 조건 설정 : firstCondition
2535
                //GeneralTransform generalTransform = this.DeepLayer._BaseLayer.TransformToVisual(Application.Current.RootVisual);
2536
                //pnts = generalTransform.Transform(pnts);
2537
                //Rect areaInAbsoluteCoordinates = new Rect(pnts.X - 10, pnts.Y - 10, 20, 20);
2538
                //var firstCondition = (from kkk in VisualTreeHelper.FindElementsInHostCoordinates(areaInAbsoluteCoordinates,
2539
                //                               this.DeepLayer._BaseLayer).ToObservable()
2540
                //                      where String.IsNullOrEmpty((kkk as FrameworkElement).Name)
2541
                //                      select kkk).FirstOrDefault();
2542

    
2543
                //var canvas = LogicalTreeHelper.FindLogicalNode(this, "drawingRotateCanvas") as Canvas;
2544
                //if (canvas !=null)
2545
                //{
2546
                //    foreach (var item in (canvas.Children[0] as ItemsControl).Items)
2547
                //    {
2548
                //        UIElement uiElement = (UIElement)(canvas.Children[0] as ItemsControl).ItemContainerGenerator.ContainerFromItem(item);
2549
                //        if (uiElement!=null)
2550
                //        {
2551
                //            uiElement.InputHitTest(currentCanvasDrawingMouseMovePoint).
2552
                //        }
2553
                //    }
2554
                //}
2555

    
2556
                //EllipseGeometry expandedHitTestArea = new EllipseGeometry(currentCanvasDrawingMouseMovePoint, 10.0, 10.0);
2557
                //hitResultsList.Clear();
2558

    
2559
                #endregion
2560
            }
2561
        }
2562

    
2563
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2564
        {
2565
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2566
            {
2567
                SetCursor();
2568
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2569
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2570

    
2571
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2572

    
2573
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2574
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2575

    
2576
                if (Sync.IsChecked)
2577
                {
2578
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2579
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2580
                }
2581
            }
2582
        }
2583

    
2584
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2585

    
2586
        private EllipseGeometry hitArea = new EllipseGeometry();
2587

    
2588
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2589
        {
2590
            IsDrawing = false;
2591

    
2592
            if (mouseHandlingMode != MouseHandlingMode.None)
2593
            {
2594
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2595
                {
2596
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2597

    
2598
                    SetCursor();
2599

    
2600
                    switch (controlType)
2601
                    {
2602
                        case ControlType.None:
2603
                            break;
2604
                        case ControlType.Rectangle:
2605
                            {
2606

    
2607
                            }
2608
                            break;
2609
                        case ControlType.PenControl:
2610
                            {
2611

    
2612
                            }
2613
                            break;
2614
                        default:
2615
                            break;
2616
                    }
2617
                }
2618
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2619
                {
2620
                    if (isLeftMouseButtonDownOnWindow)
2621
                    {
2622
                        bool wasDragSelectionApplied = false;
2623

    
2624
                        if (isDraggingSelectionRect)
2625
                        {
2626
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2627
                            {
2628
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2629
                                mouseHandlingMode = MouseHandlingMode.None;
2630
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2631
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2632
                                Set_Symbol_Capture(endPoint);
2633
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2634
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
2635
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2636
                            }
2637
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2638
                            {
2639
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2640
                                mouseHandlingMode = MouseHandlingMode.None;
2641
                                Set_Capture();
2642

    
2643
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2644
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2645
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2646
                            }
2647
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2648
                            {
2649
                                ApplyDragSelectionRect();
2650
                            }
2651
                            else
2652
                            {
2653
                                double x = Canvas.GetLeft(dragZoomBorder);
2654
                                double y = Canvas.GetTop(dragZoomBorder);
2655
                                double width = dragZoomBorder.Width;
2656
                                double height = dragZoomBorder.Height;
2657
                                Rect dragRect = new Rect(x, y, width, height);
2658

    
2659
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2660

    
2661
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2662
                            }
2663

    
2664
                            isDraggingSelectionRect = false;
2665
                            e.Handled = true;
2666
                            wasDragSelectionApplied = true;
2667
                        }
2668

    
2669
                        if (isLeftMouseButtonDownOnWindow)
2670
                        {
2671
                            isLeftMouseButtonDownOnWindow = false;
2672
                            this.ReleaseMouseCapture();
2673
                            e.Handled = true;
2674
                        }
2675

    
2676
                        if (!wasDragSelectionApplied)
2677
                        {
2678
                            init();
2679
                        }
2680
                    }
2681
                }
2682
                else if (e.RightButton == MouseButtonState.Pressed)
2683
                {
2684
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2685
                    SetCursor();
2686
                }
2687

    
2688
                zoomAndPanControl.ReleaseMouseCapture();
2689

    
2690

    
2691
                e.Handled = true;
2692
            }
2693
            else
2694
            {
2695
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2696
                SetCursor();
2697
            }
2698

    
2699
            ///mouseButtonDown = MouseButton.Left;
2700
            //controlType = ControlType.SingleLine;
2701
        }
2702

    
2703
        public void Set_Symbol_Capture(Point endPoint)
2704
        {       
2705
            double x = canvasDrawingMouseDownPoint.X;
2706
            double y = canvasDrawingMouseDownPoint.Y;
2707
            if(x > endPoint.X)
2708
            {
2709
                x = endPoint.X;
2710
                y = endPoint.Y;
2711
            }
2712

    
2713
            double width = dragCaptureBorder.Width;
2714
            double height = dragCaptureBorder.Height;
2715

    
2716
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2717

    
2718
            if (x < 0)
2719
            {
2720
                width += x;
2721
                x = 0;
2722
            }
2723
            if (y < 0)
2724
            {
2725
                height += y;
2726
                y = 0;
2727

    
2728
                width = (int)canvasImage.PixelWidth - x;
2729
            }
2730
            if (x + width > canvasImage.PixelWidth)
2731
            {
2732
                width = (int)canvasImage.PixelWidth - x;
2733
            }
2734
            if (y + height > canvasImage.PixelHeight)
2735
            {
2736
                height = (int)canvasImage.PixelHeight - y;
2737
            }
2738
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2739

    
2740
            string uri = "";
2741
            if (userData.COMPANY != "EXT")
2742
            {
2743
                uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO,
2744
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2745
            }
2746
            else
2747
            {
2748
                uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
2749
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2750
            }
2751

    
2752
            var defaultBitmapImage = new BitmapImage();
2753
            defaultBitmapImage.BeginInit();
2754
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2755
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2756
            defaultBitmapImage.UriSource = new Uri(uri);
2757
            defaultBitmapImage.EndInit();
2758

    
2759
            //GC.Collect();
2760

    
2761
            if (defaultBitmapImage.IsDownloading)
2762
            {
2763
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2764
                {
2765
                    defaultBitmapImage.Freeze();
2766
                    //GC.Collect();
2767
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2768
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2769
                };
2770
            }
2771
        }
2772

    
2773
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2774
        {
2775
            ///mouseButtonDown = MouseButton.Left;
2776
        }
2777

    
2778
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2779
        {
2780
            ///mouseButtonDown = MouseButton.Left;
2781
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2782
        }
2783

    
2784
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2785
        {
2786

    
2787
        }
2788

    
2789
        /// <summary>
2790
        /// select items by dragging
2791
        /// </summary>
2792
        private void ApplyDragSelectionRect()
2793
        {
2794
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2795

    
2796
            double x = Canvas.GetLeft(dragSelectionBorder);
2797
            double y = Canvas.GetTop(dragSelectionBorder);
2798
            double width = dragSelectionBorder.Width;
2799
            double height = dragSelectionBorder.Height;
2800
            Boolean Flag = false;
2801
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2802
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2803

    
2804
            Rect dragRect = new Rect(x, y, width, height);
2805
            ///dragRect.Inflate(width / 10, height / 10);
2806

    
2807
            foreach (var item in Items)
2808
            {
2809
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2810

    
2811
                if (Flag)
2812
                {
2813
                    adornerSet.Add(item);
2814
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2815

    
2816
                    Control_Style(item);
2817
                }
2818
            }
2819
            if (adornerSet.Count > 0)
2820
            {
2821
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2822
                SelectLayer.Children.Add(final);
2823
            }
2824
        }
2825

    
2826
        private void InitDragSelectionRect(Point pt1, Point pt2)
2827
        {
2828
            //캡쳐 중
2829
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2830
            {
2831
                dragCaptureBorder.Visibility = Visibility.Visible;
2832
            }
2833
            //선택 중
2834
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2835
            {
2836

    
2837
                dragSelectionBorder.Visibility = Visibility.Visible;
2838
            }
2839
            else
2840
            {
2841
                dragZoomBorder.Visibility = Visibility.Visible;
2842
            }
2843
            UpdateDragSelectionRect(pt1, pt2);
2844
        }
2845

    
2846
        /// <summary>
2847
        /// Update the position and size of the rectangle used for drag selection.
2848
        /// </summary>
2849
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2850
        {
2851
            double x, y, width, height;
2852

    
2853
            //
2854
            // Determine x,y,width and height of the rect inverting the points if necessary.
2855
            // 
2856

    
2857
            if (pt2.X < pt1.X)
2858
            {
2859
                x = pt2.X;
2860
                width = pt1.X - pt2.X;
2861
            }
2862
            else
2863
            {
2864
                x = pt1.X;
2865
                width = pt2.X - pt1.X;
2866
            }
2867

    
2868
            if (pt2.Y < pt1.Y)
2869
            {
2870
                y = pt2.Y;
2871
                height = pt1.Y - pt2.Y;
2872
            }
2873
            else
2874
            {
2875
                y = pt1.Y;
2876
                height = pt2.Y - pt1.Y;
2877
            }
2878

    
2879
            //
2880
            // Update the coordinates of the rectangle used for drag selection.
2881
            //
2882
            //캡쳐 중
2883
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2884
            {
2885
                Canvas.SetLeft(dragCaptureBorder, x);
2886
                Canvas.SetTop(dragCaptureBorder, y);
2887
                dragCaptureBorder.Width = width;
2888
                dragCaptureBorder.Height = height;
2889
            }
2890
            //선택 중
2891
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2892
            {
2893
                Canvas.SetLeft(dragSelectionBorder, x);
2894
                Canvas.SetTop(dragSelectionBorder, y);
2895
                dragSelectionBorder.Width = width;
2896
                dragSelectionBorder.Height = height;
2897
            }
2898
            else
2899
            {
2900
                Canvas.SetLeft(dragZoomBorder, x);
2901
                Canvas.SetTop(dragZoomBorder, y);
2902
                dragZoomBorder.Width = width;
2903
                dragZoomBorder.Height = height;
2904
            }
2905
        }
2906

    
2907
        private void drawingPannelRotate(double angle)
2908
        {
2909
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2910
            rotate.Angle = angle;
2911
            var rotationNum = Math.Abs((rotate.Angle / 90));
2912

    
2913
            if (angle == 90 || angle == 270)
2914
            {
2915
                double emptySize = zoomAndPanCanvas.Width;
2916
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2917
                zoomAndPanCanvas.Height = emptySize;
2918
            }
2919
            if (angle == 0)
2920
            {
2921
                translate.X = 0;
2922
                translate.Y = 0;
2923
            }
2924
            else if (angle == 90)
2925
            {
2926
                translate.X = zoomAndPanCanvas.Width;
2927
                translate.Y = 0;
2928
            }
2929
            else if (angle == 180)
2930
            {
2931
                translate.X = zoomAndPanCanvas.Width;
2932
                translate.Y = zoomAndPanCanvas.Height;
2933
            }
2934
            else
2935
            {
2936
                translate.X = 0;
2937
                translate.Y = zoomAndPanCanvas.Height;
2938
            }
2939

    
2940
            zoomAndPanControl.RotationAngle = rotate.Angle;
2941

    
2942

    
2943
            if (!testPanel2.IsHidden)
2944
            {
2945
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2946
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2947
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2948
            }
2949

    
2950
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2951
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2952
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2953
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2954
            ViewerDataModel.Instance.Angle = rotate.Angle;
2955
        }
2956

    
2957
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2958
        {
2959
            string Data_ = "";
2960

    
2961
            try
2962
            {
2963
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2964
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2965
                if (Data_ != null || Data_ != "")
2966
                {
2967
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2968
                }
2969
                else
2970
                {
2971
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2972
                }
2973

    
2974
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2975
                //{
2976
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2977
                //    STATE = 0,
2978
                //};
2979
                if (Data_ != null)
2980
                {
2981
                    Image img = new Image();
2982
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2983
                    if (Data_.Contains(".svg"))
2984
                    {
2985
                        byte[] imageData = null;
2986
                        DrawingImage image = null;
2987
                        using (System.Net.WebClient web = new System.Net.WebClient())
2988
                        {
2989
                            imageData = web.DownloadData(new Uri(Data_));
2990
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2991
                            image = SvgReader.Load(stream);
2992
                        }
2993
                        img.Source = image;
2994
                    }
2995
                    else
2996
                    {
2997
                        img.Source = new BitmapImage(new Uri(Data_));
2998
                    }
2999

    
3000
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
3001
                    {
3002
                        PointSet = new List<Point>(),
3003
                        FilePath = Data_,
3004
                        ImageData = img.Source,
3005
                        StartPoint = canvasZoomPanningMouseDownPoint,
3006
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
3007
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
3008
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
3009
                        canvasZoomPanningMouseDownPoint.Y),
3010
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
3011
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
3012
                    };
3013

    
3014
                    currentControl.PointSet = new List<Point>
3015
                                        {
3016
                                            currentControl.StartPoint,
3017
                                            currentControl.LeftBottomPoint,
3018
                                            currentControl.EndPoint,
3019
                                            currentControl.TopRightPoint,
3020
                                        };
3021
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
3022
                    UndoData = new Undo_data()
3023
                    {
3024
                        IsUndo = false,
3025
                        Event = Event_Type.Create,
3026
                        EventTime = DateTime.Now,
3027
                        Markup_List = new List<Multi_Undo_data>()
3028
                    };
3029
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
3030
                    {
3031
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
3032
                    });
3033

    
3034
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3035
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
3036
                    UndoData.Markup_List.Add(multi_Undo_Data);
3037
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
3038

    
3039
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
3040
                    currentControl.CommentID = Commons.shortGuid();
3041
                    currentControl.SymbolID = id;
3042
                    currentControl.GroupID = group_id;
3043
                    currentControl.ApplyTemplate();
3044
                    currentControl.SetImage();
3045

    
3046
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
3047
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
3048
                    SelectLayer.Children.Add(final);
3049
                }
3050
            }
3051
            catch (Exception ex)
3052
            {
3053
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
3054
            }
3055
        }
3056

    
3057
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
3058
        {            
3059
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
3060
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
3061
            {
3062
                set_option.Value = double.Parse(set_option.ContentText);
3063
            }
3064

    
3065
            InkControl_Convert();
3066

    
3067
            ///TODO:
3068
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
3069
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
3070

    
3071
            if (text_item != null && (currentControl as ArrowTextControl) == null)
3072
            {
3073
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
3074
            }
3075
            /// up to here
3076

    
3077
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
3078
            {
3079
                if (arrow_text as ArrowTextControl != null)
3080
                {
3081
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3082
                }
3083
            }
3084

    
3085
            ///mouseButtonDown = e.ChangedButton;
3086
            /// complete drawing text control when user click mouse right button - 2018.05.14 added by humkyung
3087

    
3088
            //if (currentControl != null)
3089
            {
3090
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
3091
                if (text_item_ != null)
3092
                {
3093
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
3094
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
3095
                    (text_item_ as TextControl).IsEditing = false;
3096
                    (text_item_ as TextControl).EnableEditing = false;
3097
                    currentControl = null;
3098
                }
3099

    
3100
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
3101
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
3102
                {
3103
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
3104
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
3105
                    currentControl = null;
3106
                }
3107
            }
3108

    
3109
            double Ang = 0;                                          
3110
            if (rotate.Angle != 0)
3111
            {
3112
                Ang = 360 - rotate.Angle;
3113
            }
3114

    
3115
            if (e.OriginalSource is System.Windows.Controls.Image)
3116
            {
3117
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
3118
            }
3119

    
3120
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
3121
            {                
3122
                //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3123
                //SetCursor();
3124

    
3125
                //canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3126
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3127
                if(symbol_id != null)
3128
                {
3129
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
3130
                }                
3131
            }
3132

    
3133
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
3134
            {
3135
                if (this._dragdropWindow != null)
3136
                {
3137
                    this._dragdropWindow.Close();
3138
                    this._dragdropWindow = null;
3139
                    symbol_id = null;
3140
                }
3141
            }
3142

    
3143
            if (e.LeftButton == MouseButtonState.Pressed)
3144
            {
3145
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
3146
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3147

    
3148
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3149
                SetCursor();
3150

    
3151
                if (!ViewerDataModel.Instance.IsPressCtrl)
3152
                {
3153
                    SelectionSet.Instance.UnSelect(this);
3154
                }
3155
            }
3156
            if (e.MiddleButton == MouseButtonState.Pressed)
3157
            {
3158
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3159
                cursor = Cursors.SizeAll;
3160
                SetCursor();
3161
            }
3162
            if (e.RightButton == MouseButtonState.Pressed)
3163
            {
3164
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
3165
                cursor = Cursors.SizeAll;
3166
                SetCursor();
3167
            }
3168
            else if (e.XButton1 == MouseButtonState.Pressed)
3169
            {
3170
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
3171
                {
3172
                    this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber + 1);
3173
                }
3174

    
3175
                this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
3176

    
3177
            }
3178
            else if (e.XButton2 == MouseButtonState.Pressed)
3179
            {
3180
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
3181
                {
3182
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
3183
                }
3184
            }
3185

    
3186
            //if (mouseButtonDown == MouseButton.Left && ViewerDataModel.Instance.MarkupControls_USER.Count > 0 && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3187
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
3188
            {
3189
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
3190
                {
3191
                    if (SelectLayer.Children.Count == 0)
3192
                    {
3193
                        isLeftMouseButtonDownOnWindow = true;
3194
                        mouseHandlingMode = MouseHandlingMode.Selecting;
3195
                    }
3196

    
3197
                    if (controlType == ControlType.None)
3198
                    {
3199
                        isLeftMouseButtonDownOnWindow = true;
3200
                    }
3201
                }
3202

    
3203
                //캡쳐 모드 설정
3204
                if (mouseHandlingMode == MouseHandlingMode.Capture)
3205
                {
3206
                    dragCaptureBorder.Visibility = Visibility.Visible;
3207
                    isLeftMouseButtonDownOnWindow = true;
3208
                }
3209

    
3210
                //줌 모드 설정
3211
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
3212
                {
3213
                    //dragSelectionBorder.Visibility = Visibility.Visible;
3214
                    isLeftMouseButtonDownOnWindow = true;
3215
                }               
3216

    
3217
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3218
                if (control != null)
3219
                {
3220
                    AdornerFinal final = null;
3221

    
3222
                    if (!ViewerDataModel.Instance.IsPressCtrl)
3223
                    {
3224
                        /// 기존 selection 해제
3225
                        SelectionSet.Instance.UnSelect(this);
3226

    
3227
                        final = new AdornerFinal(control);
3228

    
3229
                        Control_Style(control);
3230

    
3231
                        if ((control as IPath) != null)
3232
                        {
3233
                            if ((control as IPath).LineSize != 0)
3234
                            {
3235
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
3236
                            }
3237
                        }
3238
                        if ((control as IShapeControl) != null)
3239
                        {
3240
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
3241
                            {
3242
                                ViewerDataModel.Instance.checkHatchShape = true;
3243
                            }
3244
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
3245
                            {
3246
                                ViewerDataModel.Instance.checkFillShape = true;
3247
                            }
3248
                            else
3249
                            {
3250
                                ViewerDataModel.Instance.checkHatchShape = false;
3251
                                ViewerDataModel.Instance.checkFillShape = false;
3252
                            }
3253
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
3254
                        }
3255

    
3256
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
3257

    
3258
                        if ((control as TextControl) != null)
3259
                        {
3260
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3261
                            {
3262
                                ViewerDataModel.Instance.checkTextStyle = true;
3263
                            }
3264
                            else
3265
                            {
3266
                                ViewerDataModel.Instance.checkTextStyle = false;
3267
                            }
3268

    
3269
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3270
                            {
3271
                                ViewerDataModel.Instance.checkTextStyle = true;
3272
                            }
3273
                            else
3274
                            {
3275
                                ViewerDataModel.Instance.checkTextStyle = false;
3276
                            }
3277
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3278
                            {
3279
                                ViewerDataModel.Instance.checkTextWeight = true;
3280
                            }
3281
                            else
3282
                            {
3283
                                ViewerDataModel.Instance.checkTextWeight = false;
3284
                            }
3285
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3286
                            {
3287
                                ViewerDataModel.Instance.checkUnderLine = true;
3288
                            }
3289
                            else
3290
                            {
3291
                                ViewerDataModel.Instance.checkUnderLine = false;
3292
                            }
3293
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3294
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3295

    
3296
                        }
3297
                        else if ((control as ArrowTextControl) != null)
3298
                        {
3299
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3300
                            {
3301
                                ViewerDataModel.Instance.checkTextStyle = true;
3302
                            }
3303
                            else
3304
                            {
3305
                                ViewerDataModel.Instance.checkTextStyle = false;
3306
                            }
3307

    
3308
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3309
                            {
3310
                                ViewerDataModel.Instance.checkTextStyle = true;
3311
                            }
3312
                            else
3313
                            {
3314
                                ViewerDataModel.Instance.checkTextStyle = false;
3315
                            }
3316
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3317
                            {
3318
                                ViewerDataModel.Instance.checkTextWeight = true;
3319
                            }
3320
                            else
3321
                            {
3322
                                ViewerDataModel.Instance.checkTextWeight = false;
3323
                            }
3324
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3325
                            {
3326
                                ViewerDataModel.Instance.checkUnderLine = true;
3327
                            }
3328
                            else
3329
                            {
3330
                                ViewerDataModel.Instance.checkUnderLine = false;
3331
                            }
3332
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3333
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3334
                        }
3335
                        else if ((control as RectCloudControl) != null)
3336
                        {
3337
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3338
                        }
3339
                        else if ((control as CloudControl) != null)
3340
                        {
3341
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3342
                        }
3343
                    }
3344
                    else
3345
                    {
3346
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3347
                        SelectionSet.Instance.UnSelect(this);
3348
                        comment.Add(control);
3349

    
3350
                        Control_Style(control);
3351

    
3352
                        final = new AdornerFinal(comment);
3353
                    }
3354

    
3355
                    if(final != null) this.SelectLayer.Children.Add(final);
3356
                }              
3357
            }
3358
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3359
            {               
3360
                init();
3361
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3362
                if (cursor != Cursors.SizeAll)
3363
                {
3364
                    cursor = Cursors.Cross;
3365
                    SetCursor();
3366
                }
3367
                bool init_user = false;
3368
                foreach (var user in gridViewMarkup.Items)
3369
                {
3370
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3371
                    {
3372
                        init_user = true;
3373
                    }
3374
                }
3375
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3376
                {
3377
                    RadWindow.Alert(new DialogParameters
3378
                    {
3379
                        Owner = Application.Current.MainWindow,
3380
                        Theme = new VisualStudio2013Theme(),
3381
                        Header = "안내",
3382
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
3383
                    });
3384
                    return;
3385
                }
3386
                else
3387
                {
3388
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3389
                    if (item != null)
3390
                    {
3391
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3392
                    }
3393
                }
3394

    
3395
                multi_Undo_Data = new Multi_Undo_data();
3396
                //강인구 Undo/Redo 보류
3397
                UndoData = new Undo_data()
3398
                {
3399
                    IsUndo = false,
3400
                    Event = Event_Type.Create,
3401
                    EventTime = DateTime.Now,
3402
                    Markup_List = new List<Multi_Undo_data>()
3403
                };
3404

    
3405
                switch (controlType)
3406
                {
3407
                    case ControlType.Coordinate:
3408
                        {
3409
                            if (e.LeftButton == MouseButtonState.Pressed)
3410
                            {
3411
                                if (currentControl is CoordinateControl)
3412
                                {
3413
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3414
                                    {
3415
                                        return;
3416
                                    }
3417

    
3418
                                    CreateControl();
3419

    
3420
                                    (currentControl as CoordinateControl).ApplyOverViewData();
3421
                                    currentControl = null;
3422
                                    this.cursor = Cursors.Arrow;
3423
                                }
3424
                                else
3425
                                {
3426
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3427
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3428
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3429
                                    {
3430
                                        currentControl = null;
3431
                                        this.cursor = Cursors.Arrow;
3432
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3433
                                        return;
3434
                                    }
3435
                                    else
3436
                                    {
3437
                                        currentControl = new CoordinateControl
3438
                                        {
3439
                                            Background = new SolidColorBrush(Colors.Black),
3440
                                            ControlType = ControlType.Coordinate
3441
                                        };
3442

    
3443
                                        currentControl.CommentID = Commons.shortGuid();
3444
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3445
                                        currentControl.IsNew = true;
3446

    
3447
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3448

    
3449
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3450
                                    }
3451
                                }
3452
                            }
3453
                        }
3454
                        break;
3455
                    case ControlType.InsideWhite:
3456
                        {
3457
                            if (e.LeftButton == MouseButtonState.Pressed)
3458
                            {
3459
                                if (currentControl is InsideWhiteControl)
3460
                                {
3461
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3462
                                    {
3463
                                        return;
3464
                                    }
3465

    
3466
                                    CreateControl();
3467

    
3468
                                    (currentControl as InsideWhiteControl).ApplyOverViewData();
3469
                                    currentControl = null;
3470
                                    this.cursor = Cursors.Arrow;
3471
                                }
3472
                                else
3473
                                {
3474
                                    currentControl = new InsideWhiteControl
3475
                                    {
3476
                                        Background = new SolidColorBrush(Colors.Black),
3477
                                        ControlType = ControlType.InsideWhite
3478
                                    };
3479

    
3480
                                    currentControl.CommentID = Commons.shortGuid();
3481
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3482
                                    currentControl.IsNew = true;
3483
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3484

    
3485
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3486
                                }
3487
                            }
3488
                        }
3489
                        break;
3490
                    case ControlType.OverlapWhite:
3491
                        {
3492
                            if (e.LeftButton == MouseButtonState.Pressed)
3493
                            {
3494
                                if (currentControl is OverlapWhiteControl)
3495
                                {
3496
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3497
                                    {
3498
                                        return;
3499
                                    }
3500

    
3501
                                    CreateControl();
3502

    
3503
                                    (currentControl as OverlapWhiteControl).ApplyOverViewData();
3504
                                    currentControl = null;
3505
                                    this.cursor = Cursors.Arrow;
3506
                                }
3507
                                else
3508
                                {
3509
                                    currentControl = new OverlapWhiteControl
3510
                                    {
3511
                                        Background = new SolidColorBrush(Colors.Black),
3512
                                        ControlType = ControlType.OverlapWhite
3513
                                    };
3514

    
3515
                                    currentControl.CommentID = Commons.shortGuid();
3516
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3517
                                    currentControl.IsNew = true;
3518
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3519

    
3520
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3521
                                }
3522
                            }
3523
                        }
3524
                        break;
3525
                    case ControlType.ClipWhite:
3526
                        {
3527
                            if (e.LeftButton == MouseButtonState.Pressed)
3528
                            {
3529
                                if (currentControl is ClipWhiteControl)
3530
                                {
3531
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3532
                                    {
3533
                                        return;
3534
                                    }
3535

    
3536
                                    CreateControl();
3537

    
3538
                                    (currentControl as ClipWhiteControl).ApplyOverViewData();
3539
                                    currentControl = null;
3540
                                    this.cursor = Cursors.Arrow;
3541
                                }
3542
                                else
3543
                                {
3544
                                    currentControl = new ClipWhiteControl
3545
                                    {
3546
                                        Background = new SolidColorBrush(Colors.Black),
3547
                                        ControlType = ControlType.ClipWhite
3548
                                    };
3549

    
3550
                                    currentControl.CommentID = Commons.shortGuid();
3551
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3552
                                    currentControl.IsNew = true;
3553
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3554

    
3555
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3556
                                }
3557
                            }
3558
                        }
3559
                        break;
3560
                    case ControlType.Rectangle:
3561
                        {
3562
                            if (e.LeftButton == MouseButtonState.Pressed)
3563
                            {
3564
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3565
                                //{
3566
                                    if (currentControl is RectangleControl)
3567
                                    {
3568
                                        //20180906 LJY TEST IsRotationDrawingEnable
3569
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3570
                                        {
3571
                                            return;
3572
                                        }
3573

    
3574
                                        CreateControl();
3575

    
3576
                                        (currentControl as RectangleControl).ApplyOverViewData();
3577
                                        currentControl = null;
3578
                                    
3579
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3580
                                    }
3581
                                    else
3582
                                    {
3583
                                        currentControl = new RectangleControl
3584
                                        {
3585
                                            Background = new SolidColorBrush(Colors.Black),
3586
                                            ControlType = ControlType.Rectangle
3587
                                        };
3588

    
3589
                                        currentControl.CommentID = Commons.shortGuid();
3590
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3591
                                        currentControl.IsNew = true;
3592
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3593

    
3594
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3595
                                    }
3596
                                //}
3597
                            }
3598
                        }
3599
                        break;
3600
                    case ControlType.RectCloud:
3601
                        {
3602
                            if (e.LeftButton == MouseButtonState.Pressed)
3603
                            {
3604
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3605
                                //{
3606
                                    if (currentControl is RectCloudControl)
3607
                                    {
3608
                                        //20180906 LJY TEST IsRotationDrawingEnable
3609
                                        if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3610
                                        {
3611
                                            return;
3612
                                        }
3613

    
3614
                                        CreateControl();
3615

    
3616
                                        (currentControl as RectCloudControl).ApplyOverViewData();
3617
                                        currentControl = null;
3618
                                    
3619
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3620
                                    }
3621
                                    else
3622
                                    {
3623
                                        currentControl = new RectCloudControl
3624
                                        {
3625
                                            Background = new SolidColorBrush(Colors.Black)
3626
                                        };
3627

    
3628
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3629
                                        currentControl.CommentID = Commons.shortGuid();
3630
                                        currentControl.IsNew = true;
3631
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3632
                                    }
3633
                                //}
3634
                            }
3635
                        }
3636
                        break;
3637
                    case ControlType.Circle:
3638
                        {
3639
                            if (e.LeftButton == MouseButtonState.Pressed)
3640
                            {
3641
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3642
                                //{
3643
                                    if (currentControl is CircleControl)
3644
                                    {
3645
                                        //20180906 LJY TEST IsRotationDrawingEnable
3646
                                        if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3647
                                        {
3648
                                            return;
3649
                                        }
3650

    
3651
                                        CreateControl();
3652

    
3653
                                        (currentControl as CircleControl).ApplyOverViewData();
3654
                                        currentControl = null;
3655
                                    }
3656
                                    else
3657
                                    {
3658
                                        currentControl = new CircleControl
3659
                                        {
3660
                                            Background = new SolidColorBrush(Colors.Black)
3661
                                        };
3662

    
3663
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3664
                                        currentControl.CommentID = Commons.shortGuid();
3665
                                        currentControl.IsNew = true;
3666
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3667
                                    }
3668
                                //}
3669
                            }
3670
                        }
3671
                        break;
3672
                    case ControlType.Triangle:
3673
                        {
3674
                            if (e.LeftButton == MouseButtonState.Pressed)
3675
                            {
3676
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3677
                                //{
3678
                                    if (currentControl is TriControl)
3679
                                    {
3680
                                        var content = currentControl as TriControl;
3681
                                        if (content.MidPoint == new Point(0, 0))
3682
                                        {
3683
                                            content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3684
                                        }
3685
                                        else
3686
                                        {
3687
                                            //20180906 LJY TEST IsRotationDrawingEnable
3688
                                            if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3689
                                            {
3690
                                                return;
3691
                                            }
3692

    
3693
                                            CreateControl();
3694

    
3695
                                            (currentControl as TriControl).ApplyOverViewData();
3696
                                            currentControl = null;
3697
                                        }
3698
                                    }
3699
                                    else
3700
                                    {
3701
                                        currentControl = new TriControl
3702
                                        {
3703
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3704
                                            Background = new SolidColorBrush(Colors.Black),
3705
                                        };
3706

    
3707
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3708
                                        currentControl.CommentID = Commons.shortGuid();
3709
                                        currentControl.IsNew = true;
3710
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3711
                                    }
3712
                                //}
3713
                            }
3714
                        }
3715
                        break;
3716
                    case ControlType.SingleLine:
3717
                        {
3718
                            if (e.LeftButton == MouseButtonState.Pressed)
3719
                            {
3720
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3721
                                //{
3722
                                    if (currentControl is LineControl)
3723
                                    {
3724
                                        //20180906 LJY TEST IsRotationDrawingEnable
3725
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3726
                                        {
3727
                                            return;
3728
                                        }
3729

    
3730
                                        CreateControl();
3731

    
3732
                                        (currentControl as LineControl).ApplyOverViewData();
3733
                                        currentControl = null;
3734
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3735
                                    }
3736
                                    else
3737
                                    {
3738
                                        currentControl = new LineControl
3739
                                        {
3740
                                            Background = new SolidColorBrush(Colors.Black)
3741
                                        };
3742

    
3743
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3744
                                        currentControl.CommentID = Commons.shortGuid();
3745
                                        currentControl.IsNew = true;
3746
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3747
                                        this.MainAngle.Visibility = Visibility.Visible;
3748
                                    }
3749
                                //}
3750
                            }
3751
                        }
3752
                        break;
3753
                    case ControlType.CancelLine:
3754
                        {
3755
                            if (e.LeftButton == MouseButtonState.Pressed)
3756
                            {
3757
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3758
                                //{
3759
                                    if (currentControl is LineControl)
3760
                                    {
3761
                                        //20180906 LJY TEST IsRotationDrawingEnable
3762
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3763
                                        {
3764
                                            return;
3765
                                        }
3766

    
3767
                                        CreateControl();
3768

    
3769
                                        (currentControl as LineControl).ApplyOverViewData();
3770
                                        currentControl = null;
3771
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3772
                                    }
3773
                                    else
3774
                                    {
3775
                                        currentControl = new LineControl
3776
                                        {
3777
                                            Background = new SolidColorBrush(Colors.Black)
3778
                                        };
3779

    
3780
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3781
                                        currentControl.CommentID = Commons.shortGuid();
3782
                                        currentControl.IsNew = true;
3783
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3784
                                        this.MainAngle.Visibility = Visibility.Visible;
3785
                                    }
3786
                                //}
3787
                            }
3788
                        }
3789
                        break;
3790
                    case ControlType.ArrowLine:
3791
                        {
3792
                            if (e.LeftButton == MouseButtonState.Pressed)
3793
                            {
3794
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3795
                                //{
3796
                                    if (currentControl is LineControl)
3797
                                    {
3798
                                        //20180906 LJY TEST IsRotationDrawingEnable
3799
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3800
                                        {
3801
                                            return;
3802
                                        }
3803

    
3804
                                        CreateControl();
3805

    
3806
                                        (currentControl as LineControl).ApplyOverViewData();
3807
                                        currentControl = null;
3808
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3809
                                    }
3810
                                    else
3811
                                    {
3812
                                        currentControl = new LineControl
3813
                                        {
3814
                                            Background = new SolidColorBrush(Colors.Black)
3815
                                        };
3816

    
3817
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3818
                                        currentControl.CommentID = Commons.shortGuid();
3819
                                        currentControl.IsNew = true;
3820
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3821
                                        this.MainAngle.Visibility = Visibility.Visible;
3822
                                    }
3823
                                //}
3824
                            }
3825
                        }
3826
                        break;
3827
                    case ControlType.TwinLine:
3828
                        {
3829
                            if (e.LeftButton == MouseButtonState.Pressed)
3830
                            {
3831
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3832
                                //{
3833
                                    if (currentControl is LineControl)
3834
                                    {
3835
                                        //20180906 LJY TEST IsRotationDrawingEnable
3836
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3837
                                        {
3838
                                            return;
3839
                                        }
3840

    
3841
                                        CreateControl();
3842

    
3843
                                        (currentControl as LineControl).ApplyOverViewData();
3844
                                        currentControl = null;
3845
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3846
                                    }
3847
                                    else
3848
                                    {
3849
                                        currentControl = new LineControl
3850
                                        {
3851
                                            Background = new SolidColorBrush(Colors.Black)
3852
                                        };
3853
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3854
                                        currentControl.CommentID = Commons.shortGuid();
3855
                                        currentControl.IsNew = true;
3856
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3857
                                        this.MainAngle.Visibility = Visibility.Visible;
3858
                                    }
3859
                                //}
3860
                            }
3861
                        }
3862
                        break;
3863
                    case ControlType.DimLine:
3864
                        {
3865
                            if (e.LeftButton == MouseButtonState.Pressed)
3866
                            {
3867
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3868
                                //{
3869
                                    if (currentControl is LineControl)
3870
                                    {
3871
                                        //20180906 LJY TEST IsRotationDrawingEnable
3872
                                        if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3873
                                        {
3874
                                            return;
3875
                                        }
3876
                                        CreateControl();
3877

    
3878
                                        (currentControl as LineControl).ApplyOverViewData();
3879
                                        currentControl = null;
3880
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3881
                                    }
3882
                                    else
3883
                                    {
3884
                                        currentControl = new LineControl
3885
                                        {
3886
                                            Background = new SolidColorBrush(Colors.Black)
3887
                                        };
3888
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3889
                                        currentControl.CommentID = Commons.shortGuid();
3890
                                        currentControl.IsNew = true;
3891
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3892
                                        this.MainAngle.Visibility = Visibility.Visible;
3893
                                    }
3894
                                //}
3895
                            }
3896
                        }
3897
                        break;
3898
                    case ControlType.ChainLine:
3899
                        {
3900
                            if (currentControl is PolygonControl)
3901
                            {
3902
                                var control = currentControl as PolygonControl;
3903

    
3904
                                if (e.RightButton == MouseButtonState.Pressed)
3905
                                {
3906
                                    //20180906 LJY TEST IsRotationDrawingEnable
3907
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3908
                                    {
3909
                                        return;
3910
                                    }
3911

    
3912
                                    CreateControl();
3913

    
3914
                                    (currentControl as PolygonControl).ApplyOverViewData();
3915
                                    currentControl = null;
3916
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3917
                                    return;
3918
                                }
3919

    
3920
                                if (!control.IsCompleted)
3921
                                {
3922
                                    control.PointSet.Add(control.EndPoint);
3923
                                    this.MainAngle.Visibility = Visibility.Visible;
3924
                                }
3925
                            }
3926
                            else
3927
                            {
3928
                                if (e.LeftButton == MouseButtonState.Pressed)
3929
                                {
3930
                                    MainAngle.Visibility = Visibility.Visible;
3931
                                    currentControl = new PolygonControl
3932
                                    {
3933
                                        PointSet = new List<Point>(),
3934
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3935
                                        ControlType = ControlType.ChainLine,
3936
                                        DashSize = ViewerDataModel.Instance.DashSize,
3937
                                        LineSize = ViewerDataModel.Instance.LineSize,
3938
                                        //PointC = new StylusPointSet()
3939
                                    };
3940

    
3941
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3942
                                    //{
3943
                                        var polygonControl = (currentControl as PolygonControl);
3944
                                        currentControl.CommentID = Commons.shortGuid();
3945
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3946
                                        currentControl.IsNew = true;
3947
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3948
                                        //currentControl.OnApplyTemplate();
3949
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3950
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3951
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3952
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3953
                                    //}
3954
                                }
3955
                            }
3956
                        }
3957
                        break;
3958
                    case ControlType.ArcLine:
3959
                        {
3960
                            if (e.LeftButton == MouseButtonState.Pressed)
3961
                            {
3962
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3963
                                //{
3964
                                    if (currentControl is ArcControl)
3965
                                    {
3966
                                        //20180906 LJY TEST IsRotationDrawingEnable
3967
                                        if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3968
                                        {
3969
                                            return;
3970
                                        }
3971

    
3972
                                        CreateControl();
3973

    
3974
                                        (currentControl as ArcControl).ApplyOverViewData();
3975
                                        currentControl = null;
3976
                                        this.MainAngle.Visibility = Visibility.Collapsed;
3977
                                    }
3978
                                    else
3979
                                    {
3980
                                        currentControl = new ArcControl
3981
                                        {
3982
                                            Background = new SolidColorBrush(Colors.Black)
3983
                                        };
3984
                                        currentControl.CommentID = Commons.shortGuid();
3985
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3986
                                        currentControl.IsNew = true;
3987
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3988
                                        this.MainAngle.Visibility = Visibility.Visible;
3989
                                    }
3990
                                //}
3991
                            }
3992
                            else if (e.RightButton == MouseButtonState.Pressed)
3993
                            {
3994
                                if (currentControl != null)
3995
                                {
3996
                                    (currentControl as ArcControl).setClock();
3997
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3998
                                    //(currentControl as ArcControl).ApplyTemplate();
3999
                                }
4000
                            }
4001
                        }
4002
                        break;
4003
                    case ControlType.ArcArrow:
4004
                        {
4005
                            if (e.LeftButton == MouseButtonState.Pressed)
4006
                            {
4007
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4008
                                //{
4009
                                if (currentControl is ArrowArcControl)
4010
                                {
4011
                                    //20180906 LJY TEST IsRotationDrawingEnable
4012
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4013
                                    {
4014
                                        return;
4015
                                    }
4016

    
4017
                                    CreateControl();
4018

    
4019
                                    (currentControl as ArrowArcControl).ApplyOverViewData();
4020
                                    currentControl = null;
4021
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4022
                                }
4023
                                else
4024
                                {
4025
                                    currentControl = new ArrowArcControl
4026
                                    {
4027
                                        Background = new SolidColorBrush(Colors.Black)
4028
                                    };
4029
                                    currentControl.CommentID = Commons.shortGuid();
4030
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4031
                                    currentControl.IsNew = true;
4032
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4033
                                    this.MainAngle.Visibility = Visibility.Visible;
4034
                                }
4035
                                //}
4036
                            }
4037
                            else if (e.RightButton == MouseButtonState.Pressed)
4038
                            {
4039
                                if (currentControl != null)
4040
                                {
4041
                                    (currentControl as ArrowArcControl).setClock();
4042
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
4043
                                    //(currentControl as ArcControl).ApplyTemplate();
4044
                                }
4045
                            }
4046
                        }
4047
                        break;
4048
                    case ControlType.ArrowMultiLine:
4049
                        {
4050
                            if (e.LeftButton == MouseButtonState.Pressed)
4051
                            {
4052
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4053
                                //{
4054

    
4055
                                    if (currentControl is ArrowControl_Multi)
4056
                                    {
4057
                                        var content = currentControl as ArrowControl_Multi;
4058
                                        if (content.MiddlePoint == new Point(0, 0))
4059
                                        {
4060
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
4061
                                            {
4062
                                                content.MiddlePoint = content.EndPoint;
4063
                                            }
4064
                                            else
4065
                                            {
4066
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
4067
                                            }
4068
                                        }
4069
                                        else
4070
                                        {
4071
                                            //20180906 LJY TEST IsRotationDrawingEnable
4072
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4073
                                            {
4074
                                                return;
4075
                                            }
4076

    
4077
                                            CreateControl();
4078

    
4079
                                            (currentControl as ArrowControl_Multi).ApplyOverViewData();
4080
                                            currentControl = null;
4081
                                            this.MainAngle.Visibility = Visibility.Collapsed;
4082
                                        }
4083
                                    }
4084
                                    else
4085
                                    {
4086
                                        currentControl = new ArrowControl_Multi
4087
                                        {
4088
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4089
                                            Background = new SolidColorBrush(Colors.Black)
4090
                                        };
4091
                                        currentControl.CommentID = Commons.shortGuid();
4092
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4093
                                        currentControl.IsNew = true;
4094
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4095
                                        this.MainAngle.Visibility = Visibility.Visible;
4096
                                    }
4097
                                //}
4098
                            }
4099
                        }
4100
                        break;
4101
                    case ControlType.PolygonCloud:
4102
                        {
4103
                            if (currentControl is CloudControl)
4104
                            {
4105
                                var control = currentControl as CloudControl;
4106
                                if (e.RightButton == MouseButtonState.Pressed)
4107
                                {
4108
                                    control.IsCompleted = true;
4109
                                }
4110

    
4111
                                if (!control.IsCompleted)
4112
                                {
4113
                                    control.PointSet.Add(control.EndPoint);
4114
                                }
4115
                                else
4116
                                {
4117
                                    //20180906 LJY TEST IsRotationDrawingEnable
4118
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4119
                                    {
4120
                                        return;
4121
                                    }
4122

    
4123
                                    CreateControl();
4124

    
4125
                                    control.isTransOn = true;
4126
                                    var firstPoint = control.PointSet.First();
4127

    
4128
                                    control.PointSet.Add(firstPoint);
4129
                                    control.DrawingCloud();
4130
                                    control.ApplyOverViewData();
4131

    
4132
                                    currentControl = null;
4133
                                }
4134
                            }
4135
                            else
4136
                            {
4137
                                if (e.LeftButton == MouseButtonState.Pressed)
4138
                                {
4139
                                    currentControl = new CloudControl
4140
                                    {
4141
                                        PointSet = new List<Point>(),
4142
                                        PointC = new StylusPointSet()
4143
                                    };
4144

    
4145
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4146
                                    //{
4147
                                        var polygonControl = (currentControl as CloudControl);
4148
                                        currentControl.CommentID = Commons.shortGuid();
4149
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4150
                                        currentControl.IsNew = true;
4151
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4152

    
4153
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4154
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4155
                                    
4156
                                    //}
4157
                                }
4158
                            }
4159
                        }
4160
                        break;
4161
                    case ControlType.ImgControl:
4162
                        {
4163
                            if (e.LeftButton == MouseButtonState.Pressed)
4164
                            {
4165
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4166
                                //{
4167
                                    if (currentControl is ImgControl)
4168
                                    {
4169
                                        //20180906 LJY TEST IsRotationDrawingEnable
4170
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4171
                                        {
4172
                                            return;
4173
                                        }
4174

    
4175
                                        CreateControl();
4176
                                        (currentControl as ImgControl).ApplyOverViewData();
4177
                                        controlType = ControlType.ImgControl;
4178
                                        currentControl = null;
4179
                                    }
4180
                                    else
4181
                                    {
4182
                                        
4183
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
4184
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
4185
                                        {
4186
                                            Image img = new Image();
4187
                                            //img.Source = new BitmapImage(new Uri(filename));
4188
                                            if (filename.Contains(".svg"))
4189
                                            {
4190
                                                byte[] imageData = null;
4191
                                                DrawingImage image = null;
4192
                                                using (System.Net.WebClient web = new System.Net.WebClient())
4193
                                                {
4194
                                                    imageData = web.DownloadData(new Uri(filename));
4195
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
4196
                                                    image = SvgReader.Load(stream);
4197
                                                }
4198
                                                img.Source = image;
4199
                                            }
4200
                                            else
4201
                                            {
4202
                                                img.Source = new BitmapImage(new Uri(filename));
4203
                                            }
4204

    
4205
                                            currentControl = new ImgControl
4206
                                            {
4207
                                                    Background = new SolidColorBrush(Colors.Black),
4208
                                                    PointSet = new List<Point>(),
4209
                                                    FilePath = filename,
4210
                                                    ImageData = img.Source,
4211
                                                    StartPoint = canvasDrawingMouseDownPoint,
4212
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
4213
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
4214
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
4215
                                                    ControlType = ControlType.ImgControl
4216
                                                };
4217

    
4218
                                        
4219
                                                currentControl.CommentID = Commons.shortGuid();                                            
4220
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4221
                                                currentControl.IsNew = true;
4222
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4223

    
4224
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4225
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
4226
                                        }
4227
                                    }
4228
                                //}
4229
                            }
4230
                        }
4231
                        break;
4232
                    case ControlType.Date:
4233
                        {
4234
                            if (e.LeftButton == MouseButtonState.Pressed)
4235
                            {
4236
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4237
                                //{
4238
                                    if (currentControl is DateControl)
4239
                                    {
4240
                                        //20180906 LJY TEST IsRotationDrawingEnable
4241
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4242
                                        {
4243
                                            return;
4244
                                        }
4245

    
4246
                                        CreateControl();
4247
                                        (currentControl as DateControl).ApplyOverViewData();
4248
                                        currentControl = null;
4249

    
4250
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4251
                                        {
4252
                                            controlType = ControlType.None;
4253
                                            IsSwingMode = false;
4254
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
4255
                                            Common.ViewerDataModel.Instance.ControlTag = null;
4256
                                            mouseHandlingMode = MouseHandlingMode.None;
4257
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
4258
                                            txtBatch.Visibility = Visibility.Collapsed;
4259

    
4260
                                        }
4261
                                    }
4262
                                    else
4263
                                    {
4264
                                        currentControl = new DateControl
4265
                                        {
4266
                                            Background = new SolidColorBrush(Colors.Black)
4267
                                        };
4268
                                        currentControl.CommentID = Commons.shortGuid();
4269
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4270
                                        currentControl.IsNew = true;
4271
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4272

    
4273
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4274
                                        (currentControl as DateControl).Angle -= rotate.Angle;
4275
                                }
4276
                                //}
4277
                            }
4278
                        }
4279
                        break;
4280
                    case ControlType.TextControl:
4281
                        {
4282
                            if (e.LeftButton == MouseButtonState.Pressed)
4283
                            {
4284
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4285
                                {
4286
                                    currentControl = new TextControl
4287
                                    {
4288
                                        ControlType = controlType
4289
                                    };
4290
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4291
                                    currentControl.CommentID = Commons.shortGuid();
4292
                                    currentControl.IsNew = true;
4293
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4294
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4295
                                    currentControl.SetValue(Canvas.ZIndexProperty, 2);
4296
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4297
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4298
                                    
4299
                                    (currentControl as TextControl).ControlType_No = 0;
4300
                                    (currentControl as TextControl).Angle -= rotate.Angle;
4301
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4302
                                    (currentControl as TextControl).ApplyTemplate();
4303
                                    (currentControl as TextControl).Base_TextBox.Focus();
4304

    
4305
                                    CreateControl();
4306

    
4307
                                }
4308
                            }
4309
                        }
4310
                        break;
4311
                    case ControlType.TextBorder:
4312
                        {
4313
                            if (e.LeftButton == MouseButtonState.Pressed)
4314
                            {
4315
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4316
                                {
4317
                                    currentControl = new TextControl
4318
                                    {
4319
                                        ControlType = controlType
4320
                                    };
4321

    
4322
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4323
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4324
                                    currentControl.CommentID = Commons.shortGuid();
4325
                                    currentControl.IsNew = true;
4326
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4327
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4328
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4329
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
4330
                                    
4331
                                    (currentControl as TextControl).ControlType_No = 1;
4332
                                    (currentControl as TextControl).Angle = Ang;
4333
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4334
                                    (currentControl as TextControl).ApplyTemplate();
4335
                                    (currentControl as TextControl).Base_TextBox.Focus();
4336
                                    CreateControl();
4337

    
4338
                                    //currentControl = null;
4339
                                }
4340
                            }
4341
                        }
4342
                        break;
4343
                    case ControlType.TextCloud:
4344
                        {
4345
                            if (e.LeftButton == MouseButtonState.Pressed)
4346
                            {
4347
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4348
                                {
4349
                                    currentControl = new TextControl
4350
                                    {
4351
                                        ControlType = controlType
4352
                                    };
4353

    
4354
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4355
                                    currentControl.CommentID = Commons.shortGuid();
4356
                                    currentControl.IsNew = true;
4357
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4358
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4359

    
4360
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4361
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
4362
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
4363

    
4364
                                    (currentControl as TextControl).Angle = Ang;
4365
                                    (currentControl as TextControl).ControlType_No = 2;
4366
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4367
                                    (currentControl as TextControl).ApplyTemplate();
4368
                                    (currentControl as TextControl).Base_TextBox.Focus();
4369
                                    CreateControl();
4370
                                    //currentControl = null;
4371
                                }
4372
                            }
4373
                        }
4374
                        break;
4375
                    case ControlType.ArrowTextControl:
4376
                         {
4377
                            if (e.LeftButton == MouseButtonState.Pressed)
4378
                            {
4379
                                if (currentControl is ArrowTextControl)
4380
                                {
4381
                                    //20180906 LJY TEST IsRotationDrawingEnable
4382
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4383
                                    {
4384
                                        return;
4385
                                    }                                    
4386

    
4387
                                    CreateControl();
4388

    
4389
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4390
                                    (currentControl as ArrowTextControl).IsEditing = false;
4391
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4392
                                    (currentControl as ArrowTextControl).IsNew = false;
4393
                                    currentControl = null;
4394
                                }
4395
                                else
4396
                                {
4397
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4398
                                    //{
4399
                                        currentControl = new ArrowTextControl();
4400
                                        currentControl.CommentID = Commons.shortGuid();
4401
                                        currentControl.IsNew = true;
4402
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4403
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4404

    
4405
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4406
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4407
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4408
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4409
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4410

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

    
4414
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4415
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4416
                                        this.MainAngle.Visibility = Visibility.Visible;
4417

    
4418
                                    
4419
                                    //}
4420
                                }
4421
                            }
4422
                        }
4423
                        break;
4424
                    case ControlType.ArrowTransTextControl:
4425
                        {
4426
                            if (e.LeftButton == MouseButtonState.Pressed)
4427
                            {
4428
                                if (currentControl is ArrowTextControl)
4429
                                {
4430
                                    //20180906 LJY TEST IsRotationDrawingEnable
4431
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4432
                                    {
4433
                                        return;
4434
                                    }                                    
4435

    
4436
                                    CreateControl();
4437
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4438
                                    currentControl.IsNew = false;
4439
                                    currentControl = null;
4440
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4441
                                }
4442
                                else
4443
                                {
4444
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4445
                                    //{
4446
                                         currentControl = new ArrowTextControl();
4447
                                        currentControl.CommentID = Commons.shortGuid();
4448
                                        currentControl.IsNew = true;
4449
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4450
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4451
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4452
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4453
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
4454
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4455
                                        (currentControl as ArrowTextControl).isFixed = true;
4456
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4457

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

    
4461
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4462
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4463
                                        (currentControl as ArrowTextControl).isTrans = true;
4464
                                }
4465
                            }
4466
                        }
4467
                        break;
4468
                    case ControlType.ArrowTextBorderControl:
4469
                         {
4470
                            if (e.LeftButton == MouseButtonState.Pressed)
4471
                            {
4472
                                if (currentControl is ArrowTextControl)
4473
                                {
4474
                                    //20180906 LJY TEST IsRotationDrawingEnable
4475
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4476
                                    {
4477
                                        return;
4478
                                    }
4479

    
4480
                                    CreateControl();
4481
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4482
                                    currentControl.IsNew = false;
4483
                                    currentControl = null;
4484
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4485
                                }
4486
                                else
4487
                                {
4488
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4489
                                    //{
4490
                                        currentControl = new ArrowTextControl()
4491
                                        {
4492
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4493
                                        };
4494
                                        currentControl.CommentID = Commons.shortGuid();
4495
                                        currentControl.IsNew = true;
4496
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4497
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4498

    
4499
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4500

    
4501
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4502

    
4503
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
4504
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4505
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4506

    
4507
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4508
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4509
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4510
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4511
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
4512
                                    //}
4513
                                }
4514
                            }
4515
                        }
4516
                        break;
4517
                    case ControlType.ArrowTransTextBorderControl:
4518
                        {
4519
                            if (e.LeftButton == MouseButtonState.Pressed)
4520
                            {
4521
                                if (currentControl is ArrowTextControl)
4522
                                {
4523
                                    //20180906 LJY TEST IsRotationDrawingEnable
4524
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4525
                                    {
4526
                                        return;
4527
                                    }
4528
                                    CreateControl();
4529
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4530
                                    currentControl.IsNew = false;
4531
                                    currentControl = null;
4532
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4533
                                }
4534
                                else
4535
                                {
4536
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4537
                                    //{
4538
                                    
4539

    
4540
                                    currentControl = new ArrowTextControl()
4541
                                        {
4542
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4543
                                        };
4544
                                        currentControl.CommentID = Commons.shortGuid();
4545
                                        currentControl.IsNew = true;
4546
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4547
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4548

    
4549
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4550

    
4551
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4552
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
4553
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4554
                                        (currentControl as ArrowTextControl).isFixed = true;
4555
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4556
                                     
4557
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4558
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4559
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4560

    
4561
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
4562
                                        this.MainAngle.Visibility = Visibility.Visible;
4563
                                    
4564
                                    //20180911 LJY
4565
                                        (currentControl as ArrowTextControl).isTrans = true;
4566
                                    
4567

    
4568
                                    //}
4569
                                }
4570
                            }
4571
                        }
4572
                        break;
4573
                    case ControlType.ArrowTextCloudControl:
4574
                        {
4575
                            if (e.LeftButton == MouseButtonState.Pressed)
4576
                            {
4577
                                if (currentControl is ArrowTextControl)
4578
                                {
4579
                                    //20180906 LJY TEST IsRotationDrawingEnable
4580
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4581
                                    {
4582
                                        return;
4583
                                    }
4584
                                    CreateControl();
4585
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4586
                                    currentControl.IsNew = false;
4587
                                    currentControl = null;
4588
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4589
                                }
4590
                                else
4591
                                {
4592
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4593
                                    //{
4594
                                        currentControl = new ArrowTextControl()
4595
                                        {
4596
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4597
                                        };
4598
                                        currentControl.CommentID = Commons.shortGuid();
4599
                                        currentControl.IsNew = true;
4600
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4601
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4602

    
4603
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4604
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4605
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
4606
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4607
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4608

    
4609
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4610
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
4611
                                    
4612
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4613
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4614
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
4615
                                    //}
4616
                                }
4617
                            }
4618
                        }
4619
                        break;
4620
                    case ControlType.ArrowTransTextCloudControl:
4621
                        {
4622
                            if (e.LeftButton == MouseButtonState.Pressed)
4623
                            {
4624
                                if (currentControl is ArrowTextControl)
4625
                                {
4626
                                    //20180906 LJY TEST IsRotationDrawingEnable
4627
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4628
                                    {
4629
                                        return;
4630
                                    }
4631
                                    CreateControl();
4632
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4633
                                    currentControl.IsNew = false;
4634
                                    currentControl = null;
4635
                                    this.MainAngle.Visibility = Visibility.Collapsed;
4636
                                }
4637
                                else
4638
                                {
4639
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4640
                                    //{
4641
                                        currentControl = new ArrowTextControl()
4642
                                        {
4643
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4644
                                        };
4645
                                        currentControl.CommentID = Commons.shortGuid();
4646
                                        currentControl.IsNew = true; 
4647
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4648
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4649
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
4650

    
4651
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
4652
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
4653
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4654
                                        (currentControl as ArrowTextControl).isFixed = true;
4655
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4656

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

    
4660
                                        (currentControl as ArrowTextControl).ApplyTemplate();
4661
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
4662
                                        this.MainAngle.Visibility = Visibility.Visible;  
4663
                                    
4664
                                    //20180911 LJY
4665
                                        (currentControl as ArrowTextControl).isTrans = true;
4666
                                    //}
4667
                                }
4668
                            }
4669
                        }
4670
                        break;
4671
                    case ControlType.PolygonControl:
4672
                        {
4673
                            if (currentControl is PolygonControl)
4674
                            {
4675
                                var control = currentControl as PolygonControl;
4676

    
4677
                                if (e.RightButton == MouseButtonState.Pressed)
4678
                                {
4679
                                    control.IsCompleted = true;
4680
                                }
4681

    
4682
                                if (!control.IsCompleted)
4683
                                {
4684
                                    control.PointSet.Add(control.EndPoint);
4685
                                }
4686
                                else
4687
                                {
4688
                                    //20180906 LJY TEST IsRotationDrawingEnable
4689
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4690
                                    {
4691
                                        return;
4692
                                    }
4693

    
4694
                                    var firstPoint = control.PointSet.First();
4695
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
4696
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
4697
                                    control.PointSet.Add(firstPoint);
4698

    
4699
                                    control.ApplyOverViewData();
4700

    
4701
                                    CreateControl();
4702
                                    control.updateControl();
4703
                                    currentControl = null;
4704
                                }
4705
                            }
4706
                            else
4707
                            {
4708
                                if (e.LeftButton == MouseButtonState.Pressed)
4709
                                {
4710
                                    currentControl = new PolygonControl
4711
                                    {
4712
                                        PointSet = new List<Point>(),
4713
                                    };
4714

    
4715
                                    var polygonControl = (currentControl as PolygonControl);
4716
                                    currentControl.CommentID = Commons.shortGuid();
4717
                                    currentControl.IsNew = true;
4718
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4719
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
4720
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
4721
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4722
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
4723
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4724
                                    polygonControl.ApplyTemplate();
4725
                                    polygonControl.Visibility = Visibility.Visible;
4726
                                }
4727
                            }
4728
                        }
4729
                        break;
4730
                    //강인구 추가
4731
                    case ControlType.Sign:
4732
                        {
4733
                            if (e.LeftButton == MouseButtonState.Pressed)
4734
                            {
4735
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4736
                                //{
4737
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
4738

    
4739
                                    if (_sign == null)
4740
                                    {
4741
                                        txtBatch.Visibility = Visibility.Collapsed;
4742
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4743
                                        controlType = ControlType.None;
4744

    
4745
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4746
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4747
                                        return;
4748
                                    }
4749

    
4750
                                    if (currentControl is SignControl)
4751
                                    {
4752
                                        //20180906 LJY TEST IsRotationDrawingEnable
4753
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4754
                                        {
4755
                                            return;
4756
                                        }
4757

    
4758
                                        CreateControl();
4759
                                        currentControl = null;
4760
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4761
                                        {
4762
                                            txtBatch.Text = "Place Date";
4763
                                            controlType = ControlType.Date;
4764
                                        }
4765
                                    }
4766
                                    else
4767
                                    {
4768
                                        currentControl = new SignControl
4769
                                        {
4770
                                            Background = new SolidColorBrush(Colors.Black),
4771
                                            UserNumber = App.ViewInfo.UserID,
4772
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4773
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4774
                                            ControlType = ControlType.Sign
4775
                                        };
4776

    
4777
                                        currentControl.CommentID = Commons.shortGuid();
4778
                                        currentControl.IsNew = true;
4779
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4780
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4781

    
4782
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
4783
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
4784
                                }
4785
                                //}
4786
                            }
4787
                        }
4788
                        break;
4789
                    case ControlType.Mark:
4790
                        {
4791
                            if (e.LeftButton == MouseButtonState.Pressed)
4792
                            {
4793
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4794
                                //{
4795
                                    if (currentControl is RectangleControl)
4796
                                    {
4797
                                        //20180906 LJY TEST IsRotationDrawingEnable
4798
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4799
                                        {
4800
                                            return;
4801
                                        }
4802

    
4803
                                        CreateControl();
4804
                                        (currentControl as RectangleControl).ApplyOverViewData();
4805
                                        currentControl = null;
4806
                                    
4807
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4808

    
4809
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4810
                                        {
4811
                                            txtBatch.Text = "Place Signature";
4812
                                            controlType = ControlType.Sign;
4813
                                        }
4814
                                    }
4815
                                    else
4816
                                    {
4817
                                        currentControl = new RectangleControl
4818
                                        {
4819
                                            Background = new SolidColorBrush(Colors.Black),
4820
                                            Paint = PaintSet.Fill
4821
                                        };
4822

    
4823
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4824
                                        currentControl.CommentID = Commons.shortGuid();
4825
                                        currentControl.IsNew = true;
4826
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4827
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4828
                                    }
4829
                                //}
4830
                            }
4831
                        }
4832
                        break;
4833
                    case ControlType.Symbol:
4834
                        {
4835
                            if (e.LeftButton == MouseButtonState.Pressed)
4836
                            {
4837
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4838
                                //{
4839
                                    if (currentControl is SymControl)
4840
                                    {
4841
                                        //20180906 LJY TEST IsRotationDrawingEnable
4842
                                        if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4843
                                        {
4844
                                            return;
4845
                                        }
4846
                                        CreateControl();
4847
                                        currentControl = null;
4848
                                    
4849
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4850
                                    }
4851
                                    else
4852
                                    {
4853
                                        currentControl = new SymControl
4854
                                        {
4855
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4856
                                            Background = new SolidColorBrush(Colors.Black),
4857
                                            ControlType = ControlType.Symbol
4858
                                        };
4859

    
4860
                                        currentControl.IsNew = true;
4861
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4862
                                        currentControl.CommentID = Commons.shortGuid();
4863
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4864

    
4865
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4866
                                        (currentControl as SymControl).Angle -= rotate.Angle;
4867
                                }
4868
                                //}
4869
                            }
4870
                        }
4871
                        break;
4872
                    case ControlType.Stamp:
4873
                        {
4874
                            if (e.LeftButton == MouseButtonState.Pressed)
4875
                            {
4876
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4877
                                //{
4878
                                    if (currentControl is SymControlN)
4879
                                    {
4880
                                        //20180906 LJY TEST IsRotationDrawingEnable
4881
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4882
                                        {
4883
                                            return;
4884
                                        }
4885

    
4886
                                        CreateControl();
4887
                                        currentControl = null;
4888
                                   
4889

    
4890
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4891
                                    }
4892
                                    else
4893
                                    {
4894
                                        currentControl = new SymControlN
4895
                                        {
4896
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
4897
                                            Background = new SolidColorBrush(Colors.Black),
4898
                                            ControlType = ControlType.Stamp
4899
                                        };
4900

    
4901
                                        currentControl.IsNew = true;
4902
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4903
                                        currentControl.CommentID = Commons.shortGuid();
4904
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4905
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
4906
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
4907
                                }                                    
4908
                                //}
4909
                            }
4910
                        }
4911
                        break;
4912
                    case ControlType.PenControl:
4913
                        {
4914
                            if (inkBoard.Tag.ToString() == "Ink")
4915
                            {
4916
                                inkBoard.IsEnabled = true;
4917
                                StartNewStroke(canvasDrawingMouseDownPoint);
4918
                            }
4919
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4920
                            {
4921
                                RemovePointStroke(canvasDrawingMouseDownPoint);
4922
                            }
4923
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4924
                            {
4925
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
4926
                            }
4927
                            IsDrawing = true;
4928
                            return;
4929
                        }
4930
                    default:
4931
                        if (currentControl != null)
4932
                        {
4933
                            currentControl.CommentID = null;
4934
                            currentControl.IsNew = false;
4935
                        }
4936
                        break;
4937
                }
4938
            }
4939
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4940
            {
4941
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4942
                {
4943
                    bool mouseOff = false;
4944
                    foreach (var item in SelectLayer.Children)
4945
                    {
4946
                        if (item is AdornerFinal)
4947
                        {
4948

    
4949
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4950
                            if (over != null)
4951
                            {
4952
                                mouseOff = true;
4953
                            }
4954
                        }
4955
                    }
4956

    
4957
                    if (!mouseOff)
4958
                    {
4959
                        SelectionSet.Instance.UnSelect(this);
4960
                    }
4961
                }
4962
                zoomAndPanControl.CaptureMouse();
4963
                e.Handled = true;
4964
            }
4965
        }
4966

    
4967
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4968
        {
4969
            ///mouseButtonDown = e.ChangedButton;
4970
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4971
        }
4972

    
4973
        private void RemoveLineStroke(Point P)
4974
        {
4975
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
4976
            if (control != null)
4977
            {
4978
                UndoData = new Undo_data()
4979
                {
4980
                    IsUndo = false,
4981
                    Event = Event_Type.Delete,
4982
                    EventTime = DateTime.Now,
4983
                    Markup_List = new List<Multi_Undo_data>()
4984
                };
4985

    
4986

    
4987
                multi_Undo_Data.Markup = control as MarkupToPDF.Common.CommentUserInfo;
4988
                UndoData.Markup_List.Add(multi_Undo_Data);
4989
                multi_Undo_Data = new Multi_Undo_data();
4990

    
4991
                ViewerDataModel.Instance.MarkupControls_USER.Remove(control);
4992
                var Item_ = ViewerDataModel.Instance.MyMarkupList.Where(d => d.ID == (control as MarkupToPDF.Common.CommentUserInfo).CommentID).FirstOrDefault();
4993
                ViewerDataModel.Instance.MyMarkupList.Remove(Item_);
4994
                
4995
                //임시파일에서도 삭제한다.
4996
                TempFile.DelTemp((control as MarkupToPDF.Common.CommentUserInfo).CommentID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
4997
                
4998
                ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
4999
                {
5000
                    ViewerDataModel.Instance.UndoDataList.Remove(i);
5001
                });
5002
                ViewerDataModel.Instance.UndoDataList.Add(UndoData);
5003

    
5004
            }
5005
        }
5006

    
5007
        private void RemovePointStroke(Point P)
5008
        {
5009
            foreach (Stroke hits in inkBoard.Strokes)
5010
            {
5011
                foreach (StylusPoint sty in hits.StylusPoints)
5012
                {
5013

    
5014
                }
5015
                if (hits.HitTest(P))
5016
                {
5017
                    inkBoard.Strokes.Remove(hits);
5018
                    return;
5019
                }
5020
            }
5021
        }
5022

    
5023
        private void StartNewStroke(Point P)
5024
        {
5025
            strokePoints = new StylusPointCollection();
5026
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
5027
            strokePoints.Add(segment1Start);
5028
            stroke = new Stroke(strokePoints);
5029

    
5030
            stroke.DrawingAttributes.Color = Colors.Red;
5031
            stroke.DrawingAttributes.Width = 4;
5032
            stroke.DrawingAttributes.Height = 4;
5033

    
5034
            inkBoard.Strokes.Add(stroke);
5035

    
5036
        }
5037

    
5038
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
5039
        {
5040
            ConsolidationMethod();
5041
        }
5042

    
5043
        /// <summary>
5044
        /// execute TeamConsolidationCommand
5045
        /// </summary>
5046
        public void TeamConsolidationMethod()
5047
        {
5048
            this.UpdateMyMarkupList();
5049
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5050
            {
5051
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5052
            }
5053
            else
5054
            {
5055

    
5056
                ViewerDataModel.Instance.IsConsolidate = true;
5057
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5058

    
5059
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5060
                {
5061
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
5062
                    {
5063
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
5064
                        return;
5065
                    }                    
5066
                }
5067
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
5068
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5069
                {
5070
                    MarkupInfoList.Add(item);
5071
                }
5072
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
5073
            }
5074
        }
5075

    
5076
        public void ConsolidationMethod()
5077
        {
5078
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5079
            {
5080
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5081
            }
5082
            else
5083
            {
5084
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
5085
                foreach (var item in this.gridViewMarkup.SelectedItems)
5086
                {
5087
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
5088
                }
5089
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
5090
                
5091
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
5092
            }
5093
        }
5094

    
5095
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
5096
        {
5097
            if (App.ViewInfo != null)
5098
            {
5099
                btnConsolidate = (sender as RadRibbonButton);
5100
                if (!App.ViewInfo.NewCommentPermission)
5101
                {
5102
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
5103
                }
5104
            }
5105
        }
5106

    
5107
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
5108
        {
5109
            TeamConsolidationMethod();
5110
        }
5111

    
5112
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
5113
        {
5114
            btnTeamConsolidate = sender as RadRibbonButton;
5115
            if (App.ViewInfo != null)
5116
            {
5117
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5118
                {
5119
                    if (btnConsolidate != null)
5120
                    {
5121
                        btnConsolidate.Visibility = Visibility.Collapsed;
5122
                    }
5123

    
5124
                    if (!App.ViewInfo.NewCommentPermission)
5125
                    {
5126
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
5127
                    }
5128
                }
5129
                else
5130
                {
5131
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
5132
                }
5133
            }
5134
        }
5135

    
5136
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
5137
        {
5138
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5139
            if (item != null)
5140
            {
5141
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5142

    
5143
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
5144
            }
5145
            else
5146
            {
5147
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5148
            }
5149
        }
5150

    
5151
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
5152
        {
5153
            btnFinalPDF = sender as RadRibbonButton;
5154
            if (App.ViewInfo != null)
5155
            {
5156
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
5157
                {
5158
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5159
                    if (btnConsolidate != null)
5160
                    {
5161
                        btnConsolidate.Visibility = Visibility.Collapsed;
5162
                    }
5163
                }
5164
            }
5165
        }
5166

    
5167
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
5168
        {
5169
            UpdateMyMarkupList();
5170

    
5171
            if (this.gridViewMarkup.SelectedItems.Count == 0)
5172
            {
5173
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
5174
            }
5175
            else
5176
            {
5177
                ViewerDataModel.Instance.IsConsolidate = true;
5178
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
5179
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
5180

    
5181
                string project_no = App.ViewInfo.ProjectNO;
5182
                string doc_id = _DocInfo.ID;
5183
                string user_id = App.ViewInfo.UserID;
5184
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
5185
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
5186
                {
5187
                    markupInfoItems.Add(item);
5188
                }
5189
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
5190
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
5191
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
5192
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
5193

    
5194
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5195
                if (item2 != null)
5196
                {
5197
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5198

    
5199
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5200
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5201
                }
5202
                else
5203
                {
5204
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5205
                }
5206
            }
5207
        }
5208

    
5209
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5210
        {
5211
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5212

    
5213
            if (App.ViewInfo != null)
5214
            {
5215
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5216
                {
5217
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5218
                }
5219
            }
5220
        }
5221

    
5222
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5223
        {
5224
            if (CompareMode.IsChecked)
5225
            {
5226
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5227
                {
5228
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5229
                }
5230
                if (ViewerDataModel.Instance.PageNumber == 0)
5231
                {
5232
                    ViewerDataModel.Instance.PageNumber = 1;
5233
                }
5234

    
5235
                Logger.sendReqLog("GetCompareRectAsync", _ViewInfo.ProjectNO + "," + _ViewInfo.DocumentItemID + "," + CurrentRev.DOCUMENT_ID +
5236
                    "," + pageNavigator.CurrentPage.PageNumber.ToString() + "," + ViewerDataModel.Instance.PageNumber.ToString() + "," +
5237
                    userData.COMPANY != "EXT" ? "true" : "false", 1);
5238

    
5239
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5240
            }
5241
            else
5242
            {
5243
                da.From = 1;
5244
                da.To = 1;
5245
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5246
                da.AutoReverse = false;
5247
                canvas_compareBorder.Children.Clear();
5248
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5249
            }
5250
        }
5251

    
5252
        private void Sync_Click(object sender, RoutedEventArgs e)
5253
        {
5254
            if (Sync.IsChecked)
5255
            {
5256
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5257
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5258
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5259
            }
5260
        }
5261

    
5262
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5263
        {
5264
            if (UserList.IsChecked)
5265
            {
5266
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5267
            }
5268
            else
5269
            {
5270
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5271
            }
5272
        }
5273

    
5274
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5275
        {
5276

    
5277
            if (BalanceMode.IsChecked)
5278
            {
5279
                ViewerDataModel.Instance.PageBalanceMode = true;
5280
            }
5281
            else
5282
            {
5283
                ViewerDataModel.Instance.PageBalanceMode = false;
5284
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5285
            }
5286
        }
5287

    
5288
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5289
        {
5290
            //초기화
5291
            testPanel2.IsHidden = true;
5292
            ViewerDataModel.Instance.PageBalanceMode = false;
5293
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5294
            ViewerDataModel.Instance.PageNumber = 0;
5295
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5296
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5297
            UserList.IsChecked = false;
5298
            BalanceMode.IsChecked = false;
5299
        }
5300

    
5301
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
5302
        {
5303
            if ((sender as System.Windows.Controls.Control).Tag != null)
5304
            {
5305
                //Compare 초기화
5306
                CompareMode.IsChecked = false;
5307
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5308

    
5309
                if (ViewerDataModel.Instance.PageNumber == 0)
5310
                {
5311
                    ViewerDataModel.Instance.PageNumber = 1;
5312
                }
5313

    
5314
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5315
                {
5316
                }
5317
                else
5318
                {
5319
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5320
                }
5321

    
5322
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
5323
                {
5324

    
5325
                }
5326
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
5327
                {
5328
                    ViewerDataModel.Instance.PageNumber += balancePoint;
5329
                }
5330

    
5331
                if (!testPanel2.IsHidden)
5332
                {
5333
                    if (IsSyncPDFMode)
5334
                    {
5335
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5336
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
5337

    
5338
                        if (pdfpath.IsDownloading)
5339
                        {
5340
                            pdfpath.DownloadCompleted += (ex, arg) =>
5341
                            {
5342
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5343
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5344
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5345
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5346
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5347
                            };
5348
                        }
5349
                        else
5350
                        {
5351
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5352
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5353
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5354

    
5355
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5356
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5357
                        }
5358

    
5359
                    }
5360
                    else
5361
                    {
5362
                        string uri = "";
5363

    
5364
                        if (userData.COMPANY != "EXT")
5365
                        {
5366
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5367
                        }
5368
                        else
5369
                        {
5370
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
5371
                        }
5372

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

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

    
5379
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5380
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5381

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

    
5390
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5391
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5392
                            };
5393
                        }
5394
                    }
5395

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

    
5400
                    foreach (var item in gridSelectionRevItem)
5401
                    {
5402
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
5403
                        {
5404
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
5405
                        });
5406
                    }
5407

    
5408
                    //강인구 추가
5409
                    zoomAndPanControl2.ZoomTo(new Rect
5410
                    {
5411
                        X = 0,
5412
                        Y = 0,
5413
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
5414
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
5415
                    });
5416

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

    
5419
                }
5420
            }
5421
        }
5422

    
5423
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5424
        {
5425
            if (MarkupMode.IsChecked)
5426
            {
5427
                IsSyncPDFMode = true;
5428

    
5429
                var uri = CurrentRev.TO_VENDOR;
5430

    
5431
                if (ViewerDataModel.Instance.PageNumber == 0)
5432
                {
5433
                    ViewerDataModel.Instance.PageNumber = 1;
5434
                }
5435

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

    
5440
                if (pdfpath.IsDownloading)
5441
                {
5442
                    pdfpath.DownloadCompleted += (ex, arg) =>
5443
                    {
5444
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5445
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5446
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5447
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5448
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5449
                    };
5450
                }
5451
                else
5452
                {
5453
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5454
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5455
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5456

    
5457
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5458
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5459
                }
5460
            }
5461
            else
5462
            {
5463
                IsSyncPDFMode = false;
5464
                string uri = "";
5465
                if (userData.COMPANY != "EXT")
5466
                {
5467
                    uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5468
                }
5469
                else
5470
                {
5471
                    uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5472
                }
5473

    
5474
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5475

    
5476
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5477
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5478
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5479

    
5480
                if (defaultBitmapImage_Compare.IsDownloading)
5481
                {
5482
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5483
                    {
5484
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5485
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5486
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5487
                    };
5488
                }
5489
                zoomAndPanControl2.ApplyTemplate();
5490
                zoomAndPanControl2.UpdateLayout();
5491
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5492
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5493
            }
5494
        }
5495

    
5496
        private void RadButton_Click(object sender, RoutedEventArgs e)
5497
        {
5498
            gridViewHistory_Busy.IsBusy = true;
5499

    
5500
            RadButton instance = sender as RadButton;
5501
            if (instance.CommandParameter != null)
5502
            {
5503
                CurrentRev = instance.CommandParameter as VPRevision;
5504
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5505
                {
5506
                    if (ea.Error == null && ea.Result != null)
5507
                    {
5508
                        testPanel2.IsHidden = false;
5509

    
5510
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5511
                        foreach(var info in ea.Result)
5512
                        {
5513
                            if(info.UserID == App.ViewInfo.UserID)
5514
                            {
5515
                                info.userDelete = true;
5516
                                info.DisplayColor = "FFFF0000";
5517
                            }
5518
                            else
5519
                            {
5520
                                info.userDelete = false;
5521
                            }
5522
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5523
                        }
5524
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5525

    
5526
                        string uri = "";
5527
                        if (userData.COMPANY != "EXT")
5528
                        {
5529
                            uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5530
                        }
5531
                        else
5532
                        {
5533
                            uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5534
                        }
5535

    
5536
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5537

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

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

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

    
5554
                        zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5555
                        zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5556
                        zoomAndPanControl2.RotationAngle = zoomAndPanControl.RotationAngle;
5557
                        zoomAndPanControl2.ApplyTemplate();
5558
                        zoomAndPanControl2.UpdateLayout();
5559

    
5560
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5561
                        {
5562
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5563
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5564
                        }
5565

    
5566
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5567
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5568
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5569

    
5570
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5571
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5572
                        gridViewHistory_Busy.IsBusy = false;
5573
                    }
5574

    
5575
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5576
                };
5577
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5578
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5579
            }
5580
        }
5581

    
5582
        public void Sync_Event(VPRevision Currnet_Rev)
5583
        {
5584
            CurrentRev = Currnet_Rev;
5585

    
5586
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5587
            {
5588
                if (ea.Error == null && ea.Result != null)
5589
                {
5590
                    testPanel2.IsHidden = false;
5591

    
5592
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5593
                    foreach(var info in ea.Result)
5594
                    {
5595
                        if(info.UserID == App.ViewInfo.UserID)
5596
                        {
5597
                            info.userDelete = true;
5598
                            info.DisplayColor = "FFFF0000";
5599
                        }
5600
                        else
5601
                        {
5602
                            info.userDelete = false;
5603
                        }
5604
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5605
                    }
5606
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5607

    
5608
                    string uri = "";
5609
                    if (userData.COMPANY != "EXT")
5610
                    {
5611
                        uri = String.Format(Properties.Settings.Default.mainServerImageWebPath, _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5612
                    }
5613
                    else
5614
                    {
5615
                        uri = String.Format(Properties.Settings.Default.subServerImageWebPath, _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5616
                    }
5617

    
5618
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5619

    
5620
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5621

    
5622
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5623
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5624
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5625

    
5626
                    if (defaultBitmapImage_Compare.IsDownloading)
5627
                    {
5628
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5629
                        {
5630
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5631
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5632
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5633
                        };
5634
                    }
5635

    
5636

    
5637
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5638
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5639
                    zoomAndPanControl2.ApplyTemplate();
5640
                    zoomAndPanControl2.UpdateLayout();
5641

    
5642
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5643
                    {
5644
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5645
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5646
                    }
5647
                    //}
5648

    
5649
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5650
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5651
                    gridViewHistory_Busy.IsBusy = false;
5652
                }
5653
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5654

    
5655
            };
5656
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5657
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5658
        }
5659

    
5660
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5661
        {
5662
            if (sender is Image)
5663
            {
5664
                if ((sender as Image).Tag != null)
5665
                {
5666
                    var pdfUrl = (sender as Image).Tag.ToString();
5667
                    System.Diagnostics.Process.Start(pdfUrl);
5668
                }
5669
                else
5670
                {
5671
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5672
                }
5673
            }
5674
        }
5675

    
5676
        private void Create_Symbol(object sender, RoutedEventArgs e)
5677
        {
5678
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5679

    
5680
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5681
            {
5682
                DialogMessage_Alert("Please Select Controls", "Alert");
5683
            }
5684
            else //선택된 것이 있으면
5685
            {
5686
                string MarkupData = "";
5687
                adorner_ = new AdornerFinal();
5688

    
5689
                foreach (var item in SelectLayer.Children)
5690
                {
5691
                    if (item.GetType().Name == "AdornerFinal")
5692
                    {
5693
                        adorner_ = (item as Controls.AdornerFinal);
5694
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5695
                        {
5696
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5697
                            {
5698
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5699
                                MarkupData += markupReturn.ConvertData;
5700
                            }
5701
                        }
5702
                    }
5703
                }
5704
                DialogParameters parameters = new DialogParameters()
5705
                {
5706
                    Owner = Application.Current.MainWindow,
5707
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5708
                    DefaultPromptResultValue = "Custom State",
5709
                    Content = "Name :",
5710
                    Header = "Insert Custom Symbol Name",
5711
                    Theme = new VisualStudio2013Theme(),
5712
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5713
                };
5714
                RadWindow.Prompt(parameters);
5715
            }
5716

    
5717
        }
5718
        public int symbolselectindex = 0;
5719
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5720
        {
5721
            //Save save = new Save();
5722
            try
5723
            {
5724
                string svgfilename = null;
5725
                if (symbolname != null)
5726
                {
5727
                    if (symbolpng == true || symbolsvg == true)
5728
                    {
5729
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5730
                        string guid = Commons.shortGuid();
5731

    
5732
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5733
                        //Check_Uri.UriCheck();
5734
                        fileUploader.RunCompleted += (ex, arg) =>
5735
                        {
5736
                            filename = arg.Result;
5737
                            if (symbolpng == true)
5738
                            {
5739
                                if (filename != null)
5740
                                { 
5741
                                    if (symbolselectindex == 0)
5742
                                    {
5743
                                        SymbolSave(symbolname, filename, data);
5744
                                    }
5745
                                    else
5746
                                    {
5747
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5748
                                    }
5749
                                    DataBind();
5750
                                }                                
5751
                            }
5752

    
5753
                            if (symbolsvg == true)
5754
                            {
5755
                                try
5756
                                {
5757
                                    var defaultBitmapImage = new BitmapImage();
5758
                                    defaultBitmapImage.BeginInit();
5759
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5760
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5761
                                    Check_Uri.UriCheck(filename);
5762
                                    defaultBitmapImage.UriSource = new Uri(filename);
5763
                                    defaultBitmapImage.EndInit();
5764

    
5765
                                    System.Drawing.Bitmap image;
5766

    
5767
                                    if (defaultBitmapImage.IsDownloading)
5768
                                    {
5769
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5770
                                        {
5771
                                            defaultBitmapImage.Freeze();
5772
                                            image = GetBitmap(defaultBitmapImage);
5773
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5774
                                            Process potrace = new Process
5775
                                            {
5776
                                                StartInfo = new ProcessStartInfo
5777
                                                {
5778
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5779
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5780
                                                    RedirectStandardInput = true,
5781
                                                    RedirectStandardOutput = true,
5782
                                                    RedirectStandardError = true,
5783
                                                    UseShellExecute = false,
5784
                                                    CreateNoWindow = true,
5785
                                                    WindowStyle = ProcessWindowStyle.Hidden
5786
                                                },
5787
                                            };
5788

    
5789
                                            StringBuilder svgBuilder = new StringBuilder();
5790
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5791
                                            {
5792
                                                svgBuilder.AppendLine(e2.Data);
5793
                                            };
5794

    
5795
                                            potrace.EnableRaisingEvents = true;
5796
                                            potrace.Start();
5797
                                            potrace.Exited += (sender, e) =>
5798
                                            {
5799
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5800
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5801
                                                Check_Uri.UriCheck(svgfilename);
5802
                                                if (symbolselectindex == 0)
5803
                                                {
5804
                                                    SymbolSave(symbolname, svgfilename, data);
5805
                                                }
5806
                                                else
5807
                                                {
5808
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5809
                                                }
5810

    
5811
                                                DataBind();
5812
                                            };
5813
                                            potrace.WaitForExit();
5814
                                        };
5815
                                    }
5816
                                    else
5817
                                    {
5818
                                        //GC.Collect();
5819
                                    }
5820
                                }
5821
                                catch(Exception ee)
5822
                                {
5823
                                    DialogMessage_Alert("" + ee, "Alert");
5824
                                }
5825
                            }
5826
                        };                                             
5827
                    }
5828
                }
5829
            }
5830
            catch (Exception e)
5831
            {
5832
                //DialogMessage_Alert(e + "", "Alert");
5833
            }            
5834
        }
5835

    
5836
        public void SymbolSave(string Name, string Url, string Data)
5837
        {
5838
            try
5839
            {
5840
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5841
                {
5842
                    ID = Commons.shortGuid(),
5843
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5844
                    NAME = Name,
5845
                    IMAGE_URL = Url,
5846
                    DATA = Data
5847
                };
5848

    
5849
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5850
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5851
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5852
            }
5853
            catch (Exception)
5854
            {
5855
                throw;
5856
            }
5857
        }
5858

    
5859
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5860
        {
5861
            try
5862
            {
5863
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5864
                {
5865
                    ID = Commons.shortGuid(),
5866
                    DEPARTMENT = Department,
5867
                    NAME = Name,
5868
                    IMAGE_URL = Url,
5869
                    DATA = Data
5870
                };
5871
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5872
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5873
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5874
            }
5875
            catch (Exception)
5876
            {
5877
                throw;
5878
            }
5879
        }
5880

    
5881
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5882
        {           
5883
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5884
            DataBind();
5885
        }
5886

    
5887
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5888
        {
5889
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5890
            DataBind();
5891
        }
5892
        private void DataBind()
5893
        {
5894
            try
5895
            {
5896
                Symbol_Custom Custom = new Symbol_Custom();
5897
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5898
                //ServiceDeepView.ServiceDeepViewClient client = new ServiceDeepView.ServiceDeepViewClient(App._binding, App._EndPoint);
5899
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5900
                foreach (var item in symbol_Private)
5901
                {
5902
                    Custom.Name = item.NAME;
5903
                    Custom.ImageUri = item.IMAGE_URL;
5904
                    Custom.ID = item.ID;
5905
                    Custom_List.Add(Custom);
5906
                    Custom = new Symbol_Custom();
5907
                }
5908
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5909
                
5910
                Custom = new Symbol_Custom();
5911
                Custom_List = new List<Symbol_Custom>();
5912

    
5913
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5914

    
5915
                List<SYMBOL_PUBLIC> symbol_Public;
5916

    
5917
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5918
                {
5919
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5920
                }
5921
                else
5922
                {
5923
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5924
                }
5925
                foreach (var item in symbol_Public)
5926
                {
5927
                    Custom.Name = item.NAME;
5928
                    Custom.ImageUri = item.IMAGE_URL;
5929
                    Custom.ID = item.ID;
5930
                    Custom_List.Add(Custom);
5931
                    Custom = new Symbol_Custom();
5932
                }
5933
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5934
                BaseClient.Close();                
5935
            }
5936
            catch(Exception e)
5937
            {
5938
                //DialogMessage_Alert("DataBind", "Alert");
5939
            }
5940
            
5941
        }
5942
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5943
        {
5944
            try
5945
            {
5946
                if (args.PromptResult != null)
5947
                {
5948
                    if (args.DialogResult.Value)
5949
                    {
5950
                        PngBitmapEncoder _Encoder = symImage(data);
5951

    
5952
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5953
                        _Encoder.Save(fs);
5954
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5955

    
5956
                        byte[] Img_byte = fs.ToArray();
5957

    
5958
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5959
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5960
                        Check_Uri.UriCheck(filename);
5961
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5962
                        {
5963
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5964
                        }
5965
                        else
5966
                        {
5967
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5968
                        }
5969
                        DataBind();
5970
                    }
5971
                }
5972
            }
5973
            catch(Exception ex)
5974
            {
5975
                DialogMessage_Alert("" + ex, "Alert");
5976
            }
5977
        }
5978

    
5979
        public PngBitmapEncoder symImage(string data)
5980
        {
5981

    
5982
            Canvas _canvas = new Canvas();
5983
            _canvas.Background = Brushes.White;
5984
            _canvas.Width = adorner_.BorderSize.Width;
5985
            _canvas.Height = adorner_.BorderSize.Height;
5986
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5987

    
5988
            BitmapEncoder encoder = new PngBitmapEncoder();
5989

    
5990

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

    
5993
            DrawingVisual dv = new DrawingVisual();
5994

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

    
5998
            using (DrawingContext ctx = dv.RenderOpen())
5999
            {
6000
                VisualBrush vb = new VisualBrush(_canvas);
6001
                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)));
6002
            }
6003

    
6004
            try
6005
            {
6006
                renderBitmap.Render(dv);
6007

    
6008
                //GC.Collect();
6009
                GC.WaitForPendingFinalizers();
6010
                //GC.Collect();
6011
                // encode png data
6012
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
6013
                // puch rendered bitmap into it
6014
                pngEncoder.Interlace = PngInterlaceOption.Off;
6015
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
6016
                return pngEncoder;
6017

    
6018
            }
6019
            catch //(Exception ex)
6020
            {
6021
                return null;
6022
            }
6023

    
6024
        }
6025

    
6026
        public void DialogMessage_Alert(string content, string header)
6027
        {
6028
            var box = new TextBlock();
6029
            box.MinWidth = 400;
6030
            box.FontSize = 11;
6031
            //box.FontSize = 12;
6032
            box.Text = content;
6033
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
6034

    
6035
            DialogParameters parameters = new DialogParameters()
6036
            {
6037
                Owner = Application.Current.MainWindow,
6038
                Content = box,
6039
                Header = header,
6040
                Theme = new VisualStudio2013Theme(),
6041
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6042
            };            
6043
            RadWindow.Alert(parameters);
6044
        }
6045

    
6046
        #region 캡쳐 기능
6047

    
6048
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
6049
        {
6050
            if (x < 0)
6051
            {
6052
                width += x;
6053
                x = 0;
6054
            }
6055
            if (y < 0)
6056
            {
6057
                height += y;
6058
                y = 0;
6059

    
6060
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6061
            }
6062
            if (x + width > zoomAndPanCanvas.ActualWidth)
6063
            {
6064
                width = (int)zoomAndPanCanvas.ActualWidth - x;
6065
            }
6066
            if (y + height > zoomAndPanCanvas.ActualHeight)
6067
            {
6068
                height = (int)zoomAndPanCanvas.ActualHeight - y;
6069
            }
6070

    
6071
            byte[] pixels = CopyPixels(x, y, width, height);
6072

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

    
6075
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
6076
        }
6077

    
6078
        public byte[] CopyPixels(int x, int y, int width, int height)
6079
        {
6080
            byte[] pixels = new byte[width * height * 4];
6081
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
6082

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

    
6086
            return pixels;
6087
        }
6088

    
6089
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
6090
        {
6091
            DrawingVisual drawingVisual = new DrawingVisual();
6092
            DrawingContext drawingContext = drawingVisual.RenderOpen();
6093

    
6094
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
6095
            drawingContext.DrawRectangle(new VisualBrush(element), null,
6096
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
6097
            drawingContext.Close();
6098

    
6099
            // 비트맵으로 변환합니다.
6100
            RenderTargetBitmap target =
6101
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
6102
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
6103

    
6104
            target.Render(drawingVisual);
6105
            return target;
6106
        }
6107

    
6108
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
6109
        {
6110
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
6111
            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);
6112
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
6113
            bmp.UnlockBits(data);
6114
            return bmp;
6115
        }
6116
        public string symbolname = null;
6117
        public bool symbolsvg = true;
6118
        public bool symbolpng = true;
6119

    
6120
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
6121
        {
6122
            System.Drawing.Bitmap image = GetBitmap(source);
6123
            //흰색 제거
6124
            //image.MakeTransparent(System.Drawing.Color.White);
6125

    
6126
            var imageStream = new System.IO.MemoryStream();
6127
            byte[] imageBytes = null;
6128
            using (imageStream)
6129
            {
6130
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
6131
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
6132
                imageStream.Position = 0;
6133
                imageBytes = imageStream.ToArray();
6134
            }
6135

    
6136
            SymbolPrompt symbolPrompt = new SymbolPrompt();
6137

    
6138
            RadWindow CheckPop = new RadWindow();
6139
            //Alert check = new Alert(Msg);
6140

    
6141
            CheckPop = new RadWindow
6142
            {
6143
                MinWidth = 400,
6144
                MinHeight = 100,
6145
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6146
                Header = "Alert",
6147
                Content = symbolPrompt,
6148
                //DialogResult = 
6149
                ResizeMode = System.Windows.ResizeMode.NoResize,
6150
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6151
                IsTopmost = true,
6152
            };
6153
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6154
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6155
            CheckPop.ShowDialog();
6156

    
6157
            /*
6158
            DialogParameters parameters = new DialogParameters()
6159
            {
6160
                Owner = Application.Current.MainWindow,
6161
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6162
                DefaultPromptResultValue = "Custom State",
6163
                Content = "Name :",
6164
                Header = "Insert Custom Symbol Name",
6165
                Theme = new VisualStudio2013Theme(),
6166
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6167
            };            
6168
            RadWindow.Prompt(parameters);
6169
            */
6170
        }
6171

    
6172
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6173
        {
6174
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6175
            KCOMDataModel.DataModel.CHECK_LIST check_;
6176
            string Result = streamToBase64.ImageToBase64(source);
6177
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6178
            string projectno = App.ViewInfo.ProjectNO;
6179
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6180

    
6181
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6182
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6183
            if (Item != null)
6184
            {
6185
                Logger.sendResLog("GetCheckList", "TRUE", 1);
6186
            }
6187
            else
6188
            {
6189
                Logger.sendResLog("GetCheckList", "FALSE", 1);
6190
            }
6191

    
6192
            if (Item == null)
6193
            {
6194
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6195
                {
6196
                    ID = Commons.shortGuid(),
6197
                    USER_ID = App.ViewInfo.UserID,
6198
                    IMAGE_URL = Result,
6199
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6200
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6201
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6202
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6203
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6204
                    STATUS = "False",
6205
                    CREATE_TIME = DateTime.Now,
6206
                    UPDATE_TIME = DateTime.Now,
6207
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6208
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6209
                };
6210
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6211
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6212
                //this.BaseClient.AddCheckList(projectno, check_);
6213
            }
6214
            else
6215
            {
6216
                Item.IMAGE_URL = Result;
6217
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6218
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6219
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6220
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6221
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6222
            }
6223

    
6224
        }
6225

    
6226
        public void Set_Capture()
6227
        {
6228
            double x = canvasDrawingMouseDownPoint.X;
6229
            double y = canvasDrawingMouseDownPoint.Y;
6230
            double width = dragCaptureBorder.Width;
6231
            double height = dragCaptureBorder.Height;
6232

    
6233
            if (width > 5 || height > 5)
6234
            {
6235
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6236
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6237
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6238
            }
6239
        }
6240
        #endregion
6241

    
6242
        //MarkupInfoItem
6243
        public void CreateControl()
6244
        {
6245

    
6246
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6247
            {
6248
                ViewerDataModel.Instance.UndoDataList.Remove(i);
6249
            });
6250
            multi_Undo_Data.Markup = currentControl;
6251
            UndoData.Markup_List.Add(multi_Undo_Data);
6252

    
6253
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6254

    
6255
            //List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
6256
        }
6257

    
6258
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6259
        {
6260
            multi_Undo_Data = new Multi_Undo_data();
6261

    
6262
            multi_Undo_Data.Markup = control;
6263

    
6264
            if ((control as IShapeControl) != null)
6265
            {
6266
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6267
            }
6268
            if ((control as IDashControl) != null)
6269
            {
6270
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6271
            }
6272
            if ((control as IPath) != null)
6273
            {
6274
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6275
            }
6276
            if ((control as UIElement) != null)
6277
            {
6278
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6279
            }
6280

    
6281
            return multi_Undo_Data;
6282
        }
6283

    
6284
        private void Comment_Move(object sender, MouseButtonEventArgs e)
6285
        {
6286
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
6287
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6288
            {
6289
                if (items.UserID == Select_ID)
6290
                {
6291
                    foreach (var item in items.MarkupList)
6292
                    {
6293
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6294
                        {
6295
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
6296
                                items.MarkupInfoID, Commons.shortGuid());
6297
                        }
6298
                    }
6299
                }
6300
            }
6301
        }
6302

    
6303
        public void InkControl_Convert()
6304
        {
6305
            Logger.sendCheckLog("pageNavigator_PageChanging_InkControl_Convert", 1);
6306
            if (inkBoard.Strokes.Count > 0)
6307
            {
6308
                inkBoard.Strokes.ToList().ForEach(stroke =>
6309
                {
6310
                    List<Stroke> removingStroke = new List<Stroke>();
6311
                    StrokeCollection stC = new StrokeCollection();
6312

    
6313
                    removingStroke.Add(stroke);
6314

    
6315
                    InkToPath ip = new InkToPath();
6316
                    List<Point> inkPointSet = new List<Point>();
6317
                    PolygonControl pc = null;
6318
                    pc = new PolygonControl()
6319
                    {
6320
                        Angle = 0,
6321
                        PointSet = new List<Point>(),
6322
                        ControlType = ControlType.Ink
6323
                    };
6324
                    foreach (var item in removingStroke)
6325
                    {
6326
                        inkPointSet.AddRange(ip.StrokeGetPointsPlus(item));
6327
                        inkBoard.Strokes.Remove(item);
6328
                    }
6329
                    if (inkPointSet.Count != 0)
6330
                    {
6331
                        //강인구 추가(PenControl Undo Redo 추가)
6332
                        UndoData = new Undo_data()
6333
                        {
6334
                            IsUndo = false,
6335
                            Event = Event_Type.Create,
6336
                            EventTime = DateTime.Now,
6337
                            Markup_List = new List<Multi_Undo_data>()
6338
                        };
6339

    
6340
                        pc.StartPoint = inkPointSet[0];
6341
                        pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6342
                        pc.PointSet = inkPointSet;
6343
                        pc.LineSize = 3;
6344
                        pc.CommentID = Commons.shortGuid();
6345
                        pc.StrokeColor = new SolidColorBrush(Colors.Red);
6346
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6347
                        ///pc.SetPolyPath();
6348

    
6349
                        ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
6350
                        {
6351
                            ViewerDataModel.Instance.UndoDataList.Remove(i);
6352
                        });
6353
                        multi_Undo_Data.Markup = pc as CommentUserInfo;
6354
                        UndoData.Markup_List.Add(multi_Undo_Data);
6355
                        ViewerDataModel.Instance.UndoDataList.Add(UndoData);
6356
                    }
6357
                });
6358
            }
6359
        }
6360

    
6361
        /// <summary>
6362
        /// 정원, 정사각형, 정삼각형을 그리기 위한 EndPoint계산
6363
        /// </summary>
6364
        /// <param name="StartP">StartPoint</param>
6365
        /// <param name="EndP">EndPoint</param>
6366
        /// <returns>Return_EndPoint</returns>
6367
        private Point GetSquareEndPoint(Point StartP, Point EndP)
6368
        {
6369
            Point Return_Point = new Point();
6370

    
6371
            double dx = EndP.X - StartP.X;
6372
            double dy = EndP.Y - StartP.Y;
6373
            double length;
6374

    
6375
            switch (controlType)
6376
            {
6377
                case ControlType.Triangle:
6378
                    {
6379
                        //삼각형의 StartPoint기준으로 반지름 만큼 증가하기 때문에 곱하기2 필요
6380
                        length = Math.Max(Math.Abs(dx) * 2, Math.Abs(dy));
6381
                        Return_Point = (dy < 0) ? new Point(StartP.X + length / 2, StartP.Y - length) : new Point(StartP.X + length / 2, StartP.Y + length);
6382
                    }
6383
                    break;
6384
                default:
6385
                    {
6386
                        length = Math.Max(Math.Abs(dx), Math.Abs(dy));
6387
                        Return_Point.X = (dx > 0) ? StartP.X + length : StartP.X - length;
6388
                        Return_Point.Y = (dy > 0) ? StartP.Y + length : StartP.Y - length;
6389
                    }
6390
                    break;
6391
            }
6392

    
6393
            return Return_Point;
6394
        }
6395

    
6396
        /// <summary>
6397
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
6398
        /// </summary>
6399
        /// <author>humkyung</author>
6400
        /// <date>2018.04.26</date>
6401
        /// <param name="StartP"></param>
6402
        /// <param name="EndP"></param>
6403
        /// <returns></returns>
6404
        /// <history>humkyung 2018.05.11 apply axis lock</history>
6405
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
6406
        {
6407
            List<Point> res = new List<Point>();
6408

    
6409
            double dx = EndP.X - StartP.X;
6410
            double dy = EndP.Y - StartP.Y;
6411
            double length = Math.Sqrt(dx * dx + dy * dy);
6412
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
6413
            dx /= length;
6414
            dy /= length;
6415
            double tmp = dx;
6416
            dx = -dy; dy = tmp; /// rotate by 90 degree
6417

    
6418
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
6419
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
6420

    
6421
            return res;
6422
        }
6423

    
6424
        /// <summary>
6425
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6426
        /// </summary>
6427
        /// <author>ingu</author>
6428
        /// <date>2018.06.05</date>
6429
        /// <param name="getPoint"></param>
6430
        /// <returns></returns>
6431
        private bool IsGetoutpoint(Point getPoint)
6432
        {
6433
            if (getPoint == new Point())
6434
            {
6435
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6436
                currentControl = null;
6437
                return true;
6438
            }
6439

    
6440
            return false;
6441
        }
6442

    
6443
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6444
        {
6445
            e.Effects = DragDropEffects.Copy;
6446
        }
6447

    
6448
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6449
        {
6450
            e.Effects = DragDropEffects.Copy;
6451
        }
6452

    
6453
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6454
        {
6455
            e.Effects = DragDropEffects.None;
6456
        }
6457

    
6458
        /*
6459
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6460
        {
6461
            try
6462
            {
6463
                if (e.Data.GetDataPresent(typeof(string)))
6464
                {
6465
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6466
                    string dragData = e.Data.GetData(typeof(string)) as string;
6467
                    Move_Symbol(sender, dragData);
6468
                }
6469
            }
6470
            catch (Exception ex)
6471
            {
6472
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6473
            }            
6474
        }
6475
        */
6476
    }
6477
}
클립보드 이미지 추가 (최대 크기: 500 MB)