프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 4fcb686a

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

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

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

    
47
            T instance = Activator.CreateInstance<T>();
48

    
49
            foreach (PropertyInfo propInfo in controlProperties)
50
            {
51
                if (propInfo.CanWrite)
52
                {
53
                    if (propInfo.Name != "WindowTarget")
54
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
55
                }
56
            }
57
            return instance;
58
        }
59
    }
60

    
61
    public class MyConsole
62
    {
63
        private readonly System.Threading.ManualResetEvent _readLineSignal;
64
        private string _lastLine;
65

    
66
        public MyConsole()
67
        {
68
            _readLineSignal = new System.Threading.ManualResetEvent(false);
69
            Gui = new TextBox();
70
            Gui.AcceptsReturn = true;
71
            Gui.KeyUp += OnKeyUp;
72
        }
73

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

    
86
        public TextBox Gui { get; private set; }
87

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

    
101
        public void WriteLine(string line)
102
        {
103
            if (!Gui.Dispatcher.CheckAccess())
104
            {
105
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
106
                return;
107
            }
108

    
109
            Gui.Text += line + Environment.NewLine;
110
        }
111
    }
112

    
113
    /// <summary>
114
    /// MainMenu.xaml에 대한 상호 작용 논리
115
    /// </summary>
116
    public partial class MainMenu : UserControl
117
    {
118
        #region 프로퍼티
119

    
120
        public CommentUserInfo currentControl { get; set; }
121
        public ControlType controlType { get; set; }
122
        private Move move = new Move();
123
        private double[] rotateValue = { 0, 90, 180, 270 };
124
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
125
        private static readonly double DragThreshold = 5;
126
        private System.Windows.Input.Cursor cursor { get; set; }
127

    
128
        /// <summary>
129
        ///  문서의 마우스 위치
130
        /// </summary>
131
        public Point CanvasDrawingMouseDownPoint;
132

    
133
        public string filename { get; set; }
134
        private Point canvasZoomPanningMouseDownPoint;
135
        public Point getCurrentPoint;
136
        private Point canvasZoommovingMouseDownPoint;
137
        private List<object> ControlList = new List<object>();
138
        private ListBox listBox = new ListBox();
139
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
140
        private bool isDraggingSelectionRect = false;
141
        private DrawingAttributes inkDA = new DrawingAttributes();
142
        private VPRevision CurrentRev { get; set; }
143
        public RadRibbonButton btnConsolidate { get; set; }
144
        public RadRibbonButton btnFinalPDF { get; set; }
145
        public RadRibbonButton btnTeamConsolidate { get; set; }
146
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
147

    
148
        public string Filename_ { get; set; }
149
        public double L_Size = 0;
150
        public AdornerFinal adorner_;
151
        public Multi_Undo_data multi_Undo_Data;
152
        public string Symbol_ID = "";
153

    
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
        private Stroke stroke;
161
        private Boolean IsDrawing = false;
162
        private StylusPointCollection strokePoints;
163

    
164
        //StylusPointCollection erasePoints;
165
        private RenderTargetBitmap canvasImage;
166

    
167
        private Point Sync_Offset_Point;
168

    
169
        //강인구 테스트
170
        private Path _SelectionPath { get; set; }
171

    
172
        public Path SelectionPath
173
        {
174
            get
175
            {
176
                return _SelectionPath;
177
            }
178
            set
179
            {
180
                if (_SelectionPath != value)
181
                {
182
                    _SelectionPath = value;
183
                    RaisePropertyChanged("SelectionPath");
184
                }
185
            }
186
        }
187

    
188
        private System.Windows.Controls.Image _imageViewer { get; set; }
189

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

    
213
        public bool IsSyncPDFMode { get; set; }
214

    
215
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
216

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

    
240
        #endregion 프로퍼티
241

    
242
        public MainMenu()
243
        {
244
            //App.splashString(ISplashMessage.MAINMENU_0);
245
            InitializeComponent();
246

    
247
            //List<testItem> testItems = new List<testItem>
248
            //{
249
            //    new testItem{Title = "test1"},
250
            //    new testItem{Title = "test2"},
251
            //    new testItem{Title = "test3"},
252
            //    new testItem{Title = "test4"},
253
            //};
254

    
255
            //lstSymbolPrivate.ItemsSource = testItems;
256

    
257
            this.Loaded += MainMenu_Loaded;
258
        }
259

    
260
        public class TempDt
261
        {
262
            public int PageNumber { get; set; }
263
            public string CommentID { get; set; }
264
            public string ConvertData { get; set; }
265
            public int DATA_TYPE { get; set; }
266
            public string MarkupInfoID { get; set; }
267
            public int IsUpdate { get; set; }
268
        }
269

    
270
        private List<TempDt> tempDtList = new List<TempDt>();
271

    
272
        private void SetCursor()
273
        {
274
            this.Cursor = cursor;
275
        }
276

    
277
        /// <summary>
278
        /// get image url
279
        /// </summary>
280
        /// <author>humkyung</author>
281
        /// <param name="sDocumentID"></param>
282
        /// <returns></returns>
283
        public string GetImageURL(string sDocumentID, int iPageNo)
284
        {
285
            string uri = string.Empty;
286

    
287
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
288
            if (userData.COMPANY != "EXT")
289
            {
290
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, iPageNo);
291
            }
292
            else
293
            {
294
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, iPageNo);
295
            }
296

    
297
            return uri;
298
        }
299

    
300
        /// <summary>
301
        /// 외부망에서의 Original PDF Download 를 위한 리소스 web path 경로로 치환
302
        /// </summary>
303
        /// <returns></returns>
304
        public string GetOriginalPDFURL()
305
        {
306
            string uri = string.Empty;
307
            string sDocumentID = this._DocItem.DOCUMENT_ID;
308
            string filename = string.Empty;
309
            if (this._DocInfo.ORIGINAL_FILE.Contains("fileName"))
310
            {
311
                filename = HttpUtility.ParseQueryString(this._DocInfo.ORIGINAL_FILE).Get("fileName");
312
            }
313
            else
314
            {
315
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
316
            }
317

    
318
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
319

    
320
            if (!string.IsNullOrWhiteSpace(directUri))
321
            {
322
                uri = string.Format(directUri, filename);
323
            }
324
            else
325
            {
326
                string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
327
                if (userData.COMPANY != "EXT")
328
                {
329
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
330
                }
331
                else
332
                {
333
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
334
                }
335
                uri = uri.Replace(".png", "");
336
            }
337

    
338
            return uri;
339
        }
340

    
341
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
342
        {
343
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
344
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
345
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
346
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
347
            {
348
                return true;
349
            }
350

    
351
            return false;
352
        }
353

    
354
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
355
        {
356
            if (rotate.Angle == 90 || rotate.Angle == 270)
357
            {
358
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
359
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
360
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
361
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
362
                {
363
                    return true;
364
                }
365
            }
366
            else
367
            {
368
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
369
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
370
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
371
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
372
                {
373
                    return true;
374
                }
375
            }
376

    
377
            return false;
378
        }
379

    
380
        public void DeleteItem(MarkupInfoItem item)
381
        {
382
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
383
            {
384
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
385
            }
386

    
387
            ViewerDataModel.Instance._markupInfoList.Remove(item);
388

    
389
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
390
            {
391
                ViewerDataModel.Instance.MarkupControls.Remove(a);
392
            });
393

    
394
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
395
            {
396
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
397
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
398
                null, Event_Type.Delete, a.CommentID, null);
399
            });
400

    
401
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
402
            {
403
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
404
                //임시파일에서도 삭제
405
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
406
            });
407

    
408
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
409

    
410
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
411
            {
412
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
413
                {
414
                    var infoId = Commons.shortGuid();
415
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
416
                    {
417
                        CreateTime = DateTime.Now,
418
                        Depatment = userData.DEPARTMENT,
419
                        UpdateTime = DateTime.Now,
420
                        DisplayColor = "#FFFF0000",
421
                        UserID = userData.ID,
422
                        UserName = userData.NAME,
423
                        PageCount = 1,
424
                        Description = "",
425
                        MarkupInfoID = infoId,
426
                        MarkupList = null,
427
                        MarkupVersionID = Commons.shortGuid(),
428
                        Consolidate = 0,
429
                        PartConsolidate = 0,
430
                        userDelete = true,
431
                        AvoidConsolidate = 0,
432
                        IsPreviewUser = true
433
                    };
434
                    App.Custom_ViewInfoId = infoId;
435
                }
436
            }
437
            //Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
438
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
439
        }
440

    
441
        /// <summary>
442
        /// delete selected comments
443
        /// </summary>
444
        /// <param name="sender"></param>
445
        /// <param name="e"></param>
446
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
447
        {
448
            //정말 삭제 하시겠습니까?
449
            DialogParameters parameters = new DialogParameters()
450
            {
451
                Owner = Application.Current.MainWindow,
452
                Content = new TextBlock()
453
                {
454
                    MinWidth = 400,
455
                    FontSize = 11,
456
                    Text = "Are you sure you want to delete?",
457
                    TextWrapping = System.Windows.TextWrapping.Wrap
458
                },
459
                Header = "Confirm",
460
                Theme = new VisualStudio2013Theme(),
461
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
462
                OkButtonContent = "Yes",
463
                CancelButtonContent = "No",
464
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
465
                {
466
                    if (wc.DialogResult == true)
467
                    {
468
                        //선택된 어도너가 있을시 삭제가 되지 않음
469
                        SelectionSet.Instance.UnSelect(this);
470

    
471
                        Button content = (sender as Button);
472
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
473

    
474
                        DeleteItem(item);
475
                    }
476
                }
477
            };
478
            RadWindow.Confirm(parameters);
479
        }
480

    
481
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
482

    
483
        private static Timer timer;
484
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
485

    
486
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
487
        {
488
            //InitializeComponent();
489
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
490

    
491
            if (App.ParameterMode)
492
            {
493

    
494
                App.splashString(ISplashMessage.MAINMENU_1);
495
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
496
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
497
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
498

    
499
                imageViewer_Compare = new Image();
500
                ViewerDataModel.Instance.Capture_Opacity = 0;
501
                da.From = 0.8;
502
                da.To = 0;
503
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
504
                da.AutoReverse = true;
505
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
506

    
507
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
508
                {
509
                    this.SymbolPane.Visibility = Visibility.Collapsed;
510
                    this.FavoritePane.Visibility = Visibility.Collapsed;
511
                    this.drawingRotateCanvas.IsHitTestVisible = false;
512
                }
513
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
514
            }
515

    
516
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
517
        }
518

    
519
        private void DownloadOriginalFile()
520
        {
521
            #region 임시파일 다운로드
522
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
523
       
524
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
525
            bool isRestDownload = false;
526

    
527
            if (!string.IsNullOrWhiteSpace(directUri))
528
            {
529
                isRestDownload = true;
530
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
531

    
532
                downloadurl = string.Format(directUri, filename);
533
             }
534
            else
535
            {
536
                downloadurl = GetOriginalPDFURL();
537
            }
538

    
539
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
540
            
541
            string endpoint = Common.Commons.shortGuid() + "file";
542
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
543
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
544
            wcfServer.Start();
545
            
546
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
547
            #endregion
548
        }
549

    
550
        string instnaceFile;
551
        string downloadurl;
552

    
553
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
554
        {
555
            Dispatcher.BeginInvoke((Action)delegate () { ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress; });
556

    
557
            if (e.IsFinish)
558
            {
559
                ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
560
                ViewerDataModel.Instance.IsDownloadOriginal = true;
561
           
562
            }
563
        }
564

    
565
        private void timercallback(Object o)
566
        {
567
            Stopwatch sw = new Stopwatch();
568
            sw.Start();
569
            TempFile.TempFileAdd();
570
            sw.Stop();
571

    
572
            Dispatcher.InvokeAsync(new Action(delegate
573
            {
574
                if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
575
                {
576
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
577
                }
578
            }));
579

    
580
            ////GC.Collect();
581
        }
582

    
583
        /// <summary>
584
        /// update my markuplist
585
        ///  - update existing markup data if already exist
586
        ///  - add new markup data if control is new
587
        /// </summary>
588
        public void UpdateMyMarkupList()
589
        {
590
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
591

    
592
            /// add or update markup list
593
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
594
            {
595
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
596

    
597
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
598
                if (exist != null) //신규 추가 된 코멘트
599
                {
600
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
601
                    {
602
                        exist.Data = root.ConvertData;
603
                        exist.IsUpdate = true;
604
                    }
605
                }
606
                else if (root.CommentID != null)
607
                {
608
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
609
                    {
610
                        ID = control.CommentID,
611
                        Data = root.ConvertData,
612
                        Data_Type = root.DATA_TYPE,
613
                        MarkupInfoID = App.Custom_ViewInfoId,
614
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
615
                        Symbol_ID = control.SymbolID,
616
                        //Group_ID = control.GroupID,
617
                    });
618
                }
619
            }
620

    
621
            //if (this.pageNavigator.CurrentPage != null)
622
            //{
623
            //    /// delete markup list
624
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
625

    
626
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
627
            //                   where (markup.PageNumber == iPageNo)
628
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
629
            //                   select markup).ToList();
630

    
631
            //    foreach (var markup in deleted)
632
            //    {
633
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
634
            //    }
635
            //}
636
            //else
637
            //{
638
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
639
            //}
640

    
641
            /// up to here
642

    
643
            //if (modified)
644
            //{
645
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
646
            //    {
647
            //        ComingNewBieEnd = true;
648
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
649
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
650
            //        gridViewMarkup.ItemsSource = null;
651
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
652
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
653

    
654
            //        GroupDescriptor descriptor = new GroupDescriptor();
655
            //        descriptor.Member = "Depatment";
656
            //        descriptor.DisplayContent = "DEPT";
657
            //        descriptor.SortDirection = ListSortDirection.Ascending;
658
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
659
            //    }
660
            //}
661
        }
662

    
663
        /// <summary>
664
        /// start page changing
665
        ///  - save controls if page is modified
666
        ///  - starting download page image
667
        /// </summary>
668
        /// <param name="sender"></param>
669
        /// <param name="e"></param>
670
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
671
        {
672
            //await Task.Delay(10);
673

    
674
            // 마크업 로드
675
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
676

    
677
            ViewerDataModel.Instance.PageAngle = e.CurrentPage.PAGE_ANGLE;
678

    
679
            var token = ViewerDataModel.Instance.NewCancellationToken();
680
            
681
            await MarkupLoadAsync(e.PageNumber, ViewerDataModel.Instance.PageAngle, token);
682

    
683
            // 페이지 이미지 변경
684
            await PageChangingAsync(e.CurrentPage, e.PageNumber, token);
685
        }
686

    
687
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
688
        {
689
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
690

    
691
            #region 페이지가 벗어난 경우
692

    
693
            if (BalancePoint < 1)
694
            {
695
                BalancePoint = 1;
696
                ViewerDataModel.Instance.PageBalanceNumber = 0;
697
            }
698

    
699
            if (pageNavigator.PageCount < BalancePoint)
700
            {
701
                BalancePoint = pageNavigator.PageCount;
702
                ViewerDataModel.Instance.PageBalanceNumber = 0;
703
            }
704

    
705
            #endregion 페이지가 벗어난 경우
706

    
707
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
708

    
709
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
710
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
711
            var contentScale = zoomAndPanControl.ContentScale;
712

    
713
            #region 페이지 이미지 로딩 수정
714

    
715
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
716

    
717
            ScaleImage(pageWidth, pageHeight);
718

    
719
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
720
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
721

    
722
            zoomAndPanCanvas.Width = pageWidth;
723
            zoomAndPanCanvas.Height = pageHeight;
724

    
725
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
726
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
727

    
728
            inkBoard.Width = pageWidth;
729
            inkBoard.Height = pageHeight;
730

    
731
            #endregion 페이지 이미지 로딩 수정
732

    
733
            if (!testPanel2.IsHidden)
734
            {
735
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
736
                //PDF모드일때 잠시 대기(강인구)
737
                if (IsSyncPDFMode)
738
                {
739
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
740
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
741

    
742
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
743
                    if (pdfpath.IsDownloading)
744
                    {
745
                        pdfpath.DownloadCompleted += (ex, arg) =>
746
                        {
747
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
748
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
749
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
750
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
751
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
752
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
753
                        };
754
                    }
755
                    else
756
                    {
757
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
758
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
759
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
760
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
761

    
762
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
763
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
764
                    }
765
                }
766
                else
767
                {
768
                    Logger.sendCheckLog("Compare Image Download", 1);
769
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
770
                    ComparePageLoad(compareImageUri,false);
771
                }
772

    
773
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
774
            }
775

    
776
            SearchFocusBorder.Visibility = Visibility.Collapsed;
777

    
778
            this.pageNavigator.ChangePage(changePageNumber);
779
        }
780

    
781
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
782
        {
783
            /// 현재 보고 있는 VP와 같은 크기로 로딩
784
            ViewerDataModel.Instance.ImageViewPath_C = null;
785

    
786
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
787
            {
788
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
789
            }
790
            else
791
            {
792
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
793
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
794
            }
795

    
796
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
797
            {
798
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
799
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
800
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
801
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
802

    
803
                zoomAndPanControl.ZoomTo(new Rect
804
                {
805
                    X = 0,
806
                    Y = 0,
807
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
808
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
809
                });
810

    
811
                if (Sync.IsChecked)
812
                {
813
                    Sync_Click(null, new RoutedEventArgs());
814
                }
815

    
816
                if (CompareMode.IsChecked)
817
                {
818
                    SyncCompare_Click(null, new RoutedEventArgs());
819
                }
820
            }
821
        }
822

    
823
        /// <summary>
824
        /// called after page is changed
825
        /// </summary>
826
        /// <param name="sender"></param>
827
        /// <param name="e"></param>
828
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
829
        {
830
            //if (zoomAndPanCanvas.Width.IsNaN())
831
            //{
832
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
833
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
834
            //    );
835
            //}
836

    
837
            var instanceMain = ViewerDataModel.Instance.SystemMain;
838

    
839
            instanceMain.dzMainMenu.CanvasDrawingMouseDownPoint = new Point(ViewerDataModel.Instance.ImageViewWidth / 2, ViewerDataModel.Instance.ImageViewHeight / 2);
840

    
841
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
842
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
843

    
844
            instanceMain.dzTopMenu.rotateOffSet = 0;
845
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
846
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
847

    
848
            /// 페이지의 모든 마크업을 로드한 후 호출
849
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
850
            ViewerDataModel.Instance.LoadPageMarkupFinish(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
851

    
852
            //Point startPoint = new Point(15, 15);
853

    
854
            //var markupinfo = ViewerDataModel.Instance._markupInfoList.Where(x => x.UserID == App.ViewInfo.UserID).First();
855

    
856
            ////var rect = GetRectControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
857

    
858
            ////var txtApproved = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID,
859
            ////                             "APPROVED",30, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, 15);
860

    
861
            ////var txtCreator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
862
            ////                , "By HYOSUNG", 18, FontWeights.Bold, TextAlignment.Center, rect.ItemRect, txtApproved.StartPoint.Y + txtApproved.BoxHeight + 3);
863

    
864
            //var symCtrl = GetSymNControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID, startPoint);
865

    
866
            //var bottom = Rect.Offset(symCtrl.ItemRect, new Vector(0, symCtrl.ItemRect.Height));
867

    
868
            //var txtOriginator = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
869
            //               , App.ViewInfo.UserID, 18, FontWeights.Bold, TextAlignment.Left, bottom, bottom.Top + 3);
870

    
871
            //var dtfi = new System.Globalization.DateTimeFormatInfo { DateSeparator = "-", ShortDatePattern = @"yyyy/MM/dd" };
872

    
873
            //var txtDate = GetTextControl(Convert.ToDouble(pageinfo.PAGE_WIDTH), Convert.ToDouble(pageinfo.PAGE_HEIGHT), markupinfo.UserID, markupinfo.MarkupInfoID
874
            //               , DateTime.Now.ToString("d", dtfi), 18, FontWeights.Bold, TextAlignment.Left, bottom, txtOriginator.StartPoint.Y + txtOriginator.BoxHeight + 2);
875

    
876
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
877
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
878
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
879
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
880
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
881

    
882
            //symCtrl.ApplyTemplate();
883
            ////txtApproved.ApplyTemplate();
884
            ////txtCreator.ApplyTemplate();
885
            //txtOriginator.ApplyTemplate();
886
            //txtDate.ApplyTemplate();
887

    
888
            ////SetTextControl(txtApproved);
889
            ////SetTextControl(txtCreator);
890
            //SetTextControl(txtOriginator);
891
            //SetTextControl(txtDate);
892

    
893
            //multi_Undo_Data = new Multi_Undo_data();
894

    
895
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
896
            //{
897
            //    IsUndo = false,
898
            //    Event = Event_Type.Create,
899
            //    EventTime = DateTime.Now,
900
            //    Markup_List = new List<Multi_Undo_data>()
901
            //};
902

    
903
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
904
            //UndoData.Markup_List.Add(multi_Undo_Data);
905

    
906
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
907
            ////UndoData.Markup_List.Add(multi_Undo_Data);
908

    
909
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
910
            ////UndoData.Markup_List.Add(multi_Undo_Data);
911

    
912
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
913
            //UndoData.Markup_List.Add(multi_Undo_Data);
914

    
915
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
916
            //UndoData.Markup_List.Add(multi_Undo_Data);
917

    
918
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
919

    
920
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
921
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
922
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
923
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
924
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
925
        }
926

    
927
        private void SetTextControl(TextControl textControl)
928
        {
929
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
930
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
931
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
932
        }
933

    
934
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
935
        {
936
            SymControlN result = null;
937

    
938
            try
939
            {
940
                double height = 80;
941
                double itemWidth = 180;
942

    
943
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
944
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
945
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
946
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
947

    
948
                result = new SymControlN
949
                {
950
                    CommentID = Commons.shortGuid(),
951
                    MarkupInfoID = markupInfoId,
952
                    UserID = userId,
953
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
954
                    StartPoint = startPoint,
955
                    EndPoint = endPoint,
956
                    CommentAngle = 0,
957
                    LeftBottomPoint = leftBottomPoint,
958
                    TopRightPoint = topRightPoint,
959
                    Opacity = 1,
960
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
961
                    Memo = null
962
                };
963
            }
964
            catch (Exception ex)
965
            {
966
                System.Diagnostics.Debug.WriteLine(ex.ToString());
967
            }
968

    
969
            return result;
970
        }
971

    
972
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
973
        {
974
            RectangleControl result = null;
975

    
976
            try
977
            {
978
                double height = 80;
979
                double itemWidth = 180;
980

    
981
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
982
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
983
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
984
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
985

    
986
                result = new RectangleControl
987
                {
988
                    CommentID = Commons.shortGuid(),
989
                    MarkupInfoID = markupInfoId,
990
                    LineSize = 5,
991
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
992
                    StartPoint = startPoint,
993
                    EndPoint = endPoint,
994
                    CommentAngle = 0,
995
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
996
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
997
                    FillColor = null,
998
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
999
                    Opacity = 1,
1000
                    LeftBottomPoint = leftBottomPoint,
1001
                    TopRightPoint = topRightPoint,
1002
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1003
                    UserID = userId,
1004
                    Memo = null
1005
                };
1006
            }
1007
            catch (Exception ex)
1008
            {
1009
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1010
            }
1011

    
1012
            return result;
1013
        }
1014

    
1015
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1016
        {
1017
            TextControl result = null;
1018

    
1019
            try
1020
            {
1021
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1022

    
1023
                double startPositionX = parentRect.X;
1024

    
1025
                switch (textAlignment)
1026
                {
1027
                    case TextAlignment.Right:
1028
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1029
                        break;
1030

    
1031
                    case TextAlignment.Center:
1032
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1033
                        break;
1034
                }
1035

    
1036
                Point startPosition = new Point
1037
                {
1038
                    X = startPositionX,
1039
                    Y = positionY
1040
                };
1041

    
1042
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1043
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1044
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1045
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1046

    
1047
                result = new TextControl
1048
                {
1049
                    CommentID = Commons.shortGuid(),
1050
                    MarkupInfoID = markupInfoId,
1051
                    Text = Text,
1052
                    StartPoint = startPoint,
1053
                    EndPoint = endPoint,
1054
                    CanvasX = startPosition.X,
1055
                    CanvasY = startPosition.Y,
1056
                    BoxWidth = txtSize.Width,
1057
                    BoxHeight = txtSize.Height,
1058
                    ControlType_No = 0,
1059
                    LineSize = new Thickness(5),
1060
                    TextSize = fontSize,
1061
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1062
                    FontSize = 10,
1063
                    UserID = userId,
1064
                    IsHighLight = false,
1065
                    CommentAngle = 0,
1066
                    PointSet = new List<Point>(),
1067
                    Opacity = 1,
1068
                    IsSelected = false,
1069
                    TextFamily = new FontFamily("Tahoma"),
1070
                    TextStyle = FontStyles.Normal,
1071
                    TextWeight = FontWeights.Bold
1072
                };
1073
            }
1074
            catch (Exception ex)
1075
            {
1076
            }
1077

    
1078
            return result;
1079
        }
1080

    
1081
        public static Size ShapeMeasure(UIElement e)
1082
        {
1083
            // Measured Size is bounded to be less than maxSize
1084
            Size maxSize = new Size(
1085
                 double.PositiveInfinity,
1086
                 double.PositiveInfinity);
1087
            e.Measure(maxSize);
1088
            return e.DesiredSize;
1089
        }
1090

    
1091
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1092
        {
1093
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1094
            stopwatch.Start();
1095

    
1096
            /// 컨트롤을 새로 생성한다.
1097
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1098
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1099

    
1100
            System.Diagnostics.Debug.WriteLine("MarkupLoad - Clear " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1101

    
1102
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1103
            {
1104
                if (cts.IsCancellationRequested)
1105
                {
1106
                    return;
1107
                }
1108

    
1109
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1110
                if (info != null)
1111
                {
1112
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1113
                    if (info.UserID == App.ViewInfo.UserID)
1114
                    {
1115
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1116
                                        markup.MarkupInfoID, markup.ID);
1117
                        control.Visibility = Visibility.Hidden;
1118
                    }
1119
                    else
1120
                    {
1121
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1122
                                                                markup.MarkupInfoID, markup.ID);
1123
                        control.Visibility = Visibility.Hidden;
1124
                    }
1125
                }
1126
            };
1127
            /// up to here
1128

    
1129
            System.Diagnostics.Debug.WriteLine("MarkupLoad - MarkupParser " + new TimeSpan(stopwatch.ElapsedTicks).ToString());
1130

    
1131
            /// fire selection event
1132
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1133
            this.gridViewMarkup.UnselectAll();
1134
            this.gridViewMarkup.Select(gridSelectionItem);
1135

    
1136
            if (!testPanel2.IsHidden)
1137
            {
1138
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1139
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1140
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1141

    
1142
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1143
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1144

    
1145
                foreach (var item in gridSelectionRevItem)
1146
                {
1147
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1148

    
1149
                    foreach (var markupitem in markupitems)
1150
                    {
1151
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1152

    
1153
                        if (cts.IsCancellationRequested)
1154
                        {
1155
                            return;
1156
                        }
1157
                    }
1158
                }
1159
            }
1160

    
1161
            SetCommentPages(cts);
1162
        }
1163

    
1164
        public void SetCommentPages(CancellationToken? cts)
1165
        {
1166
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1167
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1168
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1169
            {
1170
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1171
                if (item.MarkupList != null)
1172
                {
1173
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1174
                    instance.UserName = item.UserName;
1175
                    instance.Depart = item.Depatment;
1176
                    instance.MarkupInfoID = item.MarkupInfoID;
1177
                    instance.IsSelected = true;
1178
                    instance.isConSolidation = item.Consolidate;
1179
                    instance.SetColor = item.DisplayColor;
1180
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1181
                    {
1182
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1183
                    }
1184
                    else
1185
                    {
1186
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1187
                    }
1188
                    _pages.Add(instance);
1189
                }
1190

    
1191
                if (cts != null)
1192
                {
1193
                    if (cts.Value.IsCancellationRequested)
1194
                        return;
1195
                }
1196
            }
1197

    
1198
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1199
        }
1200

    
1201
        public void MarkupitemViewUpdate(string markupinfo_id)
1202
        {
1203
            //db에 업데이트 한 list 를 view 에 업데이트
1204
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1205
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1206
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1207
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1208
            if (dbinfo.MarkupList.Count > 0)
1209
            {
1210
                if (viewinfo.MarkupList != null)
1211
                {
1212
                    viewinfo.MarkupList.Clear();
1213
                    viewinfo.MarkupList = null;
1214
                }
1215
                viewinfo.MarkupList = new List<MarkupItem>();
1216
                foreach (var item in dbinfo.MarkupList)
1217
                {
1218
                    viewinfo.MarkupList.Add(item);
1219
                }
1220
            }
1221
        }
1222

    
1223
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1224
        {
1225
            var instance = ViewerDataModel.Instance;
1226

    
1227
            if (instance.IsWheelPageChanage)
1228
            {
1229
                return;
1230
            }
1231

    
1232
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1233
            {
1234
                int changePage = 0;
1235

    
1236
                if (e.Delta > 0)
1237
                {
1238
                    if (0 < instance.ContentOffsetY)
1239
                    {
1240
                        Vector dragOffset = new Vector(0, e.Delta);
1241
                        MoveZoomAndPanControl(dragOffset);
1242
                    }
1243
                    //else
1244
                    //{
1245
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1246
                    //    {
1247
                    //        instance.IsWheelPageChanage = true;
1248
                    //        changePage -= 1;
1249
                    //    }
1250
                    //}
1251
                }
1252
                else if (e.Delta < 0)
1253
                {
1254
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1255
                    {
1256
                        Vector dragOffset = new Vector(0, e.Delta);
1257
                        MoveZoomAndPanControl(dragOffset);
1258
                    }
1259
                    //else
1260
                    //{
1261
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1262
                    //    {
1263
                    //        instance.IsWheelPageChanage = true;
1264
                    //        changePage += 1;
1265
                    //    }
1266
                    //}
1267
                }
1268

    
1269
                //if (changePage != 0)
1270
                //{
1271
                //    await Task.Factory.StartNew(() =>
1272
                //    {
1273
                //        double beforeScale = instance.ContentScale;
1274

    
1275
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1276

    
1277
                //        handler = (snd, evt) =>
1278
                //        {
1279
                //            /// 최상단으로 이전 zoomScale로 위치한다
1280
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1281
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1282
                //            instance.IsWheelPageChanage = false;
1283
                //            pageNavigator.PageChanged -= handler;
1284
                //        };
1285

    
1286
                //        pageNavigator.PageChanged += handler;
1287

    
1288
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1289
                //    });
1290

    
1291
                //}
1292
            }
1293
            else
1294
            {
1295
                e.Handled = true;
1296
                if (e.Delta > 0)
1297
                {
1298
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1299
                    ZoomIn(currentContentMousePoint);
1300
                }
1301
                else
1302
                {
1303
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1304
                    ZoomOut(currentContentMousePoint);
1305
                }
1306
            }
1307
        }
1308

    
1309
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1310
        {
1311
            e.Handled = true;
1312
            if (e.Delta > 0)
1313
            {
1314
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1315
                ZoomIn_Sync(currentContentMousePoint);
1316
            }
1317
            else
1318
            {
1319
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1320
                ZoomOut_Sync(currentContentMousePoint);
1321
            }
1322
        }
1323

    
1324
        #region ZoomIn & ZoomOut
1325

    
1326
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1327
        {
1328
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1329
                zoomAndPanControl.ContentZoomFocusY));
1330
        }
1331

    
1332
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1333
        {
1334
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1335
                zoomAndPanControl.ContentZoomFocusY));
1336
        }
1337

    
1338
        //강인구 추가 (줌 인아웃 수치 변경)
1339
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1340
        private void ZoomOut(Point contentZoomCenter)
1341
        {
1342
            if (zoomAndPanControl.ContentScale > 0.39)
1343
            {
1344
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1345
            }
1346
            else
1347
            {
1348
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1349
            }
1350

    
1351
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1352
            {
1353
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1354
            }
1355
        }
1356

    
1357
        private void ZoomIn(Point contentZoomCenter)
1358
        {
1359
            if (zoomAndPanControl.ContentScale > 0.19)
1360
            {
1361
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1362
            }
1363
            else
1364
            {
1365
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1366
            }
1367

    
1368
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1369
            {
1370
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1371
            }
1372
        }
1373

    
1374
        private void ZoomOut_Sync(Point contentZoomCenter)
1375
        {
1376
            if (zoomAndPanControl2.ContentScale > 0.39)
1377
            {
1378
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1379
            }
1380
            else
1381
            {
1382
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1383
            }
1384

    
1385
            if (Sync.IsChecked)
1386
            {
1387
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1388
            }
1389
        }
1390

    
1391
        private void ZoomIn_Sync(Point contentZoomCenter)
1392
        {
1393
            if (zoomAndPanControl2.ContentScale > 0.19)
1394
            {
1395
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1396
            }
1397
            else
1398
            {
1399
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1400
            }
1401

    
1402
            if (Sync.IsChecked)
1403
            {
1404
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1405
            }
1406
        }
1407

    
1408
        private void ZoomOut()
1409
        {
1410
            zoomAndPanControl.ContentScale -= 0.1;
1411
            //if (zoomAndPanControl2 != null)
1412
            //{
1413
            //    zoomAndPanControl2.ContentScale -= 0.1;
1414
            //}
1415
        }
1416

    
1417
        private void ZoomIn()
1418
        {
1419
            zoomAndPanControl.ContentScale += 0.1;
1420
            //if (zoomAndPanControl2 != null)
1421
            //{
1422
            //    zoomAndPanControl2.ContentScale += 0.1;
1423
            //}
1424
        }
1425

    
1426
        #endregion ZoomIn & ZoomOut
1427

    
1428
        private void init()
1429
        {
1430
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1431
            {
1432
                ControlList.Clear();
1433
                listBox.Items.Clear();
1434
                selected_item.Clear();
1435

    
1436
                (item as IMarkupCommonData).IsSelected = false;
1437
            }
1438
        }
1439

    
1440
        private HitTestResultBehavior MyCallback(HitTestResult result)
1441
        {
1442
            //this.cursor = Cursors.UpArrow;
1443
            var element = result.VisualHit;
1444
            while (element != null && !(element is CommentUserInfo))
1445
                element = VisualTreeHelper.GetParent(element);
1446

    
1447
            if (element == null)
1448
            {
1449
                return HitTestResultBehavior.Stop;
1450
            }
1451
            else
1452
            {
1453
                if (element is CommentUserInfo)
1454
                {
1455
                    if (!hitList.Contains(element))
1456
                    {
1457
                        hitList.Add((CommentUserInfo)element);
1458
                    }
1459
                    else
1460
                    {
1461
                        return HitTestResultBehavior.Stop;
1462
                    }
1463
                }
1464
            }
1465
            return HitTestResultBehavior.Continue;
1466
        }
1467

    
1468
        public void ReleaseSelectPath()
1469
        {
1470
            if (SelectionPath == null)
1471
            {
1472
                SelectionPath = new Path();
1473
                SelectionPath.Name = "";
1474
            }
1475
            if (SelectionPath.Name != "")
1476
            {
1477
                SelectionPath.Name = "None";
1478
            }
1479
            SelectionPath.Opacity = 0.01;
1480
            SelectionPath.RenderTransform = null;
1481
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1482
        }
1483

    
1484
        #region 컨트롤 초기화
1485

    
1486
        public void Control_Init(object control)
1487
        {
1488
            if (L_Size != 0 && (control as IPath) != null)
1489
            {
1490
                (control as IPath).LineSize = L_Size;
1491
                L_Size = 0;
1492
            }
1493

    
1494
            switch (control.GetType().Name)
1495
            {
1496
                case "RectangleControl":
1497
                    {
1498
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1499
                    }
1500
                    break;
1501

    
1502
                case "CircleControl":
1503
                    {
1504
                        (control as CircleControl).StrokeColor = Brushes.Red;
1505
                    }
1506
                    break;
1507

    
1508
                case "TriControl":
1509
                    {
1510
                        (control as TriControl).StrokeColor = Brushes.Red;
1511
                    }
1512
                    break;
1513

    
1514
                case "RectCloudControl":
1515
                    {
1516
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1517
                    }
1518
                    break;
1519

    
1520
                case "CloudControl":
1521
                    {
1522
                        (control as CloudControl).StrokeColor = Brushes.Red;
1523
                    }
1524
                    break;
1525

    
1526
                case "PolygonControl":
1527
                    {
1528
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1529
                    }
1530
                    break;
1531

    
1532
                case "ArcControl":
1533
                    {
1534
                        (control as ArcControl).StrokeColor = Brushes.Red;
1535
                    }
1536
                    break;
1537

    
1538
                case "ArrowArcControl":
1539
                    {
1540
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1541
                    }
1542
                    break;
1543

    
1544
                case "LineControl":
1545
                    {
1546
                        (control as LineControl).StrokeColor = Brushes.Red;
1547
                    }
1548
                    break;
1549

    
1550
                case "ArrowControl_Multi":
1551
                    {
1552
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1553
                    }
1554
                    break;
1555

    
1556
                case "TextControl":
1557
                    {
1558
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1559
                    }
1560
                    break;
1561

    
1562
                case "ArrowTextControl":
1563
                    {
1564
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1565
                    }
1566
                    break;
1567

    
1568
                case "InsideWhiteControl":
1569
                    {
1570
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1571
                    }
1572
                    break;
1573

    
1574
                case "OverlapWhiteControl":
1575
                    {
1576
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1577
                    }
1578
                    break;
1579

    
1580
                case "ClipWhiteControl":
1581
                    {
1582
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1583
                    }
1584
                    break;
1585

    
1586
                case "CoordinateControl":
1587
                    {
1588
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1589
                    }
1590
                    break;
1591
            }
1592
        }
1593

    
1594
        #endregion 컨트롤 초기화
1595

    
1596
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1597
        {
1598
            //Control_Init(e.Source);
1599
        }
1600

    
1601
        //private Window _dragdropWindow = null;
1602

    
1603
        [DllImport("user32.dll")]
1604
        [return: MarshalAs(UnmanagedType.Bool)]
1605
        internal static extern bool GetCursorPos(ref Win32Point pt);
1606

    
1607
        [StructLayout(LayoutKind.Sequential)]
1608
        internal struct Win32Point
1609
        {
1610
            public Int32 X;
1611
            public Int32 Y;
1612
        };
1613

    
1614
        /*
1615
       public string symbol_id = null;
1616
       public long symbol_group_id;
1617
       public int symbol_SelectedIndex;
1618
       public ImageSource symbol_img;
1619
       public string symbol_Data = null;
1620
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1621
       {
1622
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1623
               zoomAndPanCanvas.ActualHeight / 2));
1624

    
1625
               if (this._dragdropWindow != null)
1626
               {
1627
                   this._dragdropWindow.Close();
1628
                   this._dragdropWindow = null;
1629
               }
1630

    
1631
               symbol_id = id;
1632
               symbol_group_id = group_id;
1633
               symbol_SelectedIndex = SelectedIndex;
1634
               symbol_Data = Data_;
1635
               symbol_img = img;
1636

    
1637
               CreateDragDropWindow2(img);
1638
    }
1639

    
1640
    private void CreateDragDropWindow2(ImageSource image)
1641
        {
1642
            this._dragdropWindow = new Window();
1643
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1644
            _dragdropWindow.WindowStyle = WindowStyle.None;
1645
            _dragdropWindow.AllowsTransparency = true;
1646
            _dragdropWindow.AllowDrop = false;
1647
            _dragdropWindow.Background = null;
1648
            _dragdropWindow.IsHitTestVisible = false;
1649
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1650
            _dragdropWindow.Topmost = true;
1651
            _dragdropWindow.ShowInTaskbar = false;
1652

    
1653
            Rectangle r = new Rectangle();
1654
            r.Width = image.Width;
1655
            r.Height = image.Height;
1656
            r.Opacity = 0.5;
1657
            r.Fill = new ImageBrush(image);
1658
            this._dragdropWindow.Content = r;
1659

    
1660
            Win32Point w32Mouse = new Win32Point();
1661
            GetCursorPos(ref w32Mouse);
1662

    
1663
            //w32Mouse.X = getCurrentPoint.X;
1664
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1665
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1666
            this._dragdropWindow.Show();
1667
        }
1668

    
1669
         */
1670

    
1671
        public void MoveZoomAndPanControl(Vector dragOffset)
1672
        {
1673
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1674
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1675

    
1676
            if (Sync.IsChecked)
1677
            {
1678
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1679
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1680
            }
1681
        }
1682

    
1683
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1684
        {
1685
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1686
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1687
            //if(this.txtBatch.Visibility == Visibility.Visible)
1688
            {
1689
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1690

    
1691
                Point currentPos = e.GetPosition(rect);
1692

    
1693
                floatingTip.HorizontalOffset = currentPos.X + 20;
1694
                floatingTip.VerticalOffset = currentPos.Y;
1695
            }
1696

    
1697
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1698

    
1699
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1700
            {
1701
                SetCursor();
1702
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1703
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1704

    
1705
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1706

    
1707
                MoveZoomAndPanControl(dragOffset);
1708
            }
1709

    
1710
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1711
            {
1712
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1713
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1714
                SetCursor();
1715

    
1716
                if (currentControl != null)
1717
                {
1718
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1719
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1720
                    //강인구 추가
1721
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1722

    
1723
                    if ((currentControl as IPath) != null)
1724
                    {
1725
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1726
                    }
1727
                    if ((currentControl as LineControl) != null)
1728
                    {
1729
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1730
                    }
1731

    
1732
                    if ((currentControl as IShapeControl) != null)
1733
                    {
1734
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1735
                    }
1736
                    if ((currentControl as TextControl) != null)
1737
                    {
1738
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1739
                        {
1740
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1741
                        }
1742
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1743
                        {
1744
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1745
                        }
1746
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1747
                        {
1748
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1749
                        }
1750
                    }
1751
                    else if ((currentControl as ArrowTextControl) != null)
1752
                    {
1753
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1754
                        {
1755
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1756
                        }
1757
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1758
                        {
1759
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1760
                        }
1761
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1762
                        {
1763
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1764
                        }
1765
                    }
1766
                    else if ((currentControl as RectCloudControl) != null)
1767
                    {
1768
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1769
                    }
1770
                    else if ((currentControl as CloudControl) != null)
1771
                    {
1772
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1773
                    }
1774

    
1775
                    #region // 모든 컨트롤의 공통기능 제어
1776

    
1777
                    if (controlType != ControlType.PenControl)
1778
                    {
1779
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1780
                    }
1781

    
1782
                    #endregion // 모든 컨트롤의 공통기능 제어
1783

    
1784
                    #region // 각 컨트롤의 특별한 기능을 제어한다.
1785

    
1786
                    switch (controlType)
1787
                    {
1788
                        case (ControlType.Coordinate):
1789
                            {
1790
                                var control = currentControl as CoordinateControl;
1791
                                if (control != null)
1792
                                {
1793
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1794
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1795
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1796
                                }
1797
                            }
1798
                            break;
1799

    
1800
                        case (ControlType.InsideWhite):
1801
                            {
1802
                                var control = currentControl as InsideWhiteControl;
1803
                                if (control != null)
1804
                                {
1805
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1806
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1807
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1808
                                    control.Paint = PaintSet.Fill;
1809
                                }
1810
                            }
1811
                            break;
1812

    
1813
                        case ControlType.OverlapWhite:
1814
                            {
1815
                                var control = currentControl as OverlapWhiteControl;
1816
                                if (control != null)
1817
                                {
1818
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1819
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1820
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1821
                                    control.Paint = PaintSet.Fill;
1822
                                }
1823
                            }
1824
                            break;
1825

    
1826
                        case ControlType.ClipWhite:
1827
                            {
1828
                                var control = currentControl as ClipWhiteControl;
1829
                                if (control != null)
1830
                                {
1831
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1832
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1833
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1834
                                    control.Paint = PaintSet.Fill;
1835
                                }
1836
                            }
1837
                            break;
1838

    
1839
                        case ControlType.RectCloud:
1840
                            {
1841
                                var control = currentControl as RectCloudControl;
1842
                                if (control != null)
1843
                                {
1844
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1845
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1846
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1847
                                }
1848
                            }
1849
                            break;
1850

    
1851
                        case ControlType.SingleLine:
1852
                        case ControlType.CancelLine:
1853
                        case ControlType.ArrowLine:
1854
                        case ControlType.TwinLine:
1855
                        case ControlType.DimLine:
1856
                            {
1857
                                var control = currentControl as LineControl;
1858
                                if (control != null)
1859
                                {
1860
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1861
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1862
                                }
1863
                            }
1864
                            break;
1865

    
1866
                        case ControlType.ArcLine:
1867
                            {
1868
                                var control = currentControl as ArcControl;
1869
                                if (control != null)
1870
                                {
1871
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1872
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1873
                                }
1874
                            }
1875
                            break;
1876

    
1877
                        case ControlType.ArcArrow:
1878
                            {
1879
                                var control = currentControl as ArrowArcControl;
1880
                                if (control != null)
1881
                                {
1882
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1883
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1884
                                }
1885
                            }
1886
                            break;
1887

    
1888
                        case ControlType.ArrowMultiLine:
1889
                            {
1890
                                var control = currentControl as ArrowControl_Multi;
1891
                                if (control != null)
1892
                                {
1893
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1894
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1895
                                }
1896
                            }
1897
                            break;
1898

    
1899
                        case ControlType.Circle:
1900
                            {
1901
                                var control = currentControl as CircleControl;
1902

    
1903
                                if (control != null)
1904
                                {
1905
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1906
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1907
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1908
                                }
1909
                            }
1910
                            break;
1911

    
1912
                        case ControlType.PolygonCloud:
1913
                            {
1914
                                var control = currentControl as CloudControl;
1915
                                if (control != null)
1916
                                {
1917
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
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
                                if (control != null)
1928
                                {
1929
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1930
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1931
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1932
                                }
1933
                            }
1934
                            break;
1935

    
1936
                        case ControlType.ImgControl:
1937
                            {
1938
                                var control = currentControl as ImgControl;
1939
                                if (control != null)
1940
                                {
1941
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1942
                                }
1943
                            }
1944
                            break;
1945

    
1946
                        case ControlType.Date:
1947
                            {
1948
                                var control = currentControl as DateControl;
1949
                                if (control != null)
1950
                                {
1951
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1952
                                }
1953
                            }
1954
                            break;
1955

    
1956
                        case ControlType.ArrowTextControl:
1957
                        case ControlType.ArrowTransTextControl:
1958
                        case ControlType.ArrowTextBorderControl:
1959
                        case ControlType.ArrowTransTextBorderControl:
1960
                        case ControlType.ArrowTextCloudControl:
1961
                        case ControlType.ArrowTransTextCloudControl:
1962
                            {
1963
                                var control = currentControl as ArrowTextControl;
1964
                                if (control != null)
1965
                                {
1966
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1967
                                }
1968
                            }
1969
                            break;
1970

    
1971
                        case ControlType.PolygonControl:
1972
                        case ControlType.ChainLine:
1973
                            {
1974
                                var control = currentControl as PolygonControl;
1975
                                if (control != null)
1976
                                {
1977
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1978
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1979
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1980
                                }
1981
                            }
1982
                            break;
1983

    
1984
                        case ControlType.Sign:
1985
                            {
1986
                                var control = currentControl as SignControl;
1987
                                if (control != null)
1988
                                {
1989
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1990
                                }
1991
                            }
1992
                            break;
1993

    
1994
                        case ControlType.Symbol:
1995
                            {
1996
                                var control = currentControl as SymControl;
1997
                                if (control != null)
1998
                                {
1999
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2000
                                }
2001
                            }
2002
                            break;
2003

    
2004
                        case ControlType.Stamp:
2005
                            {
2006
                                var control = currentControl as SymControlN;
2007
                                if (control != null)
2008
                                {
2009
                                    if (control.STAMP != null)
2010
                                    {
2011
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2012
                                    }
2013
                                    else
2014
                                    {
2015
                                        currentControl = null;
2016
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2017
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2018
                                    }
2019
                                }
2020
                            }
2021
                            break;
2022

    
2023
                        case ControlType.Rectangle:
2024
                        case ControlType.Mark:
2025
                            {
2026
                                var control = currentControl as RectangleControl;
2027
                                if (control != null)
2028
                                {
2029
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2030
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2031
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2032
                                }
2033
                            }
2034
                            break;
2035

    
2036
                        case ControlType.PenControl:
2037
                            {
2038
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2039
                                //inkBoard.Strokes.Add(stroke);
2040
                            }
2041
                            break;
2042

    
2043
                        default:
2044
                            break;
2045
                    }
2046

    
2047
                    #endregion // 각 컨트롤의 특별한 기능을 제어한다.
2048

    
2049
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2050
                    {
2051
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2052
                    }
2053
                }
2054
            }
2055
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2056
            {
2057
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2058
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2059
                SetCursor();
2060
                if (currentControl == null)
2061
                {
2062
                    switch (controlType)
2063
                    {
2064
                        case ControlType.PenControl:
2065
                            {
2066
                                if (inkBoard.Tag.ToString() == "Ink")
2067
                                {
2068
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2069
                                }
2070
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2071
                                {
2072
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2073
                                }
2074
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2075
                                {
2076
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2077
                                }
2078

    
2079
                                //inkBoard.Strokes.Add(stroke);
2080
                            }
2081
                            break;
2082
                    }
2083
                    return;
2084
                }
2085
            }
2086
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2087
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2088
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2089
            {
2090
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2091

    
2092
                if (isDraggingSelectionRect)
2093
                {
2094
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2095
                    e.Handled = true;
2096
                }
2097
                else if (isLeftMouseButtonDownOnWindow)
2098
                {
2099
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2100
                    double dragDistance = Math.Abs(dragDelta.Length);
2101

    
2102
                    if (dragDistance > DragThreshold)
2103
                    {
2104
                        isDraggingSelectionRect = true;
2105
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2106
                    }
2107

    
2108
                    e.Handled = true;
2109
                }
2110

    
2111
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2112
                {
2113
                }
2114
                else
2115
                {
2116
                    e.Handled = true;
2117
                }
2118
            }
2119
            /*
2120
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2121
            { //symbol
2122
                if(_dragdropWindow != null)
2123
                {
2124
                    Win32Point w32Mouse = new Win32Point();
2125
                    GetCursorPos(ref w32Mouse);
2126

    
2127
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2128
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2129
                }
2130
            }
2131
            */
2132
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2133
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2134
            {
2135
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2136
                if (control != null)
2137
                {
2138
                    this.cursor = Cursors.Hand;
2139
                    SetCursor();
2140
                }
2141
                else
2142
                {
2143
                    if (this.Cursor != Cursors.None)
2144
                    {
2145
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2146
                        SetCursor();
2147
                    }
2148
                }
2149
            }
2150
            else
2151
            {
2152
            }
2153
        }
2154

    
2155
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2156
        {
2157
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2158
            {
2159
                SetCursor();
2160
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2161
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2162

    
2163
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2164

    
2165
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2166
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2167

    
2168
                if (Sync.IsChecked)
2169
                {
2170
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2171
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2172
                }
2173
            }
2174
        }
2175

    
2176
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2177

    
2178
        private EllipseGeometry hitArea = new EllipseGeometry();
2179

    
2180
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2181
        {
2182
            IsDrawing = false;
2183

    
2184
            if (mouseHandlingMode != MouseHandlingMode.None)
2185
            {
2186
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2187
                {
2188
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2189

    
2190
                    SetCursor();
2191

    
2192
                    switch (controlType)
2193
                    {
2194
                        case ControlType.None:
2195
                            break;
2196

    
2197
                        case ControlType.Rectangle:
2198
                            {
2199
                            }
2200
                            break;
2201

    
2202
                        case ControlType.PenControl:
2203
                            {
2204
                            }
2205
                            break;
2206

    
2207
                        default:
2208
                            break;
2209
                    }
2210
                }
2211
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2212
                {
2213
                    if (isLeftMouseButtonDownOnWindow)
2214
                    {
2215
                        bool wasDragSelectionApplied = false;
2216

    
2217
                        if (isDraggingSelectionRect)
2218
                        {
2219
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2220
                            {
2221
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2222
                                mouseHandlingMode = MouseHandlingMode.None;
2223
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2224
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2225
                                Set_Symbol_Capture(endPoint);
2226
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2227
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2228
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2229
                            }
2230
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2231
                            {
2232
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2233
                                mouseHandlingMode = MouseHandlingMode.None;
2234
                                Set_Capture();
2235

    
2236
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2237
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2238
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2239
                            }
2240
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2241
                            {
2242
                                ApplyDragSelectionRect();
2243
                            }
2244
                            else
2245
                            {
2246
                                double x = Canvas.GetLeft(dragZoomBorder);
2247
                                double y = Canvas.GetTop(dragZoomBorder);
2248
                                double width = dragZoomBorder.Width;
2249
                                double height = dragZoomBorder.Height;
2250
                                Rect dragRect = new Rect(x, y, width, height);
2251

    
2252
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2253

    
2254
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2255
                            }
2256

    
2257
                            isDraggingSelectionRect = false;
2258
                            e.Handled = true;
2259
                            wasDragSelectionApplied = true;
2260
                        }
2261

    
2262
                        if (isLeftMouseButtonDownOnWindow)
2263
                        {
2264
                            isLeftMouseButtonDownOnWindow = false;
2265
                            this.ReleaseMouseCapture();
2266
                            e.Handled = true;
2267
                        }
2268

    
2269
                        if (!wasDragSelectionApplied)
2270
                        {
2271
                            init();
2272
                        }
2273
                    }
2274
                }
2275
                else if (e.RightButton == MouseButtonState.Pressed)
2276
                {
2277
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2278
                    SetCursor();
2279
                }
2280

    
2281
                zoomAndPanControl.ReleaseMouseCapture();
2282

    
2283
                e.Handled = true;
2284
            }
2285
            else
2286
            {
2287
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2288
                SetCursor();
2289
            }
2290

    
2291
            ///mouseButtonDown = MouseButton.Left;
2292
            //controlType = ControlType.SingleLine;
2293
        }
2294

    
2295
        public void Set_Symbol_Capture(Point endPoint)
2296
        {
2297
            double x = CanvasDrawingMouseDownPoint.X;
2298
            double y = CanvasDrawingMouseDownPoint.Y;
2299
            if (x > endPoint.X)
2300
            {
2301
                x = endPoint.X;
2302
                y = endPoint.Y;
2303
            }
2304

    
2305
            double width = dragCaptureBorder.Width;
2306
            double height = dragCaptureBorder.Height;
2307

    
2308
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2309

    
2310
            if (x < 0)
2311
            {
2312
                width += x;
2313
                x = 0;
2314
            }
2315
            if (y < 0)
2316
            {
2317
                height += y;
2318
                y = 0;
2319

    
2320
                width = (int)canvasImage.PixelWidth - x;
2321
            }
2322
            if (x + width > canvasImage.PixelWidth)
2323
            {
2324
                width = (int)canvasImage.PixelWidth - x;
2325
            }
2326
            if (y + height > canvasImage.PixelHeight)
2327
            {
2328
                height = (int)canvasImage.PixelHeight - y;
2329
            }
2330
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2331

    
2332
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2333
            var defaultBitmapImage = new BitmapImage();
2334
            defaultBitmapImage.BeginInit();
2335
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2336
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2337
            defaultBitmapImage.UriSource = new Uri(uri);
2338
            defaultBitmapImage.EndInit();
2339

    
2340
            //GC.Collect();
2341

    
2342
            if (defaultBitmapImage.IsDownloading)
2343
            {
2344
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2345
                {
2346
                    defaultBitmapImage.Freeze();
2347
                    //GC.Collect();
2348
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2349
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2350
                };
2351
            }
2352
        }
2353

    
2354
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2355
        {
2356
            ///mouseButtonDown = MouseButton.Left;
2357
        }
2358

    
2359
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2360
        {
2361
            ///mouseButtonDown = MouseButton.Left;
2362
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2363
        }
2364

    
2365
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2366
        {
2367
        }
2368

    
2369
        /// <summary>
2370
        /// select items by dragging
2371
        /// </summary>
2372
        private void ApplyDragSelectionRect()
2373
        {
2374
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2375

    
2376
            double x = Canvas.GetLeft(dragSelectionBorder);
2377
            double y = Canvas.GetTop(dragSelectionBorder);
2378
            double width = dragSelectionBorder.Width;
2379
            double height = dragSelectionBorder.Height;
2380
            Boolean Flag = false;
2381
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2382
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2383

    
2384
            Rect dragRect = new Rect(x, y, width, height);
2385
            ///dragRect.Inflate(width / 10, height / 10);
2386

    
2387
            foreach (var item in Items)
2388
            {
2389
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2390

    
2391
                if (Flag)
2392
                {
2393
                    adornerSet.Add(item);
2394
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2395
                    Control_Style(item);
2396
                }
2397
            }
2398
            if (adornerSet.Count > 0)
2399
            {
2400
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2401
                SelectLayer.Children.Add(final);
2402
            }
2403
        }
2404

    
2405
        private void InitDragSelectionRect(Point pt1, Point pt2)
2406
        {
2407
            //캡쳐 중
2408
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2409
            {
2410
                dragCaptureBorder.Visibility = Visibility.Visible;
2411
            }
2412
            //선택 중
2413
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2414
            {
2415
                dragSelectionBorder.Visibility = Visibility.Visible;
2416
            }
2417
            else
2418
            {
2419
                dragZoomBorder.Visibility = Visibility.Visible;
2420
            }
2421
            UpdateDragSelectionRect(pt1, pt2);
2422
        }
2423

    
2424
        /// <summary>
2425
        /// Update the position and size of the rectangle used for drag selection.
2426
        /// </summary>
2427
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2428
        {
2429
            double x, y, width, height;
2430

    
2431
            //
2432
            // Determine x,y,width and height of the rect inverting the points if necessary.
2433
            //
2434

    
2435
            if (pt2.X < pt1.X)
2436
            {
2437
                x = pt2.X;
2438
                width = pt1.X - pt2.X;
2439
            }
2440
            else
2441
            {
2442
                x = pt1.X;
2443
                width = pt2.X - pt1.X;
2444
            }
2445

    
2446
            if (pt2.Y < pt1.Y)
2447
            {
2448
                y = pt2.Y;
2449
                height = pt1.Y - pt2.Y;
2450
            }
2451
            else
2452
            {
2453
                y = pt1.Y;
2454
                height = pt2.Y - pt1.Y;
2455
            }
2456

    
2457
            //
2458
            // Update the coordinates of the rectangle used for drag selection.
2459
            //
2460
            //캡쳐 중
2461
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2462
            {
2463
                Canvas.SetLeft(dragCaptureBorder, x);
2464
                Canvas.SetTop(dragCaptureBorder, y);
2465
                dragCaptureBorder.Width = width;
2466
                dragCaptureBorder.Height = height;
2467
            }
2468
            //선택 중
2469
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2470
            {
2471
                Canvas.SetLeft(dragSelectionBorder, x);
2472
                Canvas.SetTop(dragSelectionBorder, y);
2473
                dragSelectionBorder.Width = width;
2474
                dragSelectionBorder.Height = height;
2475
            }
2476
            else
2477
            {
2478
                Canvas.SetLeft(dragZoomBorder, x);
2479
                Canvas.SetTop(dragZoomBorder, y);
2480
                dragZoomBorder.Width = width;
2481
                dragZoomBorder.Height = height;
2482
            }
2483
        }
2484

    
2485
        private void drawingPannelRotate(double angle)
2486
        {
2487
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2488
            rotate.Angle = angle;
2489
            var rotationNum = Math.Abs((rotate.Angle / 90));
2490

    
2491
            if (angle == 90 || angle == 270)
2492
            {
2493
                double emptySize = zoomAndPanCanvas.Width;
2494
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2495
                zoomAndPanCanvas.Height = emptySize;
2496
            }
2497
            if (angle == 0)
2498
            {
2499
                translate.X = 0;
2500
                translate.Y = 0;
2501
            }
2502
            else if (angle == 90)
2503
            {
2504
                translate.X = zoomAndPanCanvas.Width;
2505
                translate.Y = 0;
2506
            }
2507
            else if (angle == 180)
2508
            {
2509
                translate.X = zoomAndPanCanvas.Width;
2510
                translate.Y = zoomAndPanCanvas.Height;
2511
            }
2512
            else
2513
            {
2514
                translate.X = 0;
2515
                translate.Y = zoomAndPanCanvas.Height;
2516
            }
2517

    
2518
            zoomAndPanControl.RotationAngle = rotate.Angle;
2519

    
2520
            if (!testPanel2.IsHidden)
2521
            {
2522
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2523
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2524
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2525
            }
2526

    
2527
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2528
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2529
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2530
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2531
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2532
        }
2533

    
2534
        private void syncPannelRotate(double angle)
2535
        {
2536
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2537
            rotate.Angle = angle;
2538
            var rotationNum = Math.Abs((rotate.Angle / 90));
2539

    
2540
            if (angle == 90 || angle == 270)
2541
            {
2542
                double emptySize = zoomAndPanCanvas2.Width;
2543
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2544
                zoomAndPanCanvas2.Height = emptySize;
2545
            }
2546
            if (angle == 0)
2547
            {
2548
                translate2.X = 0;
2549
                translate2.Y = 0;
2550
            }
2551
            else if (angle == 90)
2552
            {
2553
                translate2.X = zoomAndPanCanvas2.Width;
2554
                translate2.Y = 0;
2555
            }
2556
            else if (angle == 180)
2557
            {
2558
                translate2.X = zoomAndPanCanvas2.Width;
2559
                translate2.Y = zoomAndPanCanvas2.Height;
2560
            }
2561
            else
2562
            {
2563
                translate2.X = 0;
2564
                translate2.Y = zoomAndPanCanvas2.Height;
2565
            }
2566

    
2567
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2568
        }
2569

    
2570
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2571
        {
2572
            string Data_ = "";
2573

    
2574
            try
2575
            {
2576
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2577
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2578
                if (Data_ != null || Data_ != "")
2579
                {
2580
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2581
                }
2582
                else
2583
                {
2584
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2585
                }
2586

    
2587
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2588
                //{
2589
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2590
                //    STATE = 0,
2591
                //};
2592
                if (Data_ != null)
2593
                {
2594
                    Image img = new Image();
2595
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2596
                    if (Data_.Contains(".svg"))
2597
                    {
2598
                        byte[] imageData = null;
2599
                        DrawingImage image = null;
2600
                        using (System.Net.WebClient web = new System.Net.WebClient())
2601
                        {
2602
                            imageData = web.DownloadData(new Uri(Data_));
2603
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2604
                            image = SvgReader.Load(stream);
2605
                        }
2606
                        img.Source = image;
2607
                    }
2608
                    else
2609
                    {
2610
                        img.Source = new BitmapImage(new Uri(Data_));
2611
                    }
2612

    
2613
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2614
                    {
2615
                        PointSet = new List<Point>(),
2616
                        FilePath = Data_,
2617
                        ImageData = img.Source,
2618
                        StartPoint = canvasZoomPanningMouseDownPoint,
2619
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2620
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2621
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2622
                        canvasZoomPanningMouseDownPoint.Y),
2623
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2624
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2625
                    };
2626

    
2627
                    currentControl.PointSet = new List<Point>
2628
                                        {
2629
                                            currentControl.StartPoint,
2630
                                            currentControl.LeftBottomPoint,
2631
                                            currentControl.EndPoint,
2632
                                            currentControl.TopRightPoint,
2633
                                        };
2634
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2635
                    UndoData = new Undo_data()
2636
                    {
2637
                        IsUndo = false,
2638
                        Event = Event_Type.Create,
2639
                        EventTime = DateTime.Now,
2640
                        Markup_List = new List<Multi_Undo_data>()
2641
                    };
2642
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2643
                    {
2644
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2645
                    });
2646

    
2647
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2648
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2649
                    UndoData.Markup_List.Add(multi_Undo_Data);
2650
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2651

    
2652
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2653
                    currentControl.CommentID = Commons.shortGuid();
2654
                    currentControl.SymbolID = id;
2655
                    currentControl.GroupID = group_id;
2656
                    currentControl.ApplyTemplate();
2657
                    currentControl.SetImage();
2658

    
2659
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2660
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2661
                    SelectLayer.Children.Add(final);
2662
                }
2663
            }
2664
            catch (Exception ex)
2665
            {
2666
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2667
            }
2668
        }
2669

    
2670
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2671
        {
2672
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2673
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2674
            {
2675
                set_option.Value = double.Parse(set_option.ContentText);
2676
                //set_option.Focusable = false;
2677
                zoomAndPanControl.Focus();
2678
            }
2679

    
2680
            ConvertInkControlToPolygon();
2681

    
2682
            // 텍스트가 없으면 삭제됨
2683
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2684
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2685

    
2686
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2687
            {
2688
                DeleteCommand.Instance.Execute(new[] { text_item });
2689
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2690
            }
2691

    
2692
            /// up to here
2693

    
2694
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2695
            {
2696
                if (item as ArrowTextControl != null)
2697
                {
2698
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2699
                }
2700
                else if (item as TextControl != null)
2701
                {
2702
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2703
                }
2704
            }
2705

    
2706
            //if (currentControl != null)
2707
            {
2708
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2709
                if (text_item_ != null)
2710
                {
2711
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2712
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2713
                    (text_item_ as TextControl).IsEditingMode = false;
2714
                    currentControl = null;
2715
                }
2716

    
2717
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2718
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2719
                {
2720
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2721
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2722
                    currentControl = null;
2723
                }
2724
            }
2725

    
2726
            double Ang = 0;
2727
            if (rotate.Angle != 0)
2728
            {
2729
                Ang = 360 - rotate.Angle;
2730
            }
2731

    
2732
            if (e.OriginalSource is System.Windows.Controls.Image)
2733
            {
2734
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2735
            }
2736
            /*
2737
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2738
            {
2739
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2740
                if(symbol_id != null)
2741
                {
2742
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2743
                }
2744
            }
2745

    
2746
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2747
            {
2748
                if (this._dragdropWindow != null)
2749
                {
2750
                    this._dragdropWindow.Close();
2751
                    this._dragdropWindow = null;
2752
                    symbol_id = null;
2753
                }
2754
            }
2755
            */
2756

    
2757
            if (e.LeftButton == MouseButtonState.Pressed)
2758
            {
2759
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2760
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2761

    
2762
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2763
                SetCursor();
2764

    
2765
                if (!ViewerDataModel.Instance.IsPressCtrl)
2766
                {
2767
                    SelectionSet.Instance.UnSelect(this);
2768
                }
2769
            }
2770

    
2771
            if (e.MiddleButton == MouseButtonState.Pressed)
2772
            {
2773
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2774
                cursor = Cursors.SizeAll;
2775
                SetCursor();
2776
            }
2777
            if (e.RightButton == MouseButtonState.Pressed)
2778
            {
2779
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2780
                cursor = Cursors.SizeAll;
2781
                SetCursor();
2782
            }
2783
            else if (e.XButton1 == MouseButtonState.Pressed)
2784
            {
2785
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2786
                {
2787
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2788
                }
2789

    
2790
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2791
            }
2792
            else if (e.XButton2 == MouseButtonState.Pressed)
2793
            {
2794
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2795
                {
2796
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2797
                }
2798
            }
2799

    
2800
            bool isArrowTextEdit = false;
2801

    
2802
            if (currentControl is ArrowTextControl textControl)
2803
            {
2804
                if (textControl.IsEditingMode)
2805
                    isArrowTextEdit = true;
2806
            }
2807

    
2808
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2809
            {
2810
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2811
                {
2812
                    if (SelectLayer.Children.Count == 0)
2813
                    {
2814
                        isLeftMouseButtonDownOnWindow = true;
2815
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2816
                    }
2817

    
2818
                    if (controlType == ControlType.None)
2819
                    {
2820
                        isLeftMouseButtonDownOnWindow = true;
2821
                    }
2822
                }
2823

    
2824
                /// 캡쳐 모드 설정
2825
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2826
                {
2827
                    dragCaptureBorder.Visibility = Visibility.Visible;
2828
                    isLeftMouseButtonDownOnWindow = true;
2829
                }
2830

    
2831
                /// 줌 모드 설정
2832
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2833
                {
2834
                    isLeftMouseButtonDownOnWindow = true;
2835
                }
2836

    
2837
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2838

    
2839
                if (control == null)
2840
                {
2841
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2842
                }
2843
                else
2844
                {
2845
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2846
                    {
2847
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2848
                    }
2849

    
2850
                    AdornerFinal final = null;
2851

    
2852
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2853
                    {
2854
                        /// 기존 selection 해제
2855
                        SelectionSet.Instance.UnSelect(this);
2856

    
2857
                        final = new AdornerFinal(control);
2858

    
2859
                        this.Control_Style(control);
2860

    
2861
                        if ((control as IPath) != null)
2862
                        {
2863
                            if ((control as IPath).LineSize != 0)
2864
                            {
2865
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2866
                            }
2867
                        }
2868
                        if ((control as IShapeControl) != null)
2869
                        {
2870
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2871
                            {
2872
                                ViewerDataModel.Instance.checkHatchShape = true;
2873
                            }
2874
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2875
                            {
2876
                                ViewerDataModel.Instance.checkFillShape = true;
2877
                            }
2878
                            else
2879
                            {
2880
                                ViewerDataModel.Instance.checkHatchShape = false;
2881
                                ViewerDataModel.Instance.checkFillShape = false;
2882
                            }
2883
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2884
                        }
2885

    
2886
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2887

    
2888
                        if ((control as TextControl) != null)
2889
                        {
2890
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2891

    
2892
                            if (!((control as TextControl).EnableEditing))
2893
                            {
2894
                                (control as TextControl).EnableEditing = true;
2895
                            }
2896
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2897
                            {
2898
                                ViewerDataModel.Instance.checkTextStyle = true;
2899
                            }
2900
                            else
2901
                            {
2902
                                ViewerDataModel.Instance.checkTextStyle = false;
2903
                            }
2904
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2905
                            {
2906
                                ViewerDataModel.Instance.checkTextWeight = true;
2907
                            }
2908
                            else
2909
                            {
2910
                                ViewerDataModel.Instance.checkTextWeight = false;
2911
                            }
2912
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2913
                            {
2914
                                ViewerDataModel.Instance.checkUnderLine = true;
2915
                            }
2916
                            else
2917
                            {
2918
                                ViewerDataModel.Instance.checkUnderLine = false;
2919
                            }
2920
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2921
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2922
                        }
2923
                        else if ((control as ArrowTextControl) != null)
2924
                        {
2925
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2926

    
2927
                            if (!((control as ArrowTextControl).EnableEditing))
2928
                            {
2929
                                (control as ArrowTextControl).EnableEditing = true;
2930
                            }
2931
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2932
                            {
2933
                                ViewerDataModel.Instance.checkTextStyle = true;
2934
                            }
2935
                            else
2936
                            {
2937
                                ViewerDataModel.Instance.checkTextStyle = false;
2938
                            }
2939
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2940
                            {
2941
                                ViewerDataModel.Instance.checkTextWeight = true;
2942
                            }
2943
                            else
2944
                            {
2945
                                ViewerDataModel.Instance.checkTextWeight = false;
2946
                            }
2947
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2948
                            {
2949
                                ViewerDataModel.Instance.checkUnderLine = true;
2950
                            }
2951
                            else
2952
                            {
2953
                                ViewerDataModel.Instance.checkUnderLine = false;
2954
                            }
2955
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2956
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2957
                        }
2958
                        else if ((control as RectCloudControl) != null)
2959
                        {
2960
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2961
                        }
2962
                        else if ((control as CloudControl) != null)
2963
                        {
2964
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2965
                        }
2966
                    }
2967
                    else
2968
                    {
2969
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2970
                        SelectionSet.Instance.UnSelect(this);
2971
                        comment.Add(control);
2972

    
2973
                        Control_Style(control);
2974

    
2975
                        final = new AdornerFinal(comment);
2976
                    }
2977

    
2978
                    if (final != null)
2979
                    {
2980
                        this.SelectLayer.Children.Add(final);
2981
                    }
2982
                }
2983
            }
2984
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2985
            {
2986

    
2987

    
2988
                init();
2989
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2990
                if (cursor != Cursors.SizeAll)
2991
                {
2992
                    cursor = Cursors.Cross;
2993
                    SetCursor();
2994
                }
2995
                bool init_user = false;
2996
                foreach (var user in gridViewMarkup.Items)
2997
                {
2998
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2999
                    {
3000
                        init_user = true;
3001
                    }
3002
                }
3003
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3004
                {
3005
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3006
                    RadWindow.Alert(new DialogParameters
3007
                    {
3008
                        Owner = Application.Current.MainWindow,
3009
                        Theme = new VisualStudio2013Theme(),
3010
                        Header = "Info",
3011
                        Content = "Existing comments already existed. Select from the user list first",
3012
                    });
3013
                    return;
3014
                }
3015
                else
3016
                {
3017
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3018
                    if (item != null)
3019
                    {
3020
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3021
                    }
3022
                }
3023
                
3024
                switch (controlType)
3025
                {
3026
                    case ControlType.Coordinate:
3027
                        {
3028
                            if (e.LeftButton == MouseButtonState.Pressed)
3029
                            {
3030
                                if (currentControl is CoordinateControl)
3031
                                {
3032
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3033
                                    {
3034
                                        return;
3035
                                    }
3036

    
3037
                                    CreateCommand.Instance.Execute(currentControl);
3038

    
3039
                                    currentControl = null;
3040
                                    this.cursor = Cursors.Arrow;
3041
                                }
3042
                                else
3043
                                {
3044
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3045
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3046
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3047
                                    {
3048
                                        currentControl = null;
3049
                                        this.cursor = Cursors.Arrow;
3050
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3051
                                        return;
3052
                                    }
3053
                                    else
3054
                                    {
3055
                                        currentControl = new CoordinateControl
3056
                                        {
3057
                                            Background = new SolidColorBrush(Colors.Black),
3058
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3059
                                            ControlType = ControlType.Coordinate
3060
                                        };
3061

    
3062
                                        currentControl.CommentID = Commons.shortGuid();
3063
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3064
                                        currentControl.IsNew = true;
3065

    
3066
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3067

    
3068
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3069
                                    }
3070
                                }
3071
                            }
3072
                        }
3073
                        break;
3074

    
3075
                    case ControlType.InsideWhite:
3076
                        {
3077
                            if (e.LeftButton == MouseButtonState.Pressed)
3078
                            {
3079
                                if (currentControl is InsideWhiteControl)
3080
                                {
3081
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3082
                                    {
3083
                                        return;
3084
                                    }
3085

    
3086
                                    CreateCommand.Instance.Execute(currentControl);
3087

    
3088
                                    currentControl = null;
3089
                                    this.cursor = Cursors.Arrow;
3090
                                }
3091
                                else
3092
                                {
3093
                                    currentControl = new InsideWhiteControl
3094
                                    {
3095
                                        Background = new SolidColorBrush(Colors.Black),
3096
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3097
                                        ControlType = ControlType.InsideWhite
3098
                                    };
3099

    
3100
                                    currentControl.CommentID = Commons.shortGuid();
3101
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3102
                                    currentControl.IsNew = true;
3103
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3104

    
3105
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3106
                                }
3107
                            }
3108
                        }
3109
                        break;
3110

    
3111
                    case ControlType.OverlapWhite:
3112
                        {
3113
                            if (e.LeftButton == MouseButtonState.Pressed)
3114
                            {
3115
                                if (currentControl is OverlapWhiteControl)
3116
                                {
3117
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3118
                                    {
3119
                                        return;
3120
                                    }
3121

    
3122
                                    CreateCommand.Instance.Execute(currentControl);
3123

    
3124
                                    currentControl = null;
3125
                                    this.cursor = Cursors.Arrow;
3126
                                }
3127
                                else
3128
                                {
3129
                                    currentControl = new OverlapWhiteControl
3130
                                    {
3131
                                        Background = new SolidColorBrush(Colors.Black),
3132
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3133
                                        ControlType = ControlType.OverlapWhite
3134
                                    };
3135

    
3136
                                    currentControl.CommentID = Commons.shortGuid();
3137
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3138
                                    currentControl.IsNew = true;
3139
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3140

    
3141
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3142
                                }
3143
                            }
3144
                        }
3145
                        break;
3146

    
3147
                    case ControlType.ClipWhite:
3148
                        {
3149
                            if (e.LeftButton == MouseButtonState.Pressed)
3150
                            {
3151
                                if (currentControl is ClipWhiteControl)
3152
                                {
3153
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3154
                                    {
3155
                                        return;
3156
                                    }
3157

    
3158
                                    CreateCommand.Instance.Execute(currentControl);
3159

    
3160
                                    currentControl = null;
3161
                                    this.cursor = Cursors.Arrow;
3162
                                }
3163
                                else
3164
                                {
3165
                                    currentControl = new ClipWhiteControl
3166
                                    {
3167
                                        Background = new SolidColorBrush(Colors.Black),
3168
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3169
                                        ControlType = ControlType.ClipWhite
3170
                                    };
3171

    
3172
                                    currentControl.CommentID = Commons.shortGuid();
3173
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3174
                                    currentControl.IsNew = true;
3175
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3176

    
3177
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3178
                                }
3179
                            }
3180
                        }
3181
                        break;
3182

    
3183
                    case ControlType.Rectangle:
3184
                        {
3185
                            if (e.LeftButton == MouseButtonState.Pressed)
3186
                            {
3187
                                if (currentControl is RectangleControl)
3188
                                {
3189
                                    //20180906 LJY TEST IsRotationDrawingEnable
3190
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3191
                                    {
3192
                                        return;
3193
                                    }
3194

    
3195
                                    CreateCommand.Instance.Execute(currentControl);
3196
                                    currentControl = null;
3197
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3198
                                }
3199
                                else
3200
                                {
3201
                                    currentControl = new RectangleControl
3202
                                    {
3203
                                        Background = new SolidColorBrush(Colors.Black),
3204
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3205
                                        ControlType = ControlType.Rectangle
3206
                                    };
3207

    
3208
                                    currentControl.CommentID = Commons.shortGuid();
3209
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3210
                                    currentControl.IsNew = true;
3211
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3212

    
3213
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3214
                                }
3215
                            }
3216
                        }
3217
                        break;
3218

    
3219
                    case ControlType.RectCloud:
3220
                        {
3221
                            if (e.LeftButton == MouseButtonState.Pressed)
3222
                            {
3223
                                if (currentControl is RectCloudControl)
3224
                                {
3225
                                    //20180906 LJY TEST IsRotationDrawingEnable
3226
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3227
                                    {
3228
                                        return;
3229
                                    }
3230

    
3231
                                    CreateCommand.Instance.Execute(currentControl);
3232

    
3233
                                    currentControl = null;
3234

    
3235
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3236
                                }
3237
                                else
3238
                                {
3239
                                    currentControl = new RectCloudControl
3240
                                    {
3241
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3242
                                        ControlType = ControlType.RectCloud,
3243
                                        Background = new SolidColorBrush(Colors.Black)
3244
                                    };
3245

    
3246
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3247
                                    currentControl.CommentID = Commons.shortGuid();
3248
                                    currentControl.IsNew = true;
3249
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3250
                                }
3251
                            }
3252
                        }
3253
                        break;
3254

    
3255
                    case ControlType.Circle:
3256
                        {
3257
                            if (e.LeftButton == MouseButtonState.Pressed)
3258
                            {
3259
                                if (currentControl is CircleControl)
3260
                                {
3261
                                    //20180906 LJY TEST IsRotationDrawingEnable
3262
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3263
                                    {
3264
                                        return;
3265
                                    }
3266

    
3267
                                    CreateCommand.Instance.Execute(currentControl);
3268

    
3269
                                    currentControl = null;
3270
                                }
3271
                                else
3272
                                {
3273
                                    currentControl = new CircleControl
3274
                                    {
3275
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3276
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3277
                                        Background = new SolidColorBrush(Colors.Black)
3278
                                    };
3279

    
3280
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3281
                                    currentControl.CommentID = Commons.shortGuid();
3282
                                    currentControl.IsNew = true;
3283
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3284
                                }
3285
                            }
3286
                        }
3287
                        break;
3288

    
3289
                    case ControlType.Triangle:
3290
                        {
3291
                            if (e.LeftButton == MouseButtonState.Pressed)
3292
                            {
3293
                                if (currentControl is TriControl)
3294
                                {
3295
                                    var content = currentControl as TriControl;
3296
                                    if (content.MidPoint == new Point(0, 0))
3297
                                    {
3298
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3299
                                    }
3300
                                    else
3301
                                    {
3302
                                        //20180906 LJY TEST IsRotationDrawingEnable
3303
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3304
                                        {
3305
                                            return;
3306
                                        }
3307

    
3308
                                        CreateCommand.Instance.Execute(currentControl);
3309

    
3310
                                        currentControl = null;
3311
                                    }
3312
                                }
3313
                                else
3314
                                {
3315
                                    currentControl = new TriControl
3316
                                    {
3317
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3318
                                        Background = new SolidColorBrush(Colors.Black),
3319
                                    };
3320

    
3321
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3322
                                    currentControl.CommentID = Commons.shortGuid();
3323
                                    currentControl.IsNew = true;
3324
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3325
                                }
3326
                            }
3327
                        }
3328
                        break;
3329

    
3330
                    case ControlType.CancelLine:
3331
                    case ControlType.SingleLine:
3332
                    case ControlType.ArrowLine:
3333
                    case ControlType.TwinLine:
3334
                    case ControlType.DimLine:
3335
                        {
3336
                            if (e.LeftButton == MouseButtonState.Pressed)
3337
                            {
3338
                                if (currentControl is LineControl)
3339
                                {
3340
                                    //20180906 LJY TEST IsRotationDrawingEnable
3341
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3342
                                    {
3343
                                        return;
3344
                                    }
3345

    
3346
                                    CreateCommand.Instance.Execute(currentControl);
3347
                                    currentControl = null;
3348
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3349
                                }
3350
                                else
3351
                                {
3352
                                    currentControl = new LineControl
3353
                                    {
3354
                                        ControlType = this.controlType,
3355
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3356
                                        Background = new SolidColorBrush(Colors.Black)
3357
                                    };
3358

    
3359
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3360
                                    currentControl.CommentID = Commons.shortGuid();
3361
                                    currentControl.IsNew = true;
3362
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3363
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3364
                                }
3365
                            }
3366
                        }
3367
                        break;
3368

    
3369
                    case ControlType.PolygonControl:
3370
                        {
3371
                            if (currentControl is PolygonControl)
3372
                            {
3373
                                var control = currentControl as PolygonControl;
3374

    
3375
                                if (e.RightButton == MouseButtonState.Pressed)
3376
                                {
3377
                                    control.IsCompleted = true;
3378
                                }
3379

    
3380
                                if (!control.IsCompleted)
3381
                                {
3382
                                    control.PointSet.Add(control.EndPoint);
3383
                                }
3384
                                else
3385
                                {
3386
                                    //20180906 LJY TEST IsRotationDrawingEnable
3387
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3388
                                    {
3389
                                        return;
3390
                                    }
3391

    
3392
                                    var firstPoint = control.PointSet.First();
3393
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3394
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3395
                                    control.PointSet.Add(firstPoint);
3396

    
3397
                                    control.ApplyOverViewData();
3398

    
3399
                                    CreateCommand.Instance.Execute(currentControl);
3400
                                    control.UpdateControl();
3401
                                    currentControl = null;
3402
                                }
3403
                            }
3404
                            else
3405
                            {
3406
                                if (e.LeftButton == MouseButtonState.Pressed)
3407
                                {
3408
                                    currentControl = new PolygonControl
3409
                                    {
3410
                                        PointSet = new List<Point>(),
3411
                                    };
3412

    
3413
                                    var polygonControl = (currentControl as PolygonControl);
3414
                                    currentControl.CommentID = Commons.shortGuid();
3415
                                    currentControl.IsNew = true;
3416
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3417
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3418
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3419
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3420
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3421
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3422
                                    polygonControl.ApplyTemplate();
3423
                                    polygonControl.Visibility = Visibility.Visible;
3424
                                }
3425
                            }
3426
                        }
3427
                        break;
3428

    
3429
                    case ControlType.ChainLine:
3430
                        {
3431
                            if (currentControl is PolygonControl)
3432
                            {
3433
                                var control = currentControl as PolygonControl;
3434

    
3435
                                if (e.RightButton == MouseButtonState.Pressed)
3436
                                {
3437
                                    //20180906 LJY TEST IsRotationDrawingEnable
3438
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3439
                                    {
3440
                                        return;
3441
                                    }
3442

    
3443
                                    CreateCommand.Instance.Execute(currentControl);
3444

    
3445
                                    currentControl = null;
3446
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3447
                                    return;
3448
                                }
3449

    
3450
                                if (!control.IsCompleted)
3451
                                {
3452
                                    control.PointSet.Add(control.EndPoint);
3453
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3454
                                }
3455
                            }
3456
                            else
3457
                            {
3458
                                if (e.LeftButton == MouseButtonState.Pressed)
3459
                                {
3460
                                    MainAngle.Visibility = Visibility.Visible;
3461
                                    currentControl = new PolygonControl
3462
                                    {
3463
                                        PointSet = new List<Point>(),
3464
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3465
                                        ControlType = ControlType.ChainLine,
3466
                                        DashSize = ViewerDataModel.Instance.DashSize,
3467
                                        LineSize = ViewerDataModel.Instance.LineSize,
3468
                                        //PointC = new StylusPointSet()
3469
                                    };
3470

    
3471
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3472
                                    //{
3473
                                    var polygonControl = (currentControl as PolygonControl);
3474
                                    currentControl.CommentID = Commons.shortGuid();
3475
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3476
                                    currentControl.IsNew = true;
3477
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3478
                                    //currentControl.OnApplyTemplate();
3479
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3480
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3481
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3482
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3483
                                    //}
3484
                                }
3485
                            }
3486
                        }
3487
                        break;
3488

    
3489
                    case ControlType.ArcLine:
3490
                        {
3491
                            if (e.LeftButton == MouseButtonState.Pressed)
3492
                            {
3493
                                if (currentControl is ArcControl)
3494
                                {
3495
                                    //20180906 LJY TEST IsRotationDrawingEnable
3496
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3497
                                    {
3498
                                        return;
3499
                                    }
3500

    
3501
                                    CreateCommand.Instance.Execute(currentControl);
3502

    
3503
                                    currentControl = null;
3504
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3505
                                }
3506
                                else
3507
                                {
3508
                                    currentControl = new ArcControl
3509
                                    {
3510
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3511
                                        Background = new SolidColorBrush(Colors.Black)
3512
                                    };
3513
                                    currentControl.CommentID = Commons.shortGuid();
3514
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3515
                                    currentControl.IsNew = true;
3516
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3517
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3518
                                }
3519
                            }
3520
                            else if (e.RightButton == MouseButtonState.Pressed)
3521
                            {
3522
                                if (currentControl != null)
3523
                                {
3524
                                    (currentControl as ArcControl).setClock();
3525
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3526
                                }
3527
                            }
3528
                        }
3529
                        break;
3530

    
3531
                    case ControlType.ArcArrow:
3532
                        {
3533
                            if (e.LeftButton == MouseButtonState.Pressed)
3534
                            {
3535
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3536
                                //{
3537
                                if (currentControl is ArrowArcControl)
3538
                                {
3539
                                    //20180906 LJY TEST IsRotationDrawingEnable
3540
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3541
                                    {
3542
                                        return;
3543
                                    }
3544

    
3545
                                    CreateCommand.Instance.Execute(currentControl);
3546

    
3547
                                    currentControl = null;
3548
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3549
                                }
3550
                                else
3551
                                {
3552
                                    currentControl = new ArrowArcControl
3553
                                    {
3554
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3555
                                        Background = new SolidColorBrush(Colors.Black)
3556
                                    };
3557
                                    currentControl.CommentID = Commons.shortGuid();
3558
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3559
                                    currentControl.IsNew = true;
3560
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3561
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3562
                                }
3563
                                //}
3564
                            }
3565
                            else if (e.RightButton == MouseButtonState.Pressed)
3566
                            {
3567
                                if (currentControl != null)
3568
                                {
3569
                                    (currentControl as ArrowArcControl).setClock();
3570
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3571
                                    //(currentControl as ArcControl).ApplyTemplate();
3572
                                }
3573
                            }
3574
                        }
3575
                        break;
3576

    
3577
                    case ControlType.ArrowMultiLine:
3578
                        {
3579
                            if (e.LeftButton == MouseButtonState.Pressed)
3580
                            {
3581
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3582
                                //{
3583
                                if (currentControl is ArrowControl_Multi)
3584
                                {
3585
                                    var content = currentControl as ArrowControl_Multi;
3586
                                    if (content.MiddlePoint == new Point(0, 0))
3587
                                    {
3588
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3589
                                        {
3590
                                            content.MiddlePoint = content.EndPoint;
3591
                                        }
3592
                                        else
3593
                                        {
3594
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3595
                                        }
3596
                                    }
3597
                                    else
3598
                                    {
3599
                                        //20180906 LJY TEST IsRotationDrawingEnable
3600
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3601
                                        {
3602
                                            return;
3603
                                        }
3604

    
3605
                                        CreateCommand.Instance.Execute(currentControl);
3606

    
3607
                                        currentControl = null;
3608
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3609
                                    }
3610
                                }
3611
                                else
3612
                                {
3613
                                    currentControl = new ArrowControl_Multi
3614
                                    {
3615
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3616
                                        Background = new SolidColorBrush(Colors.Black)
3617
                                    };
3618
                                    currentControl.CommentID = Commons.shortGuid();
3619
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3620
                                    currentControl.IsNew = true;
3621
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3622
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3623
                                }
3624
                                //}
3625
                            }
3626
                        }
3627
                        break;
3628

    
3629
                    case ControlType.PolygonCloud:
3630
                        {
3631
                            if (currentControl is CloudControl)
3632
                            {
3633
                                var control = currentControl as CloudControl;
3634
                                if (e.RightButton == MouseButtonState.Pressed)
3635
                                {
3636
                                    control.IsCompleted = true;
3637
                                }
3638

    
3639
                                if (!control.IsCompleted)
3640
                                {
3641
                                    control.PointSet.Add(control.EndPoint);
3642
                                }
3643
                                else
3644
                                {
3645
                                    //20180906 LJY TEST IsRotationDrawingEnable
3646
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3647
                                    {
3648
                                        return;
3649
                                    }
3650

    
3651
                                    CreateCommand.Instance.Execute(currentControl);
3652

    
3653
                                    control.isTransOn = true;
3654
                                    var firstPoint = control.PointSet.First();
3655

    
3656
                                    control.PointSet.Add(firstPoint);
3657
                                    control.DrawingCloud();
3658
                                    control.ApplyOverViewData();
3659

    
3660
                                    currentControl = null;
3661
                                }
3662
                            }
3663
                            else
3664
                            {
3665
                                if (e.LeftButton == MouseButtonState.Pressed)
3666
                                {
3667
                                    currentControl = new CloudControl
3668
                                    {
3669
                                        PointSet = new List<Point>(),
3670
                                        PointC = new StylusPointSet()
3671
                                    };
3672

    
3673
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3674
                                    //{
3675
                                    var polygonControl = (currentControl as CloudControl);
3676
                                    currentControl.CommentID = Commons.shortGuid();
3677
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3678
                                    currentControl.IsNew = true;
3679
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3680

    
3681
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3682
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3683

    
3684
                                    //}
3685
                                }
3686
                            }
3687
                        }
3688
                        break;
3689

    
3690
                    case ControlType.ImgControl:
3691
                        {
3692
                            if (e.LeftButton == MouseButtonState.Pressed)
3693
                            {
3694
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3695
                                //{
3696
                                if (currentControl is ImgControl)
3697
                                {
3698
                                    //20180906 LJY TEST IsRotationDrawingEnable
3699
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3700
                                    {
3701
                                        return;
3702
                                    }
3703

    
3704
                                    CreateCommand.Instance.Execute(currentControl);
3705
                                    controlType = ControlType.ImgControl;
3706
                                    currentControl = null;
3707
                                }
3708
                                else
3709
                                {
3710
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3711
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3712
                                    {
3713
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3714
                                        UriBuilder uri = new UriBuilder(filename);
3715
                                        uri.Host = downloadUri.Host;
3716
                                        uri.Port = downloadUri.Port;
3717

    
3718
                                        Image img = new Image();
3719
                                        if (filename.Contains(".svg"))
3720
                                        {
3721
                                            byte[] imageData = null;
3722
                                            DrawingImage image = null;
3723
                                            using (System.Net.WebClient web = new System.Net.WebClient())
3724
                                            {
3725
                                                imageData = web.DownloadData(uri.Uri);
3726
                                                System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3727
                                                image = SvgReader.Load(stream);
3728
                                            }
3729
                                            img.Source = image;
3730
                                        }
3731
                                        else
3732
                                        {
3733
                                            img.Source = new BitmapImage(uri.Uri);
3734
                                        }
3735

    
3736
                                        currentControl = new ImgControl
3737
                                        {
3738
                                            Background = new SolidColorBrush(Colors.Black),
3739
                                            PointSet = new List<Point>(),
3740
                                            FilePath = uri.Uri.ToString(),
3741
                                            ImageData = img.Source,
3742
                                            StartPoint = CanvasDrawingMouseDownPoint,
3743
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3744
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3745
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3746
                                            ControlType = ControlType.ImgControl
3747
                                        };
3748

    
3749
                                        currentControl.CommentID = Commons.shortGuid();
3750
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3751
                                        currentControl.IsNew = true;
3752
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3753

    
3754
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3755
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3756
                                    }
3757
                                }
3758
                                //}
3759
                            }
3760
                        }
3761
                        break;
3762

    
3763
                    case ControlType.Date:
3764
                        {
3765
                            if (e.LeftButton == MouseButtonState.Pressed)
3766
                            {
3767
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3768
                                //{
3769
                                if (currentControl is DateControl)
3770
                                {
3771
                                    //20180906 LJY TEST IsRotationDrawingEnable
3772
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3773
                                    {
3774
                                        return;
3775
                                    }
3776

    
3777
                                    CreateCommand.Instance.Execute(currentControl);
3778
                                    currentControl = null;
3779

    
3780
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3781
                                    { 
3782
                                        controlType = ControlType.None;
3783
                                        IsSwingMode = false;
3784
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3785
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3786
                                        mouseHandlingMode = MouseHandlingMode.None;
3787
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3788
                                        txtBatch.Visibility = Visibility.Collapsed;
3789
                                    }
3790
                                }
3791
                                else
3792
                                {
3793
                                    currentControl = new DateControl
3794
                                    {
3795
                                        StartPoint = CanvasDrawingMouseDownPoint,
3796
                                        Background = new SolidColorBrush(Colors.Black)
3797
                                    };
3798
                                    currentControl.CommentID = Commons.shortGuid();
3799
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3800
                                    currentControl.IsNew = true;
3801
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3802

    
3803
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3804
                                    if (currentControl is ImgControl)
3805
                                    {
3806
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3807
                                    }
3808
                                }
3809
                                //}
3810
                            }
3811
                        }
3812
                        break;
3813

    
3814
                    case ControlType.TextControl:
3815
                        {
3816
                            if (e.LeftButton == MouseButtonState.Pressed)
3817
                            {
3818
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3819
                                {
3820
                                    currentControl = new TextControl
3821
                                    {
3822
                                        ControlType = controlType
3823
                                    };
3824
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3825
                                    currentControl.CommentID = Commons.shortGuid();
3826
                                    currentControl.IsNew = true;
3827
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3828
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3829
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3830

    
3831
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3832
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3833

    
3834
                                    (currentControl as TextControl).ControlType_No = 0;
3835
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3836
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3837
                                    (currentControl as TextControl).ApplyTemplate();
3838
                                    (currentControl as TextControl).Base_TextBox.Focus();
3839
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3840
                                    CreateCommand.Instance.Execute(currentControl);
3841
                                }
3842
                            }
3843
                        }
3844
                        break;
3845

    
3846
                    case ControlType.TextBorder:
3847
                        {
3848
                            if (e.LeftButton == MouseButtonState.Pressed)
3849
                            {
3850
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3851
                                {
3852
                                    currentControl = new TextControl
3853
                                    {
3854
                                        ControlType = controlType
3855
                                    };
3856

    
3857
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3858
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3859
                                    currentControl.CommentID = Commons.shortGuid();
3860
                                    currentControl.IsNew = true;
3861
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3862
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3863
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3864
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3865

    
3866
                                    (currentControl as TextControl).ControlType_No = 1;
3867
                                    (currentControl as TextControl).CommentAngle = Ang;
3868
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3869
                                    (currentControl as TextControl).ApplyTemplate();
3870
                                    (currentControl as TextControl).Base_TextBox.Focus();
3871
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3872
                                    CreateCommand.Instance.Execute(currentControl);
3873
                                }
3874
                            }
3875
                        }
3876
                        break;
3877

    
3878
                    case ControlType.TextCloud:
3879
                        {
3880
                            if (e.LeftButton == MouseButtonState.Pressed)
3881
                            {
3882
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3883
                                {
3884
                                    currentControl = new TextControl
3885
                                    {
3886
                                        ControlType = controlType
3887
                                    };
3888

    
3889
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3890
                                    currentControl.CommentID = Commons.shortGuid();
3891
                                    currentControl.IsNew = true;
3892
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3893
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3894

    
3895
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3896
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3897
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3898

    
3899
                                    (currentControl as TextControl).CommentAngle = Ang;
3900
                                    (currentControl as TextControl).ControlType_No = 2;
3901
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3902
                                    (currentControl as TextControl).ApplyTemplate();
3903

    
3904
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3905

    
3906
                                    (currentControl as TextControl).Base_TextBox.Focus();
3907
                                    CreateCommand.Instance.Execute(currentControl);
3908
                                    
3909
                                    //currentControl = null;
3910
                                }
3911
                            }
3912
                        }
3913
                        break;
3914

    
3915
                    case ControlType.ArrowTextControl:
3916
                        {
3917
                            if (e.LeftButton == MouseButtonState.Pressed)
3918
                            {
3919
                                if (currentControl is ArrowTextControl)
3920
                                {
3921
                                    //20180906 LJY TEST IsRotationDrawingEnable
3922
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3923
                                    {
3924
                                        return;
3925
                                    }
3926

    
3927
                                    CreateCommand.Instance.Execute(currentControl);
3928

    
3929
                                    try
3930
                                    {
3931
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3932
                                        {
3933
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3934
                                        }
3935
                                    }
3936
                                    catch (Exception ex)
3937
                                    {
3938
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3939
                                    }
3940

    
3941
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3942
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3943
                                    (currentControl as ArrowTextControl).IsNew = false;
3944
                                    currentControl = null;
3945
                                }
3946
                                else
3947
                                {
3948
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3949
                                    //{
3950
                                    currentControl = new ArrowTextControl()
3951
                                    {
3952
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3953
                                    };
3954

    
3955
                                    currentControl.CommentID = Commons.shortGuid();
3956
                                    currentControl.IsNew = true;
3957
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3958

    
3959
                                    try
3960
                                    {
3961
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3962
                                    }
3963
                                    catch (Exception ex)
3964
                                    {
3965
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3966
                                    }
3967

    
3968
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3969
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3970
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3971
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3972
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3973

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

    
3977
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3978
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3979
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3980
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3981

    
3982
                                    //}
3983
                                }
3984
                            }
3985
                        }
3986
                        break;
3987

    
3988
                    case ControlType.ArrowTransTextControl:
3989
                        {
3990
                            if (e.LeftButton == MouseButtonState.Pressed)
3991
                            {
3992
                                if (currentControl is ArrowTextControl)
3993
                                {
3994
                                    //20180906 LJY TEST IsRotationDrawingEnable
3995
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3996
                                    {
3997
                                        return;
3998
                                    }
3999

    
4000
                                    CreateCommand.Instance.Execute(currentControl);
4001

    
4002
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4003

    
4004
                                    currentControl.IsNew = false;
4005
                                    currentControl = null;
4006
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4007
                                }
4008
                                else
4009
                                {
4010
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4011
                                    //{
4012
                                    currentControl = new ArrowTextControl()
4013
                                    {
4014
                                        ControlType = ControlType.ArrowTransTextControl,
4015
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4016
                                    };
4017
                                    currentControl.CommentID = Commons.shortGuid();
4018
                                    currentControl.IsNew = true;
4019
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4020
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4021
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4022
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4023
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4024
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4025
                                    (currentControl as ArrowTextControl).isFixed = true;
4026
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4027

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

    
4031
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4032
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4033
                                    (currentControl as ArrowTextControl).isTrans = true;
4034
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4035
                                }
4036
                            }
4037
                        }
4038
                        break;
4039

    
4040
                    case ControlType.ArrowTextBorderControl:
4041
                        {
4042
                            if (e.LeftButton == MouseButtonState.Pressed)
4043
                            {
4044
                                if (currentControl is ArrowTextControl)
4045
                                {
4046
                                    //20180906 LJY TEST IsRotationDrawingEnable
4047
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4048
                                    {
4049
                                        return;
4050
                                    }
4051

    
4052
                                    CreateCommand.Instance.Execute(currentControl);
4053
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4054
                                    currentControl.IsNew = false;
4055
                                    currentControl = null;
4056
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4057
                                }
4058
                                else
4059
                                {
4060
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4061
                                    //{
4062
                                    currentControl = new ArrowTextControl()
4063
                                    {
4064
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4065
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4066
                                    };
4067
                                    currentControl.CommentID = Commons.shortGuid();
4068
                                    currentControl.IsNew = true;
4069
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4070
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4071

    
4072
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4073

    
4074
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4075

    
4076
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4077
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4078
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4079
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4080
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4081
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4082
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4083
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4084
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4085
                                    //}
4086
                                }
4087
                            }
4088
                        }
4089
                        break;
4090

    
4091
                    case ControlType.ArrowTransTextBorderControl:
4092
                        {
4093
                            if (e.LeftButton == MouseButtonState.Pressed)
4094
                            {
4095
                                if (currentControl is ArrowTextControl)
4096
                                {
4097
                                    //20180906 LJY TEST IsRotationDrawingEnable
4098
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4099
                                    {
4100
                                        return;
4101
                                    }
4102
                                    CreateCommand.Instance.Execute(currentControl);
4103
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4104
                                    currentControl.IsNew = false;
4105
                                    currentControl = null;
4106

    
4107
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4108
                                }
4109
                                else
4110
                                {
4111
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4112
                                    //{
4113
                                    currentControl = new ArrowTextControl()
4114
                                    {
4115
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4116
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4117
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4118
                                    };
4119
                                    
4120
                                    currentControl.CommentID = Commons.shortGuid();
4121
                                    currentControl.IsNew = true;
4122
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4123
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4124

    
4125
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4126

    
4127
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4128
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4129
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4130
                                    (currentControl as ArrowTextControl).isFixed = true;
4131
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4132

    
4133
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4134
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4135
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4136
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4137
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4138
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4139

    
4140
                                    //20180911 LJY
4141
                                    (currentControl as ArrowTextControl).isTrans = true;
4142

    
4143
                                    //}
4144
                                }
4145
                            }
4146
                        }
4147
                        break;
4148

    
4149
                    case ControlType.ArrowTextCloudControl:
4150
                        {
4151
                            if (e.LeftButton == MouseButtonState.Pressed)
4152
                            {
4153
                                if (currentControl is ArrowTextControl)
4154
                                {
4155
                                    //20180906 LJY TEST IsRotationDrawingEnable
4156
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4157
                                    {
4158
                                        return;
4159
                                    }
4160
                                    CreateCommand.Instance.Execute(currentControl);
4161
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4162
                                    currentControl.IsNew = false;
4163
                                    currentControl = null;
4164
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4165
                                }
4166
                                else
4167
                                {
4168
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4169
                                    //{
4170
                                    currentControl = new ArrowTextControl()
4171
                                    {
4172
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4173
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4174
                                        ControlType = ControlType.ArrowTextCloudControl
4175
                                    };
4176
                                    currentControl.CommentID = Commons.shortGuid();
4177
                                    currentControl.IsNew = true;
4178
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4179
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4180

    
4181
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4182
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4183
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4184
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4185
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4186
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4187
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4188
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4189

    
4190
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4191
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4192
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4193
                                    //}
4194
                                }
4195
                            }
4196
                        }
4197
                        break;
4198

    
4199
                    case ControlType.ArrowTransTextCloudControl:
4200
                        {
4201
                            if (e.LeftButton == MouseButtonState.Pressed)
4202
                            {
4203
                                if (currentControl is ArrowTextControl)
4204
                                {
4205
                                    //20180906 LJY TEST IsRotationDrawingEnable
4206
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4207
                                    {
4208
                                        return;
4209
                                    }
4210
                                    CreateCommand.Instance.Execute(currentControl);
4211
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4212
                                    currentControl.IsNew = false;
4213
                                    currentControl = null;
4214
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4215
                                }
4216
                                else
4217
                                {
4218
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4219
                                    //{
4220
                                    currentControl = new ArrowTextControl()
4221
                                    {
4222
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4223
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4224
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4225
                                    };
4226
                                    currentControl.CommentID = Commons.shortGuid();
4227
                                    currentControl.IsNew = true;
4228
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4229
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4230
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4231

    
4232
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4233
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4234
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4235
                                    (currentControl as ArrowTextControl).isFixed = true;
4236
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4237

    
4238
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4239
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4240
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4241
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4242
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4243
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4244

    
4245
                                    //20180911 LJY
4246
                                    (currentControl as ArrowTextControl).isTrans = true;
4247
                                    //}
4248
                                }
4249
                            }
4250
                        }
4251
                        break;
4252
                    //강인구 추가
4253
                    case ControlType.Sign:
4254
                        {
4255
                            if (e.LeftButton == MouseButtonState.Pressed)
4256
                            {
4257
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4258
                                //{
4259
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4260

    
4261
                                if (_sign == null)
4262
                                {
4263
                                    txtBatch.Visibility = Visibility.Collapsed;
4264
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4265
                                    controlType = ControlType.None;
4266

    
4267
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4268
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4269
                                    return;
4270
                                }
4271
                                else
4272
                                {
4273
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4274
                                    {
4275
                                        Application.Current.Resources.Add("UserSign", _sign);
4276
                                    }
4277
                                    else
4278
                                    {
4279
                                        Application.Current.Resources["UserSign"] = _sign;
4280
                                    }
4281
                                }
4282

    
4283
                                if (currentControl is SignControl)
4284
                                {
4285
                                    //20180906 LJY TEST IsRotationDrawingEnable
4286
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4287
                                    {
4288
                                        return;
4289
                                    }
4290

    
4291
                                    CreateCommand.Instance.Execute(currentControl);
4292
                                    currentControl = null;
4293
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4294
                                    {
4295
                                        txtBatch.Text = "Place Date";
4296
                                        controlType = ControlType.Date;
4297
                                    }
4298
                                }
4299
                                else
4300
                                {
4301
                                    currentControl = new SignControl
4302
                                    {
4303
                                        Background = new SolidColorBrush(Colors.Black),
4304
                                        UserNumber = App.ViewInfo.UserID,
4305
                                        ProjectNO = App.ViewInfo.ProjectNO,
4306
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4307
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4308
                                        ControlType = ControlType.Sign
4309
                                    };
4310

    
4311
                                    currentControl.CommentID = Commons.shortGuid();
4312
                                    currentControl.IsNew = true;
4313
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4314
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4315

    
4316
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4317
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4318
                                }
4319
                                //}
4320
                            }
4321
                        }
4322
                        break;
4323

    
4324
                    case ControlType.Mark:
4325
                        {
4326
                            if (e.LeftButton == MouseButtonState.Pressed)
4327
                            {
4328
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4329
                                //{
4330
                                if (currentControl is RectangleControl)
4331
                                {
4332
                                    //20180906 LJY TEST IsRotationDrawingEnable
4333
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4334
                                    {
4335
                                        return;
4336
                                    }
4337

    
4338
                                    CreateCommand.Instance.Execute(currentControl);
4339
                                    (currentControl as RectangleControl).ApplyOverViewData();
4340
                                    currentControl = null;
4341

    
4342
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4343

    
4344
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4345
                                    {
4346
                                        txtBatch.Text = "Place Signature";
4347
                                        controlType = ControlType.Sign;
4348
                                    }
4349
                                }
4350
                                else
4351
                                {
4352
                                    currentControl = new RectangleControl
4353
                                    {
4354
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4355
                                        Background = new SolidColorBrush(Colors.Black),
4356
                                        ControlType = ControlType.Mark,
4357
                                        Paint = PaintSet.Fill
4358
                                    };
4359

    
4360
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4361
                                    currentControl.CommentID = Commons.shortGuid();
4362
                                    currentControl.IsNew = true;
4363
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4364
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4365
                                }
4366
                                //}
4367
                            }
4368
                        }
4369
                        break;
4370

    
4371
                    case ControlType.Symbol:
4372
                        {
4373
                            if (e.LeftButton == MouseButtonState.Pressed)
4374
                            {
4375
                                if (currentControl is SymControl)
4376
                                {
4377
                                    //20180906 LJY TEST IsRotationDrawingEnable
4378
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4379
                                    {
4380
                                        return;
4381
                                    }
4382
                                    CreateCommand.Instance.Execute(currentControl);
4383
                                    currentControl = null;
4384

    
4385
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4386
                                }
4387
                                else
4388
                                {
4389
                                    currentControl = new SymControl
4390
                                    {
4391
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4392
                                        Background = new SolidColorBrush(Colors.Black),
4393
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4394
                                        ControlType = ControlType.Symbol
4395
                                    };
4396

    
4397
                                    currentControl.IsNew = true;
4398
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4399
                                    currentControl.CommentID = Commons.shortGuid();
4400
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4401

    
4402
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4403
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4404
                                }
4405
                                //}
4406
                            }
4407
                        }
4408
                        break;
4409

    
4410
                    case ControlType.Stamp:
4411
                        {
4412
                            if (e.LeftButton == MouseButtonState.Pressed)
4413
                            {
4414
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4415
                                //{
4416
                                if (currentControl is SymControlN)
4417
                                {
4418
                                    //20180906 LJY TEST IsRotationDrawingEnable
4419
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4420
                                    {
4421
                                        return;
4422
                                    }
4423

    
4424
                                    CreateCommand.Instance.Execute(currentControl);
4425
                                    currentControl = null;
4426

    
4427
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4428
                                }
4429
                                else
4430
                                {
4431
                                    currentControl = new SymControlN
4432
                                    {
4433
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4434
                                        Background = new SolidColorBrush(Colors.Black),
4435
                                        STAMP = App.SystemInfo.STAMP,
4436
                                        ControlType = ControlType.Stamp
4437
                                    };
4438

    
4439
                                    currentControl.IsNew = true;
4440
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4441
                                    currentControl.CommentID = Commons.shortGuid();
4442
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4443
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4444
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4445
                                }
4446
                                //}
4447
                            }
4448
                        }
4449
                        break;
4450

    
4451
                    case ControlType.PenControl:
4452
                        {
4453
                            if (inkBoard.Tag.ToString() == "Ink")
4454
                            {
4455
                                inkBoard.IsEnabled = true;
4456
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4457
                            }
4458
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4459
                            {
4460
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4461
                            }
4462
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4463
                            {
4464
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4465
                            }
4466
                            IsDrawing = true;
4467
                            return;
4468
                        }
4469
                    default:
4470
                        if (currentControl != null)
4471
                        {
4472
                            currentControl.CommentID = null;
4473
                            currentControl.IsNew = false;
4474
                        }
4475
                        break;
4476
                }
4477

    
4478
                try
4479
                {
4480
                    if (currentControl is ITextControl)
4481
                    {
4482
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4483

    
4484
                        if(textBox.Count() > 0)
4485
                        {
4486
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4487
                            specialcharRemove.Attach(textBox.First());
4488
                        }
4489
                        else
4490
                        {
4491

    
4492
                        }
4493

    
4494
                    }
4495
                }
4496
                catch (Exception ex)
4497
                {
4498
                    System.Diagnostics.Debug.WriteLine(ex);
4499

    
4500
                }
4501

    
4502
                if (currentControl is ArrowTextControl)
4503
                {
4504
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4505
                    {
4506
                        var control = snd as ArrowTextControl;
4507

    
4508
                        if (string.IsNullOrEmpty(control.ArrowText))
4509
                        {
4510
                            DeleteCommand.Instance.Execute(new [] { control });
4511
                        }
4512
                    };
4513

    
4514
                }
4515

    
4516
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4517
                {
4518
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4519
                    {
4520
                        MacroHelper.MacroAction();
4521
                    }
4522
                    //if (currentControl.ControlType)
4523
                    //txtBatch.Text = "Draw a TextBox";
4524
                    //controlType = ControlType.ArrowTextBorderControl;
4525
                }
4526

    
4527
                //if (currentControl != null)
4528
                //{
4529
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4530
                //}
4531
            }
4532
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4533
            {
4534
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4535
             
4536

    
4537
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4538
                {
4539
                    bool mouseOff = false;
4540
                    foreach (var item in SelectLayer.Children)
4541
                    {
4542
                        if (item is AdornerFinal)
4543
                        {
4544
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4545
                            if (over != null)
4546
                            {
4547
                                mouseOff = true;
4548
                            }
4549
                        }
4550
                    }
4551

    
4552
                    if (!mouseOff)
4553
                    {
4554
                        SelectionSet.Instance.UnSelect(this);
4555
                    }
4556
                }
4557
                zoomAndPanControl.CaptureMouse();
4558
                e.Handled = true;
4559
            }
4560
        }
4561

    
4562
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4563
        {
4564
            ///mouseButtonDown = e.ChangedButton;
4565
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4566
        }
4567

    
4568
        private void RemoveLineStroke(Point P)
4569
        {
4570
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4571
            if (control != null)
4572
            {
4573
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4574
            }
4575
        }
4576

    
4577
        private void RemovePointStroke(Point P)
4578
        {
4579
            foreach (Stroke hits in inkBoard.Strokes)
4580
            {
4581
                foreach (StylusPoint sty in hits.StylusPoints)
4582
                {
4583
                }
4584
                if (hits.HitTest(P))
4585
                {
4586
                    inkBoard.Strokes.Remove(hits);
4587
                    return;
4588
                }
4589
            }
4590
        }
4591

    
4592
        private void StartNewStroke(Point P)
4593
        {
4594
            strokePoints = new StylusPointCollection();
4595
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4596
            strokePoints.Add(segment1Start);
4597
            stroke = new Stroke(strokePoints);
4598

    
4599
            stroke.DrawingAttributes.Color = Colors.Red;
4600
            stroke.DrawingAttributes.Width = 4;
4601
            stroke.DrawingAttributes.Height = 4;
4602

    
4603
            inkBoard.Strokes.Add(stroke);
4604
        }
4605

    
4606
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4607
        {
4608
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4609
            //// update mylist and gridview
4610
            //this.UpdateMyMarkupList();
4611

    
4612
            //bool result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4613

    
4614
            //if (result)
4615
            //{
4616
                btnFinalPDF.IsEnabled = false;
4617

    
4618
              await  ConsolidationMethod();
4619
            //}
4620
            //else
4621
            //{
4622
            //    MessageBox.Show("오류");
4623
            //}
4624
        }
4625

    
4626
        /// <summary>
4627
        /// execute TeamConsolidationCommand
4628
        /// </summary>
4629
        public void TeamConsolidationMethod2()
4630
        {
4631
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4632
            {
4633
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4634
            }
4635
            else
4636
            {
4637

    
4638
                ViewerDataModel.Instance.IsConsolidate = true;
4639
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4640
                // update mylist and gridview
4641
        
4642
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommand(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4643
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4644
                ViewerDataModel.Instance.IsConsolidate = false;
4645
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4646
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4647
                {
4648
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4649
                    {
4650
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4651
                        return;
4652
                    }
4653
                }
4654
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4655
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4656
                {
4657
                    MarkupInfoList.Add(item);
4658
                }
4659

    
4660
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4661
            }
4662
        }
4663
        public async void TeamConsolidationMethod()
4664
        {
4665
            bool result = false;
4666

    
4667
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4668
            {
4669
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4670
            }
4671
            else
4672
            {
4673
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4674
                {
4675
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4676
                    {
4677
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4678
                    }
4679
                }
4680

    
4681
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4682

    
4683
                if (isSave)
4684
                {
4685
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4686

    
4687
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4688
                     
4689
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4690
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4691
                    {
4692
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4693
                    }
4694

    
4695
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4696
                    result = true;
4697
                }
4698
            }
4699
        }
4700

    
4701
        public async Task<bool> ConsolidationMethod()
4702
        {
4703
            bool result = false;
4704

    
4705
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4706
            {
4707
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4708
            }
4709
            else
4710
            {
4711
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4712

    
4713
                if (isSave)
4714
                {
4715
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4716
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4717

    
4718
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4719
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4720
                    {
4721
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4722
                    }
4723
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4724

    
4725
                    result = ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4726
                }
4727
            }
4728

    
4729
            return result;
4730
        }
4731

    
4732
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4733
        {
4734
            if (App.ViewInfo != null)
4735
            {
4736
                btnConsolidate = (sender as RadRibbonButton);
4737
                if (!App.ViewInfo.NewCommentPermission)
4738
                {
4739
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4740
                }
4741
            }
4742
        }
4743

    
4744
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4745
        {
4746
            TeamConsolidationMethod();
4747
        }
4748

    
4749
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4750
        {
4751
            btnTeamConsolidate = sender as RadRibbonButton;
4752
            if (App.ViewInfo != null)
4753
            {
4754
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4755
                {
4756
                    if (btnConsolidate != null)
4757
                    {
4758
                        btnConsolidate.Visibility = Visibility.Collapsed;
4759
                    }
4760

    
4761
                    if (!App.ViewInfo.NewCommentPermission)
4762
                    {
4763
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4764
                    }
4765
                }
4766
                else
4767
                {
4768
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4769
                }
4770
            }
4771
        }
4772

    
4773
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4774
        {
4775
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4776
            // update mylist and gridview
4777
            this.UpdateMyMarkupList();
4778

    
4779
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4780

    
4781
            if(!result)
4782
            {
4783

    
4784
            }
4785
            else
4786
            {
4787
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4788

    
4789
                if (item != null)
4790
                {
4791
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4792
                    {
4793
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4794

    
4795
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4796

    
4797
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4798
                    }
4799
                    else
4800
                    {
4801
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4802
                    }
4803
                }
4804
                else
4805
                {
4806
                    //Consolidate 가 없는 경우
4807
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4808
                }
4809
            }
4810

    
4811
        }
4812

    
4813
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4814
        {
4815
            btnFinalPDF = sender as RadRibbonButton;
4816
            if (App.ViewInfo != null)
4817
            {
4818
                //btnFinalPDF.IsEnabled = false;
4819

    
4820
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4821
                {
4822
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4823
                    if (btnConsolidate != null)
4824
                    {
4825
                        btnConsolidate.Visibility = Visibility.Collapsed;
4826
                    }
4827
                }
4828
            }
4829
        }
4830

    
4831
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4832
        {
4833
            //UpdateMyMarkupList();
4834

    
4835
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4836
            {
4837
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4838
            }
4839
            else
4840
            {
4841
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4842
                //{
4843
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4844
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4845
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4846

    
4847
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4848
                //// update mylist and gridview
4849
                //this.UpdateMyMarkupList();
4850

    
4851
                //var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4852

    
4853
                Mouse.SetCursor(Cursors.Wait);
4854

    
4855
                bool result = await ConsolidationMethod();
4856

    
4857
                System.Threading.Thread.Sleep(500);
4858

    
4859
                if (result)
4860
                {
4861
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4862

    
4863
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4864
                    if (item2 != null)
4865
                    {
4866
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4867
                        {
4868
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4869

    
4870
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4871
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4872

    
4873
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4874

    
4875
                            Mouse.SetCursor(Cursors.Arrow);
4876
                        }
4877
                        else
4878
                        {
4879
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4880
                        }
4881
                    }
4882
                    else
4883
                    {
4884
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4885
                    }
4886
                }
4887
                else
4888
                {
4889
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4890
                }
4891

    
4892
                Mouse.SetCursor(Cursors.Arrow);
4893
            }
4894
        }
4895

    
4896
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4897
        {
4898
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4899
#if Hyosung
4900
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4901
#else
4902

    
4903
            //btnConsolidateFinalPDF.IsEnabled = false;
4904

    
4905
            if (App.ViewInfo != null)
4906
            {
4907
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4908
                {
4909
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4910
                }
4911
            }
4912
#endif
4913
        }
4914

    
4915
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4916
        {
4917
            SetCompareRect();
4918
        }
4919

    
4920
        private void Sync_Click(object sender, RoutedEventArgs e)
4921
        {
4922
            if (Sync.IsChecked)
4923
            {
4924
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4925
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4926
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4927
            }
4928
        }
4929

    
4930
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4931
        {
4932
            if (UserList.IsChecked)
4933
            {
4934
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4935
            }
4936
            else
4937
            {
4938
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4939
            }
4940
        }
4941

    
4942
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4943
        {
4944
            if (BalanceMode.IsChecked)
4945
            {
4946
                ViewerDataModel.Instance.PageBalanceMode = true;
4947
            }
4948
            else
4949
            {
4950
                ViewerDataModel.Instance.PageBalanceMode = false;
4951
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4952
            }
4953
        }
4954

    
4955
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4956
        {
4957
            //초기화
4958
            testPanel2.IsHidden = true;
4959
            ViewerDataModel.Instance.PageBalanceMode = false;
4960
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4961
            ViewerDataModel.Instance.SyncPageNumber = 0;
4962
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4963
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4964
            UserList.IsChecked = false;
4965
            BalanceMode.IsChecked = false;
4966
        }
4967

    
4968
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4969
        {
4970
            if ((sender as System.Windows.Controls.Control).Tag != null)
4971
            {
4972
                //Compare 초기화
4973
                CompareMode.IsChecked = false;
4974
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4975
                
4976
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4977
                {
4978
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4979
                }
4980

    
4981
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4982
                {
4983
                }
4984
                else
4985
                {
4986
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4987
                }
4988

    
4989
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
4990
                {
4991
                }
4992
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
4993
                {
4994
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
4995
                }
4996

    
4997
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4998

    
4999
                if (!testPanel2.IsHidden)
5000
                {
5001
                    if (IsSyncPDFMode)
5002
                    {
5003
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5004
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5005

    
5006
                        if (pdfpath.IsDownloading)
5007
                        {
5008
                            pdfpath.DownloadCompleted += (ex, arg) =>
5009
                            {
5010
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5011
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5012
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5013
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5014
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5015
                            };
5016
                        }
5017
                        else
5018
                        {
5019
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5020
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5021
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5022

    
5023
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5024
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5025
                        }
5026
                    }
5027
                    else
5028
                    {
5029
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5030

    
5031
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5032
                        ComparePageLoad(uri, isOriginalSize);
5033
                    }
5034
                   
5035
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5036
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5037
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5038

    
5039
                    foreach (var item in gridSelectionRevItem)
5040
                    {
5041
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5042
                        foreach (var markupitem in markupitems)
5043
                        {
5044
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5045
                        }
5046
                    }
5047

    
5048
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5049
                }
5050
            }
5051
        }
5052

    
5053
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5054
        {
5055
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5056

    
5057
            double translateX = 0;
5058
            double translateY = 0;
5059
            double angle = rotate2.Angle;
5060

    
5061
            if (direction == 1)
5062
            {
5063
                if (angle < 270)
5064
                {
5065
                    angle += 90;
5066
                }
5067
                else
5068
                {
5069
                    angle = 0;
5070
                }
5071
            }
5072
            else
5073
            {
5074
                if (angle > 0)
5075
                {
5076
                    angle -= 90;
5077
                }
5078
                else
5079
                {
5080
                    angle = 270;
5081
                }
5082
            }
5083
            zoomAndPanControl2.RotationAngle = angle;
5084
            zoomAndPanControl2.ScaleToFit();
5085

    
5086
            //if (angle == 90 || angle == 270)
5087
            //{
5088
                double emptySize = zoomAndPanCanvas2.Width;
5089
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5090
                zoomAndPanCanvas2.Height = emptySize;
5091
            //}
5092

    
5093
            if (angle == 90)
5094
            {
5095
                translateX = zoomAndPanCanvas2.Width;
5096
                translateY = 0;
5097
            }
5098
            else if (angle == 180)
5099
            {
5100
                translateX = zoomAndPanCanvas2.Width;
5101
                translateY = zoomAndPanCanvas2.Height;
5102
            }
5103
            else if (angle == 270)
5104
            {
5105
                translateX = 0;
5106
                translateY = zoomAndPanCanvas2.Height;
5107
            }
5108
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5109
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5110
            translate2.X = translateX;
5111
            translate2.Y = translateY;
5112
            rotate2.Angle = angle;
5113
            //translate2CompareBorder.X = translateX;
5114
            //translate2CompareBorder.Y = translateY;
5115
            //rotate2CompareBorder.Angle = angle;
5116

    
5117
        }
5118

    
5119
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5120
        {
5121
            if (MarkupMode.IsChecked)
5122
            {
5123
                IsSyncPDFMode = true;
5124

    
5125
                var uri = CurrentRev.TO_VENDOR;
5126

    
5127
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5128
                {
5129
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5130
                }
5131

    
5132
                //PDF모드 잠시 대기(강인구)
5133
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5134
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5135

    
5136
                if (pdfpath.IsDownloading)
5137
                {
5138
                    pdfpath.DownloadCompleted += (ex, arg) =>
5139
                    {
5140
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5141
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5142
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5143
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5144
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5145
                    };
5146
                }
5147
                else
5148
                {
5149
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5150
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5151
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5152

    
5153
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5154
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5155
                }
5156
            }
5157
            else
5158
            {
5159
                IsSyncPDFMode = false;
5160
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5161

    
5162
                ComparePageLoad(uri,false);
5163

    
5164
                zoomAndPanControl2.ApplyTemplate();
5165
                zoomAndPanControl2.UpdateLayout();
5166
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5167
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5168
            }
5169
        }
5170

    
5171
        /// <summary>
5172
        /// Compare된 영역을 초기화
5173
        /// </summary>
5174
        private void ClearCompareRect()
5175
        {
5176
            da.From = 1;
5177
            da.To = 1;
5178
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5179
            da.AutoReverse = false;
5180
            canvas_compareBorder.Children.Clear();
5181
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5182
        }
5183

    
5184
        /// <summary>
5185
        /// 문서 Comprare
5186
        /// </summary>
5187
        private void SetCompareRect()
5188
        {
5189
            canvas_compareBorder.Children.Clear();
5190

    
5191
            if (CompareMode.IsChecked)
5192
            {
5193
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5194
                {
5195
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5196
                }
5197
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5198
                {
5199
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5200
                }
5201

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

    
5204
                /// 비교대상원본, 비교할 대상
5205
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5206
            }
5207
            else
5208
            {
5209
                canvas_compareBorder.Visibility = Visibility.Hidden;
5210
                ClearCompareRect();
5211
            }
5212
        }
5213

    
5214
        private void btnSync_Click(object sender, RoutedEventArgs e)
5215
        {
5216
            gridViewHistory_Busy.IsBusy = true;
5217

    
5218
            RadButton instance = sender as RadButton;
5219
            if (instance.CommandParameter != null)
5220
            {
5221
                CurrentRev = instance.CommandParameter as VPRevision;
5222
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5223

    
5224
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5225
                {
5226
                    if (ea.Error == null && ea.Result != null)
5227
                    {
5228
                        testPanel2.IsHidden = false;
5229

    
5230
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5231
                        foreach (var info in ea.Result)
5232
                        {
5233
                            if (info.UserID == App.ViewInfo.UserID)
5234
                            {
5235
                                info.userDelete = true;
5236
                                info.DisplayColor = "#FFFF0000";
5237
                            }
5238
                            else
5239
                            {
5240
                                info.userDelete = false;
5241
                            }
5242
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5243
                        }
5244
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5245

    
5246
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5247
                        ComparePageLoad(uri,false);
5248

    
5249
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5250

    
5251
                        zoomAndPanControl2.ApplyTemplate();
5252
                        zoomAndPanControl2.UpdateLayout();
5253

    
5254
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5255
                        {
5256
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5257
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5258
                        }
5259

    
5260
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5261
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5262
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5263

    
5264
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5265
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5266

    
5267
                        zoomAndPanControl.ScaleToFit();
5268
                        zoomAndPanControl2.ScaleToFit();
5269

    
5270
                        gridViewHistory_Busy.IsBusy = false;
5271
                    }
5272

    
5273
                    //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5274

    
5275
                    if (GetSyncMarkupInfoItemshandler != null)
5276
                    {
5277
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5278
                    }
5279

    
5280
                    //ClearCompareRect();
5281
                    SetCompareRect();
5282
                };
5283

    
5284
                /// 중복 실행이 발생하여 수정함.
5285
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5286
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5287

    
5288
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5289
            }
5290
        }
5291

    
5292
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5293
        {
5294
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5295
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5296

    
5297
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5298
        }
5299

    
5300
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5301
        {
5302
            try
5303
            {
5304
                if (sender is RadButton)
5305
                {
5306
                    if ((sender as RadButton).Tag != null)
5307
                    {
5308
                        var url = (sender as RadButton).Tag.ToString();
5309
                        System.Diagnostics.Process.Start(url);
5310
                    }
5311
                    else
5312
                    {
5313
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5314
                    }
5315
                }
5316
            }
5317
            catch (Exception ex)
5318
            {
5319
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5320
            }
5321
        }
5322

    
5323
        public void Sync_Event(VPRevision Currnet_Rev)
5324
        {
5325
            CurrentRev = Currnet_Rev;
5326

    
5327
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5328
            {
5329
                if (ea.Error == null && ea.Result != null)
5330
                {
5331
                    testPanel2.IsHidden = false;
5332

    
5333
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5334
                    foreach (var info in ea.Result)
5335
                    {
5336
                        if (info.UserID == App.ViewInfo.UserID)
5337
                        {
5338
                            info.userDelete = true;
5339
                            info.DisplayColor = "#FFFF0000";
5340
                        }
5341
                        else
5342
                        {
5343
                            info.userDelete = false;
5344
                        }
5345
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5346
                    }
5347
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5348

    
5349
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5350

    
5351
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5352

    
5353
                    ComparePageLoad(uri,false);
5354

    
5355
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5356
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5357
                    zoomAndPanControl2.ApplyTemplate();
5358
                    zoomAndPanControl2.UpdateLayout();
5359

    
5360
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5361
                    {
5362
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5363
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5364
                    }
5365
                    //}
5366
                    
5367
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5368
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5369
                    gridViewHistory_Busy.IsBusy = false;
5370
                }
5371
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5372
            };
5373
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5374
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5375
        }
5376

    
5377
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5378
        {
5379
            if (sender is Image)
5380
            {
5381
                if ((sender as Image).Tag != null)
5382
                {
5383
                    var pdfUrl = (sender as Image).Tag.ToString();
5384
                    System.Diagnostics.Process.Start(pdfUrl);
5385
                }
5386
                else
5387
                {
5388
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5389
                }
5390
            }
5391
        }
5392

    
5393
        private void Create_Symbol(object sender, RoutedEventArgs e)
5394
        {
5395
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5396

    
5397
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5398
            {
5399
                DialogMessage_Alert("Please Select Controls", "Alert");
5400
            }
5401
            else //선택된 것이 있으면
5402
            {
5403
                string MarkupData = "";
5404
                adorner_ = new AdornerFinal();
5405

    
5406
                foreach (var item in SelectLayer.Children)
5407
                {
5408
                    if (item.GetType().Name == "AdornerFinal")
5409
                    {
5410
                        adorner_ = (item as Controls.AdornerFinal);
5411
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5412
                        {
5413
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5414
                            {
5415
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5416
                                MarkupData += markupReturn.ConvertData;
5417
                            }
5418
                        }
5419
                    }
5420
                }
5421
                DialogParameters parameters = new DialogParameters()
5422
                {
5423
                    Owner = Application.Current.MainWindow,
5424
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5425
                    DefaultPromptResultValue = "Custom State",
5426
                    Content = "Name :",
5427
                    Header = "Insert Custom Symbol Name",
5428
                    Theme = new VisualStudio2013Theme(),
5429
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5430
                };
5431
                RadWindow.Prompt(parameters);
5432
            }
5433
        }
5434

    
5435
        public int symbolselectindex = 0;
5436

    
5437
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5438
        {
5439
            //Save save = new Save();
5440
            try
5441
            {
5442
                string svgfilename = null;
5443
                if (symbolname != null)
5444
                {
5445
                    if (symbolpng == true || symbolsvg == true)
5446
                    {
5447
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5448
                        string guid = Commons.shortGuid();
5449

    
5450
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5451
                        //Check_Uri.UriCheck();
5452
                        fileUploader.RunCompleted += (ex, arg) =>
5453
                        {
5454
                            filename = arg.Result;
5455
                            if (symbolpng == true)
5456
                            {
5457
                                if (filename != null)
5458
                                {
5459
                                    if (symbolselectindex == 0)
5460
                                    {
5461
                                        SymbolSave(symbolname, filename, data);
5462
                                    }
5463
                                    else
5464
                                    {
5465
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5466
                                    }
5467
                                    DataBind();
5468
                                }
5469
                            }
5470

    
5471
                            if (symbolsvg == true)
5472
                            {
5473
                                try
5474
                                {
5475
                                    var defaultBitmapImage = new BitmapImage();
5476
                                    defaultBitmapImage.BeginInit();
5477
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5478
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5479
                                    Check_Uri.UriCheck(filename);
5480
                                    defaultBitmapImage.UriSource = new Uri(filename);
5481
                                    defaultBitmapImage.EndInit();
5482

    
5483
                                    System.Drawing.Bitmap image;
5484

    
5485
                                    if (defaultBitmapImage.IsDownloading)
5486
                                    {
5487
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5488
                                        {
5489
                                            defaultBitmapImage.Freeze();
5490
                                            image = GetBitmap(defaultBitmapImage);
5491
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5492
                                            Process potrace = new Process
5493
                                            {
5494
                                                StartInfo = new ProcessStartInfo
5495
                                                {
5496
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5497
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5498
                                                    RedirectStandardInput = true,
5499
                                                    RedirectStandardOutput = true,
5500
                                                    RedirectStandardError = true,
5501
                                                    UseShellExecute = false,
5502
                                                    CreateNoWindow = true,
5503
                                                    WindowStyle = ProcessWindowStyle.Hidden
5504
                                                },
5505
                                            };
5506

    
5507
                                            StringBuilder svgBuilder = new StringBuilder();
5508
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5509
                                            {
5510
                                                svgBuilder.AppendLine(e2.Data);
5511
                                            };
5512

    
5513
                                            potrace.EnableRaisingEvents = true;
5514
                                            potrace.Start();
5515
                                            potrace.Exited += (sender, e) =>
5516
                                            {
5517
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5518
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5519
                                                Check_Uri.UriCheck(svgfilename);
5520
                                                if (symbolselectindex == 0)
5521
                                                {
5522
                                                    SymbolSave(symbolname, svgfilename, data);
5523
                                                }
5524
                                                else
5525
                                                {
5526
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5527
                                                }
5528

    
5529
                                                DataBind();
5530
                                            };
5531
                                            potrace.WaitForExit();
5532
                                        };
5533
                                    }
5534
                                    else
5535
                                    {
5536
                                        //GC.Collect();
5537
                                    }
5538
                                }
5539
                                catch (Exception ee)
5540
                                {
5541
                                    DialogMessage_Alert("" + ee, "Alert");
5542
                                }
5543
                            }
5544
                        };
5545
                    }
5546
                }
5547
            }
5548
            catch (Exception e)
5549
            {
5550
                //DialogMessage_Alert(e + "", "Alert");
5551
            }
5552
        }
5553

    
5554
        public void SymbolSave(string Name, string Url, string Data)
5555
        {
5556
            try
5557
            {
5558
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5559
                {
5560
                    ID = Commons.shortGuid(),
5561
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5562
                    NAME = Name,
5563
                    IMAGE_URL = Url,
5564
                    DATA = Data
5565
                };
5566

    
5567
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5568
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5569
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5570
            }
5571
            catch (Exception)
5572
            {
5573
                throw;
5574
            }
5575
        }
5576

    
5577
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5578
        {
5579
            try
5580
            {
5581
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5582
                {
5583
                    ID = Commons.shortGuid(),
5584
                    DEPARTMENT = Department,
5585
                    NAME = Name,
5586
                    IMAGE_URL = Url,
5587
                    DATA = Data
5588
                };
5589
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5590
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5591
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5592
            }
5593
            catch (Exception)
5594
            {
5595
                throw;
5596
            }
5597
        }
5598

    
5599
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5600
        {
5601
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5602
            DataBind();
5603
        }
5604

    
5605
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5606
        {
5607
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5608
            DataBind();
5609
        }
5610

    
5611
        private void DataBind()
5612
        {
5613
            try
5614
            {
5615
                Symbol_Custom Custom = new Symbol_Custom();
5616
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5617

    
5618
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5619
                foreach (var item in symbol_Private)
5620
                {
5621
                    Custom.Name = item.NAME;
5622
                    Custom.ImageUri = item.IMAGE_URL;
5623
                    Custom.ID = item.ID;
5624
                    Custom_List.Add(Custom);
5625
                    Custom = new Symbol_Custom();
5626
                }
5627
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5628

    
5629
                Custom = new Symbol_Custom();
5630
                Custom_List = new List<Symbol_Custom>();
5631

    
5632
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5633

    
5634
                List<SYMBOL_PUBLIC> symbol_Public;
5635

    
5636
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5637
                {
5638
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5639
                }
5640
                else
5641
                {
5642
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5643
                }
5644
                foreach (var item in symbol_Public)
5645
                {
5646
                    Custom.Name = item.NAME;
5647
                    Custom.ImageUri = item.IMAGE_URL;
5648
                    Custom.ID = item.ID;
5649
                    Custom_List.Add(Custom);
5650
                    Custom = new Symbol_Custom();
5651
                }
5652
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5653
                BaseClient.Close();
5654
            }
5655
            catch (Exception e)
5656
            {
5657
                //DialogMessage_Alert("DataBind", "Alert");
5658
            }
5659
        }
5660

    
5661
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5662
        {
5663
            try
5664
            {
5665
                if (args.PromptResult != null)
5666
                {
5667
                    if (args.DialogResult.Value)
5668
                    {
5669
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5670

    
5671
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5672
                        _Encoder.Save(fs);
5673
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5674

    
5675
                        byte[] Img_byte = fs.ToArray();
5676

    
5677
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5678
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5679
                        Check_Uri.UriCheck(filename);
5680
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5681
                        {
5682
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5683
                        }
5684
                        else
5685
                        {
5686
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5687
                        }
5688
                        DataBind();
5689
                    }
5690
                }
5691
            }
5692
            catch (Exception ex)
5693
            {
5694
                DialogMessage_Alert("" + ex, "Alert");
5695
            }
5696
        }
5697

    
5698
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5699
        {
5700
            Canvas _canvas = new Canvas();
5701
            _canvas.Background = Brushes.White;
5702
            _canvas.Width = adorner_.BorderSize.Width;
5703
            _canvas.Height = adorner_.BorderSize.Height;
5704
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5705

    
5706
            BitmapEncoder encoder = new PngBitmapEncoder();
5707

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

    
5710
            DrawingVisual dv = new DrawingVisual();
5711

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

    
5715
            using (DrawingContext ctx = dv.RenderOpen())
5716
            {
5717
                VisualBrush vb = new VisualBrush(_canvas);
5718
                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)));
5719
            }
5720

    
5721
            try
5722
            {
5723
                renderBitmap.Render(dv);
5724

    
5725
                GC.Collect(2);
5726
                GC.WaitForPendingFinalizers();
5727
                //GC.Collect();
5728
                // encode png data
5729
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5730
                // puch rendered bitmap into it
5731
                pngEncoder.Interlace = PngInterlaceOption.Off;
5732
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5733
                return pngEncoder;
5734
            }
5735
            catch //(Exception ex)
5736
            {
5737
                return null;
5738
            }
5739
        }
5740

    
5741
        public void DialogMessage_Alert(string content, string header)
5742
        {
5743
            App.splashScreen.Close();
5744
            App.FileLogger.Error(content + " " + header);
5745

    
5746
            DialogParameters parameters = new DialogParameters()
5747
            {
5748
                Owner = this.ParentOfType<MainWindow>(),
5749
                Content = new TextBlock()
5750
                {
5751
                    MinWidth = 400,
5752
                    FontSize = 11,
5753
                    Text = content,
5754
                    TextWrapping = System.Windows.TextWrapping.Wrap
5755
                },
5756
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5757
                Header = header,
5758
                Theme = new VisualStudio2013Theme(),
5759
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5760
            };
5761
            RadWindow.Alert(parameters);
5762
        }
5763

    
5764
        #region 캡쳐 기능
5765

    
5766
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5767
        {
5768
            if (x < 0)
5769
            {
5770
                width += x;
5771
                x = 0;
5772
            }
5773
            if (y < 0)
5774
            {
5775
                height += y;
5776
                y = 0;
5777

    
5778
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5779
            }
5780
            if (x + width > zoomAndPanCanvas.ActualWidth)
5781
            {
5782
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5783
            }
5784
            if (y + height > zoomAndPanCanvas.ActualHeight)
5785
            {
5786
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5787
            }
5788

    
5789
            byte[] pixels = CopyPixels(x, y, width, height);
5790

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

    
5793
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5794
        }
5795

    
5796
        public byte[] CopyPixels(int x, int y, int width, int height)
5797
        {
5798
            byte[] pixels = new byte[width * height * 4];
5799
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5800

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

    
5804
            return pixels;
5805
        }
5806

    
5807
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5808
        {
5809
            DrawingVisual drawingVisual = new DrawingVisual();
5810
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5811

    
5812
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5813
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5814
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5815
            drawingContext.Close();
5816

    
5817
            // 비트맵으로 변환합니다.
5818
            RenderTargetBitmap target =
5819
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5820
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5821

    
5822
            target.Render(drawingVisual);
5823
            return target;
5824
        }
5825

    
5826
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5827
        {
5828
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5829
            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);
5830
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5831
            bmp.UnlockBits(data);
5832
            return bmp;
5833
        }
5834

    
5835
        public string symbolname = null;
5836
        public bool symbolsvg = true;
5837
        public bool symbolpng = true;
5838

    
5839
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5840
        {
5841
            System.Drawing.Bitmap image = GetBitmap(source);
5842
            //흰색 제거
5843
            //image.MakeTransparent(System.Drawing.Color.White);
5844

    
5845
            var imageStream = new System.IO.MemoryStream();
5846
            byte[] imageBytes = null;
5847
            using (imageStream)
5848
            {
5849
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5850
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5851
                imageStream.Position = 0;
5852
                imageBytes = imageStream.ToArray();
5853
            }
5854

    
5855
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5856

    
5857
            RadWindow CheckPop = new RadWindow();
5858
            //Alert check = new Alert(Msg);
5859

    
5860
            CheckPop = new RadWindow
5861
            {
5862
                MinWidth = 400,
5863
                MinHeight = 100,
5864
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5865
                Header = "Alert",
5866
                Content = symbolPrompt,
5867
                //DialogResult =
5868
                ResizeMode = System.Windows.ResizeMode.NoResize,
5869
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5870
                IsTopmost = true,
5871
            };
5872
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5873
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5874
            CheckPop.ShowDialog();
5875

    
5876
            /*
5877
            DialogParameters parameters = new DialogParameters()
5878
            {
5879
                Owner = Application.Current.MainWindow,
5880
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5881
                DefaultPromptResultValue = "Custom State",
5882
                Content = "Name :",
5883
                Header = "Insert Custom Symbol Name",
5884
                Theme = new VisualStudio2013Theme(),
5885
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5886
            };
5887
            RadWindow.Prompt(parameters);
5888
            */
5889
        }
5890

    
5891
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5892
        {
5893
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5894
            KCOMDataModel.DataModel.CHECK_LIST check_;
5895
            string Result = streamToBase64.ImageToBase64(source);
5896
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5897
            string projectno = App.ViewInfo.ProjectNO;
5898
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5899

    
5900
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5901
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5902
            if (Item != null)
5903
            {
5904
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5905
            }
5906
            else
5907
            {
5908
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5909
            }
5910

    
5911
            if (Item == null)
5912
            {
5913
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5914
                {
5915
                    ID = Commons.shortGuid(),
5916
                    USER_ID = App.ViewInfo.UserID,
5917
                    IMAGE_URL = Result,
5918
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5919
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5920
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5921
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5922
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5923
                    STATUS = "False",
5924
                    CREATE_TIME = DateTime.Now,
5925
                    UPDATE_TIME = DateTime.Now,
5926
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5927
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5928
                };
5929
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5930
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5931
                this.BaseClient.AddCheckList(projectno, check_);
5932
            }
5933
            else
5934
            {
5935
                Item.IMAGE_URL = Result;
5936
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5937
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5938
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5939
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5940
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5941
            }
5942
        }
5943

    
5944
        public void Set_Capture()
5945
        {
5946
            double x = CanvasDrawingMouseDownPoint.X;
5947
            double y = CanvasDrawingMouseDownPoint.Y;
5948
            double width = dragCaptureBorder.Width;
5949
            double height = dragCaptureBorder.Height;
5950

    
5951
            if (width > 5 || height > 5)
5952
            {
5953
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5954
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5955
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5956
            }
5957
        }
5958

    
5959
        #endregion 캡쳐 기능
5960

    
5961
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5962
        {
5963
            multi_Undo_Data = new Multi_Undo_data();
5964

    
5965
            multi_Undo_Data.Markup = control;
5966

    
5967
            if ((control as IShapeControl) != null)
5968
            {
5969
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5970
            }
5971
            if ((control as IDashControl) != null)
5972
            {
5973
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5974
            }
5975
            if ((control as IPath) != null)
5976
            {
5977
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5978
            }
5979
            if ((control as UIElement) != null)
5980
            {
5981
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5982
            }
5983

    
5984
            return multi_Undo_Data;
5985
        }
5986

    
5987
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5988
        {
5989
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
5990
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5991
            {
5992
                if (items.MarkupInfoID == Select_ID)
5993
                {
5994
                    foreach (var item in items.MarkupList)
5995
                    {
5996
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5997
                        {
5998
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
5999
                                 items.MarkupInfoID, Commons.shortGuid());
6000
                        }
6001
                    }
6002
                }
6003
            }
6004
        }
6005

    
6006
        /// <summary>
6007
        /// convert inkcontrol to polygoncontrol
6008
        /// </summary>
6009
        public void ConvertInkControlToPolygon()
6010
        {
6011
            if (inkBoard.Strokes.Count > 0)
6012
            {
6013
                inkBoard.Strokes.ToList().ForEach(stroke =>
6014
                {
6015
                    InkToPath ip = new InkToPath();
6016

    
6017
                    List<Point> inkPointSet = new List<Point>();
6018
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6019

    
6020
                    PolygonControl pc = new PolygonControl()
6021
                    {
6022
                        CommentAngle = 0,
6023
                        PointSet = inkPointSet,
6024
                        ControlType = ControlType.Ink
6025
                    };
6026
                    pc.StartPoint = inkPointSet[0];
6027
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6028
                    pc.LineSize = 3;
6029
                    pc.CommentID = Commons.shortGuid();
6030
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6031

    
6032
                    if (pc.PointSet.Count > 0)
6033
                    {
6034
                        CreateCommand.Instance.Execute(pc);
6035
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6036
                    }
6037
                });
6038
                inkBoard.Strokes.Clear();
6039
            }
6040
        }
6041

    
6042
        /// <summary>
6043
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6044
        /// </summary>
6045
        /// <author>ingu</author>
6046
        /// <date>2018.06.05</date>
6047
        /// <param name="getPoint"></param>
6048
        /// <returns></returns>
6049
        private bool IsGetoutpoint(Point getPoint)
6050
        {
6051
            if (getPoint == new Point())
6052
            {
6053
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6054
                currentControl = null;
6055
                return true;
6056
            }
6057

    
6058
            return false;
6059
        }
6060

    
6061
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6062
        {
6063
            e.Effects = DragDropEffects.Copy;
6064
        }
6065

    
6066
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6067
        {
6068
            e.Effects = DragDropEffects.Copy;
6069
        }
6070

    
6071
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6072
        {
6073
            e.Effects = DragDropEffects.None;
6074
        }
6075

    
6076
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6077
        {
6078
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6079
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6080

    
6081
            ScaleImage(pageWidth, pageHeight);
6082
        }
6083

    
6084
        /// <summary>
6085
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6086
        /// </summary>
6087
        /// <param name="pageWidth">원본 사이즈</param>
6088
        /// <param name="pageHeight">원본 사이즈</param>
6089
        /// <returns></returns>
6090
        private void ScaleImage(double pageWidth, double pageHeight)
6091
        {
6092
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6093
        }
6094

    
6095
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6096
        {
6097
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6098
        }
6099

    
6100
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6101
        {
6102
            var checkbox = (sender as CheckBox);
6103

    
6104
            if (checkbox != null)
6105
            {
6106
                if (checkbox.IsChecked.GetValueOrDefault())
6107
                {
6108
                    gridViewMarkup.SelectAll();
6109
                }
6110
                else
6111
                {
6112
                    gridViewMarkup.UnselectAll();
6113
                }
6114
            }
6115
        }
6116
        
6117
        /*
6118
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6119
        {
6120
            try
6121
            {
6122
                if (e.Data.GetDataPresent(typeof(string)))
6123
                {
6124
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6125
                    string dragData = e.Data.GetData(typeof(string)) as string;
6126
                    Move_Symbol(sender, dragData);
6127
                }
6128
            }
6129
            catch (Exception ex)
6130
            {
6131
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6132
            }
6133
        }
6134
        */
6135
    }
6136

    
6137
    public class testItem
6138
    {
6139
        public string Title { get; set; }
6140
    }
6141
}
클립보드 이미지 추가 (최대 크기: 500 MB)