프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 77cdac33

이력 | 보기 | 이력해설 | 다운로드 (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(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
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(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
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).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3903

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

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

    
3926
                                    CreateCommand.Instance.Execute(currentControl);
3927

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

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

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

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

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

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

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

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

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

    
3999
                                    CreateCommand.Instance.Execute(currentControl);
4000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
4336
                                    CreateCommand.Instance.Execute(currentControl);
4337
                                    (currentControl as RectangleControl).ApplyOverViewData();
4338
                                    currentControl = null;
4339

    
4340
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4341

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

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

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

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

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

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

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

    
4422
                                    CreateCommand.Instance.Execute(currentControl);
4423
                                    currentControl = null;
4424

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

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

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

    
4476
             
4477
                if (currentControl is ArrowTextControl)
4478
                {
4479
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4480
                    {
4481
                        var control = snd as ArrowTextControl;
4482

    
4483
                        if (string.IsNullOrEmpty(control.ArrowText))
4484
                        {
4485
                            DeleteCommand.Instance.Execute(new [] { control });
4486
                        }
4487
                    };
4488

    
4489
                }
4490

    
4491
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4492
                {
4493
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4494
                    {
4495
                        MacroHelper.MacroAction();
4496
                    }
4497
                    //if (currentControl.ControlType)
4498
                    //txtBatch.Text = "Draw a TextBox";
4499
                    //controlType = ControlType.ArrowTextBorderControl;
4500
                }
4501

    
4502
                //if (currentControl != null)
4503
                //{
4504
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4505
                //}
4506
            }
4507
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4508
            {
4509
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4510
             
4511

    
4512
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4513
                {
4514
                    bool mouseOff = false;
4515
                    foreach (var item in SelectLayer.Children)
4516
                    {
4517
                        if (item is AdornerFinal)
4518
                        {
4519
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4520
                            if (over != null)
4521
                            {
4522
                                mouseOff = true;
4523
                            }
4524
                        }
4525
                    }
4526

    
4527
                    if (!mouseOff)
4528
                    {
4529
                        SelectionSet.Instance.UnSelect(this);
4530
                    }
4531
                }
4532
                zoomAndPanControl.CaptureMouse();
4533
                e.Handled = true;
4534
            }
4535
        }
4536

    
4537
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4538
        {
4539
            ///mouseButtonDown = e.ChangedButton;
4540
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4541
        }
4542

    
4543
        private void RemoveLineStroke(Point P)
4544
        {
4545
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4546
            if (control != null)
4547
            {
4548
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4549
            }
4550
        }
4551

    
4552
        private void RemovePointStroke(Point P)
4553
        {
4554
            foreach (Stroke hits in inkBoard.Strokes)
4555
            {
4556
                foreach (StylusPoint sty in hits.StylusPoints)
4557
                {
4558
                }
4559
                if (hits.HitTest(P))
4560
                {
4561
                    inkBoard.Strokes.Remove(hits);
4562
                    return;
4563
                }
4564
            }
4565
        }
4566

    
4567
        private void StartNewStroke(Point P)
4568
        {
4569
            strokePoints = new StylusPointCollection();
4570
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4571
            strokePoints.Add(segment1Start);
4572
            stroke = new Stroke(strokePoints);
4573

    
4574
            stroke.DrawingAttributes.Color = Colors.Red;
4575
            stroke.DrawingAttributes.Width = 4;
4576
            stroke.DrawingAttributes.Height = 4;
4577

    
4578
            inkBoard.Strokes.Add(stroke);
4579
        }
4580

    
4581
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4582
        {
4583
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4584
            //// update mylist and gridview
4585
            //this.UpdateMyMarkupList();
4586

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

    
4589
            //if (result)
4590
            //{
4591
                btnFinalPDF.IsEnabled = false;
4592

    
4593
              await  ConsolidationMethod();
4594
            //}
4595
            //else
4596
            //{
4597
            //    MessageBox.Show("오류");
4598
            //}
4599
        }
4600

    
4601
        /// <summary>
4602
        /// execute TeamConsolidationCommand
4603
        /// </summary>
4604
        public void TeamConsolidationMethod2()
4605
        {
4606
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4607
            {
4608
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4609
            }
4610
            else
4611
            {
4612

    
4613
                ViewerDataModel.Instance.IsConsolidate = true;
4614
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4615
                // update mylist and gridview
4616
        
4617
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommand(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4618
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4619
                ViewerDataModel.Instance.IsConsolidate = false;
4620
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4621
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4622
                {
4623
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4624
                    {
4625
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4626
                        return;
4627
                    }
4628
                }
4629
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4630
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4631
                {
4632
                    MarkupInfoList.Add(item);
4633
                }
4634

    
4635
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4636
            }
4637
        }
4638
        public async void TeamConsolidationMethod()
4639
        {
4640
            bool result = false;
4641

    
4642
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4643
            {
4644
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4645
            }
4646
            else
4647
            {
4648
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4649
                {
4650
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4651
                    {
4652
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4653
                    }
4654
                }
4655

    
4656
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4657

    
4658
                if (isSave)
4659
                {
4660
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4661

    
4662
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4663
                     
4664
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4665
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4666
                    {
4667
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4668
                    }
4669

    
4670
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4671
                    result = true;
4672
                }
4673
            }
4674
        }
4675

    
4676
        public async Task<bool> ConsolidationMethod()
4677
        {
4678
            bool result = false;
4679

    
4680
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4681
            {
4682
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4683
            }
4684
            else
4685
            {
4686
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4687

    
4688
                if (isSave)
4689
                {
4690
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4691
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4692

    
4693
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4694
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4695
                    {
4696
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4697
                    }
4698
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4699

    
4700
                    result = ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4701
                }
4702
            }
4703

    
4704
            return result;
4705
        }
4706

    
4707
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4708
        {
4709
            if (App.ViewInfo != null)
4710
            {
4711
                btnConsolidate = (sender as RadRibbonButton);
4712
                if (!App.ViewInfo.NewCommentPermission)
4713
                {
4714
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4715
                }
4716
            }
4717
        }
4718

    
4719
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4720
        {
4721
            TeamConsolidationMethod();
4722
        }
4723

    
4724
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4725
        {
4726
            btnTeamConsolidate = sender as RadRibbonButton;
4727
            if (App.ViewInfo != null)
4728
            {
4729
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4730
                {
4731
                    if (btnConsolidate != null)
4732
                    {
4733
                        btnConsolidate.Visibility = Visibility.Collapsed;
4734
                    }
4735

    
4736
                    if (!App.ViewInfo.NewCommentPermission)
4737
                    {
4738
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4739
                    }
4740
                }
4741
                else
4742
                {
4743
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4744
                }
4745
            }
4746
        }
4747

    
4748
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4749
        {
4750
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4751
            // update mylist and gridview
4752
            this.UpdateMyMarkupList();
4753

    
4754
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4755

    
4756
            if(!result)
4757
            {
4758

    
4759
            }
4760
            else
4761
            {
4762
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4763

    
4764
                if (item != null)
4765
                {
4766
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4767
                    {
4768
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4769

    
4770
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4771

    
4772
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4773
                    }
4774
                    else
4775
                    {
4776
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4777
                    }
4778
                }
4779
                else
4780
                {
4781
                    //Consolidate 가 없는 경우
4782
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4783
                }
4784
            }
4785

    
4786
        }
4787

    
4788
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4789
        {
4790
            btnFinalPDF = sender as RadRibbonButton;
4791
            if (App.ViewInfo != null)
4792
            {
4793
                //btnFinalPDF.IsEnabled = false;
4794

    
4795
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4796
                {
4797
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4798
                    if (btnConsolidate != null)
4799
                    {
4800
                        btnConsolidate.Visibility = Visibility.Collapsed;
4801
                    }
4802
                }
4803
            }
4804
        }
4805

    
4806
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4807
        {
4808
            //UpdateMyMarkupList();
4809

    
4810
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4811
            {
4812
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4813
            }
4814
            else
4815
            {
4816
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4817
                //{
4818
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4819
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4820
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4821

    
4822
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4823
                //// update mylist and gridview
4824
                //this.UpdateMyMarkupList();
4825

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

    
4828
                Mouse.SetCursor(Cursors.Wait);
4829

    
4830
                bool result = await ConsolidationMethod();
4831

    
4832
                System.Threading.Thread.Sleep(500);
4833

    
4834
                if (result)
4835
                {
4836
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4837

    
4838
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4839
                    if (item2 != null)
4840
                    {
4841
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4842
                        {
4843
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4844

    
4845
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4846
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4847

    
4848
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4849

    
4850
                            Mouse.SetCursor(Cursors.Arrow);
4851
                        }
4852
                        else
4853
                        {
4854
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4855
                        }
4856
                    }
4857
                    else
4858
                    {
4859
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4860
                    }
4861
                }
4862
                else
4863
                {
4864
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4865
                }
4866

    
4867
                Mouse.SetCursor(Cursors.Arrow);
4868
            }
4869
        }
4870

    
4871
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4872
        {
4873
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4874
#if Hyosung
4875
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4876
#else
4877

    
4878
            //btnConsolidateFinalPDF.IsEnabled = false;
4879

    
4880
            if (App.ViewInfo != null)
4881
            {
4882
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4883
                {
4884
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4885
                }
4886
            }
4887
#endif
4888
        }
4889

    
4890
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4891
        {
4892
            SetCompareRect();
4893
        }
4894

    
4895
        private void Sync_Click(object sender, RoutedEventArgs e)
4896
        {
4897
            if (Sync.IsChecked)
4898
            {
4899
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4900
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4901
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4902
            }
4903
        }
4904

    
4905
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4906
        {
4907
            if (UserList.IsChecked)
4908
            {
4909
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4910
            }
4911
            else
4912
            {
4913
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4914
            }
4915
        }
4916

    
4917
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4918
        {
4919
            if (BalanceMode.IsChecked)
4920
            {
4921
                ViewerDataModel.Instance.PageBalanceMode = true;
4922
            }
4923
            else
4924
            {
4925
                ViewerDataModel.Instance.PageBalanceMode = false;
4926
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4927
            }
4928
        }
4929

    
4930
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4931
        {
4932
            //초기화
4933
            testPanel2.IsHidden = true;
4934
            ViewerDataModel.Instance.PageBalanceMode = false;
4935
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4936
            ViewerDataModel.Instance.SyncPageNumber = 0;
4937
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4938
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4939
            UserList.IsChecked = false;
4940
            BalanceMode.IsChecked = false;
4941
        }
4942

    
4943
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4944
        {
4945
            if ((sender as System.Windows.Controls.Control).Tag != null)
4946
            {
4947
                //Compare 초기화
4948
                CompareMode.IsChecked = false;
4949
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4950
                
4951
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4952
                {
4953
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4954
                }
4955

    
4956
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4957
                {
4958
                }
4959
                else
4960
                {
4961
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4962
                }
4963

    
4964
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
4965
                {
4966
                }
4967
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
4968
                {
4969
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
4970
                }
4971

    
4972
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4973

    
4974
                if (!testPanel2.IsHidden)
4975
                {
4976
                    if (IsSyncPDFMode)
4977
                    {
4978
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4979
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
4980

    
4981
                        if (pdfpath.IsDownloading)
4982
                        {
4983
                            pdfpath.DownloadCompleted += (ex, arg) =>
4984
                            {
4985
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4986
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4987
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4988
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4989
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4990
                            };
4991
                        }
4992
                        else
4993
                        {
4994
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4995
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4996
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4997

    
4998
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4999
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5000
                        }
5001
                    }
5002
                    else
5003
                    {
5004
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5005

    
5006
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5007
                        ComparePageLoad(uri, isOriginalSize);
5008
                    }
5009
                   
5010
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5011
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5012
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5013

    
5014
                    foreach (var item in gridSelectionRevItem)
5015
                    {
5016
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5017
                        foreach (var markupitem in markupitems)
5018
                        {
5019
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5020
                        }
5021
                    }
5022

    
5023
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5024
                }
5025
            }
5026
        }
5027

    
5028
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5029
        {
5030
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5031

    
5032
            double translateX = 0;
5033
            double translateY = 0;
5034
            double angle = rotate2.Angle;
5035

    
5036
            if (direction == 1)
5037
            {
5038
                if (angle < 270)
5039
                {
5040
                    angle += 90;
5041
                }
5042
                else
5043
                {
5044
                    angle = 0;
5045
                }
5046
            }
5047
            else
5048
            {
5049
                if (angle > 0)
5050
                {
5051
                    angle -= 90;
5052
                }
5053
                else
5054
                {
5055
                    angle = 270;
5056
                }
5057
            }
5058
            zoomAndPanControl2.RotationAngle = angle;
5059
            zoomAndPanControl2.ScaleToFit();
5060

    
5061
            //if (angle == 90 || angle == 270)
5062
            //{
5063
                double emptySize = zoomAndPanCanvas2.Width;
5064
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5065
                zoomAndPanCanvas2.Height = emptySize;
5066
            //}
5067

    
5068
            if (angle == 90)
5069
            {
5070
                translateX = zoomAndPanCanvas2.Width;
5071
                translateY = 0;
5072
            }
5073
            else if (angle == 180)
5074
            {
5075
                translateX = zoomAndPanCanvas2.Width;
5076
                translateY = zoomAndPanCanvas2.Height;
5077
            }
5078
            else if (angle == 270)
5079
            {
5080
                translateX = 0;
5081
                translateY = zoomAndPanCanvas2.Height;
5082
            }
5083
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5084
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5085
            translate2.X = translateX;
5086
            translate2.Y = translateY;
5087
            rotate2.Angle = angle;
5088
            //translate2CompareBorder.X = translateX;
5089
            //translate2CompareBorder.Y = translateY;
5090
            //rotate2CompareBorder.Angle = angle;
5091

    
5092
        }
5093

    
5094
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5095
        {
5096
            if (MarkupMode.IsChecked)
5097
            {
5098
                IsSyncPDFMode = true;
5099

    
5100
                var uri = CurrentRev.TO_VENDOR;
5101

    
5102
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5103
                {
5104
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5105
                }
5106

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

    
5111
                if (pdfpath.IsDownloading)
5112
                {
5113
                    pdfpath.DownloadCompleted += (ex, arg) =>
5114
                    {
5115
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5116
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5117
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5118
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5119
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5120
                    };
5121
                }
5122
                else
5123
                {
5124
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5125
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5126
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5127

    
5128
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5129
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5130
                }
5131
            }
5132
            else
5133
            {
5134
                IsSyncPDFMode = false;
5135
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5136

    
5137
                ComparePageLoad(uri,false);
5138

    
5139
                zoomAndPanControl2.ApplyTemplate();
5140
                zoomAndPanControl2.UpdateLayout();
5141
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5142
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5143
            }
5144
        }
5145

    
5146
        /// <summary>
5147
        /// Compare된 영역을 초기화
5148
        /// </summary>
5149
        private void ClearCompareRect()
5150
        {
5151
            da.From = 1;
5152
            da.To = 1;
5153
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5154
            da.AutoReverse = false;
5155
            canvas_compareBorder.Children.Clear();
5156
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5157
        }
5158

    
5159
        /// <summary>
5160
        /// 문서 Comprare
5161
        /// </summary>
5162
        private void SetCompareRect()
5163
        {
5164
            canvas_compareBorder.Children.Clear();
5165

    
5166
            if (CompareMode.IsChecked)
5167
            {
5168
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5169
                {
5170
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5171
                }
5172
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5173
                {
5174
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5175
                }
5176

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

    
5179
                /// 비교대상원본, 비교할 대상
5180
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5181
            }
5182
            else
5183
            {
5184
                canvas_compareBorder.Visibility = Visibility.Hidden;
5185
                ClearCompareRect();
5186
            }
5187
        }
5188

    
5189
        private void btnSync_Click(object sender, RoutedEventArgs e)
5190
        {
5191
            gridViewHistory_Busy.IsBusy = true;
5192

    
5193
            RadButton instance = sender as RadButton;
5194
            if (instance.CommandParameter != null)
5195
            {
5196
                CurrentRev = instance.CommandParameter as VPRevision;
5197
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5198

    
5199
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5200
                {
5201
                    if (ea.Error == null && ea.Result != null)
5202
                    {
5203
                        testPanel2.IsHidden = false;
5204

    
5205
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5206
                        foreach (var info in ea.Result)
5207
                        {
5208
                            if (info.UserID == App.ViewInfo.UserID)
5209
                            {
5210
                                info.userDelete = true;
5211
                                info.DisplayColor = "#FFFF0000";
5212
                            }
5213
                            else
5214
                            {
5215
                                info.userDelete = false;
5216
                            }
5217
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5218
                        }
5219
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5220

    
5221
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5222
                        ComparePageLoad(uri,false);
5223

    
5224
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5225

    
5226
                        zoomAndPanControl2.ApplyTemplate();
5227
                        zoomAndPanControl2.UpdateLayout();
5228

    
5229
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5230
                        {
5231
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5232
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5233
                        }
5234

    
5235
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5236
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5237
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5238

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

    
5242
                        zoomAndPanControl.ScaleToFit();
5243
                        zoomAndPanControl2.ScaleToFit();
5244

    
5245
                        gridViewHistory_Busy.IsBusy = false;
5246
                    }
5247

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

    
5250
                    if (GetSyncMarkupInfoItemshandler != null)
5251
                    {
5252
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5253
                    }
5254

    
5255
                    //ClearCompareRect();
5256
                    SetCompareRect();
5257
                };
5258

    
5259
                /// 중복 실행이 발생하여 수정함.
5260
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5261
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5262

    
5263
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5264
            }
5265
        }
5266

    
5267
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5268
        {
5269
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5270
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5271

    
5272
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5273
        }
5274

    
5275
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5276
        {
5277
            try
5278
            {
5279
                if (sender is RadButton)
5280
                {
5281
                    if ((sender as RadButton).Tag != null)
5282
                    {
5283
                        var url = (sender as RadButton).Tag.ToString();
5284
                        System.Diagnostics.Process.Start(url);
5285
                    }
5286
                    else
5287
                    {
5288
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5289
                    }
5290
                }
5291
            }
5292
            catch (Exception ex)
5293
            {
5294
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5295
            }
5296
        }
5297

    
5298
        public void Sync_Event(VPRevision Currnet_Rev)
5299
        {
5300
            CurrentRev = Currnet_Rev;
5301

    
5302
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5303
            {
5304
                if (ea.Error == null && ea.Result != null)
5305
                {
5306
                    testPanel2.IsHidden = false;
5307

    
5308
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5309
                    foreach (var info in ea.Result)
5310
                    {
5311
                        if (info.UserID == App.ViewInfo.UserID)
5312
                        {
5313
                            info.userDelete = true;
5314
                            info.DisplayColor = "#FFFF0000";
5315
                        }
5316
                        else
5317
                        {
5318
                            info.userDelete = false;
5319
                        }
5320
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5321
                    }
5322
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5323

    
5324
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5325

    
5326
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5327

    
5328
                    ComparePageLoad(uri,false);
5329

    
5330
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5331
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5332
                    zoomAndPanControl2.ApplyTemplate();
5333
                    zoomAndPanControl2.UpdateLayout();
5334

    
5335
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5336
                    {
5337
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5338
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5339
                    }
5340
                    //}
5341
                    
5342
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5343
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5344
                    gridViewHistory_Busy.IsBusy = false;
5345
                }
5346
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5347
            };
5348
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5349
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5350
        }
5351

    
5352
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5353
        {
5354
            if (sender is Image)
5355
            {
5356
                if ((sender as Image).Tag != null)
5357
                {
5358
                    var pdfUrl = (sender as Image).Tag.ToString();
5359
                    System.Diagnostics.Process.Start(pdfUrl);
5360
                }
5361
                else
5362
                {
5363
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5364
                }
5365
            }
5366
        }
5367

    
5368
        private void Create_Symbol(object sender, RoutedEventArgs e)
5369
        {
5370
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5371

    
5372
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5373
            {
5374
                DialogMessage_Alert("Please Select Controls", "Alert");
5375
            }
5376
            else //선택된 것이 있으면
5377
            {
5378
                string MarkupData = "";
5379
                adorner_ = new AdornerFinal();
5380

    
5381
                foreach (var item in SelectLayer.Children)
5382
                {
5383
                    if (item.GetType().Name == "AdornerFinal")
5384
                    {
5385
                        adorner_ = (item as Controls.AdornerFinal);
5386
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5387
                        {
5388
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5389
                            {
5390
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5391
                                MarkupData += markupReturn.ConvertData;
5392
                            }
5393
                        }
5394
                    }
5395
                }
5396
                DialogParameters parameters = new DialogParameters()
5397
                {
5398
                    Owner = Application.Current.MainWindow,
5399
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5400
                    DefaultPromptResultValue = "Custom State",
5401
                    Content = "Name :",
5402
                    Header = "Insert Custom Symbol Name",
5403
                    Theme = new VisualStudio2013Theme(),
5404
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5405
                };
5406
                RadWindow.Prompt(parameters);
5407
            }
5408
        }
5409

    
5410
        public int symbolselectindex = 0;
5411

    
5412
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5413
        {
5414
            //Save save = new Save();
5415
            try
5416
            {
5417
                string svgfilename = null;
5418
                if (symbolname != null)
5419
                {
5420
                    if (symbolpng == true || symbolsvg == true)
5421
                    {
5422
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5423
                        string guid = Commons.shortGuid();
5424

    
5425
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5426
                        //Check_Uri.UriCheck();
5427
                        fileUploader.RunCompleted += (ex, arg) =>
5428
                        {
5429
                            filename = arg.Result;
5430
                            if (symbolpng == true)
5431
                            {
5432
                                if (filename != null)
5433
                                {
5434
                                    if (symbolselectindex == 0)
5435
                                    {
5436
                                        SymbolSave(symbolname, filename, data);
5437
                                    }
5438
                                    else
5439
                                    {
5440
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5441
                                    }
5442
                                    DataBind();
5443
                                }
5444
                            }
5445

    
5446
                            if (symbolsvg == true)
5447
                            {
5448
                                try
5449
                                {
5450
                                    var defaultBitmapImage = new BitmapImage();
5451
                                    defaultBitmapImage.BeginInit();
5452
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5453
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5454
                                    Check_Uri.UriCheck(filename);
5455
                                    defaultBitmapImage.UriSource = new Uri(filename);
5456
                                    defaultBitmapImage.EndInit();
5457

    
5458
                                    System.Drawing.Bitmap image;
5459

    
5460
                                    if (defaultBitmapImage.IsDownloading)
5461
                                    {
5462
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5463
                                        {
5464
                                            defaultBitmapImage.Freeze();
5465
                                            image = GetBitmap(defaultBitmapImage);
5466
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5467
                                            Process potrace = new Process
5468
                                            {
5469
                                                StartInfo = new ProcessStartInfo
5470
                                                {
5471
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5472
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5473
                                                    RedirectStandardInput = true,
5474
                                                    RedirectStandardOutput = true,
5475
                                                    RedirectStandardError = true,
5476
                                                    UseShellExecute = false,
5477
                                                    CreateNoWindow = true,
5478
                                                    WindowStyle = ProcessWindowStyle.Hidden
5479
                                                },
5480
                                            };
5481

    
5482
                                            StringBuilder svgBuilder = new StringBuilder();
5483
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5484
                                            {
5485
                                                svgBuilder.AppendLine(e2.Data);
5486
                                            };
5487

    
5488
                                            potrace.EnableRaisingEvents = true;
5489
                                            potrace.Start();
5490
                                            potrace.Exited += (sender, e) =>
5491
                                            {
5492
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5493
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5494
                                                Check_Uri.UriCheck(svgfilename);
5495
                                                if (symbolselectindex == 0)
5496
                                                {
5497
                                                    SymbolSave(symbolname, svgfilename, data);
5498
                                                }
5499
                                                else
5500
                                                {
5501
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5502
                                                }
5503

    
5504
                                                DataBind();
5505
                                            };
5506
                                            potrace.WaitForExit();
5507
                                        };
5508
                                    }
5509
                                    else
5510
                                    {
5511
                                        //GC.Collect();
5512
                                    }
5513
                                }
5514
                                catch (Exception ee)
5515
                                {
5516
                                    DialogMessage_Alert("" + ee, "Alert");
5517
                                }
5518
                            }
5519
                        };
5520
                    }
5521
                }
5522
            }
5523
            catch (Exception e)
5524
            {
5525
                //DialogMessage_Alert(e + "", "Alert");
5526
            }
5527
        }
5528

    
5529
        public void SymbolSave(string Name, string Url, string Data)
5530
        {
5531
            try
5532
            {
5533
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5534
                {
5535
                    ID = Commons.shortGuid(),
5536
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5537
                    NAME = Name,
5538
                    IMAGE_URL = Url,
5539
                    DATA = Data
5540
                };
5541

    
5542
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5543
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5544
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5545
            }
5546
            catch (Exception)
5547
            {
5548
                throw;
5549
            }
5550
        }
5551

    
5552
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5553
        {
5554
            try
5555
            {
5556
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5557
                {
5558
                    ID = Commons.shortGuid(),
5559
                    DEPARTMENT = Department,
5560
                    NAME = Name,
5561
                    IMAGE_URL = Url,
5562
                    DATA = Data
5563
                };
5564
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5565
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5566
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5567
            }
5568
            catch (Exception)
5569
            {
5570
                throw;
5571
            }
5572
        }
5573

    
5574
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5575
        {
5576
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5577
            DataBind();
5578
        }
5579

    
5580
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5581
        {
5582
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5583
            DataBind();
5584
        }
5585

    
5586
        private void DataBind()
5587
        {
5588
            try
5589
            {
5590
                Symbol_Custom Custom = new Symbol_Custom();
5591
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5592

    
5593
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5594
                foreach (var item in symbol_Private)
5595
                {
5596
                    Custom.Name = item.NAME;
5597
                    Custom.ImageUri = item.IMAGE_URL;
5598
                    Custom.ID = item.ID;
5599
                    Custom_List.Add(Custom);
5600
                    Custom = new Symbol_Custom();
5601
                }
5602
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5603

    
5604
                Custom = new Symbol_Custom();
5605
                Custom_List = new List<Symbol_Custom>();
5606

    
5607
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5608

    
5609
                List<SYMBOL_PUBLIC> symbol_Public;
5610

    
5611
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5612
                {
5613
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5614
                }
5615
                else
5616
                {
5617
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5618
                }
5619
                foreach (var item in symbol_Public)
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.lstSymbolPublic.ItemsSource = Custom_List;
5628
                BaseClient.Close();
5629
            }
5630
            catch (Exception e)
5631
            {
5632
                //DialogMessage_Alert("DataBind", "Alert");
5633
            }
5634
        }
5635

    
5636
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5637
        {
5638
            try
5639
            {
5640
                if (args.PromptResult != null)
5641
                {
5642
                    if (args.DialogResult.Value)
5643
                    {
5644
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5645

    
5646
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5647
                        _Encoder.Save(fs);
5648
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5649

    
5650
                        byte[] Img_byte = fs.ToArray();
5651

    
5652
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5653
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5654
                        Check_Uri.UriCheck(filename);
5655
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5656
                        {
5657
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5658
                        }
5659
                        else
5660
                        {
5661
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5662
                        }
5663
                        DataBind();
5664
                    }
5665
                }
5666
            }
5667
            catch (Exception ex)
5668
            {
5669
                DialogMessage_Alert("" + ex, "Alert");
5670
            }
5671
        }
5672

    
5673
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5674
        {
5675
            Canvas _canvas = new Canvas();
5676
            _canvas.Background = Brushes.White;
5677
            _canvas.Width = adorner_.BorderSize.Width;
5678
            _canvas.Height = adorner_.BorderSize.Height;
5679
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5680

    
5681
            BitmapEncoder encoder = new PngBitmapEncoder();
5682

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

    
5685
            DrawingVisual dv = new DrawingVisual();
5686

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

    
5690
            using (DrawingContext ctx = dv.RenderOpen())
5691
            {
5692
                VisualBrush vb = new VisualBrush(_canvas);
5693
                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)));
5694
            }
5695

    
5696
            try
5697
            {
5698
                renderBitmap.Render(dv);
5699

    
5700
                GC.Collect(2);
5701
                GC.WaitForPendingFinalizers();
5702
                //GC.Collect();
5703
                // encode png data
5704
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5705
                // puch rendered bitmap into it
5706
                pngEncoder.Interlace = PngInterlaceOption.Off;
5707
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5708
                return pngEncoder;
5709
            }
5710
            catch //(Exception ex)
5711
            {
5712
                return null;
5713
            }
5714
        }
5715

    
5716
        public void DialogMessage_Alert(string content, string header)
5717
        {
5718
            App.splashScreen.Close();
5719
            App.FileLogger.Error(content + " " + header);
5720

    
5721
            DialogParameters parameters = new DialogParameters()
5722
            {
5723
                Owner = this.ParentOfType<MainWindow>(),
5724
                Content = new TextBlock()
5725
                {
5726
                    MinWidth = 400,
5727
                    FontSize = 11,
5728
                    Text = content,
5729
                    TextWrapping = System.Windows.TextWrapping.Wrap
5730
                },
5731
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5732
                Header = header,
5733
                Theme = new VisualStudio2013Theme(),
5734
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5735
            };
5736
            RadWindow.Alert(parameters);
5737
        }
5738

    
5739
        #region 캡쳐 기능
5740

    
5741
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5742
        {
5743
            if (x < 0)
5744
            {
5745
                width += x;
5746
                x = 0;
5747
            }
5748
            if (y < 0)
5749
            {
5750
                height += y;
5751
                y = 0;
5752

    
5753
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5754
            }
5755
            if (x + width > zoomAndPanCanvas.ActualWidth)
5756
            {
5757
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5758
            }
5759
            if (y + height > zoomAndPanCanvas.ActualHeight)
5760
            {
5761
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5762
            }
5763

    
5764
            byte[] pixels = CopyPixels(x, y, width, height);
5765

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

    
5768
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5769
        }
5770

    
5771
        public byte[] CopyPixels(int x, int y, int width, int height)
5772
        {
5773
            byte[] pixels = new byte[width * height * 4];
5774
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5775

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

    
5779
            return pixels;
5780
        }
5781

    
5782
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5783
        {
5784
            DrawingVisual drawingVisual = new DrawingVisual();
5785
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5786

    
5787
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5788
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5789
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5790
            drawingContext.Close();
5791

    
5792
            // 비트맵으로 변환합니다.
5793
            RenderTargetBitmap target =
5794
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5795
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5796

    
5797
            target.Render(drawingVisual);
5798
            return target;
5799
        }
5800

    
5801
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5802
        {
5803
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5804
            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);
5805
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5806
            bmp.UnlockBits(data);
5807
            return bmp;
5808
        }
5809

    
5810
        public string symbolname = null;
5811
        public bool symbolsvg = true;
5812
        public bool symbolpng = true;
5813

    
5814
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5815
        {
5816
            System.Drawing.Bitmap image = GetBitmap(source);
5817
            //흰색 제거
5818
            //image.MakeTransparent(System.Drawing.Color.White);
5819

    
5820
            var imageStream = new System.IO.MemoryStream();
5821
            byte[] imageBytes = null;
5822
            using (imageStream)
5823
            {
5824
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5825
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5826
                imageStream.Position = 0;
5827
                imageBytes = imageStream.ToArray();
5828
            }
5829

    
5830
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5831

    
5832
            RadWindow CheckPop = new RadWindow();
5833
            //Alert check = new Alert(Msg);
5834

    
5835
            CheckPop = new RadWindow
5836
            {
5837
                MinWidth = 400,
5838
                MinHeight = 100,
5839
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5840
                Header = "Alert",
5841
                Content = symbolPrompt,
5842
                //DialogResult =
5843
                ResizeMode = System.Windows.ResizeMode.NoResize,
5844
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5845
                IsTopmost = true,
5846
            };
5847
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5848
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5849
            CheckPop.ShowDialog();
5850

    
5851
            /*
5852
            DialogParameters parameters = new DialogParameters()
5853
            {
5854
                Owner = Application.Current.MainWindow,
5855
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5856
                DefaultPromptResultValue = "Custom State",
5857
                Content = "Name :",
5858
                Header = "Insert Custom Symbol Name",
5859
                Theme = new VisualStudio2013Theme(),
5860
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5861
            };
5862
            RadWindow.Prompt(parameters);
5863
            */
5864
        }
5865

    
5866
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5867
        {
5868
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5869
            KCOMDataModel.DataModel.CHECK_LIST check_;
5870
            string Result = streamToBase64.ImageToBase64(source);
5871
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5872
            string projectno = App.ViewInfo.ProjectNO;
5873
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5874

    
5875
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5876
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5877
            if (Item != null)
5878
            {
5879
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5880
            }
5881
            else
5882
            {
5883
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5884
            }
5885

    
5886
            if (Item == null)
5887
            {
5888
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5889
                {
5890
                    ID = Commons.shortGuid(),
5891
                    USER_ID = App.ViewInfo.UserID,
5892
                    IMAGE_URL = Result,
5893
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5894
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5895
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5896
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5897
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5898
                    STATUS = "False",
5899
                    CREATE_TIME = DateTime.Now,
5900
                    UPDATE_TIME = DateTime.Now,
5901
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5902
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5903
                };
5904
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5905
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5906
                this.BaseClient.AddCheckList(projectno, check_);
5907
            }
5908
            else
5909
            {
5910
                Item.IMAGE_URL = Result;
5911
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5912
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5913
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5914
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5915
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5916
            }
5917
        }
5918

    
5919
        public void Set_Capture()
5920
        {
5921
            double x = CanvasDrawingMouseDownPoint.X;
5922
            double y = CanvasDrawingMouseDownPoint.Y;
5923
            double width = dragCaptureBorder.Width;
5924
            double height = dragCaptureBorder.Height;
5925

    
5926
            if (width > 5 || height > 5)
5927
            {
5928
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5929
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5930
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5931
            }
5932
        }
5933

    
5934
        #endregion 캡쳐 기능
5935

    
5936
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5937
        {
5938
            multi_Undo_Data = new Multi_Undo_data();
5939

    
5940
            multi_Undo_Data.Markup = control;
5941

    
5942
            if ((control as IShapeControl) != null)
5943
            {
5944
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5945
            }
5946
            if ((control as IDashControl) != null)
5947
            {
5948
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5949
            }
5950
            if ((control as IPath) != null)
5951
            {
5952
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5953
            }
5954
            if ((control as UIElement) != null)
5955
            {
5956
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5957
            }
5958

    
5959
            return multi_Undo_Data;
5960
        }
5961

    
5962
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5963
        {
5964
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
5965
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5966
            {
5967
                if (items.MarkupInfoID == Select_ID)
5968
                {
5969
                    foreach (var item in items.MarkupList)
5970
                    {
5971
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5972
                        {
5973
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
5974
                                 items.MarkupInfoID, Commons.shortGuid());
5975
                        }
5976
                    }
5977
                }
5978
            }
5979
        }
5980

    
5981
        /// <summary>
5982
        /// convert inkcontrol to polygoncontrol
5983
        /// </summary>
5984
        public void ConvertInkControlToPolygon()
5985
        {
5986
            if (inkBoard.Strokes.Count > 0)
5987
            {
5988
                inkBoard.Strokes.ToList().ForEach(stroke =>
5989
                {
5990
                    InkToPath ip = new InkToPath();
5991

    
5992
                    List<Point> inkPointSet = new List<Point>();
5993
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5994

    
5995
                    PolygonControl pc = new PolygonControl()
5996
                    {
5997
                        CommentAngle = 0,
5998
                        PointSet = inkPointSet,
5999
                        ControlType = ControlType.Ink
6000
                    };
6001
                    pc.StartPoint = inkPointSet[0];
6002
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6003
                    pc.LineSize = 3;
6004
                    pc.CommentID = Commons.shortGuid();
6005
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6006

    
6007
                    if (pc.PointSet.Count > 0)
6008
                    {
6009
                        CreateCommand.Instance.Execute(pc);
6010
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6011
                    }
6012
                });
6013
                inkBoard.Strokes.Clear();
6014
            }
6015
        }
6016

    
6017
        /// <summary>
6018
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6019
        /// </summary>
6020
        /// <author>ingu</author>
6021
        /// <date>2018.06.05</date>
6022
        /// <param name="getPoint"></param>
6023
        /// <returns></returns>
6024
        private bool IsGetoutpoint(Point getPoint)
6025
        {
6026
            if (getPoint == new Point())
6027
            {
6028
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6029
                currentControl = null;
6030
                return true;
6031
            }
6032

    
6033
            return false;
6034
        }
6035

    
6036
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6037
        {
6038
            e.Effects = DragDropEffects.Copy;
6039
        }
6040

    
6041
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6042
        {
6043
            e.Effects = DragDropEffects.Copy;
6044
        }
6045

    
6046
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6047
        {
6048
            e.Effects = DragDropEffects.None;
6049
        }
6050

    
6051
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6052
        {
6053
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6054
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6055

    
6056
            ScaleImage(pageWidth, pageHeight);
6057
        }
6058

    
6059
        /// <summary>
6060
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6061
        /// </summary>
6062
        /// <param name="pageWidth">원본 사이즈</param>
6063
        /// <param name="pageHeight">원본 사이즈</param>
6064
        /// <returns></returns>
6065
        private void ScaleImage(double pageWidth, double pageHeight)
6066
        {
6067
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6068
        }
6069

    
6070
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6071
        {
6072
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6073
        }
6074

    
6075
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6076
        {
6077
            var checkbox = (sender as CheckBox);
6078

    
6079
            if (checkbox != null)
6080
            {
6081
                if (checkbox.IsChecked.GetValueOrDefault())
6082
                {
6083
                    gridViewMarkup.SelectAll();
6084
                }
6085
                else
6086
                {
6087
                    gridViewMarkup.UnselectAll();
6088
                }
6089
            }
6090
        }
6091
        
6092
        /*
6093
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6094
        {
6095
            try
6096
            {
6097
                if (e.Data.GetDataPresent(typeof(string)))
6098
                {
6099
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6100
                    string dragData = e.Data.GetData(typeof(string)) as string;
6101
                    Move_Symbol(sender, dragData);
6102
                }
6103
            }
6104
            catch (Exception ex)
6105
            {
6106
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6107
            }
6108
        }
6109
        */
6110
    }
6111

    
6112
    public class testItem
6113
    {
6114
        public string Title { get; set; }
6115
    }
6116
}
클립보드 이미지 추가 (최대 크기: 500 MB)