프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (272 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
            string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt32(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
319
            if (userData.COMPANY != "EXT")
320
            {
321
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
322
            }
323
            else
324
            {
325
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
326
            }
327
            uri = uri.Replace(".png", "");
328
            return uri;
329
        }
330

    
331
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
332
        {
333
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
334
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
335
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
336
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
337
            {
338
                return true;
339
            }
340

    
341
            return false;
342
        }
343

    
344
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
345
        {
346
            if (rotate.Angle == 90 || rotate.Angle == 270)
347
            {
348
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
349
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
350
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
351
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
352
                {
353
                    return true;
354
                }
355
            }
356
            else
357
            {
358
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
359
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
360
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
361
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
362
                {
363
                    return true;
364
                }
365
            }
366

    
367
            return false;
368
        }
369

    
370
        public void DeleteItem(MarkupInfoItem item)
371
        {
372
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
373
            {
374
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
375
            }
376

    
377
            ViewerDataModel.Instance._markupInfoList.Remove(item);
378

    
379
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
380
            {
381
                ViewerDataModel.Instance.MarkupControls.Remove(a);
382
            });
383

    
384
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
385
            {
386
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
387
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
388
                null, Event_Type.Delete, a.CommentID, null);
389
            });
390

    
391
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
392
            {
393
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
394
                //임시파일에서도 삭제
395
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
396
            });
397

    
398
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
399

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

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

    
461
                        Button content = (sender as Button);
462
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
463

    
464
                        DeleteItem(item);
465
                    }
466
                }
467
            };
468
            RadWindow.Confirm(parameters);
469
        }
470

    
471
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
472

    
473
        private static Timer timer;
474
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
475

    
476
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
477
        {
478
            //InitializeComponent();
479
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
480

    
481
            if (App.ParameterMode)
482
            {
483

    
484
                App.splashString(ISplashMessage.MAINMENU_1);
485
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
486
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
487
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
488

    
489
                imageViewer_Compare = new Image();
490
                ViewerDataModel.Instance.Capture_Opacity = 0;
491
                da.From = 0.8;
492
                da.To = 0;
493
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
494
                da.AutoReverse = true;
495
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
496

    
497
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
498
                {
499
                    this.SymbolPane.Visibility = Visibility.Collapsed;
500
                    this.FavoritePane.Visibility = Visibility.Collapsed;
501
                    this.drawingRotateCanvas.IsHitTestVisible = false;
502
                }
503
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
504
            }
505

    
506
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
507
        }
508

    
509
        private void DownloadOriginalFile()
510
        {
511
            #region 임시파일 다운로드
512
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
513
            downloadurl = GetOriginalPDFURL();
514

    
515
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
516
            
517
            string endpoint = Common.Commons.shortGuid() + "file";
518
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
519
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
520
            wcfServer.Start();
521
            
522
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile);
523
            #endregion
524
        }
525

    
526
        string instnaceFile;
527
        string downloadurl;
528

    
529
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
530
        {
531
            Dispatcher.BeginInvoke((Action)delegate () { ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress; });
532

    
533
            if (e.IsFinish)
534
            {
535
                ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
536
                ViewerDataModel.Instance.IsDownloadOriginal = true;
537
           
538
            }
539
        }
540

    
541
        private void timercallback(Object o)
542
        {
543
            Stopwatch sw = new Stopwatch();
544
            sw.Start();
545
            TempFile.TempFileAdd();
546
            sw.Stop();
547

    
548
            Dispatcher.InvokeAsync(new Action(delegate
549
            {
550
                if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
551
                {
552
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
553
                }
554
            }));
555

    
556
            ////GC.Collect();
557
        }
558

    
559
        /// <summary>
560
        /// update my markuplist
561
        ///  - update existing markup data if already exist
562
        ///  - add new markup data if control is new
563
        /// </summary>
564
        public void UpdateMyMarkupList()
565
        {
566
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
567

    
568
            /// add or update markup list
569
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
570
            {
571
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
572

    
573
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
574
                if (exist != null) //신규 추가 된 코멘트
575
                {
576
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
577
                    {
578
                        exist.Data = root.ConvertData;
579
                        exist.IsUpdate = true;
580
                    }
581
                }
582
                else if (root.CommentID != null)
583
                {
584
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
585
                    {
586
                        ID = control.CommentID,
587
                        Data = root.ConvertData,
588
                        Data_Type = root.DATA_TYPE,
589
                        MarkupInfoID = App.Custom_ViewInfoId,
590
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
591
                        Symbol_ID = control.SymbolID,
592
                        //Group_ID = control.GroupID,
593
                    });
594
                }
595
            }
596

    
597
            //if (this.pageNavigator.CurrentPage != null)
598
            //{
599
            //    /// delete markup list
600
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
601

    
602
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
603
            //                   where (markup.PageNumber == iPageNo)
604
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
605
            //                   select markup).ToList();
606

    
607
            //    foreach (var markup in deleted)
608
            //    {
609
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
610
            //    }
611
            //}
612
            //else
613
            //{
614
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
615
            //}
616

    
617
            /// up to here
618

    
619
            //if (modified)
620
            //{
621
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
622
            //    {
623
            //        ComingNewBieEnd = true;
624
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
625
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
626
            //        gridViewMarkup.ItemsSource = null;
627
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
628
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
629

    
630
            //        GroupDescriptor descriptor = new GroupDescriptor();
631
            //        descriptor.Member = "Depatment";
632
            //        descriptor.DisplayContent = "DEPT";
633
            //        descriptor.SortDirection = ListSortDirection.Ascending;
634
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
635
            //    }
636
            //}
637
        }
638

    
639
        /// <summary>
640
        /// start page changing
641
        ///  - save controls if page is modified
642
        ///  - starting download page image
643
        /// </summary>
644
        /// <param name="sender"></param>
645
        /// <param name="e"></param>
646
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
647
        {
648
            //await Task.Delay(10);
649

    
650
            // 마크업 로드
651
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
652

    
653
            ViewerDataModel.Instance.PageAngle = e.CurrentPage.PAGE_ANGLE;
654

    
655
            var token = ViewerDataModel.Instance.NewCancellationToken();
656
            
657
            await MarkupLoadAsync(e.PageNumber, ViewerDataModel.Instance.PageAngle, token);
658

    
659
            // 페이지 이미지 변경
660
            await PageChangingAsync(e.CurrentPage, e.PageNumber, token);
661
        }
662

    
663
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
664
        {
665
            CompareMode.IsChecked = false;
666
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
667

    
668
            #region 페이지가 벗어난 경우
669

    
670
            if (BalancePoint < 1)
671
            {
672
                BalancePoint = 1;
673
                ViewerDataModel.Instance.PageBalanceNumber = 0;
674
            }
675

    
676
            if (pageNavigator.PageCount < BalancePoint)
677
            {
678
                BalancePoint = pageNavigator.PageCount;
679
                ViewerDataModel.Instance.PageBalanceNumber = 0;
680
            }
681

    
682
            #endregion 페이지가 벗어난 경우
683

    
684
            ViewerDataModel.Instance.PageNumber = BalancePoint;
685

    
686
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
687
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
688
            var contentScale = zoomAndPanControl.ContentScale;
689

    
690
            #region 페이지 이미지 로딩 수정
691

    
692
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
693

    
694
            ScaleImage(pageWidth, pageHeight);
695

    
696
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
697
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
698

    
699
            zoomAndPanCanvas.Width = pageWidth;
700
            zoomAndPanCanvas.Height = pageHeight;
701

    
702
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
703
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
704

    
705
            inkBoard.Width = pageWidth;
706
            inkBoard.Height = pageHeight;
707

    
708
            #endregion 페이지 이미지 로딩 수정
709

    
710
            if (!testPanel2.IsHidden)
711
            {
712
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
713
                //PDF모드일때 잠시 대기(강인구)
714
                if (IsSyncPDFMode)
715
                {
716
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
717
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
718

    
719
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
720
                    if (pdfpath.IsDownloading)
721
                    {
722
                        pdfpath.DownloadCompleted += (ex, arg) =>
723
                        {
724
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
725
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
726
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
727
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
728
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
729
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
730
                        };
731
                    }
732
                    else
733
                    {
734
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
735
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
736
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
737
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
738

    
739
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
740
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
741
                    }
742
                }
743
                else
744
                {
745
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
746
                    string uri2 = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
747

    
748
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
749
                    var defaultBitmapImage_Compare = new BitmapImage();
750
                    defaultBitmapImage_Compare.BeginInit();
751
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
752
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
753
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
754
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
755
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
756
                    defaultBitmapImage_Compare.EndInit();
757

    
758
                    ViewerDataModel.Instance.ImageViewPath_C = null;
759

    
760
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
761
                    zoomAndPanControl.ZoomTo(new Rect
762
                    {
763
                        X = 0,
764
                        Y = 0,
765
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
766
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
767
                    });
768

    
769
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
770
                    if (defaultBitmapImage_Compare.IsDownloading)
771
                    {
772
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
773
                        {
774
                            defaultBitmapImage_Compare.Freeze();
775
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
776
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
777
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
778
                            ComparePanel.UpdateLayout();
779
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
780
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
781

    
782
                            zoomAndPanControl.ZoomTo(new Rect
783
                            {
784
                                X = 0,
785
                                Y = 0,
786
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
787
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
788
                            });
789

    
790
                            //defaultBitmapImage_Compare dispose
791
                            defaultBitmapImage_Compare = null;
792
                            GC.Collect();
793
                        };
794
                    }
795
                }
796
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
797
            }
798

    
799
            SearchFocusBorder.Visibility = Visibility.Collapsed;
800

    
801
            this.pageNavigator.ChangePage(changePageNumber);
802
        }
803

    
804
        /// <summary>
805
        /// called after page is changed
806
        /// </summary>
807
        /// <param name="sender"></param>
808
        /// <param name="e"></param>
809
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
810
        {
811
            //if (zoomAndPanCanvas.Width.IsNaN())
812
            //{
813
            await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
814
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
815
                );
816
            //}
817

    
818
            var instanceMain = ViewerDataModel.Instance.SystemMain;
819

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

    
822
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
823
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
824

    
825
            instanceMain.dzTopMenu.rotateOffSet = 0;
826
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
827
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
828

    
829
            /// 페이지의 모든 마크업을 로드한 후 호출
830
            /// 좌측 마크업 list의 아이템을 클릭하는 경우 MarkupControls_USER가 0으로 나와서 추가함.
831
            ViewerDataModel.Instance.LoadPageMarkupFinish();
832

    
833
            //Point startPoint = new Point(15, 15);
834

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

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

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

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

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

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

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

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

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

    
857
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
858
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
859
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
860
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
861
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
862

    
863
            //symCtrl.ApplyTemplate();
864
            ////txtApproved.ApplyTemplate();
865
            ////txtCreator.ApplyTemplate();
866
            //txtOriginator.ApplyTemplate();
867
            //txtDate.ApplyTemplate();
868

    
869
            ////SetTextControl(txtApproved);
870
            ////SetTextControl(txtCreator);
871
            //SetTextControl(txtOriginator);
872
            //SetTextControl(txtDate);
873

    
874
            //multi_Undo_Data = new Multi_Undo_data();
875

    
876
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
877
            //{
878
            //    IsUndo = false,
879
            //    Event = Event_Type.Create,
880
            //    EventTime = DateTime.Now,
881
            //    Markup_List = new List<Multi_Undo_data>()
882
            //};
883

    
884
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
885
            //UndoData.Markup_List.Add(multi_Undo_Data);
886

    
887
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
888
            ////UndoData.Markup_List.Add(multi_Undo_Data);
889

    
890
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
891
            ////UndoData.Markup_List.Add(multi_Undo_Data);
892

    
893
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
894
            //UndoData.Markup_List.Add(multi_Undo_Data);
895

    
896
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
897
            //UndoData.Markup_List.Add(multi_Undo_Data);
898

    
899
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
900

    
901
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
902
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
903
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
904
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
905
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
906
        }
907

    
908
        private void SetTextControl(TextControl textControl)
909
        {
910
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
911
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
912
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
913
        }
914

    
915
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
916
        {
917
            SymControlN result = null;
918

    
919
            try
920
            {
921
                double height = 80;
922
                double itemWidth = 180;
923

    
924
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
925
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
926
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
927
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
928

    
929
                result = new SymControlN
930
                {
931
                    CommentID = Commons.shortGuid(),
932
                    MarkupInfoID = markupInfoId,
933
                    UserID = userId,
934
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
935
                    StartPoint = startPoint,
936
                    EndPoint = endPoint,
937
                    CommentAngle = 0,
938
                    LeftBottomPoint = leftBottomPoint,
939
                    TopRightPoint = topRightPoint,
940
                    Opacity = 1,
941
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
942
                    Memo = null
943
                };
944
            }
945
            catch (Exception ex)
946
            {
947
                System.Diagnostics.Debug.WriteLine(ex.ToString());
948
            }
949

    
950
            return result;
951
        }
952

    
953
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
954
        {
955
            RectangleControl result = null;
956

    
957
            try
958
            {
959
                double height = 80;
960
                double itemWidth = 180;
961

    
962
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
963
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
964
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
965
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
966

    
967
                result = new RectangleControl
968
                {
969
                    CommentID = Commons.shortGuid(),
970
                    MarkupInfoID = markupInfoId,
971
                    LineSize = 5,
972
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
973
                    StartPoint = startPoint,
974
                    EndPoint = endPoint,
975
                    CommentAngle = 0,
976
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
977
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
978
                    FillColor = null,
979
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
980
                    Opacity = 1,
981
                    LeftBottomPoint = leftBottomPoint,
982
                    TopRightPoint = topRightPoint,
983
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
984
                    UserID = userId,
985
                    Memo = null
986
                };
987
            }
988
            catch (Exception ex)
989
            {
990
                System.Diagnostics.Debug.WriteLine(ex.ToString());
991
            }
992

    
993
            return result;
994
        }
995

    
996
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
997
        {
998
            TextControl result = null;
999

    
1000
            try
1001
            {
1002
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1003

    
1004
                double startPositionX = parentRect.X;
1005

    
1006
                switch (textAlignment)
1007
                {
1008
                    case TextAlignment.Right:
1009
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1010
                        break;
1011

    
1012
                    case TextAlignment.Center:
1013
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1014
                        break;
1015
                }
1016

    
1017
                Point startPosition = new Point
1018
                {
1019
                    X = startPositionX,
1020
                    Y = positionY
1021
                };
1022

    
1023
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1024
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1025
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1026
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1027

    
1028
                result = new TextControl
1029
                {
1030
                    CommentID = Commons.shortGuid(),
1031
                    MarkupInfoID = markupInfoId,
1032
                    Text = Text,
1033
                    StartPoint = startPoint,
1034
                    EndPoint = endPoint,
1035
                    CanvasX = startPosition.X,
1036
                    CanvasY = startPosition.Y,
1037
                    BoxWidth = txtSize.Width,
1038
                    BoxHeight = txtSize.Height,
1039
                    ControlType_No = 0,
1040
                    LineSize = new Thickness(5),
1041
                    TextSize = fontSize,
1042
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1043
                    FontSize = 10,
1044
                    UserID = userId,
1045
                    IsHighLight = false,
1046
                    CommentAngle = 0,
1047
                    PointSet = new List<Point>(),
1048
                    Opacity = 1,
1049
                    IsSelected = false,
1050
                    TextFamily = new FontFamily("Tahoma"),
1051
                    TextStyle = FontStyles.Normal,
1052
                    TextWeight = FontWeights.Bold
1053
                };
1054
            }
1055
            catch (Exception ex)
1056
            {
1057
            }
1058

    
1059
            return result;
1060
        }
1061

    
1062
        public static Size ShapeMeasure(UIElement e)
1063
        {
1064
            // Measured Size is bounded to be less than maxSize
1065
            Size maxSize = new Size(
1066
                 double.PositiveInfinity,
1067
                 double.PositiveInfinity);
1068
            e.Measure(maxSize);
1069
            return e.DesiredSize;
1070
        }
1071

    
1072
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1073
        {
1074
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1075
            stopwatch.Start();
1076

    
1077
            /// 컨트롤을 새로 생성한다.
1078
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1079
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1080

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

    
1083
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1084
            {
1085
                if (cts.IsCancellationRequested)
1086
                {
1087
                    return;
1088
                }
1089

    
1090
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1091
                if (info != null)
1092
                {
1093
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1094
                    if (info.UserID == App.ViewInfo.UserID)
1095
                    {
1096
                        var control = await MarkupParser.ParseExAsync(cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1097
                                        markup.MarkupInfoID, markup.ID);
1098
                        control.Visibility = Visibility.Hidden;
1099
                    }
1100
                    else
1101
                    {
1102
                        var control = await MarkupParser.ParseExAsync(cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1103
                                                                markup.MarkupInfoID, markup.ID);
1104
                        control.Visibility = Visibility.Hidden;
1105
                    }
1106
                }
1107

    
1108
            };
1109
            /// up to here
1110

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

    
1113
            /// fire selection event
1114
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1115
            this.gridViewMarkup.UnselectAll();
1116
            this.gridViewMarkup.Select(gridSelectionItem);
1117

    
1118
            if (!testPanel2.IsHidden)
1119
            {
1120
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1121
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1122
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1123

    
1124
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1125
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1126

    
1127
                foreach (var item in gridSelectionRevItem)
1128
                {
1129
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1130

    
1131
                    foreach (var markupitem in markupitems)
1132
                    {
1133
                        await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1134

    
1135
                        if (cts.IsCancellationRequested)
1136
                        {
1137
                            return;
1138
                        }
1139
                    }
1140
                }
1141
            }
1142

    
1143
            SetCommentPages(cts);
1144
        }
1145

    
1146
        public void SetCommentPages(CancellationToken? cts)
1147
        {
1148
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1149
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1150
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1151
            {
1152
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1153
                if (item.MarkupList != null)
1154
                {
1155
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1156
                    instance.UserName = item.UserName;
1157
                    instance.Depart = item.Depatment;
1158
                    instance.MarkupInfoID = item.MarkupInfoID;
1159
                    instance.IsSelected = true;
1160
                    instance.isConSolidation = item.Consolidate;
1161
                    instance.SetColor = item.DisplayColor;
1162
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1163
                    {
1164
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1165
                    }
1166
                    else
1167
                    {
1168
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1169
                    }
1170
                    _pages.Add(instance);
1171
                }
1172

    
1173
                if (cts != null)
1174
                {
1175
                    if (cts.Value.IsCancellationRequested)
1176
                        return;
1177
                }
1178
            }
1179

    
1180
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1181
        }
1182

    
1183
        public void MarkupitemViewUpdate(string markupinfo_id)
1184
        {
1185
            //db에 업데이트 한 list 를 view 에 업데이트
1186
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1187
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1188
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1189
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1190
            if (dbinfo.MarkupList.Count > 0)
1191
            {
1192
                if (viewinfo.MarkupList != null)
1193
                {
1194
                    viewinfo.MarkupList.Clear();
1195
                    viewinfo.MarkupList = null;
1196
                }
1197
                viewinfo.MarkupList = new List<MarkupItem>();
1198
                foreach (var item in dbinfo.MarkupList)
1199
                {
1200
                    viewinfo.MarkupList.Add(item);
1201
                }
1202
            }
1203
        }
1204

    
1205
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1206
        {
1207
            var instance = ViewerDataModel.Instance;
1208

    
1209
            if (instance.IsWheelPageChanage)
1210
            {
1211
                return;
1212
            }
1213

    
1214
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1215
            {
1216
                int changePage = 0;
1217

    
1218
                if (e.Delta > 0)
1219
                {
1220
                    if (0 < instance.ContentOffsetY)
1221
                    {
1222
                        Vector dragOffset = new Vector(0, e.Delta);
1223
                        MoveZoomAndPanControl(dragOffset);
1224
                    }
1225
                    //else
1226
                    //{
1227
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1228
                    //    {
1229
                    //        instance.IsWheelPageChanage = true;
1230
                    //        changePage -= 1;
1231
                    //    }
1232
                    //}
1233
                }
1234
                else if (e.Delta < 0)
1235
                {
1236
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1237
                    {
1238
                        Vector dragOffset = new Vector(0, e.Delta);
1239
                        MoveZoomAndPanControl(dragOffset);
1240
                    }
1241
                    //else
1242
                    //{
1243
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1244
                    //    {
1245
                    //        instance.IsWheelPageChanage = true;
1246
                    //        changePage += 1;
1247
                    //    }
1248
                    //}
1249
                }
1250

    
1251
                //if (changePage != 0)
1252
                //{
1253
                //    await Task.Factory.StartNew(() =>
1254
                //    {
1255
                //        double beforeScale = instance.ContentScale;
1256

    
1257
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1258

    
1259
                //        handler = (snd, evt) =>
1260
                //        {
1261
                //            /// 최상단으로 이전 zoomScale로 위치한다
1262
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1263
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1264
                //            instance.IsWheelPageChanage = false;
1265
                //            pageNavigator.PageChanged -= handler;
1266
                //        };
1267

    
1268
                //        pageNavigator.PageChanged += handler;
1269

    
1270
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1271
                //    });
1272

    
1273
                //}
1274
            }
1275
            else
1276
            {
1277
                e.Handled = true;
1278
                if (e.Delta > 0)
1279
                {
1280
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1281
                    ZoomIn(currentContentMousePoint);
1282
                }
1283
                else
1284
                {
1285
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1286
                    ZoomOut(currentContentMousePoint);
1287
                }
1288
            }
1289
        }
1290

    
1291
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1292
        {
1293
            e.Handled = true;
1294
            if (e.Delta > 0)
1295
            {
1296
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1297
                ZoomIn_Sync(currentContentMousePoint);
1298
            }
1299
            else
1300
            {
1301
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1302
                ZoomOut_Sync(currentContentMousePoint);
1303
            }
1304
        }
1305

    
1306
        #region ZoomIn & ZoomOut
1307

    
1308
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1309
        {
1310
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1311
                zoomAndPanControl.ContentZoomFocusY));
1312
        }
1313

    
1314
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1315
        {
1316
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1317
                zoomAndPanControl.ContentZoomFocusY));
1318
        }
1319

    
1320
        //강인구 추가 (줌 인아웃 수치 변경)
1321
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1322
        private void ZoomOut(Point contentZoomCenter)
1323
        {
1324
            if (zoomAndPanControl.ContentScale > 0.39)
1325
            {
1326
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1327
            }
1328
            else
1329
            {
1330
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1331
            }
1332

    
1333
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1334
            {
1335
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1336
            }
1337
        }
1338

    
1339
        private void ZoomIn(Point contentZoomCenter)
1340
        {
1341
            if (zoomAndPanControl.ContentScale > 0.19)
1342
            {
1343
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1344
            }
1345
            else
1346
            {
1347
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1348
            }
1349

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

    
1356
        private void ZoomOut_Sync(Point contentZoomCenter)
1357
        {
1358
            if (zoomAndPanControl2.ContentScale > 0.39)
1359
            {
1360
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1361
            }
1362
            else
1363
            {
1364
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1365
            }
1366

    
1367
            if (Sync.IsChecked)
1368
            {
1369
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1370
            }
1371
        }
1372

    
1373
        private void ZoomIn_Sync(Point contentZoomCenter)
1374
        {
1375
            if (zoomAndPanControl2.ContentScale > 0.19)
1376
            {
1377
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1378
            }
1379
            else
1380
            {
1381
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1382
            }
1383

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

    
1390
        private void ZoomOut()
1391
        {
1392
            zoomAndPanControl.ContentScale -= 0.1;
1393
            //if (zoomAndPanControl2 != null)
1394
            //{
1395
            //    zoomAndPanControl2.ContentScale -= 0.1;
1396
            //}
1397
        }
1398

    
1399
        private void ZoomIn()
1400
        {
1401
            zoomAndPanControl.ContentScale += 0.1;
1402
            //if (zoomAndPanControl2 != null)
1403
            //{
1404
            //    zoomAndPanControl2.ContentScale += 0.1;
1405
            //}
1406
        }
1407

    
1408
        #endregion ZoomIn & ZoomOut
1409

    
1410
        private void init()
1411
        {
1412
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1413
            {
1414
                ControlList.Clear();
1415
                listBox.Items.Clear();
1416
                selected_item.Clear();
1417

    
1418
                (item as IMarkupCommonData).IsSelected = false;
1419
            }
1420
        }
1421

    
1422
        private HitTestResultBehavior MyCallback(HitTestResult result)
1423
        {
1424
            //this.cursor = Cursors.UpArrow;
1425
            var element = result.VisualHit;
1426
            while (element != null && !(element is CommentUserInfo))
1427
                element = VisualTreeHelper.GetParent(element);
1428

    
1429
            if (element == null)
1430
            {
1431
                return HitTestResultBehavior.Stop;
1432
            }
1433
            else
1434
            {
1435
                if (element is CommentUserInfo)
1436
                {
1437
                    if (!hitList.Contains(element))
1438
                    {
1439
                        hitList.Add((CommentUserInfo)element);
1440
                    }
1441
                    else
1442
                    {
1443
                        return HitTestResultBehavior.Stop;
1444
                    }
1445
                }
1446
            }
1447
            return HitTestResultBehavior.Continue;
1448
        }
1449

    
1450
        public void ReleaseSelectPath()
1451
        {
1452
            if (SelectionPath == null)
1453
            {
1454
                SelectionPath = new Path();
1455
                SelectionPath.Name = "";
1456
            }
1457
            if (SelectionPath.Name != "")
1458
            {
1459
                SelectionPath.Name = "None";
1460
            }
1461
            SelectionPath.Opacity = 0.01;
1462
            SelectionPath.RenderTransform = null;
1463
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1464
        }
1465

    
1466
        #region 컨트롤 초기화
1467

    
1468
        public void Control_Init(object control)
1469
        {
1470
            if (L_Size != 0 && (control as IPath) != null)
1471
            {
1472
                (control as IPath).LineSize = L_Size;
1473
                L_Size = 0;
1474
            }
1475

    
1476
            switch (control.GetType().Name)
1477
            {
1478
                case "RectangleControl":
1479
                    {
1480
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1481
                    }
1482
                    break;
1483

    
1484
                case "CircleControl":
1485
                    {
1486
                        (control as CircleControl).StrokeColor = Brushes.Red;
1487
                    }
1488
                    break;
1489

    
1490
                case "TriControl":
1491
                    {
1492
                        (control as TriControl).StrokeColor = Brushes.Red;
1493
                    }
1494
                    break;
1495

    
1496
                case "RectCloudControl":
1497
                    {
1498
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1499
                    }
1500
                    break;
1501

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

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

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

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

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

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

    
1538
                case "TextControl":
1539
                    {
1540
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1541
                    }
1542
                    break;
1543

    
1544
                case "ArrowTextControl":
1545
                    {
1546
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1547
                    }
1548
                    break;
1549

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

    
1556
                case "OverlapWhiteControl":
1557
                    {
1558
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1559
                    }
1560
                    break;
1561

    
1562
                case "ClipWhiteControl":
1563
                    {
1564
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1565
                    }
1566
                    break;
1567

    
1568
                case "CoordinateControl":
1569
                    {
1570
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1571
                    }
1572
                    break;
1573
            }
1574
        }
1575

    
1576
        #endregion 컨트롤 초기화
1577

    
1578
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1579
        {
1580
            //Control_Init(e.Source);
1581
        }
1582

    
1583
        //private Window _dragdropWindow = null;
1584

    
1585
        [DllImport("user32.dll")]
1586
        [return: MarshalAs(UnmanagedType.Bool)]
1587
        internal static extern bool GetCursorPos(ref Win32Point pt);
1588

    
1589
        [StructLayout(LayoutKind.Sequential)]
1590
        internal struct Win32Point
1591
        {
1592
            public Int32 X;
1593
            public Int32 Y;
1594
        };
1595

    
1596
        /*
1597
       public string symbol_id = null;
1598
       public long symbol_group_id;
1599
       public int symbol_SelectedIndex;
1600
       public ImageSource symbol_img;
1601
       public string symbol_Data = null;
1602
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1603
       {
1604
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1605
               zoomAndPanCanvas.ActualHeight / 2));
1606

    
1607
               if (this._dragdropWindow != null)
1608
               {
1609
                   this._dragdropWindow.Close();
1610
                   this._dragdropWindow = null;
1611
               }
1612

    
1613
               symbol_id = id;
1614
               symbol_group_id = group_id;
1615
               symbol_SelectedIndex = SelectedIndex;
1616
               symbol_Data = Data_;
1617
               symbol_img = img;
1618

    
1619
               CreateDragDropWindow2(img);
1620
    }
1621

    
1622
    private void CreateDragDropWindow2(ImageSource image)
1623
        {
1624
            this._dragdropWindow = new Window();
1625
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1626
            _dragdropWindow.WindowStyle = WindowStyle.None;
1627
            _dragdropWindow.AllowsTransparency = true;
1628
            _dragdropWindow.AllowDrop = false;
1629
            _dragdropWindow.Background = null;
1630
            _dragdropWindow.IsHitTestVisible = false;
1631
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1632
            _dragdropWindow.Topmost = true;
1633
            _dragdropWindow.ShowInTaskbar = false;
1634

    
1635
            Rectangle r = new Rectangle();
1636
            r.Width = image.Width;
1637
            r.Height = image.Height;
1638
            r.Opacity = 0.5;
1639
            r.Fill = new ImageBrush(image);
1640
            this._dragdropWindow.Content = r;
1641

    
1642
            Win32Point w32Mouse = new Win32Point();
1643
            GetCursorPos(ref w32Mouse);
1644

    
1645
            //w32Mouse.X = getCurrentPoint.X;
1646
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1647
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1648
            this._dragdropWindow.Show();
1649
        }
1650

    
1651
         */
1652

    
1653
        public void MoveZoomAndPanControl(Vector dragOffset)
1654
        {
1655
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1656
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1657

    
1658
            if (Sync.IsChecked)
1659
            {
1660
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1661
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1662
            }
1663
        }
1664

    
1665
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1666
        {
1667
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1668
            {
1669
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1670

    
1671
                Point currentPos = e.GetPosition(rect);
1672

    
1673
                floatingTip.HorizontalOffset = currentPos.X + 20;
1674
                floatingTip.VerticalOffset = currentPos.Y;
1675
            }
1676

    
1677
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1678

    
1679
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1680
            {
1681
                SetCursor();
1682
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1683
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1684

    
1685
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1686

    
1687
                MoveZoomAndPanControl(dragOffset);
1688
            }
1689

    
1690
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1691
            {
1692
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1693
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1694
                SetCursor();
1695

    
1696
                if (currentControl != null)
1697
                {
1698
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1699
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1700
                    //강인구 추가
1701
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1702

    
1703
                    if ((currentControl as IPath) != null)
1704
                    {
1705
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1706
                    }
1707
                    if ((currentControl as LineControl) != null)
1708
                    {
1709
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1710
                    }
1711

    
1712
                    if ((currentControl as IShapeControl) != null)
1713
                    {
1714
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1715
                    }
1716
                    if ((currentControl as TextControl) != null)
1717
                    {
1718
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1719
                        {
1720
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1721
                        }
1722
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1723
                        {
1724
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1725
                        }
1726
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1727
                        {
1728
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1729
                        }
1730
                    }
1731
                    else if ((currentControl as ArrowTextControl) != null)
1732
                    {
1733
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1734
                        {
1735
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1736
                        }
1737
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1738
                        {
1739
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1740
                        }
1741
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1742
                        {
1743
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1744
                        }
1745
                    }
1746
                    else if ((currentControl as RectCloudControl) != null)
1747
                    {
1748
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1749
                    }
1750
                    else if ((currentControl as CloudControl) != null)
1751
                    {
1752
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1753
                    }
1754

    
1755
                    #region // 모든 컨트롤의 공통기능 제어
1756

    
1757
                    if (controlType != ControlType.PenControl)
1758
                    {
1759
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1760
                    }
1761

    
1762
                    #endregion // 모든 컨트롤의 공통기능 제어
1763

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

    
1766
                    switch (controlType)
1767
                    {
1768
                        case (ControlType.Coordinate):
1769
                            {
1770
                                var control = currentControl as CoordinateControl;
1771
                                if (control != null)
1772
                                {
1773
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1774
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1775
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1776
                                }
1777
                            }
1778
                            break;
1779

    
1780
                        case (ControlType.InsideWhite):
1781
                            {
1782
                                var control = currentControl as InsideWhiteControl;
1783
                                if (control != null)
1784
                                {
1785
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1786
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1787
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1788
                                    control.Paint = PaintSet.Fill;
1789
                                }
1790
                            }
1791
                            break;
1792

    
1793
                        case ControlType.OverlapWhite:
1794
                            {
1795
                                var control = currentControl as OverlapWhiteControl;
1796
                                if (control != null)
1797
                                {
1798
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1799
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1800
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1801
                                    control.Paint = PaintSet.Fill;
1802
                                }
1803
                            }
1804
                            break;
1805

    
1806
                        case ControlType.ClipWhite:
1807
                            {
1808
                                var control = currentControl as ClipWhiteControl;
1809
                                if (control != null)
1810
                                {
1811
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1812
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1813
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1814
                                    control.Paint = PaintSet.Fill;
1815
                                }
1816
                            }
1817
                            break;
1818

    
1819
                        case ControlType.RectCloud:
1820
                            {
1821
                                var control = currentControl as RectCloudControl;
1822
                                if (control != null)
1823
                                {
1824
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1825
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1826
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1827
                                }
1828
                            }
1829
                            break;
1830

    
1831
                        case ControlType.SingleLine:
1832
                        case ControlType.CancelLine:
1833
                        case ControlType.ArrowLine:
1834
                        case ControlType.TwinLine:
1835
                        case ControlType.DimLine:
1836
                            {
1837
                                var control = currentControl as LineControl;
1838
                                if (control != null)
1839
                                {
1840
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1841
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1842
                                }
1843
                            }
1844
                            break;
1845

    
1846
                        case ControlType.ArcLine:
1847
                            {
1848
                                var control = currentControl as ArcControl;
1849
                                if (control != null)
1850
                                {
1851
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1852
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1853
                                }
1854
                            }
1855
                            break;
1856

    
1857
                        case ControlType.ArcArrow:
1858
                            {
1859
                                var control = currentControl as ArrowArcControl;
1860
                                if (control != null)
1861
                                {
1862
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1863
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1864
                                }
1865
                            }
1866
                            break;
1867

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

    
1879
                        case ControlType.Circle:
1880
                            {
1881
                                var control = currentControl as CircleControl;
1882

    
1883
                                if (control != null)
1884
                                {
1885
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1886
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1887
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1888
                                }
1889
                            }
1890
                            break;
1891

    
1892
                        case ControlType.PolygonCloud:
1893
                            {
1894
                                var control = currentControl as CloudControl;
1895
                                if (control != null)
1896
                                {
1897
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1898
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1899
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1900
                                }
1901
                            }
1902
                            break;
1903

    
1904
                        case ControlType.Triangle:
1905
                            {
1906
                                var control = currentControl as TriControl;
1907
                                if (control != null)
1908
                                {
1909
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1910
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1911
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1912
                                }
1913
                            }
1914
                            break;
1915

    
1916
                        case ControlType.ImgControl:
1917
                            {
1918
                                var control = currentControl as ImgControl;
1919
                                if (control != null)
1920
                                {
1921
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1922
                                }
1923
                            }
1924
                            break;
1925

    
1926
                        case ControlType.Date:
1927
                            {
1928
                                var control = currentControl as DateControl;
1929
                                if (control != null)
1930
                                {
1931
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1932
                                }
1933
                            }
1934
                            break;
1935

    
1936
                        case ControlType.ArrowTextControl:
1937
                        case ControlType.ArrowTransTextControl:
1938
                        case ControlType.ArrowTextBorderControl:
1939
                        case ControlType.ArrowTransTextBorderControl:
1940
                        case ControlType.ArrowTextCloudControl:
1941
                        case ControlType.ArrowTransTextCloudControl:
1942
                            {
1943
                                var control = currentControl as ArrowTextControl;
1944
                                if (control != null)
1945
                                {
1946
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1947
                                }
1948
                            }
1949
                            break;
1950

    
1951
                        case ControlType.PolygonControl:
1952
                        case ControlType.ChainLine:
1953
                            {
1954
                                var control = currentControl as PolygonControl;
1955
                                if (control != null)
1956
                                {
1957
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1958
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1959
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1960
                                }
1961
                            }
1962
                            break;
1963

    
1964
                        case ControlType.Sign:
1965
                            {
1966
                                var control = currentControl as SignControl;
1967
                                if (control != null)
1968
                                {
1969
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1970
                                }
1971
                            }
1972
                            break;
1973

    
1974
                        case ControlType.Symbol:
1975
                            {
1976
                                var control = currentControl as SymControl;
1977
                                if (control != null)
1978
                                {
1979
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1980
                                }
1981
                            }
1982
                            break;
1983

    
1984
                        case ControlType.Stamp:
1985
                            {
1986
                                var control = currentControl as SymControlN;
1987
                                if (control != null)
1988
                                {
1989
                                    if (control.STAMP != null)
1990
                                    {
1991
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1992
                                    }
1993
                                    else
1994
                                    {
1995
                                        currentControl = null;
1996
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
1997
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1998
                                    }
1999
                                }
2000
                            }
2001
                            break;
2002

    
2003
                        case ControlType.Rectangle:
2004
                        case ControlType.Mark:
2005
                            {
2006
                                var control = currentControl as RectangleControl;
2007
                                if (control != null)
2008
                                {
2009
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2010
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2011
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2012
                                }
2013
                            }
2014
                            break;
2015

    
2016
                        case ControlType.PenControl:
2017
                            {
2018
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2019
                                //inkBoard.Strokes.Add(stroke);
2020
                            }
2021
                            break;
2022

    
2023
                        default:
2024
                            break;
2025
                    }
2026

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

    
2029
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2030
                    {
2031
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2032
                    }
2033
                }
2034
            }
2035
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2036
            {
2037
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2038
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2039
                SetCursor();
2040
                if (currentControl == null)
2041
                {
2042
                    switch (controlType)
2043
                    {
2044
                        case ControlType.PenControl:
2045
                            {
2046
                                if (inkBoard.Tag.ToString() == "Ink")
2047
                                {
2048
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2049
                                }
2050
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2051
                                {
2052
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2053
                                }
2054
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2055
                                {
2056
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2057
                                }
2058

    
2059
                                //inkBoard.Strokes.Add(stroke);
2060
                            }
2061
                            break;
2062
                    }
2063
                    return;
2064
                }
2065
            }
2066
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2067
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2068
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2069
            {
2070
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2071

    
2072
                if (isDraggingSelectionRect)
2073
                {
2074
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2075
                    e.Handled = true;
2076
                }
2077
                else if (isLeftMouseButtonDownOnWindow)
2078
                {
2079
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2080
                    double dragDistance = Math.Abs(dragDelta.Length);
2081

    
2082
                    if (dragDistance > DragThreshold)
2083
                    {
2084
                        isDraggingSelectionRect = true;
2085
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2086
                    }
2087

    
2088
                    e.Handled = true;
2089
                }
2090

    
2091
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2092
                {
2093
                }
2094
                else
2095
                {
2096
                    e.Handled = true;
2097
                }
2098
            }
2099
            /*
2100
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2101
            { //symbol
2102
                if(_dragdropWindow != null)
2103
                {
2104
                    Win32Point w32Mouse = new Win32Point();
2105
                    GetCursorPos(ref w32Mouse);
2106

    
2107
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2108
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2109
                }
2110
            }
2111
            */
2112
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2113
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2114
            {
2115
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2116
                if (control != null)
2117
                {
2118
                    this.cursor = Cursors.Hand;
2119
                    SetCursor();
2120
                }
2121
                else
2122
                {
2123
                    if (this.Cursor != Cursors.None)
2124
                    {
2125
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2126
                        SetCursor();
2127
                    }
2128
                }
2129
            }
2130
            else
2131
            {
2132
            }
2133
        }
2134

    
2135
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2136
        {
2137
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2138
            {
2139
                SetCursor();
2140
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2141
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2142

    
2143
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2144

    
2145
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2146
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2147

    
2148
                if (Sync.IsChecked)
2149
                {
2150
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2151
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2152
                }
2153
            }
2154
        }
2155

    
2156
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2157

    
2158
        private EllipseGeometry hitArea = new EllipseGeometry();
2159

    
2160
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2161
        {
2162
            IsDrawing = false;
2163

    
2164
            if (mouseHandlingMode != MouseHandlingMode.None)
2165
            {
2166
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2167
                {
2168
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2169

    
2170
                    SetCursor();
2171

    
2172
                    switch (controlType)
2173
                    {
2174
                        case ControlType.None:
2175
                            break;
2176

    
2177
                        case ControlType.Rectangle:
2178
                            {
2179
                            }
2180
                            break;
2181

    
2182
                        case ControlType.PenControl:
2183
                            {
2184
                            }
2185
                            break;
2186

    
2187
                        default:
2188
                            break;
2189
                    }
2190
                }
2191
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2192
                {
2193
                    if (isLeftMouseButtonDownOnWindow)
2194
                    {
2195
                        bool wasDragSelectionApplied = false;
2196

    
2197
                        if (isDraggingSelectionRect)
2198
                        {
2199
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2200
                            {
2201
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2202
                                mouseHandlingMode = MouseHandlingMode.None;
2203
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2204
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2205
                                Set_Symbol_Capture(endPoint);
2206
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2207
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2208
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2209
                            }
2210
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2211
                            {
2212
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2213
                                mouseHandlingMode = MouseHandlingMode.None;
2214
                                Set_Capture();
2215

    
2216
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2217
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2218
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2219
                            }
2220
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2221
                            {
2222
                                ApplyDragSelectionRect();
2223
                            }
2224
                            else
2225
                            {
2226
                                double x = Canvas.GetLeft(dragZoomBorder);
2227
                                double y = Canvas.GetTop(dragZoomBorder);
2228
                                double width = dragZoomBorder.Width;
2229
                                double height = dragZoomBorder.Height;
2230
                                Rect dragRect = new Rect(x, y, width, height);
2231

    
2232
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2233

    
2234
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2235
                            }
2236

    
2237
                            isDraggingSelectionRect = false;
2238
                            e.Handled = true;
2239
                            wasDragSelectionApplied = true;
2240
                        }
2241

    
2242
                        if (isLeftMouseButtonDownOnWindow)
2243
                        {
2244
                            isLeftMouseButtonDownOnWindow = false;
2245
                            this.ReleaseMouseCapture();
2246
                            e.Handled = true;
2247
                        }
2248

    
2249
                        if (!wasDragSelectionApplied)
2250
                        {
2251
                            init();
2252
                        }
2253
                    }
2254
                }
2255
                else if (e.RightButton == MouseButtonState.Pressed)
2256
                {
2257
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2258
                    SetCursor();
2259
                }
2260

    
2261
                zoomAndPanControl.ReleaseMouseCapture();
2262

    
2263
                e.Handled = true;
2264
            }
2265
            else
2266
            {
2267
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2268
                SetCursor();
2269
            }
2270

    
2271
            ///mouseButtonDown = MouseButton.Left;
2272
            //controlType = ControlType.SingleLine;
2273
        }
2274

    
2275
        public void Set_Symbol_Capture(Point endPoint)
2276
        {
2277
            double x = CanvasDrawingMouseDownPoint.X;
2278
            double y = CanvasDrawingMouseDownPoint.Y;
2279
            if (x > endPoint.X)
2280
            {
2281
                x = endPoint.X;
2282
                y = endPoint.Y;
2283
            }
2284

    
2285
            double width = dragCaptureBorder.Width;
2286
            double height = dragCaptureBorder.Height;
2287

    
2288
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2289

    
2290
            if (x < 0)
2291
            {
2292
                width += x;
2293
                x = 0;
2294
            }
2295
            if (y < 0)
2296
            {
2297
                height += y;
2298
                y = 0;
2299

    
2300
                width = (int)canvasImage.PixelWidth - x;
2301
            }
2302
            if (x + width > canvasImage.PixelWidth)
2303
            {
2304
                width = (int)canvasImage.PixelWidth - x;
2305
            }
2306
            if (y + height > canvasImage.PixelHeight)
2307
            {
2308
                height = (int)canvasImage.PixelHeight - y;
2309
            }
2310
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2311

    
2312
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2313
            var defaultBitmapImage = new BitmapImage();
2314
            defaultBitmapImage.BeginInit();
2315
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2316
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2317
            defaultBitmapImage.UriSource = new Uri(uri);
2318
            defaultBitmapImage.EndInit();
2319

    
2320
            //GC.Collect();
2321

    
2322
            if (defaultBitmapImage.IsDownloading)
2323
            {
2324
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2325
                {
2326
                    defaultBitmapImage.Freeze();
2327
                    //GC.Collect();
2328
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2329
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2330
                };
2331
            }
2332
        }
2333

    
2334
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2335
        {
2336
            ///mouseButtonDown = MouseButton.Left;
2337
        }
2338

    
2339
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2340
        {
2341
            ///mouseButtonDown = MouseButton.Left;
2342
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2343
        }
2344

    
2345
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2346
        {
2347
        }
2348

    
2349
        /// <summary>
2350
        /// select items by dragging
2351
        /// </summary>
2352
        private void ApplyDragSelectionRect()
2353
        {
2354
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2355

    
2356
            double x = Canvas.GetLeft(dragSelectionBorder);
2357
            double y = Canvas.GetTop(dragSelectionBorder);
2358
            double width = dragSelectionBorder.Width;
2359
            double height = dragSelectionBorder.Height;
2360
            Boolean Flag = false;
2361
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2362
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2363

    
2364
            Rect dragRect = new Rect(x, y, width, height);
2365
            ///dragRect.Inflate(width / 10, height / 10);
2366

    
2367
            foreach (var item in Items)
2368
            {
2369
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2370

    
2371
                if (Flag)
2372
                {
2373
                    adornerSet.Add(item);
2374
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2375
                    Control_Style(item);
2376
                }
2377
            }
2378
            if (adornerSet.Count > 0)
2379
            {
2380
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2381
                SelectLayer.Children.Add(final);
2382
            }
2383
        }
2384

    
2385
        private void InitDragSelectionRect(Point pt1, Point pt2)
2386
        {
2387
            //캡쳐 중
2388
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2389
            {
2390
                dragCaptureBorder.Visibility = Visibility.Visible;
2391
            }
2392
            //선택 중
2393
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2394
            {
2395
                dragSelectionBorder.Visibility = Visibility.Visible;
2396
            }
2397
            else
2398
            {
2399
                dragZoomBorder.Visibility = Visibility.Visible;
2400
            }
2401
            UpdateDragSelectionRect(pt1, pt2);
2402
        }
2403

    
2404
        /// <summary>
2405
        /// Update the position and size of the rectangle used for drag selection.
2406
        /// </summary>
2407
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2408
        {
2409
            double x, y, width, height;
2410

    
2411
            //
2412
            // Determine x,y,width and height of the rect inverting the points if necessary.
2413
            //
2414

    
2415
            if (pt2.X < pt1.X)
2416
            {
2417
                x = pt2.X;
2418
                width = pt1.X - pt2.X;
2419
            }
2420
            else
2421
            {
2422
                x = pt1.X;
2423
                width = pt2.X - pt1.X;
2424
            }
2425

    
2426
            if (pt2.Y < pt1.Y)
2427
            {
2428
                y = pt2.Y;
2429
                height = pt1.Y - pt2.Y;
2430
            }
2431
            else
2432
            {
2433
                y = pt1.Y;
2434
                height = pt2.Y - pt1.Y;
2435
            }
2436

    
2437
            //
2438
            // Update the coordinates of the rectangle used for drag selection.
2439
            //
2440
            //캡쳐 중
2441
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2442
            {
2443
                Canvas.SetLeft(dragCaptureBorder, x);
2444
                Canvas.SetTop(dragCaptureBorder, y);
2445
                dragCaptureBorder.Width = width;
2446
                dragCaptureBorder.Height = height;
2447
            }
2448
            //선택 중
2449
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2450
            {
2451
                Canvas.SetLeft(dragSelectionBorder, x);
2452
                Canvas.SetTop(dragSelectionBorder, y);
2453
                dragSelectionBorder.Width = width;
2454
                dragSelectionBorder.Height = height;
2455
            }
2456
            else
2457
            {
2458
                Canvas.SetLeft(dragZoomBorder, x);
2459
                Canvas.SetTop(dragZoomBorder, y);
2460
                dragZoomBorder.Width = width;
2461
                dragZoomBorder.Height = height;
2462
            }
2463
        }
2464

    
2465
        private void drawingPannelRotate(double angle)
2466
        {
2467
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2468
            rotate.Angle = angle;
2469
            var rotationNum = Math.Abs((rotate.Angle / 90));
2470

    
2471
            if (angle == 90 || angle == 270)
2472
            {
2473
                double emptySize = zoomAndPanCanvas.Width;
2474
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2475
                zoomAndPanCanvas.Height = emptySize;
2476
            }
2477
            if (angle == 0)
2478
            {
2479
                translate.X = 0;
2480
                translate.Y = 0;
2481
            }
2482
            else if (angle == 90)
2483
            {
2484
                translate.X = zoomAndPanCanvas.Width;
2485
                translate.Y = 0;
2486
            }
2487
            else if (angle == 180)
2488
            {
2489
                translate.X = zoomAndPanCanvas.Width;
2490
                translate.Y = zoomAndPanCanvas.Height;
2491
            }
2492
            else
2493
            {
2494
                translate.X = 0;
2495
                translate.Y = zoomAndPanCanvas.Height;
2496
            }
2497

    
2498
            zoomAndPanControl.RotationAngle = rotate.Angle;
2499

    
2500
            if (!testPanel2.IsHidden)
2501
            {
2502
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2503
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2504
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2505
            }
2506

    
2507
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2508
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2509
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2510
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2511
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2512
        }
2513

    
2514
        private void syncPannelRotate(double angle)
2515
        {
2516
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2517
            rotate.Angle = angle;
2518
            var rotationNum = Math.Abs((rotate.Angle / 90));
2519

    
2520
            if (angle == 90 || angle == 270)
2521
            {
2522
                double emptySize = zoomAndPanCanvas2.Width;
2523
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2524
                zoomAndPanCanvas2.Height = emptySize;
2525
            }
2526
            if (angle == 0)
2527
            {
2528
                translate2.X = 0;
2529
                translate2.Y = 0;
2530
            }
2531
            else if (angle == 90)
2532
            {
2533
                translate2.X = zoomAndPanCanvas2.Width;
2534
                translate2.Y = 0;
2535
            }
2536
            else if (angle == 180)
2537
            {
2538
                translate2.X = zoomAndPanCanvas2.Width;
2539
                translate2.Y = zoomAndPanCanvas2.Height;
2540
            }
2541
            else
2542
            {
2543
                translate2.X = 0;
2544
                translate2.Y = zoomAndPanCanvas2.Height;
2545
            }
2546

    
2547
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2548
        }
2549

    
2550
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2551
        {
2552
            string Data_ = "";
2553

    
2554
            try
2555
            {
2556
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2557
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2558
                if (Data_ != null || Data_ != "")
2559
                {
2560
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2561
                }
2562
                else
2563
                {
2564
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2565
                }
2566

    
2567
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2568
                //{
2569
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2570
                //    STATE = 0,
2571
                //};
2572
                if (Data_ != null)
2573
                {
2574
                    Image img = new Image();
2575
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2576
                    if (Data_.Contains(".svg"))
2577
                    {
2578
                        byte[] imageData = null;
2579
                        DrawingImage image = null;
2580
                        using (System.Net.WebClient web = new System.Net.WebClient())
2581
                        {
2582
                            imageData = web.DownloadData(new Uri(Data_));
2583
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2584
                            image = SvgReader.Load(stream);
2585
                        }
2586
                        img.Source = image;
2587
                    }
2588
                    else
2589
                    {
2590
                        img.Source = new BitmapImage(new Uri(Data_));
2591
                    }
2592

    
2593
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2594
                    {
2595
                        PointSet = new List<Point>(),
2596
                        FilePath = Data_,
2597
                        ImageData = img.Source,
2598
                        StartPoint = canvasZoomPanningMouseDownPoint,
2599
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2600
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2601
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2602
                        canvasZoomPanningMouseDownPoint.Y),
2603
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2604
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2605
                    };
2606

    
2607
                    currentControl.PointSet = new List<Point>
2608
                                        {
2609
                                            currentControl.StartPoint,
2610
                                            currentControl.LeftBottomPoint,
2611
                                            currentControl.EndPoint,
2612
                                            currentControl.TopRightPoint,
2613
                                        };
2614
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2615
                    UndoData = new Undo_data()
2616
                    {
2617
                        IsUndo = false,
2618
                        Event = Event_Type.Create,
2619
                        EventTime = DateTime.Now,
2620
                        Markup_List = new List<Multi_Undo_data>()
2621
                    };
2622
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2623
                    {
2624
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2625
                    });
2626

    
2627
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2628
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2629
                    UndoData.Markup_List.Add(multi_Undo_Data);
2630
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2631

    
2632
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2633
                    currentControl.CommentID = Commons.shortGuid();
2634
                    currentControl.SymbolID = id;
2635
                    currentControl.GroupID = group_id;
2636
                    currentControl.ApplyTemplate();
2637
                    currentControl.SetImage();
2638

    
2639
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2640
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2641
                    SelectLayer.Children.Add(final);
2642
                }
2643
            }
2644
            catch (Exception ex)
2645
            {
2646
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2647
            }
2648
        }
2649

    
2650
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2651
        {
2652
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2653
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2654
            {
2655
                set_option.Value = double.Parse(set_option.ContentText);
2656
                //set_option.Focusable = false;
2657
                zoomAndPanControl.Focus();
2658
            }
2659

    
2660
            ConvertInkControlToPolygon();
2661

    
2662
            ///TODO:
2663
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2664
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2665

    
2666
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2667
            {
2668
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2669
            }
2670
            /// up to here
2671

    
2672
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2673
            {
2674
                if (item as ArrowTextControl != null)
2675
                {
2676
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2677
                }
2678
                else if (item as TextControl != null)
2679
                {
2680
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2681
                }
2682
            }
2683

    
2684
            //if (currentControl != null)
2685
            {
2686
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2687
                if (text_item_ != null)
2688
                {
2689
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2690
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2691
                    (text_item_ as TextControl).IsEditingMode = false;
2692
                    currentControl = null;
2693
                }
2694

    
2695
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2696
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2697
                {
2698
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2699
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2700
                    currentControl = null;
2701
                }
2702
            }
2703

    
2704
            double Ang = 0;
2705
            if (rotate.Angle != 0)
2706
            {
2707
                Ang = 360 - rotate.Angle;
2708
            }
2709

    
2710
            if (e.OriginalSource is System.Windows.Controls.Image)
2711
            {
2712
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2713
            }
2714
            /*
2715
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2716
            {
2717
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2718
                if(symbol_id != null)
2719
                {
2720
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2721
                }
2722
            }
2723

    
2724
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2725
            {
2726
                if (this._dragdropWindow != null)
2727
                {
2728
                    this._dragdropWindow.Close();
2729
                    this._dragdropWindow = null;
2730
                    symbol_id = null;
2731
                }
2732
            }
2733
            */
2734

    
2735
            if (e.LeftButton == MouseButtonState.Pressed)
2736
            {
2737
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2738
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2739

    
2740
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2741
                SetCursor();
2742

    
2743
                if (!ViewerDataModel.Instance.IsPressCtrl)
2744
                {
2745
                    SelectionSet.Instance.UnSelect(this);
2746
                }
2747
            }
2748

    
2749
            if (e.MiddleButton == MouseButtonState.Pressed)
2750
            {
2751
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2752
                cursor = Cursors.SizeAll;
2753
                SetCursor();
2754
            }
2755
            if (e.RightButton == MouseButtonState.Pressed)
2756
            {
2757
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2758
                cursor = Cursors.SizeAll;
2759
                SetCursor();
2760
            }
2761
            else if (e.XButton1 == MouseButtonState.Pressed)
2762
            {
2763
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2764
                {
2765
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2766
                }
2767

    
2768
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2769
            }
2770
            else if (e.XButton2 == MouseButtonState.Pressed)
2771
            {
2772
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2773
                {
2774
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2775
                }
2776
            }
2777

    
2778
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2779
            {
2780
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2781
                {
2782
                    if (SelectLayer.Children.Count == 0)
2783
                    {
2784
                        isLeftMouseButtonDownOnWindow = true;
2785
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2786
                    }
2787

    
2788
                    if (controlType == ControlType.None)
2789
                    {
2790
                        isLeftMouseButtonDownOnWindow = true;
2791
                    }
2792
                }
2793

    
2794
                /// 캡쳐 모드 설정
2795
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2796
                {
2797
                    dragCaptureBorder.Visibility = Visibility.Visible;
2798
                    isLeftMouseButtonDownOnWindow = true;
2799
                }
2800

    
2801
                /// 줌 모드 설정
2802
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2803
                {
2804
                    isLeftMouseButtonDownOnWindow = true;
2805
                }
2806

    
2807
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2808

    
2809
                if (control == null)
2810
                {
2811
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2812
                }
2813
                else
2814
                {
2815
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2816
                    {
2817
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2818
                    }
2819

    
2820
                    AdornerFinal final = null;
2821

    
2822
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2823
                    {
2824
                        /// 기존 selection 해제
2825
                        SelectionSet.Instance.UnSelect(this);
2826

    
2827
                        final = new AdornerFinal(control);
2828

    
2829
                        this.Control_Style(control);
2830

    
2831
                        if ((control as IPath) != null)
2832
                        {
2833
                            if ((control as IPath).LineSize != 0)
2834
                            {
2835
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2836
                            }
2837
                        }
2838
                        if ((control as IShapeControl) != null)
2839
                        {
2840
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2841
                            {
2842
                                ViewerDataModel.Instance.checkHatchShape = true;
2843
                            }
2844
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2845
                            {
2846
                                ViewerDataModel.Instance.checkFillShape = true;
2847
                            }
2848
                            else
2849
                            {
2850
                                ViewerDataModel.Instance.checkHatchShape = false;
2851
                                ViewerDataModel.Instance.checkFillShape = false;
2852
                            }
2853
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2854
                        }
2855

    
2856
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2857

    
2858
                        if ((control as TextControl) != null)
2859
                        {
2860
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2861

    
2862
                            if (!((control as TextControl).EnableEditing))
2863
                            {
2864
                                (control as TextControl).EnableEditing = true;
2865
                            }
2866
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2867
                            {
2868
                                ViewerDataModel.Instance.checkTextStyle = true;
2869
                            }
2870
                            else
2871
                            {
2872
                                ViewerDataModel.Instance.checkTextStyle = false;
2873
                            }
2874
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2875
                            {
2876
                                ViewerDataModel.Instance.checkTextWeight = true;
2877
                            }
2878
                            else
2879
                            {
2880
                                ViewerDataModel.Instance.checkTextWeight = false;
2881
                            }
2882
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2883
                            {
2884
                                ViewerDataModel.Instance.checkUnderLine = true;
2885
                            }
2886
                            else
2887
                            {
2888
                                ViewerDataModel.Instance.checkUnderLine = false;
2889
                            }
2890
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2891
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2892
                        }
2893
                        else if ((control as ArrowTextControl) != null)
2894
                        {
2895
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2896

    
2897
                            if (!((control as ArrowTextControl).EnableEditing))
2898
                            {
2899
                                (control as ArrowTextControl).EnableEditing = true;
2900
                            }
2901
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2902
                            {
2903
                                ViewerDataModel.Instance.checkTextStyle = true;
2904
                            }
2905
                            else
2906
                            {
2907
                                ViewerDataModel.Instance.checkTextStyle = false;
2908
                            }
2909
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2910
                            {
2911
                                ViewerDataModel.Instance.checkTextWeight = true;
2912
                            }
2913
                            else
2914
                            {
2915
                                ViewerDataModel.Instance.checkTextWeight = false;
2916
                            }
2917
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2918
                            {
2919
                                ViewerDataModel.Instance.checkUnderLine = true;
2920
                            }
2921
                            else
2922
                            {
2923
                                ViewerDataModel.Instance.checkUnderLine = false;
2924
                            }
2925
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2926
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2927
                        }
2928
                        else if ((control as RectCloudControl) != null)
2929
                        {
2930
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2931
                        }
2932
                        else if ((control as CloudControl) != null)
2933
                        {
2934
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2935
                        }
2936
                    }
2937
                    else
2938
                    {
2939
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2940
                        SelectionSet.Instance.UnSelect(this);
2941
                        comment.Add(control);
2942

    
2943
                        Control_Style(control);
2944

    
2945
                        final = new AdornerFinal(comment);
2946
                    }
2947

    
2948
                    if (final != null)
2949
                    {
2950
                        this.SelectLayer.Children.Add(final);
2951
                    }
2952
                }
2953
            }
2954
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2955
            {
2956
                init();
2957
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2958
                if (cursor != Cursors.SizeAll)
2959
                {
2960
                    cursor = Cursors.Cross;
2961
                    SetCursor();
2962
                }
2963
                bool init_user = false;
2964
                foreach (var user in gridViewMarkup.Items)
2965
                {
2966
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2967
                    {
2968
                        init_user = true;
2969
                    }
2970
                }
2971
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2972
                {
2973
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2974
                    RadWindow.Alert(new DialogParameters
2975
                    {
2976
                        Owner = Application.Current.MainWindow,
2977
                        Theme = new VisualStudio2013Theme(),
2978
                        Header = "Info",
2979
                        Content = "Existing comments already existed. Select from the user list first",
2980
                    });
2981
                    return;
2982
                }
2983
                else
2984
                {
2985
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2986
                    if (item != null)
2987
                    {
2988
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2989
                    }
2990
                }
2991

    
2992
                switch (controlType)
2993
                {
2994
                    case ControlType.Coordinate:
2995
                        {
2996
                            if (e.LeftButton == MouseButtonState.Pressed)
2997
                            {
2998
                                if (currentControl is CoordinateControl)
2999
                                {
3000
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3001
                                    {
3002
                                        return;
3003
                                    }
3004

    
3005
                                    CreateCommand.Instance.Execute(currentControl);
3006

    
3007
                                    currentControl = null;
3008
                                    this.cursor = Cursors.Arrow;
3009
                                }
3010
                                else
3011
                                {
3012
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3013
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3014
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3015
                                    {
3016
                                        currentControl = null;
3017
                                        this.cursor = Cursors.Arrow;
3018
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3019
                                        return;
3020
                                    }
3021
                                    else
3022
                                    {
3023
                                        currentControl = new CoordinateControl
3024
                                        {
3025
                                            Background = new SolidColorBrush(Colors.Black),
3026
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3027
                                            ControlType = ControlType.Coordinate
3028
                                        };
3029

    
3030
                                        currentControl.CommentID = Commons.shortGuid();
3031
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3032
                                        currentControl.IsNew = true;
3033

    
3034
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3035

    
3036
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3037
                                    }
3038
                                }
3039
                            }
3040
                        }
3041
                        break;
3042

    
3043
                    case ControlType.InsideWhite:
3044
                        {
3045
                            if (e.LeftButton == MouseButtonState.Pressed)
3046
                            {
3047
                                if (currentControl is InsideWhiteControl)
3048
                                {
3049
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3050
                                    {
3051
                                        return;
3052
                                    }
3053

    
3054
                                    CreateCommand.Instance.Execute(currentControl);
3055

    
3056
                                    currentControl = null;
3057
                                    this.cursor = Cursors.Arrow;
3058
                                }
3059
                                else
3060
                                {
3061
                                    currentControl = new InsideWhiteControl
3062
                                    {
3063
                                        Background = new SolidColorBrush(Colors.Black),
3064
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3065
                                        ControlType = ControlType.InsideWhite
3066
                                    };
3067

    
3068
                                    currentControl.CommentID = Commons.shortGuid();
3069
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3070
                                    currentControl.IsNew = true;
3071
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3072

    
3073
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3074
                                }
3075
                            }
3076
                        }
3077
                        break;
3078

    
3079
                    case ControlType.OverlapWhite:
3080
                        {
3081
                            if (e.LeftButton == MouseButtonState.Pressed)
3082
                            {
3083
                                if (currentControl is OverlapWhiteControl)
3084
                                {
3085
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3086
                                    {
3087
                                        return;
3088
                                    }
3089

    
3090
                                    CreateCommand.Instance.Execute(currentControl);
3091

    
3092
                                    currentControl = null;
3093
                                    this.cursor = Cursors.Arrow;
3094
                                }
3095
                                else
3096
                                {
3097
                                    currentControl = new OverlapWhiteControl
3098
                                    {
3099
                                        Background = new SolidColorBrush(Colors.Black),
3100
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3101
                                        ControlType = ControlType.OverlapWhite
3102
                                    };
3103

    
3104
                                    currentControl.CommentID = Commons.shortGuid();
3105
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3106
                                    currentControl.IsNew = true;
3107
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3108

    
3109
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3110
                                }
3111
                            }
3112
                        }
3113
                        break;
3114

    
3115
                    case ControlType.ClipWhite:
3116
                        {
3117
                            if (e.LeftButton == MouseButtonState.Pressed)
3118
                            {
3119
                                if (currentControl is ClipWhiteControl)
3120
                                {
3121
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3122
                                    {
3123
                                        return;
3124
                                    }
3125

    
3126
                                    CreateCommand.Instance.Execute(currentControl);
3127

    
3128
                                    currentControl = null;
3129
                                    this.cursor = Cursors.Arrow;
3130
                                }
3131
                                else
3132
                                {
3133
                                    currentControl = new ClipWhiteControl
3134
                                    {
3135
                                        Background = new SolidColorBrush(Colors.Black),
3136
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3137
                                        ControlType = ControlType.ClipWhite
3138
                                    };
3139

    
3140
                                    currentControl.CommentID = Commons.shortGuid();
3141
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3142
                                    currentControl.IsNew = true;
3143
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3144

    
3145
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3146
                                }
3147
                            }
3148
                        }
3149
                        break;
3150

    
3151
                    case ControlType.Rectangle:
3152
                        {
3153
                            if (e.LeftButton == MouseButtonState.Pressed)
3154
                            {
3155
                                if (currentControl is RectangleControl)
3156
                                {
3157
                                    //20180906 LJY TEST IsRotationDrawingEnable
3158
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3159
                                    {
3160
                                        return;
3161
                                    }
3162

    
3163
                                    CreateCommand.Instance.Execute(currentControl);
3164
                                    currentControl = null;
3165
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3166
                                }
3167
                                else
3168
                                {
3169
                                    currentControl = new RectangleControl
3170
                                    {
3171
                                        Background = new SolidColorBrush(Colors.Black),
3172
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3173
                                        ControlType = ControlType.Rectangle
3174
                                    };
3175

    
3176
                                    currentControl.CommentID = Commons.shortGuid();
3177
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3178
                                    currentControl.IsNew = true;
3179
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3180

    
3181
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3182
                                }
3183
                            }
3184
                        }
3185
                        break;
3186

    
3187
                    case ControlType.RectCloud:
3188
                        {
3189
                            if (e.LeftButton == MouseButtonState.Pressed)
3190
                            {
3191
                                if (currentControl is RectCloudControl)
3192
                                {
3193
                                    //20180906 LJY TEST IsRotationDrawingEnable
3194
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3195
                                    {
3196
                                        return;
3197
                                    }
3198

    
3199
                                    CreateCommand.Instance.Execute(currentControl);
3200

    
3201
                                    currentControl = null;
3202

    
3203
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3204
                                }
3205
                                else
3206
                                {
3207
                                    currentControl = new RectCloudControl
3208
                                    {
3209
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3210
                                        ControlType = ControlType.RectCloud,
3211
                                        Background = new SolidColorBrush(Colors.Black)
3212
                                    };
3213

    
3214
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3215
                                    currentControl.CommentID = Commons.shortGuid();
3216
                                    currentControl.IsNew = true;
3217
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3218
                                }
3219
                            }
3220
                        }
3221
                        break;
3222

    
3223
                    case ControlType.Circle:
3224
                        {
3225
                            if (e.LeftButton == MouseButtonState.Pressed)
3226
                            {
3227
                                if (currentControl is CircleControl)
3228
                                {
3229
                                    //20180906 LJY TEST IsRotationDrawingEnable
3230
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3231
                                    {
3232
                                        return;
3233
                                    }
3234

    
3235
                                    CreateCommand.Instance.Execute(currentControl);
3236

    
3237
                                    currentControl = null;
3238
                                }
3239
                                else
3240
                                {
3241
                                    currentControl = new CircleControl
3242
                                    {
3243
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3244
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3245
                                        Background = new SolidColorBrush(Colors.Black)
3246
                                    };
3247

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

    
3257
                    case ControlType.Triangle:
3258
                        {
3259
                            if (e.LeftButton == MouseButtonState.Pressed)
3260
                            {
3261
                                if (currentControl is TriControl)
3262
                                {
3263
                                    var content = currentControl as TriControl;
3264
                                    if (content.MidPoint == new Point(0, 0))
3265
                                    {
3266
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3267
                                    }
3268
                                    else
3269
                                    {
3270
                                        //20180906 LJY TEST IsRotationDrawingEnable
3271
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3272
                                        {
3273
                                            return;
3274
                                        }
3275

    
3276
                                        CreateCommand.Instance.Execute(currentControl);
3277

    
3278
                                        currentControl = null;
3279
                                    }
3280
                                }
3281
                                else
3282
                                {
3283
                                    currentControl = new TriControl
3284
                                    {
3285
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3286
                                        Background = new SolidColorBrush(Colors.Black),
3287
                                    };
3288

    
3289
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3290
                                    currentControl.CommentID = Commons.shortGuid();
3291
                                    currentControl.IsNew = true;
3292
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3293
                                }
3294
                            }
3295
                        }
3296
                        break;
3297

    
3298
                    case ControlType.CancelLine:
3299
                    case ControlType.SingleLine:
3300
                    case ControlType.ArrowLine:
3301
                    case ControlType.TwinLine:
3302
                    case ControlType.DimLine:
3303
                        {
3304
                            if (e.LeftButton == MouseButtonState.Pressed)
3305
                            {
3306
                                if (currentControl is LineControl)
3307
                                {
3308
                                    //20180906 LJY TEST IsRotationDrawingEnable
3309
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3310
                                    {
3311
                                        return;
3312
                                    }
3313

    
3314
                                    CreateCommand.Instance.Execute(currentControl);
3315
                                    currentControl = null;
3316
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3317
                                }
3318
                                else
3319
                                {
3320
                                    currentControl = new LineControl
3321
                                    {
3322
                                        ControlType = this.controlType,
3323
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3324
                                        Background = new SolidColorBrush(Colors.Black)
3325
                                    };
3326

    
3327
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3328
                                    currentControl.CommentID = Commons.shortGuid();
3329
                                    currentControl.IsNew = true;
3330
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3331
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3332
                                }
3333
                            }
3334
                        }
3335
                        break;
3336

    
3337
                    case ControlType.PolygonControl:
3338
                        {
3339
                            if (currentControl is PolygonControl)
3340
                            {
3341
                                var control = currentControl as PolygonControl;
3342

    
3343
                                if (e.RightButton == MouseButtonState.Pressed)
3344
                                {
3345
                                    control.IsCompleted = true;
3346
                                }
3347

    
3348
                                if (!control.IsCompleted)
3349
                                {
3350
                                    control.PointSet.Add(control.EndPoint);
3351
                                }
3352
                                else
3353
                                {
3354
                                    //20180906 LJY TEST IsRotationDrawingEnable
3355
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3356
                                    {
3357
                                        return;
3358
                                    }
3359

    
3360
                                    var firstPoint = control.PointSet.First();
3361
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3362
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3363
                                    control.PointSet.Add(firstPoint);
3364

    
3365
                                    control.ApplyOverViewData();
3366

    
3367
                                    CreateCommand.Instance.Execute(currentControl);
3368
                                    control.UpdateControl();
3369
                                    currentControl = null;
3370
                                }
3371
                            }
3372
                            else
3373
                            {
3374
                                if (e.LeftButton == MouseButtonState.Pressed)
3375
                                {
3376
                                    currentControl = new PolygonControl
3377
                                    {
3378
                                        PointSet = new List<Point>(),
3379
                                    };
3380

    
3381
                                    var polygonControl = (currentControl as PolygonControl);
3382
                                    currentControl.CommentID = Commons.shortGuid();
3383
                                    currentControl.IsNew = true;
3384
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3385
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3386
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3387
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3388
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3389
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3390
                                    polygonControl.ApplyTemplate();
3391
                                    polygonControl.Visibility = Visibility.Visible;
3392
                                }
3393
                            }
3394
                        }
3395
                        break;
3396

    
3397
                    case ControlType.ChainLine:
3398
                        {
3399
                            if (currentControl is PolygonControl)
3400
                            {
3401
                                var control = currentControl as PolygonControl;
3402

    
3403
                                if (e.RightButton == MouseButtonState.Pressed)
3404
                                {
3405
                                    //20180906 LJY TEST IsRotationDrawingEnable
3406
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3407
                                    {
3408
                                        return;
3409
                                    }
3410

    
3411
                                    CreateCommand.Instance.Execute(currentControl);
3412

    
3413
                                    currentControl = null;
3414
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3415
                                    return;
3416
                                }
3417

    
3418
                                if (!control.IsCompleted)
3419
                                {
3420
                                    control.PointSet.Add(control.EndPoint);
3421
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3422
                                }
3423
                            }
3424
                            else
3425
                            {
3426
                                if (e.LeftButton == MouseButtonState.Pressed)
3427
                                {
3428
                                    MainAngle.Visibility = Visibility.Visible;
3429
                                    currentControl = new PolygonControl
3430
                                    {
3431
                                        PointSet = new List<Point>(),
3432
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3433
                                        ControlType = ControlType.ChainLine,
3434
                                        DashSize = ViewerDataModel.Instance.DashSize,
3435
                                        LineSize = ViewerDataModel.Instance.LineSize,
3436
                                        //PointC = new StylusPointSet()
3437
                                    };
3438

    
3439
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3440
                                    //{
3441
                                    var polygonControl = (currentControl as PolygonControl);
3442
                                    currentControl.CommentID = Commons.shortGuid();
3443
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3444
                                    currentControl.IsNew = true;
3445
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3446
                                    //currentControl.OnApplyTemplate();
3447
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3448
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3449
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3450
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3451
                                    //}
3452
                                }
3453
                            }
3454
                        }
3455
                        break;
3456

    
3457
                    case ControlType.ArcLine:
3458
                        {
3459
                            if (e.LeftButton == MouseButtonState.Pressed)
3460
                            {
3461
                                if (currentControl is ArcControl)
3462
                                {
3463
                                    //20180906 LJY TEST IsRotationDrawingEnable
3464
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3465
                                    {
3466
                                        return;
3467
                                    }
3468

    
3469
                                    CreateCommand.Instance.Execute(currentControl);
3470

    
3471
                                    currentControl = null;
3472
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3473
                                }
3474
                                else
3475
                                {
3476
                                    currentControl = new ArcControl
3477
                                    {
3478
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3479
                                        Background = new SolidColorBrush(Colors.Black)
3480
                                    };
3481
                                    currentControl.CommentID = Commons.shortGuid();
3482
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3483
                                    currentControl.IsNew = true;
3484
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3485
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3486
                                }
3487
                            }
3488
                            else if (e.RightButton == MouseButtonState.Pressed)
3489
                            {
3490
                                if (currentControl != null)
3491
                                {
3492
                                    (currentControl as ArcControl).setClock();
3493
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3494
                                }
3495
                            }
3496
                        }
3497
                        break;
3498

    
3499
                    case ControlType.ArcArrow:
3500
                        {
3501
                            if (e.LeftButton == MouseButtonState.Pressed)
3502
                            {
3503
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3504
                                //{
3505
                                if (currentControl is ArrowArcControl)
3506
                                {
3507
                                    //20180906 LJY TEST IsRotationDrawingEnable
3508
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3509
                                    {
3510
                                        return;
3511
                                    }
3512

    
3513
                                    CreateCommand.Instance.Execute(currentControl);
3514

    
3515
                                    currentControl = null;
3516
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3517
                                }
3518
                                else
3519
                                {
3520
                                    currentControl = new ArrowArcControl
3521
                                    {
3522
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3523
                                        Background = new SolidColorBrush(Colors.Black)
3524
                                    };
3525
                                    currentControl.CommentID = Commons.shortGuid();
3526
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3527
                                    currentControl.IsNew = true;
3528
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3530
                                }
3531
                                //}
3532
                            }
3533
                            else if (e.RightButton == MouseButtonState.Pressed)
3534
                            {
3535
                                if (currentControl != null)
3536
                                {
3537
                                    (currentControl as ArrowArcControl).setClock();
3538
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3539
                                    //(currentControl as ArcControl).ApplyTemplate();
3540
                                }
3541
                            }
3542
                        }
3543
                        break;
3544

    
3545
                    case ControlType.ArrowMultiLine:
3546
                        {
3547
                            if (e.LeftButton == MouseButtonState.Pressed)
3548
                            {
3549
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3550
                                //{
3551
                                if (currentControl is ArrowControl_Multi)
3552
                                {
3553
                                    var content = currentControl as ArrowControl_Multi;
3554
                                    if (content.MiddlePoint == new Point(0, 0))
3555
                                    {
3556
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3557
                                        {
3558
                                            content.MiddlePoint = content.EndPoint;
3559
                                        }
3560
                                        else
3561
                                        {
3562
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3563
                                        }
3564
                                    }
3565
                                    else
3566
                                    {
3567
                                        //20180906 LJY TEST IsRotationDrawingEnable
3568
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3569
                                        {
3570
                                            return;
3571
                                        }
3572

    
3573
                                        CreateCommand.Instance.Execute(currentControl);
3574

    
3575
                                        currentControl = null;
3576
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3577
                                    }
3578
                                }
3579
                                else
3580
                                {
3581
                                    currentControl = new ArrowControl_Multi
3582
                                    {
3583
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3584
                                        Background = new SolidColorBrush(Colors.Black)
3585
                                    };
3586
                                    currentControl.CommentID = Commons.shortGuid();
3587
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3588
                                    currentControl.IsNew = true;
3589
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3590
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3591
                                }
3592
                                //}
3593
                            }
3594
                        }
3595
                        break;
3596

    
3597
                    case ControlType.PolygonCloud:
3598
                        {
3599
                            if (currentControl is CloudControl)
3600
                            {
3601
                                var control = currentControl as CloudControl;
3602
                                if (e.RightButton == MouseButtonState.Pressed)
3603
                                {
3604
                                    control.IsCompleted = true;
3605
                                }
3606

    
3607
                                if (!control.IsCompleted)
3608
                                {
3609
                                    control.PointSet.Add(control.EndPoint);
3610
                                }
3611
                                else
3612
                                {
3613
                                    //20180906 LJY TEST IsRotationDrawingEnable
3614
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3615
                                    {
3616
                                        return;
3617
                                    }
3618

    
3619
                                    CreateCommand.Instance.Execute(currentControl);
3620

    
3621
                                    control.isTransOn = true;
3622
                                    var firstPoint = control.PointSet.First();
3623

    
3624
                                    control.PointSet.Add(firstPoint);
3625
                                    control.DrawingCloud();
3626
                                    control.ApplyOverViewData();
3627

    
3628
                                    currentControl = null;
3629
                                }
3630
                            }
3631
                            else
3632
                            {
3633
                                if (e.LeftButton == MouseButtonState.Pressed)
3634
                                {
3635
                                    currentControl = new CloudControl
3636
                                    {
3637
                                        PointSet = new List<Point>(),
3638
                                        PointC = new StylusPointSet()
3639
                                    };
3640

    
3641
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3642
                                    //{
3643
                                    var polygonControl = (currentControl as CloudControl);
3644
                                    currentControl.CommentID = Commons.shortGuid();
3645
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3646
                                    currentControl.IsNew = true;
3647
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3648

    
3649
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3650
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3651

    
3652
                                    //}
3653
                                }
3654
                            }
3655
                        }
3656
                        break;
3657

    
3658
                    case ControlType.ImgControl:
3659
                        {
3660
                            if (e.LeftButton == MouseButtonState.Pressed)
3661
                            {
3662
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3663
                                //{
3664
                                if (currentControl is ImgControl)
3665
                                {
3666
                                    //20180906 LJY TEST IsRotationDrawingEnable
3667
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3668
                                    {
3669
                                        return;
3670
                                    }
3671

    
3672
                                    CreateCommand.Instance.Execute(currentControl);
3673
                                    controlType = ControlType.ImgControl;
3674
                                    currentControl = null;
3675
                                }
3676
                                else
3677
                                {
3678
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3679
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3680
                                    {
3681
                                        Image img = new Image();
3682
                                        if (filename.Contains(".svg"))
3683
                                        {
3684
                                            byte[] imageData = null;
3685
                                            DrawingImage image = null;
3686
                                            using (System.Net.WebClient web = new System.Net.WebClient())
3687
                                            {
3688
                                                imageData = web.DownloadData(new Uri(filename));
3689
                                                System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3690
                                                image = SvgReader.Load(stream);
3691
                                            }
3692
                                            img.Source = image;
3693
                                        }
3694
                                        else
3695
                                        {
3696
                                            img.Source = new BitmapImage(new Uri(filename));
3697
                                        }
3698

    
3699
                                        currentControl = new ImgControl
3700
                                        {
3701
                                            Background = new SolidColorBrush(Colors.Black),
3702
                                            PointSet = new List<Point>(),
3703
                                            FilePath = filename,
3704
                                            ImageData = img.Source,
3705
                                            StartPoint = CanvasDrawingMouseDownPoint,
3706
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3707
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3708
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3709
                                            ControlType = ControlType.ImgControl
3710
                                        };
3711

    
3712
                                        currentControl.CommentID = Commons.shortGuid();
3713
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3714
                                        currentControl.IsNew = true;
3715
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3716

    
3717
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3718
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3719
                                    }
3720
                                }
3721
                                //}
3722
                            }
3723
                        }
3724
                        break;
3725

    
3726
                    case ControlType.Date:
3727
                        {
3728
                            if (e.LeftButton == MouseButtonState.Pressed)
3729
                            {
3730
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3731
                                //{
3732
                                if (currentControl is DateControl)
3733
                                {
3734
                                    //20180906 LJY TEST IsRotationDrawingEnable
3735
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3736
                                    {
3737
                                        return;
3738
                                    }
3739

    
3740
                                    CreateCommand.Instance.Execute(currentControl);
3741
                                    currentControl = null;
3742

    
3743
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3744
                                    {
3745
                                        controlType = ControlType.None;
3746
                                        IsSwingMode = false;
3747
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3748
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3749
                                        mouseHandlingMode = MouseHandlingMode.None;
3750
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3751
                                        txtBatch.Visibility = Visibility.Collapsed;
3752
                                    }
3753
                                }
3754
                                else
3755
                                {
3756
                                    currentControl = new DateControl
3757
                                    {
3758
                                        StartPoint = CanvasDrawingMouseDownPoint,
3759
                                        Background = new SolidColorBrush(Colors.Black)
3760
                                    };
3761
                                    currentControl.CommentID = Commons.shortGuid();
3762
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3763
                                    currentControl.IsNew = true;
3764
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3765

    
3766
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3767
                                    if (currentControl is ImgControl)
3768
                                    {
3769
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3770
                                    }
3771
                                }
3772
                                //}
3773
                            }
3774
                        }
3775
                        break;
3776

    
3777
                    case ControlType.TextControl:
3778
                        {
3779
                            if (e.LeftButton == MouseButtonState.Pressed)
3780
                            {
3781
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3782
                                {
3783
                                    currentControl = new TextControl
3784
                                    {
3785
                                        ControlType = controlType
3786
                                    };
3787
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3788
                                    currentControl.CommentID = Commons.shortGuid();
3789
                                    currentControl.IsNew = true;
3790
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3791
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3792
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3793

    
3794
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3795
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3796

    
3797
                                    (currentControl as TextControl).ControlType_No = 0;
3798
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3799
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3800
                                    (currentControl as TextControl).ApplyTemplate();
3801
                                    (currentControl as TextControl).Base_TextBox.Focus();
3802
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3803
                                    CreateCommand.Instance.Execute(currentControl);
3804
                                }
3805
                            }
3806
                        }
3807
                        break;
3808

    
3809
                    case ControlType.TextBorder:
3810
                        {
3811
                            if (e.LeftButton == MouseButtonState.Pressed)
3812
                            {
3813
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3814
                                {
3815
                                    currentControl = new TextControl
3816
                                    {
3817
                                        ControlType = controlType
3818
                                    };
3819

    
3820
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3821
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3822
                                    currentControl.CommentID = Commons.shortGuid();
3823
                                    currentControl.IsNew = true;
3824
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3825
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3826
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3827
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3828

    
3829
                                    (currentControl as TextControl).ControlType_No = 1;
3830
                                    (currentControl as TextControl).CommentAngle = Ang;
3831
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3832
                                    (currentControl as TextControl).ApplyTemplate();
3833
                                    (currentControl as TextControl).Base_TextBox.Focus();
3834
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3835
                                    CreateCommand.Instance.Execute(currentControl);
3836
                                }
3837
                            }
3838
                        }
3839
                        break;
3840

    
3841
                    case ControlType.TextCloud:
3842
                        {
3843
                            if (e.LeftButton == MouseButtonState.Pressed)
3844
                            {
3845
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3846
                                {
3847
                                    currentControl = new TextControl
3848
                                    {
3849
                                        ControlType = controlType
3850
                                    };
3851

    
3852
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3853
                                    currentControl.CommentID = Commons.shortGuid();
3854
                                    currentControl.IsNew = true;
3855
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3856
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3857

    
3858
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3859
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3860
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3861

    
3862
                                    (currentControl as TextControl).CommentAngle = Ang;
3863
                                    (currentControl as TextControl).ControlType_No = 2;
3864
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3865
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3866

    
3867
                                    (currentControl as TextControl).ApplyTemplate();
3868
                                    (currentControl as TextControl).Base_TextBox.Focus();
3869
                                    CreateCommand.Instance.Execute(currentControl);
3870
                                    
3871
                                    //currentControl = null;
3872
                                }
3873
                            }
3874
                        }
3875
                        break;
3876

    
3877
                    case ControlType.ArrowTextControl:
3878
                        {
3879
                            if (e.LeftButton == MouseButtonState.Pressed)
3880
                            {
3881
                                if (currentControl is ArrowTextControl)
3882
                                {
3883
                                    //20180906 LJY TEST IsRotationDrawingEnable
3884
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3885
                                    {
3886
                                        return;
3887
                                    }
3888

    
3889
                                    CreateCommand.Instance.Execute(currentControl);
3890

    
3891
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3892
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3893
                                    (currentControl as ArrowTextControl).IsNew = false;
3894
                                    currentControl = null;
3895
                                }
3896
                                else
3897
                                {
3898
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3899
                                    //{
3900
                                    currentControl = new ArrowTextControl();
3901
                                    currentControl.CommentID = Commons.shortGuid();
3902
                                    currentControl.IsNew = true;
3903
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3904
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3905

    
3906
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3907
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3908
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3909
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3910
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3911

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

    
3915
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3916
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3917
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3918
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3919

    
3920
                                    //}
3921
                                }
3922
                            }
3923
                        }
3924
                        break;
3925

    
3926
                    case ControlType.ArrowTransTextControl:
3927
                        {
3928
                            if (e.LeftButton == MouseButtonState.Pressed)
3929
                            {
3930
                                if (currentControl is ArrowTextControl)
3931
                                {
3932
                                    //20180906 LJY TEST IsRotationDrawingEnable
3933
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3934
                                    {
3935
                                        return;
3936
                                    }
3937

    
3938
                                    CreateCommand.Instance.Execute(currentControl);
3939

    
3940
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3941

    
3942
                                    currentControl.IsNew = false;
3943
                                    currentControl = null;
3944
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3945
                                }
3946
                                else
3947
                                {
3948
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3949
                                    //{
3950
                                    currentControl = new ArrowTextControl()
3951
                                    {
3952
                                        ControlType = ControlType.ArrowTransTextControl
3953
                                    };
3954
                                    currentControl.CommentID = Commons.shortGuid();
3955
                                    currentControl.IsNew = true;
3956
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3957
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3958
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3959
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3960
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3961
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3962
                                    (currentControl as ArrowTextControl).isFixed = true;
3963
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3964

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

    
3968
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3969
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3970
                                    (currentControl as ArrowTextControl).isTrans = true;
3971
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3972
                                }
3973
                            }
3974
                        }
3975
                        break;
3976

    
3977
                    case ControlType.ArrowTextBorderControl:
3978
                        {
3979
                            if (e.LeftButton == MouseButtonState.Pressed)
3980
                            {
3981
                                if (currentControl is ArrowTextControl)
3982
                                {
3983
                                    //20180906 LJY TEST IsRotationDrawingEnable
3984
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3985
                                    {
3986
                                        return;
3987
                                    }
3988

    
3989
                                    CreateCommand.Instance.Execute(currentControl);
3990
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3991
                                    currentControl.IsNew = false;
3992
                                    currentControl = null;
3993
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3994
                                }
3995
                                else
3996
                                {
3997
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3998
                                    //{
3999
                                    currentControl = new ArrowTextControl()
4000
                                    {
4001
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
4002
                                    };
4003
                                    currentControl.CommentID = Commons.shortGuid();
4004
                                    currentControl.IsNew = true;
4005
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4006
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4007

    
4008
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4009

    
4010
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4011

    
4012
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4013
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4014
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4015
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4016
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4017
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4018
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4019
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4020
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4021
                                    //}
4022
                                }
4023
                            }
4024
                        }
4025
                        break;
4026

    
4027
                    case ControlType.ArrowTransTextBorderControl:
4028
                        {
4029
                            if (e.LeftButton == MouseButtonState.Pressed)
4030
                            {
4031
                                if (currentControl is ArrowTextControl)
4032
                                {
4033
                                    //20180906 LJY TEST IsRotationDrawingEnable
4034
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4035
                                    {
4036
                                        return;
4037
                                    }
4038
                                    CreateCommand.Instance.Execute(currentControl);
4039
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4040
                                    currentControl.IsNew = false;
4041
                                    currentControl = null;
4042

    
4043
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4044
                                }
4045
                                else
4046
                                {
4047
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4048
                                    //{
4049
                                    currentControl = new ArrowTextControl()
4050
                                    {
4051
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4052
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4053
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4054
                                    };
4055

    
4056
                                    
4057
                                    currentControl.CommentID = Commons.shortGuid();
4058
                                    currentControl.IsNew = true;
4059
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4060
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4061

    
4062
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4063

    
4064
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4065
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4066
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4067
                                    (currentControl as ArrowTextControl).isFixed = true;
4068
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4069

    
4070
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4071
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4072
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4073
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4074
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4075
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4076

    
4077
                                    //20180911 LJY
4078
                                    (currentControl as ArrowTextControl).isTrans = true;
4079

    
4080
                                    //}
4081
                                }
4082
                            }
4083
                        }
4084
                        break;
4085

    
4086
                    case ControlType.ArrowTextCloudControl:
4087
                        {
4088
                            if (e.LeftButton == MouseButtonState.Pressed)
4089
                            {
4090
                                if (currentControl is ArrowTextControl)
4091
                                {
4092
                                    //20180906 LJY TEST IsRotationDrawingEnable
4093
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4094
                                    {
4095
                                        return;
4096
                                    }
4097
                                    CreateCommand.Instance.Execute(currentControl);
4098
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4099
                                    currentControl.IsNew = false;
4100
                                    currentControl = null;
4101
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4102
                                }
4103
                                else
4104
                                {
4105
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4106
                                    //{
4107
                                    currentControl = new ArrowTextControl()
4108
                                    {
4109
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4110
                                    };
4111
                                    currentControl.CommentID = Commons.shortGuid();
4112
                                    currentControl.IsNew = true;
4113
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4114
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4115

    
4116
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4117
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4118
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4119
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4120
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4121
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4122
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4123
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4124

    
4125
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4126
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4127
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4128
                                    //}
4129
                                }
4130
                            }
4131
                        }
4132
                        break;
4133

    
4134
                    case ControlType.ArrowTransTextCloudControl:
4135
                        {
4136
                            if (e.LeftButton == MouseButtonState.Pressed)
4137
                            {
4138
                                if (currentControl is ArrowTextControl)
4139
                                {
4140
                                    //20180906 LJY TEST IsRotationDrawingEnable
4141
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4142
                                    {
4143
                                        return;
4144
                                    }
4145
                                    CreateCommand.Instance.Execute(currentControl);
4146
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4147
                                    currentControl.IsNew = false;
4148
                                    currentControl = null;
4149
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4150
                                }
4151
                                else
4152
                                {
4153
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4154
                                    //{
4155
                                    currentControl = new ArrowTextControl()
4156
                                    {
4157
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4158
                                        ControlType = ControlType.ArrowTransTextCloudControl
4159
                                    };
4160
                                    currentControl.CommentID = Commons.shortGuid();
4161
                                    currentControl.IsNew = true;
4162
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4163
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4164
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4165

    
4166
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4167
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4168
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4169
                                    (currentControl as ArrowTextControl).isFixed = true;
4170
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4171

    
4172
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4173
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4174
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4175
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4176
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4177
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4178

    
4179
                                    //20180911 LJY
4180
                                    (currentControl as ArrowTextControl).isTrans = true;
4181
                                    //}
4182
                                }
4183
                            }
4184
                        }
4185
                        break;
4186
                    //강인구 추가
4187
                    case ControlType.Sign:
4188
                        {
4189
                            if (e.LeftButton == MouseButtonState.Pressed)
4190
                            {
4191
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4192
                                //{
4193
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4194

    
4195
                                if (_sign == null)
4196
                                {
4197
                                    txtBatch.Visibility = Visibility.Collapsed;
4198
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4199
                                    controlType = ControlType.None;
4200

    
4201
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4202
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4203
                                    return;
4204
                                }
4205

    
4206
                                if (currentControl is SignControl)
4207
                                {
4208
                                    //20180906 LJY TEST IsRotationDrawingEnable
4209
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4210
                                    {
4211
                                        return;
4212
                                    }
4213

    
4214
                                    CreateCommand.Instance.Execute(currentControl);
4215
                                    currentControl = null;
4216
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4217
                                    {
4218
                                        txtBatch.Text = "Place Date";
4219
                                        controlType = ControlType.Date;
4220
                                    }
4221
                                }
4222
                                else
4223
                                {
4224
                                    currentControl = new SignControl
4225
                                    {
4226
                                        Background = new SolidColorBrush(Colors.Black),
4227
                                        UserNumber = App.ViewInfo.UserID,
4228
                                        ProjectNO = App.ViewInfo.ProjectNO,
4229
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4230
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4231
                                        ControlType = ControlType.Sign
4232
                                    };
4233

    
4234
                                    currentControl.CommentID = Commons.shortGuid();
4235
                                    currentControl.IsNew = true;
4236
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4237
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4238

    
4239
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4240
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4241
                                }
4242
                                //}
4243
                            }
4244
                        }
4245
                        break;
4246

    
4247
                    case ControlType.Mark:
4248
                        {
4249
                            if (e.LeftButton == MouseButtonState.Pressed)
4250
                            {
4251
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4252
                                //{
4253
                                if (currentControl is RectangleControl)
4254
                                {
4255
                                    //20180906 LJY TEST IsRotationDrawingEnable
4256
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4257
                                    {
4258
                                        return;
4259
                                    }
4260

    
4261
                                    CreateCommand.Instance.Execute(currentControl);
4262
                                    (currentControl as RectangleControl).ApplyOverViewData();
4263
                                    currentControl = null;
4264

    
4265
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4266

    
4267
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4268
                                    {
4269
                                        txtBatch.Text = "Place Signature";
4270
                                        controlType = ControlType.Sign;
4271
                                    }
4272
                                }
4273
                                else
4274
                                {
4275
                                    currentControl = new RectangleControl
4276
                                    {
4277
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4278
                                        Background = new SolidColorBrush(Colors.Black),
4279
                                        ControlType = ControlType.Mark,
4280
                                        Paint = PaintSet.Fill
4281
                                    };
4282

    
4283
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4284
                                    currentControl.CommentID = Commons.shortGuid();
4285
                                    currentControl.IsNew = true;
4286
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4287
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4288
                                }
4289
                                //}
4290
                            }
4291
                        }
4292
                        break;
4293

    
4294
                    case ControlType.Symbol:
4295
                        {
4296
                            if (e.LeftButton == MouseButtonState.Pressed)
4297
                            {
4298
                                if (currentControl is SymControl)
4299
                                {
4300
                                    //20180906 LJY TEST IsRotationDrawingEnable
4301
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4302
                                    {
4303
                                        return;
4304
                                    }
4305
                                    CreateCommand.Instance.Execute(currentControl);
4306
                                    currentControl = null;
4307

    
4308
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4309
                                }
4310
                                else
4311
                                {
4312
                                    currentControl = new SymControl
4313
                                    {
4314
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4315
                                        Background = new SolidColorBrush(Colors.Black),
4316
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4317
                                        ControlType = ControlType.Symbol
4318
                                    };
4319

    
4320
                                    currentControl.IsNew = true;
4321
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4322
                                    currentControl.CommentID = Commons.shortGuid();
4323
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4324

    
4325
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4326
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4327
                                }
4328
                                //}
4329
                            }
4330
                        }
4331
                        break;
4332

    
4333
                    case ControlType.Stamp:
4334
                        {
4335
                            if (e.LeftButton == MouseButtonState.Pressed)
4336
                            {
4337
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4338
                                //{
4339
                                if (currentControl is SymControlN)
4340
                                {
4341
                                    //20180906 LJY TEST IsRotationDrawingEnable
4342
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4343
                                    {
4344
                                        return;
4345
                                    }
4346

    
4347
                                    CreateCommand.Instance.Execute(currentControl);
4348
                                    currentControl = null;
4349

    
4350
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4351
                                }
4352
                                else
4353
                                {
4354
                                    currentControl = new SymControlN
4355
                                    {
4356
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4357
                                        Background = new SolidColorBrush(Colors.Black),
4358
                                        STAMP = App.SystemInfo.STAMP,
4359
                                        ControlType = ControlType.Stamp
4360
                                    };
4361

    
4362
                                    currentControl.IsNew = true;
4363
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4364
                                    currentControl.CommentID = Commons.shortGuid();
4365
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4366
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4367
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4368
                                }
4369
                                //}
4370
                            }
4371
                        }
4372
                        break;
4373

    
4374
                    case ControlType.PenControl:
4375
                        {
4376
                            if (inkBoard.Tag.ToString() == "Ink")
4377
                            {
4378
                                inkBoard.IsEnabled = true;
4379
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4380
                            }
4381
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4382
                            {
4383
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4384
                            }
4385
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4386
                            {
4387
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4388
                            }
4389
                            IsDrawing = true;
4390
                            return;
4391
                        }
4392
                    default:
4393
                        if (currentControl != null)
4394
                        {
4395
                            currentControl.CommentID = null;
4396
                            currentControl.IsNew = false;
4397
                        }
4398
                        break;
4399
                }
4400

    
4401
                //if (currentControl != null)
4402
                //{
4403
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4404
                //}
4405
            }
4406
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4407
            {
4408
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4409
                {
4410
                    bool mouseOff = false;
4411
                    foreach (var item in SelectLayer.Children)
4412
                    {
4413
                        if (item is AdornerFinal)
4414
                        {
4415
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4416
                            if (over != null)
4417
                            {
4418
                                mouseOff = true;
4419
                            }
4420
                        }
4421
                    }
4422

    
4423
                    if (!mouseOff)
4424
                    {
4425
                        SelectionSet.Instance.UnSelect(this);
4426
                    }
4427
                }
4428
                zoomAndPanControl.CaptureMouse();
4429
                e.Handled = true;
4430
            }
4431
        }
4432

    
4433
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4434
        {
4435
            ///mouseButtonDown = e.ChangedButton;
4436
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4437
        }
4438

    
4439
        private void RemoveLineStroke(Point P)
4440
        {
4441
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4442
            if (control != null)
4443
            {
4444
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4445
            }
4446
        }
4447

    
4448
        private void RemovePointStroke(Point P)
4449
        {
4450
            foreach (Stroke hits in inkBoard.Strokes)
4451
            {
4452
                foreach (StylusPoint sty in hits.StylusPoints)
4453
                {
4454
                }
4455
                if (hits.HitTest(P))
4456
                {
4457
                    inkBoard.Strokes.Remove(hits);
4458
                    return;
4459
                }
4460
            }
4461
        }
4462

    
4463
        private void StartNewStroke(Point P)
4464
        {
4465
            strokePoints = new StylusPointCollection();
4466
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4467
            strokePoints.Add(segment1Start);
4468
            stroke = new Stroke(strokePoints);
4469

    
4470
            stroke.DrawingAttributes.Color = Colors.Red;
4471
            stroke.DrawingAttributes.Width = 4;
4472
            stroke.DrawingAttributes.Height = 4;
4473

    
4474
            inkBoard.Strokes.Add(stroke);
4475
        }
4476

    
4477
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4478
        {
4479
            ConsolidationMethod();
4480
        }
4481

    
4482
        /// <summary>
4483
        /// execute TeamConsolidationCommand
4484
        /// </summary>
4485
        public void TeamConsolidationMethod()
4486
        {
4487
            this.UpdateMyMarkupList();
4488
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4489
            {
4490
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4491
            }
4492
            else
4493
            {
4494
                ViewerDataModel.Instance.IsConsolidate = true;
4495
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4496

    
4497
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4498
                {
4499
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4500
                    {
4501
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4502
                        return;
4503
                    }
4504
                }
4505
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4506
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4507
                {
4508
                    MarkupInfoList.Add(item);
4509
                }
4510
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4511
            }
4512
        }
4513

    
4514
        public void ConsolidationMethod()
4515
        {
4516
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4517
            {
4518
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4519
            }
4520
            else
4521
            {
4522
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4523
                foreach (var item in this.gridViewMarkup.SelectedItems)
4524
                {
4525
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4526
                }
4527
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4528

    
4529
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4530
            }
4531
        }
4532

    
4533
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4534
        {
4535
            if (App.ViewInfo != null)
4536
            {
4537
                btnConsolidate = (sender as RadRibbonButton);
4538
                if (!App.ViewInfo.NewCommentPermission)
4539
                {
4540
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4541
                }
4542
            }
4543
        }
4544

    
4545
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4546
        {
4547
            TeamConsolidationMethod();
4548
        }
4549

    
4550
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4551
        {
4552
            btnTeamConsolidate = sender as RadRibbonButton;
4553
            if (App.ViewInfo != null)
4554
            {
4555
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4556
                {
4557
                    if (btnConsolidate != null)
4558
                    {
4559
                        btnConsolidate.Visibility = Visibility.Collapsed;
4560
                    }
4561

    
4562
                    if (!App.ViewInfo.NewCommentPermission)
4563
                    {
4564
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4565
                    }
4566
                }
4567
                else
4568
                {
4569
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4570
                }
4571
            }
4572
        }
4573

    
4574
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4575
        {
4576
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4577
            if (item != null)
4578
            {
4579
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4580
                {
4581
                    //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4582
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4583
                }
4584
                else
4585
                {
4586
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4587
                }
4588
            }
4589
            else
4590
            {
4591
                //Consolidate 가 없는 경우
4592
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4593
            }
4594
        }
4595

    
4596
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4597
        {
4598
            btnFinalPDF = sender as RadRibbonButton;
4599
            if (App.ViewInfo != null)
4600
            {
4601
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4602
                {
4603
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4604
                    if (btnConsolidate != null)
4605
                    {
4606
                        btnConsolidate.Visibility = Visibility.Collapsed;
4607
                    }
4608
                }
4609
            }
4610
        }
4611

    
4612
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4613
        {
4614
            UpdateMyMarkupList();
4615

    
4616
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4617
            {
4618
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4619
            }
4620
            else
4621
            {
4622
                ViewerDataModel.Instance.IsConsolidate = true;
4623
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4624
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4625

    
4626
                string project_no = App.ViewInfo.ProjectNO;
4627
                string doc_id = _DocInfo.ID;
4628
                string user_id = App.ViewInfo.UserID;
4629
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4630
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4631
                {
4632
                    markupInfoItems.Add(item);
4633
                }
4634
                //Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4635
                //Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4636
                //Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4637
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4638

    
4639
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4640
                if (item2 != null)
4641
                {
4642
                    //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4643

    
4644
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4645
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4646
                }
4647
                else
4648
                {
4649
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4650
                }
4651
            }
4652
        }
4653

    
4654
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4655
        {
4656
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4657
#if Hyosung
4658
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4659
#else
4660
            if (App.ViewInfo != null)
4661
            {
4662
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4663
                {
4664
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4665
                }
4666
            }
4667
#endif
4668
        }
4669

    
4670
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4671
        {
4672
            SetCompareRect();
4673
        }
4674

    
4675
        private void Sync_Click(object sender, RoutedEventArgs e)
4676
        {
4677
            if (Sync.IsChecked)
4678
            {
4679
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4680
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4681
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4682
            }
4683
        }
4684

    
4685
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4686
        {
4687
            if (UserList.IsChecked)
4688
            {
4689
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4690
            }
4691
            else
4692
            {
4693
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4694
            }
4695
        }
4696

    
4697
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4698
        {
4699
            if (BalanceMode.IsChecked)
4700
            {
4701
                ViewerDataModel.Instance.PageBalanceMode = true;
4702
            }
4703
            else
4704
            {
4705
                ViewerDataModel.Instance.PageBalanceMode = false;
4706
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4707
            }
4708
        }
4709

    
4710
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4711
        {
4712
            //초기화
4713
            testPanel2.IsHidden = true;
4714
            ViewerDataModel.Instance.PageBalanceMode = false;
4715
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4716
            ViewerDataModel.Instance.PageNumber = 0;
4717
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4718
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4719
            UserList.IsChecked = false;
4720
            BalanceMode.IsChecked = false;
4721
        }
4722

    
4723
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4724
        {
4725
            if ((sender as System.Windows.Controls.Control).Tag != null)
4726
            {
4727
                //Compare 초기화
4728
                CompareMode.IsChecked = false;
4729
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4730

    
4731
                if (ViewerDataModel.Instance.PageNumber == 0)
4732
                {
4733
                    ViewerDataModel.Instance.PageNumber = 1;
4734
                }
4735

    
4736
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4737
                {
4738
                }
4739
                else
4740
                {
4741
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4742
                }
4743

    
4744
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4745
                {
4746
                }
4747
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4748
                {
4749
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4750
                }
4751

    
4752
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4753

    
4754
                if (!testPanel2.IsHidden)
4755
                {
4756
                    if (IsSyncPDFMode)
4757
                    {
4758
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4759
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4760

    
4761
                        if (pdfpath.IsDownloading)
4762
                        {
4763
                            pdfpath.DownloadCompleted += (ex, arg) =>
4764
                            {
4765
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4766
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4767
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4768
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4769
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4770
                            };
4771
                        }
4772
                        else
4773
                        {
4774
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4775
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4776
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4777

    
4778
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4779
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4780
                        }
4781
                    }
4782
                    else
4783
                    {
4784
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4785

    
4786
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4787

    
4788
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4789
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4790
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4791

    
4792
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4793
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4794

    
4795
                        if (defaultBitmapImage_Compare.IsDownloading)
4796
                        {
4797
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4798
                            {
4799
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4800
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4801
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4802

    
4803
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4804
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4805
                            };
4806
                        }
4807
                    }
4808
                   
4809
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4810
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4811
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4812

    
4813
                    foreach (var item in gridSelectionRevItem)
4814
                    {
4815
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4816
                        foreach (var markupitem in markupitems)
4817
                        {
4818
                            await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
4819
                        }
4820
                    }
4821

    
4822
                    //강인구 추가
4823
                    zoomAndPanControl2.ZoomTo(new Rect
4824
                    {
4825
                        X = 0,
4826
                        Y = 0,
4827
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4828
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4829
                    });
4830

    
4831
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4832
                }
4833
            }
4834
        }
4835

    
4836
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4837
        {
4838
            if (MarkupMode.IsChecked)
4839
            {
4840
                IsSyncPDFMode = true;
4841

    
4842
                var uri = CurrentRev.TO_VENDOR;
4843

    
4844
                if (ViewerDataModel.Instance.PageNumber == 0)
4845
                {
4846
                    ViewerDataModel.Instance.PageNumber = 1;
4847
                }
4848

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

    
4853
                if (pdfpath.IsDownloading)
4854
                {
4855
                    pdfpath.DownloadCompleted += (ex, arg) =>
4856
                    {
4857
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4858
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4859
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4860
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4861
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4862
                    };
4863
                }
4864
                else
4865
                {
4866
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4867
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4868
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4869

    
4870
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4871
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4872
                }
4873
            }
4874
            else
4875
            {
4876
                IsSyncPDFMode = false;
4877
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4878

    
4879
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4880

    
4881
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4882
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4883
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4884

    
4885
                if (defaultBitmapImage_Compare.IsDownloading)
4886
                {
4887
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4888
                    {
4889
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4890
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4891
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4892
                    };
4893
                }
4894
                zoomAndPanControl2.ApplyTemplate();
4895
                zoomAndPanControl2.UpdateLayout();
4896
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4897
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4898
            }
4899
        }
4900

    
4901
        /// <summary>
4902
        /// Compare된 영역을 초기화
4903
        /// </summary>
4904
        private void ClearCompareRect()
4905
        {
4906
            da.From = 1;
4907
            da.To = 1;
4908
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4909
            da.AutoReverse = false;
4910
            canvas_compareBorder.Children.Clear();
4911
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4912
        }
4913

    
4914
        /// <summary>
4915
        /// 문서 Comprare
4916
        /// </summary>
4917
        private void SetCompareRect()
4918
        {
4919
            if (CompareMode.IsChecked)
4920
            {
4921
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4922
                {
4923
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4924
                }
4925
                if (ViewerDataModel.Instance.PageNumber == 0)
4926
                {
4927
                    ViewerDataModel.Instance.PageNumber = 1;
4928
                }
4929

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

    
4932
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4933
            }
4934
            else
4935
            {
4936
                ClearCompareRect();
4937
            }
4938
        }
4939

    
4940
        private void RadButton_Click(object sender, RoutedEventArgs e)
4941
        {
4942
            gridViewHistory_Busy.IsBusy = true;
4943

    
4944
            RadButton instance = sender as RadButton;
4945
            if (instance.CommandParameter != null)
4946
            {
4947
                CurrentRev = instance.CommandParameter as VPRevision;
4948
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4949

    
4950
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4951
                {
4952
                    if (ea.Error == null && ea.Result != null)
4953
                    {
4954
                        testPanel2.IsHidden = false;
4955

    
4956
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4957
                        foreach (var info in ea.Result)
4958
                        {
4959
                            if (info.UserID == App.ViewInfo.UserID)
4960
                            {
4961
                                info.userDelete = true;
4962
                                info.DisplayColor = "#FFFF0000";
4963
                            }
4964
                            else
4965
                            {
4966
                                info.userDelete = false;
4967
                            }
4968
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4969
                        }
4970
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4971

    
4972
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4973

    
4974
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4975

    
4976
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4977
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4978
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4979
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4980
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4981
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4982

    
4983
                        zoomAndPanControl2.ApplyTemplate();
4984
                        zoomAndPanControl2.UpdateLayout();
4985
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4986
                        {
4987
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4988
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4989
                        }
4990

    
4991
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4992
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4993
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4994

    
4995
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4996
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4997
                        gridViewHistory_Busy.IsBusy = false;
4998
                    }
4999

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

    
5002
                    if (GetSyncMarkupInfoItemshandler != null)
5003
                    {
5004
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5005
                    }
5006

    
5007
                    ClearCompareRect();
5008
                    SetCompareRect();
5009
                };
5010

    
5011
                /// 중복 실행이 발생하여 수정함.
5012
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5013
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5014

    
5015
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5016
            }
5017
        }
5018

    
5019
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5020
        {
5021
            try
5022
            {
5023
                if (sender is RadButton)
5024
                {
5025
                    if ((sender as RadButton).Tag != null)
5026
                    {
5027
                        var url = (sender as RadButton).Tag.ToString();
5028
                        System.Diagnostics.Process.Start(url);
5029
                    }
5030
                    else
5031
                    {
5032
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5033
                    }
5034
                }
5035
            }
5036
            catch (Exception ex)
5037
            {
5038
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5039
            }
5040
        }
5041

    
5042
        public void Sync_Event(VPRevision Currnet_Rev)
5043
        {
5044
            CurrentRev = Currnet_Rev;
5045

    
5046
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5047
            {
5048
                if (ea.Error == null && ea.Result != null)
5049
                {
5050
                    testPanel2.IsHidden = false;
5051

    
5052
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5053
                    foreach (var info in ea.Result)
5054
                    {
5055
                        if (info.UserID == App.ViewInfo.UserID)
5056
                        {
5057
                            info.userDelete = true;
5058
                            info.DisplayColor = "FFFF0000";
5059
                        }
5060
                        else
5061
                        {
5062
                            info.userDelete = false;
5063
                        }
5064
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5065
                    }
5066
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5067

    
5068
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5069

    
5070
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5071

    
5072
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5073

    
5074
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5075
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5076
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5077

    
5078
                    if (defaultBitmapImage_Compare.IsDownloading)
5079
                    {
5080
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5081
                        {
5082
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5083
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5084
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5085
                        };
5086
                    }
5087

    
5088
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5089
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5090
                    zoomAndPanControl2.ApplyTemplate();
5091
                    zoomAndPanControl2.UpdateLayout();
5092

    
5093
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5094
                    {
5095
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5096
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5097
                    }
5098
                    //}
5099

    
5100
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5101
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5102
                    gridViewHistory_Busy.IsBusy = false;
5103
                }
5104
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5105
            };
5106
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5107
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5108
        }
5109

    
5110
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5111
        {
5112
            if (sender is Image)
5113
            {
5114
                if ((sender as Image).Tag != null)
5115
                {
5116
                    var pdfUrl = (sender as Image).Tag.ToString();
5117
                    System.Diagnostics.Process.Start(pdfUrl);
5118
                }
5119
                else
5120
                {
5121
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5122
                }
5123
            }
5124
        }
5125

    
5126
        private void Create_Symbol(object sender, RoutedEventArgs e)
5127
        {
5128
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5129

    
5130
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5131
            {
5132
                DialogMessage_Alert("Please Select Controls", "Alert");
5133
            }
5134
            else //선택된 것이 있으면
5135
            {
5136
                string MarkupData = "";
5137
                adorner_ = new AdornerFinal();
5138

    
5139
                foreach (var item in SelectLayer.Children)
5140
                {
5141
                    if (item.GetType().Name == "AdornerFinal")
5142
                    {
5143
                        adorner_ = (item as Controls.AdornerFinal);
5144
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5145
                        {
5146
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5147
                            {
5148
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5149
                                MarkupData += markupReturn.ConvertData;
5150
                            }
5151
                        }
5152
                    }
5153
                }
5154
                DialogParameters parameters = new DialogParameters()
5155
                {
5156
                    Owner = Application.Current.MainWindow,
5157
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5158
                    DefaultPromptResultValue = "Custom State",
5159
                    Content = "Name :",
5160
                    Header = "Insert Custom Symbol Name",
5161
                    Theme = new VisualStudio2013Theme(),
5162
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5163
                };
5164
                RadWindow.Prompt(parameters);
5165
            }
5166
        }
5167

    
5168
        public int symbolselectindex = 0;
5169

    
5170
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5171
        {
5172
            //Save save = new Save();
5173
            try
5174
            {
5175
                string svgfilename = null;
5176
                if (symbolname != null)
5177
                {
5178
                    if (symbolpng == true || symbolsvg == true)
5179
                    {
5180
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5181
                        string guid = Commons.shortGuid();
5182

    
5183
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5184
                        //Check_Uri.UriCheck();
5185
                        fileUploader.RunCompleted += (ex, arg) =>
5186
                        {
5187
                            filename = arg.Result;
5188
                            if (symbolpng == true)
5189
                            {
5190
                                if (filename != null)
5191
                                {
5192
                                    if (symbolselectindex == 0)
5193
                                    {
5194
                                        SymbolSave(symbolname, filename, data);
5195
                                    }
5196
                                    else
5197
                                    {
5198
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5199
                                    }
5200
                                    DataBind();
5201
                                }
5202
                            }
5203

    
5204
                            if (symbolsvg == true)
5205
                            {
5206
                                try
5207
                                {
5208
                                    var defaultBitmapImage = new BitmapImage();
5209
                                    defaultBitmapImage.BeginInit();
5210
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5211
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5212
                                    Check_Uri.UriCheck(filename);
5213
                                    defaultBitmapImage.UriSource = new Uri(filename);
5214
                                    defaultBitmapImage.EndInit();
5215

    
5216
                                    System.Drawing.Bitmap image;
5217

    
5218
                                    if (defaultBitmapImage.IsDownloading)
5219
                                    {
5220
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5221
                                        {
5222
                                            defaultBitmapImage.Freeze();
5223
                                            image = GetBitmap(defaultBitmapImage);
5224
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5225
                                            Process potrace = new Process
5226
                                            {
5227
                                                StartInfo = new ProcessStartInfo
5228
                                                {
5229
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5230
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5231
                                                    RedirectStandardInput = true,
5232
                                                    RedirectStandardOutput = true,
5233
                                                    RedirectStandardError = true,
5234
                                                    UseShellExecute = false,
5235
                                                    CreateNoWindow = true,
5236
                                                    WindowStyle = ProcessWindowStyle.Hidden
5237
                                                },
5238
                                            };
5239

    
5240
                                            StringBuilder svgBuilder = new StringBuilder();
5241
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5242
                                            {
5243
                                                svgBuilder.AppendLine(e2.Data);
5244
                                            };
5245

    
5246
                                            potrace.EnableRaisingEvents = true;
5247
                                            potrace.Start();
5248
                                            potrace.Exited += (sender, e) =>
5249
                                            {
5250
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5251
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5252
                                                Check_Uri.UriCheck(svgfilename);
5253
                                                if (symbolselectindex == 0)
5254
                                                {
5255
                                                    SymbolSave(symbolname, svgfilename, data);
5256
                                                }
5257
                                                else
5258
                                                {
5259
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5260
                                                }
5261

    
5262
                                                DataBind();
5263
                                            };
5264
                                            potrace.WaitForExit();
5265
                                        };
5266
                                    }
5267
                                    else
5268
                                    {
5269
                                        //GC.Collect();
5270
                                    }
5271
                                }
5272
                                catch (Exception ee)
5273
                                {
5274
                                    DialogMessage_Alert("" + ee, "Alert");
5275
                                }
5276
                            }
5277
                        };
5278
                    }
5279
                }
5280
            }
5281
            catch (Exception e)
5282
            {
5283
                //DialogMessage_Alert(e + "", "Alert");
5284
            }
5285
        }
5286

    
5287
        public void SymbolSave(string Name, string Url, string Data)
5288
        {
5289
            try
5290
            {
5291
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5292
                {
5293
                    ID = Commons.shortGuid(),
5294
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5295
                    NAME = Name,
5296
                    IMAGE_URL = Url,
5297
                    DATA = Data
5298
                };
5299

    
5300
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5301
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5302
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5303
            }
5304
            catch (Exception)
5305
            {
5306
                throw;
5307
            }
5308
        }
5309

    
5310
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5311
        {
5312
            try
5313
            {
5314
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5315
                {
5316
                    ID = Commons.shortGuid(),
5317
                    DEPARTMENT = Department,
5318
                    NAME = Name,
5319
                    IMAGE_URL = Url,
5320
                    DATA = Data
5321
                };
5322
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5323
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5324
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5325
            }
5326
            catch (Exception)
5327
            {
5328
                throw;
5329
            }
5330
        }
5331

    
5332
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5333
        {
5334
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5335
            DataBind();
5336
        }
5337

    
5338
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5339
        {
5340
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5341
            DataBind();
5342
        }
5343

    
5344
        private void DataBind()
5345
        {
5346
            try
5347
            {
5348
                Symbol_Custom Custom = new Symbol_Custom();
5349
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5350

    
5351
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5352
                foreach (var item in symbol_Private)
5353
                {
5354
                    Custom.Name = item.NAME;
5355
                    Custom.ImageUri = item.IMAGE_URL;
5356
                    Custom.ID = item.ID;
5357
                    Custom_List.Add(Custom);
5358
                    Custom = new Symbol_Custom();
5359
                }
5360
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5361

    
5362
                Custom = new Symbol_Custom();
5363
                Custom_List = new List<Symbol_Custom>();
5364

    
5365
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5366

    
5367
                List<SYMBOL_PUBLIC> symbol_Public;
5368

    
5369
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5370
                {
5371
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5372
                }
5373
                else
5374
                {
5375
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5376
                }
5377
                foreach (var item in symbol_Public)
5378
                {
5379
                    Custom.Name = item.NAME;
5380
                    Custom.ImageUri = item.IMAGE_URL;
5381
                    Custom.ID = item.ID;
5382
                    Custom_List.Add(Custom);
5383
                    Custom = new Symbol_Custom();
5384
                }
5385
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5386
                BaseClient.Close();
5387
            }
5388
            catch (Exception e)
5389
            {
5390
                //DialogMessage_Alert("DataBind", "Alert");
5391
            }
5392
        }
5393

    
5394
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5395
        {
5396
            try
5397
            {
5398
                if (args.PromptResult != null)
5399
                {
5400
                    if (args.DialogResult.Value)
5401
                    {
5402
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5403

    
5404
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5405
                        _Encoder.Save(fs);
5406
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5407

    
5408
                        byte[] Img_byte = fs.ToArray();
5409

    
5410
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5411
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5412
                        Check_Uri.UriCheck(filename);
5413
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5414
                        {
5415
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5416
                        }
5417
                        else
5418
                        {
5419
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5420
                        }
5421
                        DataBind();
5422
                    }
5423
                }
5424
            }
5425
            catch (Exception ex)
5426
            {
5427
                DialogMessage_Alert("" + ex, "Alert");
5428
            }
5429
        }
5430

    
5431
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5432
        {
5433
            Canvas _canvas = new Canvas();
5434
            _canvas.Background = Brushes.White;
5435
            _canvas.Width = adorner_.BorderSize.Width;
5436
            _canvas.Height = adorner_.BorderSize.Height;
5437
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5438

    
5439
            BitmapEncoder encoder = new PngBitmapEncoder();
5440

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

    
5443
            DrawingVisual dv = new DrawingVisual();
5444

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

    
5448
            using (DrawingContext ctx = dv.RenderOpen())
5449
            {
5450
                VisualBrush vb = new VisualBrush(_canvas);
5451
                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)));
5452
            }
5453

    
5454
            try
5455
            {
5456
                renderBitmap.Render(dv);
5457

    
5458
                GC.Collect(2);
5459
                GC.WaitForPendingFinalizers();
5460
                //GC.Collect();
5461
                // encode png data
5462
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5463
                // puch rendered bitmap into it
5464
                pngEncoder.Interlace = PngInterlaceOption.Off;
5465
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5466
                return pngEncoder;
5467
            }
5468
            catch //(Exception ex)
5469
            {
5470
                return null;
5471
            }
5472
        }
5473

    
5474
        public void DialogMessage_Alert(string content, string header)
5475
        {
5476
            DialogParameters parameters = new DialogParameters()
5477
            {
5478
                Owner = this.ParentOfType<MainWindow>(),
5479
                Content = new TextBlock()
5480
                {
5481
                    MinWidth = 400,
5482
                    FontSize = 11,
5483
                    Text = content,
5484
                    TextWrapping = System.Windows.TextWrapping.Wrap
5485
                },
5486
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5487
                Header = header,
5488
                Theme = new VisualStudio2013Theme(),
5489
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5490
            };
5491
            RadWindow.Alert(parameters);
5492
        }
5493

    
5494
        #region 캡쳐 기능
5495

    
5496
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5497
        {
5498
            if (x < 0)
5499
            {
5500
                width += x;
5501
                x = 0;
5502
            }
5503
            if (y < 0)
5504
            {
5505
                height += y;
5506
                y = 0;
5507

    
5508
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5509
            }
5510
            if (x + width > zoomAndPanCanvas.ActualWidth)
5511
            {
5512
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5513
            }
5514
            if (y + height > zoomAndPanCanvas.ActualHeight)
5515
            {
5516
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5517
            }
5518

    
5519
            byte[] pixels = CopyPixels(x, y, width, height);
5520

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

    
5523
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5524
        }
5525

    
5526
        public byte[] CopyPixels(int x, int y, int width, int height)
5527
        {
5528
            byte[] pixels = new byte[width * height * 4];
5529
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5530

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

    
5534
            return pixels;
5535
        }
5536

    
5537
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5538
        {
5539
            DrawingVisual drawingVisual = new DrawingVisual();
5540
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5541

    
5542
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5543
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5544
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5545
            drawingContext.Close();
5546

    
5547
            // 비트맵으로 변환합니다.
5548
            RenderTargetBitmap target =
5549
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5550
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5551

    
5552
            target.Render(drawingVisual);
5553
            return target;
5554
        }
5555

    
5556
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5557
        {
5558
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5559
            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);
5560
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5561
            bmp.UnlockBits(data);
5562
            return bmp;
5563
        }
5564

    
5565
        public string symbolname = null;
5566
        public bool symbolsvg = true;
5567
        public bool symbolpng = true;
5568

    
5569
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5570
        {
5571
            System.Drawing.Bitmap image = GetBitmap(source);
5572
            //흰색 제거
5573
            //image.MakeTransparent(System.Drawing.Color.White);
5574

    
5575
            var imageStream = new System.IO.MemoryStream();
5576
            byte[] imageBytes = null;
5577
            using (imageStream)
5578
            {
5579
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5580
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5581
                imageStream.Position = 0;
5582
                imageBytes = imageStream.ToArray();
5583
            }
5584

    
5585
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5586

    
5587
            RadWindow CheckPop = new RadWindow();
5588
            //Alert check = new Alert(Msg);
5589

    
5590
            CheckPop = new RadWindow
5591
            {
5592
                MinWidth = 400,
5593
                MinHeight = 100,
5594
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5595
                Header = "Alert",
5596
                Content = symbolPrompt,
5597
                //DialogResult =
5598
                ResizeMode = System.Windows.ResizeMode.NoResize,
5599
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5600
                IsTopmost = true,
5601
            };
5602
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5603
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5604
            CheckPop.ShowDialog();
5605

    
5606
            /*
5607
            DialogParameters parameters = new DialogParameters()
5608
            {
5609
                Owner = Application.Current.MainWindow,
5610
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5611
                DefaultPromptResultValue = "Custom State",
5612
                Content = "Name :",
5613
                Header = "Insert Custom Symbol Name",
5614
                Theme = new VisualStudio2013Theme(),
5615
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5616
            };
5617
            RadWindow.Prompt(parameters);
5618
            */
5619
        }
5620

    
5621
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5622
        {
5623
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5624
            KCOMDataModel.DataModel.CHECK_LIST check_;
5625
            string Result = streamToBase64.ImageToBase64(source);
5626
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5627
            string projectno = App.ViewInfo.ProjectNO;
5628
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5629

    
5630
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5631
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5632
            if (Item != null)
5633
            {
5634
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5635
            }
5636
            else
5637
            {
5638
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5639
            }
5640

    
5641
            if (Item == null)
5642
            {
5643
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5644
                {
5645
                    ID = Commons.shortGuid(),
5646
                    USER_ID = App.ViewInfo.UserID,
5647
                    IMAGE_URL = Result,
5648
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5649
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5650
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5651
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5652
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5653
                    STATUS = "False",
5654
                    CREATE_TIME = DateTime.Now,
5655
                    UPDATE_TIME = DateTime.Now,
5656
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5657
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5658
                };
5659
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5660
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5661
                this.BaseClient.AddCheckList(projectno, check_);
5662
            }
5663
            else
5664
            {
5665
                Item.IMAGE_URL = Result;
5666
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5667
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5668
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5669
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5670
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5671
            }
5672
        }
5673

    
5674
        public void Set_Capture()
5675
        {
5676
            double x = CanvasDrawingMouseDownPoint.X;
5677
            double y = CanvasDrawingMouseDownPoint.Y;
5678
            double width = dragCaptureBorder.Width;
5679
            double height = dragCaptureBorder.Height;
5680

    
5681
            if (width > 5 || height > 5)
5682
            {
5683
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5684
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5685
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5686
            }
5687
        }
5688

    
5689
        #endregion 캡쳐 기능
5690

    
5691
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5692
        {
5693
            multi_Undo_Data = new Multi_Undo_data();
5694

    
5695
            multi_Undo_Data.Markup = control;
5696

    
5697
            if ((control as IShapeControl) != null)
5698
            {
5699
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5700
            }
5701
            if ((control as IDashControl) != null)
5702
            {
5703
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5704
            }
5705
            if ((control as IPath) != null)
5706
            {
5707
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5708
            }
5709
            if ((control as UIElement) != null)
5710
            {
5711
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5712
            }
5713

    
5714
            return multi_Undo_Data;
5715
        }
5716

    
5717
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5718
        {
5719
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
5720
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5721
            {
5722
                if (items.MarkupInfoID == Select_ID)
5723
                {
5724
                    foreach (var item in items.MarkupList)
5725
                    {
5726
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5727
                        {
5728
                            await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
5729
                                 items.MarkupInfoID, Commons.shortGuid());
5730
                        }
5731
                    }
5732
                }
5733
            }
5734
        }
5735

    
5736
        /// <summary>
5737
        /// convert inkcontrol to polygoncontrol
5738
        /// </summary>
5739
        public void ConvertInkControlToPolygon()
5740
        {
5741
            if (inkBoard.Strokes.Count > 0)
5742
            {
5743
                inkBoard.Strokes.ToList().ForEach(stroke =>
5744
                {
5745
                    InkToPath ip = new InkToPath();
5746

    
5747
                    List<Point> inkPointSet = new List<Point>();
5748
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5749

    
5750
                    PolygonControl pc = new PolygonControl()
5751
                    {
5752
                        CommentAngle = 0,
5753
                        PointSet = inkPointSet,
5754
                        ControlType = ControlType.Ink
5755
                    };
5756
                    pc.StartPoint = inkPointSet[0];
5757
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5758
                    pc.LineSize = 3;
5759
                    pc.CommentID = Commons.shortGuid();
5760
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5761

    
5762
                    if (pc.PointSet.Count > 0)
5763
                    {
5764
                        CreateCommand.Instance.Execute(pc);
5765
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5766
                    }
5767
                });
5768
                inkBoard.Strokes.Clear();
5769
            }
5770
        }
5771

    
5772
        /// <summary>
5773
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5774
        /// </summary>
5775
        /// <author>ingu</author>
5776
        /// <date>2018.06.05</date>
5777
        /// <param name="getPoint"></param>
5778
        /// <returns></returns>
5779
        private bool IsGetoutpoint(Point getPoint)
5780
        {
5781
            if (getPoint == new Point())
5782
            {
5783
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5784
                currentControl = null;
5785
                return true;
5786
            }
5787

    
5788
            return false;
5789
        }
5790

    
5791
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5792
        {
5793
            e.Effects = DragDropEffects.Copy;
5794
        }
5795

    
5796
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5797
        {
5798
            e.Effects = DragDropEffects.Copy;
5799
        }
5800

    
5801
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5802
        {
5803
            e.Effects = DragDropEffects.None;
5804
        }
5805

    
5806
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5807
        {
5808
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5809
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5810

    
5811
            ScaleImage(pageWidth, pageHeight);
5812
        }
5813

    
5814
        /// <summary>
5815
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5816
        /// </summary>
5817
        /// <param name="pageWidth">원본 사이즈</param>
5818
        /// <param name="pageHeight">원본 사이즈</param>
5819
        /// <returns></returns>
5820
        private void ScaleImage(double pageWidth, double pageHeight)
5821
        {
5822
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5823
        }
5824

    
5825
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5826
        {
5827
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5828
        }
5829

    
5830
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5831
        {
5832
            var checkbox = (sender as CheckBox);
5833

    
5834
            if (checkbox != null)
5835
            {
5836
                if (checkbox.IsChecked.GetValueOrDefault())
5837
                {
5838
                    gridViewMarkup.SelectAll();
5839
                }
5840
                else
5841
                {
5842
                    gridViewMarkup.UnselectAll();
5843
                }
5844
            }
5845
        }
5846

    
5847
        /*
5848
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5849
        {
5850
            try
5851
            {
5852
                if (e.Data.GetDataPresent(typeof(string)))
5853
                {
5854
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5855
                    string dragData = e.Data.GetData(typeof(string)) as string;
5856
                    Move_Symbol(sender, dragData);
5857
                }
5858
            }
5859
            catch (Exception ex)
5860
            {
5861
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5862
            }
5863
        }
5864
        */
5865
    }
5866

    
5867
    public class testItem
5868
    {
5869
        public string Title { get; set; }
5870
    }
5871
}
클립보드 이미지 추가 (최대 크기: 500 MB)