프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 274cde11

이력 | 보기 | 이력해설 | 다운로드 (271 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
            var token = ViewerDataModel.Instance.NewCancellationToken();
654

    
655
            await MarkupLoadAsync(e.PageNumber,token);
656

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

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

    
666
            #region 페이지가 벗어난 경우
667

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

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

    
680
            #endregion 페이지가 벗어난 경우
681

    
682
            ViewerDataModel.Instance.PageNumber = BalancePoint;
683

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

    
688
            #region 페이지 이미지 로딩 수정
689

    
690
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
691

    
692
            ScaleImage(pageWidth, pageHeight);
693

    
694
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
695
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
696

    
697
            zoomAndPanCanvas.Width = pageWidth;
698
            zoomAndPanCanvas.Height = pageHeight;
699

    
700
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
701
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
702

    
703
            inkBoard.Width = pageWidth;
704
            inkBoard.Height = pageHeight;
705

    
706
            #endregion 페이지 이미지 로딩 수정
707

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

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

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

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

    
756
                    ViewerDataModel.Instance.ImageViewPath_C = null;
757

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

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

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

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

    
797
            SearchFocusBorder.Visibility = Visibility.Collapsed;
798

    
799
            this.pageNavigator.ChangePage(changePageNumber);
800
        }
801

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

    
816
            var instanceMain = ViewerDataModel.Instance.SystemMain;
817

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

    
820
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
821
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
822

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

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

    
831
            //Point startPoint = new Point(15, 15);
832

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

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

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

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

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

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

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

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

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

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

    
861
            //symCtrl.ApplyTemplate();
862
            ////txtApproved.ApplyTemplate();
863
            ////txtCreator.ApplyTemplate();
864
            //txtOriginator.ApplyTemplate();
865
            //txtDate.ApplyTemplate();
866

    
867
            ////SetTextControl(txtApproved);
868
            ////SetTextControl(txtCreator);
869
            //SetTextControl(txtOriginator);
870
            //SetTextControl(txtDate);
871

    
872
            //multi_Undo_Data = new Multi_Undo_data();
873

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

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

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

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

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

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

    
897
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
898

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

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

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

    
917
            try
918
            {
919
                double height = 80;
920
                double itemWidth = 180;
921

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

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

    
948
            return result;
949
        }
950

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

    
955
            try
956
            {
957
                double height = 80;
958
                double itemWidth = 180;
959

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

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

    
991
            return result;
992
        }
993

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

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

    
1002
                double startPositionX = parentRect.X;
1003

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

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

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

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

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

    
1057
            return result;
1058
        }
1059

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

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

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

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

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

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

    
1106
            };
1107
            /// up to here
1108

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

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

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

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

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

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

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

    
1141
            SetCommentPages(cts);
1142
        }
1143

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

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

    
1178
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1179
        }
1180

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

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

    
1207
            if (instance.IsWheelPageChanage)
1208
            {
1209
                return;
1210
            }
1211

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

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

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

    
1255
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1256

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

    
1266
                //        pageNavigator.PageChanged += handler;
1267

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

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

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

    
1304
        #region ZoomIn & ZoomOut
1305

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

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

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

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

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

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

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

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

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

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

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

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

    
1406
        #endregion ZoomIn & ZoomOut
1407

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

    
1416
                (item as IMarkupCommonData).IsSelected = false;
1417
            }
1418
        }
1419

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

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

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

    
1464
        #region 컨트롤 초기화
1465

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1574
        #endregion 컨트롤 초기화
1575

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

    
1581
        //private Window _dragdropWindow = null;
1582

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

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

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

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

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

    
1617
               CreateDragDropWindow2(img);
1618
    }
1619

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

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

    
1640
            Win32Point w32Mouse = new Win32Point();
1641
            GetCursorPos(ref w32Mouse);
1642

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

    
1649
         */
1650

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

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

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

    
1669
                Point currentPos = e.GetPosition(rect);
1670

    
1671
                floatingTip.HorizontalOffset = currentPos.X + 20;
1672
                floatingTip.VerticalOffset = currentPos.Y;
1673
            }
1674

    
1675
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1676

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

    
1683
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1684

    
1685
                MoveZoomAndPanControl(dragOffset);
1686
            }
1687

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

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

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

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

    
1753
                    #region // 모든 컨트롤의 공통기능 제어
1754

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

    
1760
                    #endregion // 모든 컨트롤의 공통기능 제어
1761

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

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

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

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

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

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

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

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

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

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

    
1877
                        case ControlType.Circle:
1878
                            {
1879
                                var control = currentControl as CircleControl;
1880

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

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

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

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

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

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

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

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

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

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

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

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

    
2021
                        default:
2022
                            break;
2023
                    }
2024

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

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

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

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

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

    
2086
                    e.Handled = true;
2087
                }
2088

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

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

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

    
2141
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2142

    
2143
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2144
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2145

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

    
2154
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2155

    
2156
        private EllipseGeometry hitArea = new EllipseGeometry();
2157

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

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

    
2168
                    SetCursor();
2169

    
2170
                    switch (controlType)
2171
                    {
2172
                        case ControlType.None:
2173
                            break;
2174

    
2175
                        case ControlType.Rectangle:
2176
                            {
2177
                            }
2178
                            break;
2179

    
2180
                        case ControlType.PenControl:
2181
                            {
2182
                            }
2183
                            break;
2184

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

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

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

    
2230
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2231

    
2232
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2233
                            }
2234

    
2235
                            isDraggingSelectionRect = false;
2236
                            e.Handled = true;
2237
                            wasDragSelectionApplied = true;
2238
                        }
2239

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

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

    
2259
                zoomAndPanControl.ReleaseMouseCapture();
2260

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

    
2269
            ///mouseButtonDown = MouseButton.Left;
2270
            //controlType = ControlType.SingleLine;
2271
        }
2272

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

    
2283
            double width = dragCaptureBorder.Width;
2284
            double height = dragCaptureBorder.Height;
2285

    
2286
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2287

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

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

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

    
2318
            //GC.Collect();
2319

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

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

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

    
2343
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2344
        {
2345
        }
2346

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2496
            zoomAndPanControl.RotationAngle = rotate.Angle;
2497

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

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

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

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

    
2545
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2546
        }
2547

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

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

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

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

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

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

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

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

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

    
2658
            ConvertInkControlToPolygon();
2659

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

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

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

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

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

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

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

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

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

    
2738
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2739
                SetCursor();
2740

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

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

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

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

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

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

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

    
2805
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2806

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

    
2818
                    AdornerFinal final = null;
2819

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

    
2825
                        final = new AdornerFinal(control);
2826

    
2827
                        this.Control_Style(control);
2828

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

    
2854
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2855

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

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

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

    
2941
                        Control_Style(control);
2942

    
2943
                        final = new AdornerFinal(comment);
2944
                    }
2945

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

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

    
3003
                                    CreateCommand.Instance.Execute(currentControl);
3004

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

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

    
3032
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3033

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

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

    
3052
                                    CreateCommand.Instance.Execute(currentControl);
3053

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

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

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

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

    
3088
                                    CreateCommand.Instance.Execute(currentControl);
3089

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

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

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

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

    
3124
                                    CreateCommand.Instance.Execute(currentControl);
3125

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

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

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

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

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

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

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

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

    
3197
                                    CreateCommand.Instance.Execute(currentControl);
3198

    
3199
                                    currentControl = null;
3200

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

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

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

    
3233
                                    CreateCommand.Instance.Execute(currentControl);
3234

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

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

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

    
3274
                                        CreateCommand.Instance.Execute(currentControl);
3275

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

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

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

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

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

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

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

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

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

    
3363
                                    control.ApplyOverViewData();
3364

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

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

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

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

    
3409
                                    CreateCommand.Instance.Execute(currentControl);
3410

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

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

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

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

    
3467
                                    CreateCommand.Instance.Execute(currentControl);
3468

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

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

    
3511
                                    CreateCommand.Instance.Execute(currentControl);
3512

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

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

    
3571
                                        CreateCommand.Instance.Execute(currentControl);
3572

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

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

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

    
3617
                                    CreateCommand.Instance.Execute(currentControl);
3618

    
3619
                                    control.isTransOn = true;
3620
                                    var firstPoint = control.PointSet.First();
3621

    
3622
                                    control.PointSet.Add(firstPoint);
3623
                                    control.DrawingCloud();
3624
                                    control.ApplyOverViewData();
3625

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

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

    
3647
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3648
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3649

    
3650
                                    //}
3651
                                }
3652
                            }
3653
                        }
3654
                        break;
3655

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

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

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

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

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

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

    
3738
                                    CreateCommand.Instance.Execute(currentControl);
3739
                                    currentControl = null;
3740

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

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

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

    
3792
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3793
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3794

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

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

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

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

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

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

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

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

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

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

    
3887
                                    CreateCommand.Instance.Execute(currentControl);
3888

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

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

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

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

    
3918
                                    //}
3919
                                }
3920
                            }
3921
                        }
3922
                        break;
3923

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

    
3936
                                    CreateCommand.Instance.Execute(currentControl);
3937

    
3938
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3939

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

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

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

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

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

    
4006
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4007

    
4008
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4009

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

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

    
4041
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4042
                                }
4043
                                else
4044
                                {
4045
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4046
                                    //{
4047
                                    currentControl = new ArrowTextControl()
4048
                                    {
4049
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4050
                                        ControlType = ControlType.ArrowTransTextBorderControl
4051
                                    };
4052
                                    currentControl.CommentID = Commons.shortGuid();
4053
                                    currentControl.IsNew = true;
4054
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4055
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4056

    
4057
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4058

    
4059
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4060
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4061
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4062
                                    (currentControl as ArrowTextControl).isFixed = true;
4063
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4064

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

    
4072
                                    //20180911 LJY
4073
                                    (currentControl as ArrowTextControl).isTrans = true;
4074

    
4075
                                    //}
4076
                                }
4077
                            }
4078
                        }
4079
                        break;
4080

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

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

    
4120
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4121
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4122
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4123
                                    //}
4124
                                }
4125
                            }
4126
                        }
4127
                        break;
4128

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

    
4161
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4162
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4163
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4164
                                    (currentControl as ArrowTextControl).isFixed = true;
4165
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4166

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

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

    
4190
                                if (_sign == null)
4191
                                {
4192
                                    txtBatch.Visibility = Visibility.Collapsed;
4193
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4194
                                    controlType = ControlType.None;
4195

    
4196
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4197
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4198
                                    return;
4199
                                }
4200

    
4201
                                if (currentControl is SignControl)
4202
                                {
4203
                                    //20180906 LJY TEST IsRotationDrawingEnable
4204
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4205
                                    {
4206
                                        return;
4207
                                    }
4208

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

    
4229
                                    currentControl.CommentID = Commons.shortGuid();
4230
                                    currentControl.IsNew = true;
4231
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4232
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4233

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

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

    
4256
                                    CreateCommand.Instance.Execute(currentControl);
4257
                                    (currentControl as RectangleControl).ApplyOverViewData();
4258
                                    currentControl = null;
4259

    
4260
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4261

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

    
4278
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4279
                                    currentControl.CommentID = Commons.shortGuid();
4280
                                    currentControl.IsNew = true;
4281
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4282
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4283
                                }
4284
                                //}
4285
                            }
4286
                        }
4287
                        break;
4288

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

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

    
4315
                                    currentControl.IsNew = true;
4316
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4317
                                    currentControl.CommentID = Commons.shortGuid();
4318
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4319

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

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

    
4342
                                    CreateCommand.Instance.Execute(currentControl);
4343
                                    currentControl = null;
4344

    
4345
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4346
                                }
4347
                                else
4348
                                {
4349
                                    currentControl = new SymControlN
4350
                                    {
4351
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4352
                                        Background = new SolidColorBrush(Colors.Black),
4353
                                        STAMP = App.SystemInfo.STAMP,
4354
                                        ControlType = ControlType.Stamp
4355
                                    };
4356

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

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

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

    
4418
                    if (!mouseOff)
4419
                    {
4420
                        SelectionSet.Instance.UnSelect(this);
4421
                    }
4422
                }
4423
                zoomAndPanControl.CaptureMouse();
4424
                e.Handled = true;
4425
            }
4426
        }
4427

    
4428
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4429
        {
4430
            ///mouseButtonDown = e.ChangedButton;
4431
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4432
        }
4433

    
4434
        private void RemoveLineStroke(Point P)
4435
        {
4436
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4437
            if (control != null)
4438
            {
4439
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4440
            }
4441
        }
4442

    
4443
        private void RemovePointStroke(Point P)
4444
        {
4445
            foreach (Stroke hits in inkBoard.Strokes)
4446
            {
4447
                foreach (StylusPoint sty in hits.StylusPoints)
4448
                {
4449
                }
4450
                if (hits.HitTest(P))
4451
                {
4452
                    inkBoard.Strokes.Remove(hits);
4453
                    return;
4454
                }
4455
            }
4456
        }
4457

    
4458
        private void StartNewStroke(Point P)
4459
        {
4460
            strokePoints = new StylusPointCollection();
4461
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4462
            strokePoints.Add(segment1Start);
4463
            stroke = new Stroke(strokePoints);
4464

    
4465
            stroke.DrawingAttributes.Color = Colors.Red;
4466
            stroke.DrawingAttributes.Width = 4;
4467
            stroke.DrawingAttributes.Height = 4;
4468

    
4469
            inkBoard.Strokes.Add(stroke);
4470
        }
4471

    
4472
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4473
        {
4474
            ConsolidationMethod();
4475
        }
4476

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

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

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

    
4524
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4525
            }
4526
        }
4527

    
4528
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4529
        {
4530
            if (App.ViewInfo != null)
4531
            {
4532
                btnConsolidate = (sender as RadRibbonButton);
4533
                if (!App.ViewInfo.NewCommentPermission)
4534
                {
4535
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4536
                }
4537
            }
4538
        }
4539

    
4540
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4541
        {
4542
            TeamConsolidationMethod();
4543
        }
4544

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

    
4557
                    if (!App.ViewInfo.NewCommentPermission)
4558
                    {
4559
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4560
                    }
4561
                }
4562
                else
4563
                {
4564
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4565
                }
4566
            }
4567
        }
4568

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

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

    
4607
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4608
        {
4609
            UpdateMyMarkupList();
4610

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

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

    
4634
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4635
                if (item2 != null)
4636
                {
4637
                    //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4638

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

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

    
4665
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4666
        {
4667
            SetCompareRect();
4668
        }
4669

    
4670
        private void Sync_Click(object sender, RoutedEventArgs e)
4671
        {
4672
            if (Sync.IsChecked)
4673
            {
4674
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4675
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4676
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4677
            }
4678
        }
4679

    
4680
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4681
        {
4682
            if (UserList.IsChecked)
4683
            {
4684
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4685
            }
4686
            else
4687
            {
4688
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4689
            }
4690
        }
4691

    
4692
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4693
        {
4694
            if (BalanceMode.IsChecked)
4695
            {
4696
                ViewerDataModel.Instance.PageBalanceMode = true;
4697
            }
4698
            else
4699
            {
4700
                ViewerDataModel.Instance.PageBalanceMode = false;
4701
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4702
            }
4703
        }
4704

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

    
4718
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4719
        {
4720
            if ((sender as System.Windows.Controls.Control).Tag != null)
4721
            {
4722
                //Compare 초기화
4723
                CompareMode.IsChecked = false;
4724
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4725

    
4726
                if (ViewerDataModel.Instance.PageNumber == 0)
4727
                {
4728
                    ViewerDataModel.Instance.PageNumber = 1;
4729
                }
4730

    
4731
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4732
                {
4733
                }
4734
                else
4735
                {
4736
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4737
                }
4738

    
4739
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4740
                {
4741
                }
4742
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4743
                {
4744
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4745
                }
4746

    
4747
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4748

    
4749
                if (!testPanel2.IsHidden)
4750
                {
4751
                    if (IsSyncPDFMode)
4752
                    {
4753
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4754
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4755

    
4756
                        if (pdfpath.IsDownloading)
4757
                        {
4758
                            pdfpath.DownloadCompleted += (ex, arg) =>
4759
                            {
4760
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4761
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4762
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4763
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4764
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4765
                            };
4766
                        }
4767
                        else
4768
                        {
4769
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4770
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4771
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4772

    
4773
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4774
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4775
                        }
4776
                    }
4777
                    else
4778
                    {
4779
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4780

    
4781
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4782

    
4783
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4784
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4785
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4786

    
4787
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4788
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4789

    
4790
                        if (defaultBitmapImage_Compare.IsDownloading)
4791
                        {
4792
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4793
                            {
4794
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4795
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4796
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4797

    
4798
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4799
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4800
                            };
4801
                        }
4802
                    }
4803

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

    
4808
                    foreach (var item in gridSelectionRevItem)
4809
                    {
4810
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4811
                        foreach (var markupitem in markupitems)
4812
                        {
4813
                            await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4814
                        }
4815
                    }
4816

    
4817
                    //강인구 추가
4818
                    zoomAndPanControl2.ZoomTo(new Rect
4819
                    {
4820
                        X = 0,
4821
                        Y = 0,
4822
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4823
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4824
                    });
4825

    
4826
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4827
                }
4828
            }
4829
        }
4830

    
4831
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4832
        {
4833
            if (MarkupMode.IsChecked)
4834
            {
4835
                IsSyncPDFMode = true;
4836

    
4837
                var uri = CurrentRev.TO_VENDOR;
4838

    
4839
                if (ViewerDataModel.Instance.PageNumber == 0)
4840
                {
4841
                    ViewerDataModel.Instance.PageNumber = 1;
4842
                }
4843

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

    
4848
                if (pdfpath.IsDownloading)
4849
                {
4850
                    pdfpath.DownloadCompleted += (ex, arg) =>
4851
                    {
4852
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4853
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4854
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4855
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4856
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4857
                    };
4858
                }
4859
                else
4860
                {
4861
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4862
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4863
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4864

    
4865
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4866
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4867
                }
4868
            }
4869
            else
4870
            {
4871
                IsSyncPDFMode = false;
4872
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4873

    
4874
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4875

    
4876
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4877
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4878
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4879

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

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

    
4909
        /// <summary>
4910
        /// 문서 Comprare
4911
        /// </summary>
4912
        private void SetCompareRect()
4913
        {
4914
            if (CompareMode.IsChecked)
4915
            {
4916
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4917
                {
4918
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4919
                }
4920
                if (ViewerDataModel.Instance.PageNumber == 0)
4921
                {
4922
                    ViewerDataModel.Instance.PageNumber = 1;
4923
                }
4924

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

    
4927
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4928
            }
4929
            else
4930
            {
4931
                ClearCompareRect();
4932
            }
4933
        }
4934

    
4935
        private void RadButton_Click(object sender, RoutedEventArgs e)
4936
        {
4937
            gridViewHistory_Busy.IsBusy = true;
4938

    
4939
            RadButton instance = sender as RadButton;
4940
            if (instance.CommandParameter != null)
4941
            {
4942
                CurrentRev = instance.CommandParameter as VPRevision;
4943
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4944

    
4945
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4946
                {
4947
                    if (ea.Error == null && ea.Result != null)
4948
                    {
4949
                        testPanel2.IsHidden = false;
4950

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

    
4967
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4968

    
4969
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4970

    
4971
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4972
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4973
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4974
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4975
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4976
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4977

    
4978
                        zoomAndPanControl2.ApplyTemplate();
4979
                        zoomAndPanControl2.UpdateLayout();
4980
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4981
                        {
4982
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4983
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4984
                        }
4985

    
4986
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4987
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4988
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4989

    
4990
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4991
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4992
                        gridViewHistory_Busy.IsBusy = false;
4993
                    }
4994

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

    
4997
                    if (GetSyncMarkupInfoItemshandler != null)
4998
                    {
4999
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5000
                    }
5001

    
5002
                    ClearCompareRect();
5003
                    SetCompareRect();
5004
                };
5005

    
5006
                /// 중복 실행이 발생하여 수정함.
5007
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5008
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5009

    
5010
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5011
            }
5012
        }
5013

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

    
5037
        public void Sync_Event(VPRevision Currnet_Rev)
5038
        {
5039
            CurrentRev = Currnet_Rev;
5040

    
5041
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5042
            {
5043
                if (ea.Error == null && ea.Result != null)
5044
                {
5045
                    testPanel2.IsHidden = false;
5046

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

    
5063
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5064

    
5065
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5066

    
5067
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5068

    
5069
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5070
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5071
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5072

    
5073
                    if (defaultBitmapImage_Compare.IsDownloading)
5074
                    {
5075
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5076
                        {
5077
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5078
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5079
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5080
                        };
5081
                    }
5082

    
5083
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5084
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5085
                    zoomAndPanControl2.ApplyTemplate();
5086
                    zoomAndPanControl2.UpdateLayout();
5087

    
5088
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5089
                    {
5090
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5091
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5092
                    }
5093
                    //}
5094

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

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

    
5121
        private void Create_Symbol(object sender, RoutedEventArgs e)
5122
        {
5123
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5124

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

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

    
5163
        public int symbolselectindex = 0;
5164

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

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

    
5199
                            if (symbolsvg == true)
5200
                            {
5201
                                try
5202
                                {
5203
                                    var defaultBitmapImage = new BitmapImage();
5204
                                    defaultBitmapImage.BeginInit();
5205
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5206
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5207
                                    Check_Uri.UriCheck(filename);
5208
                                    defaultBitmapImage.UriSource = new Uri(filename);
5209
                                    defaultBitmapImage.EndInit();
5210

    
5211
                                    System.Drawing.Bitmap image;
5212

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

    
5235
                                            StringBuilder svgBuilder = new StringBuilder();
5236
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5237
                                            {
5238
                                                svgBuilder.AppendLine(e2.Data);
5239
                                            };
5240

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

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

    
5282
        public void SymbolSave(string Name, string Url, string Data)
5283
        {
5284
            try
5285
            {
5286
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5287
                {
5288
                    ID = Commons.shortGuid(),
5289
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5290
                    NAME = Name,
5291
                    IMAGE_URL = Url,
5292
                    DATA = Data
5293
                };
5294

    
5295
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5296
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5297
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5298
            }
5299
            catch (Exception)
5300
            {
5301
                throw;
5302
            }
5303
        }
5304

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

    
5327
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5328
        {
5329
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5330
            DataBind();
5331
        }
5332

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

    
5339
        private void DataBind()
5340
        {
5341
            try
5342
            {
5343
                Symbol_Custom Custom = new Symbol_Custom();
5344
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5345

    
5346
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5347
                foreach (var item in symbol_Private)
5348
                {
5349
                    Custom.Name = item.NAME;
5350
                    Custom.ImageUri = item.IMAGE_URL;
5351
                    Custom.ID = item.ID;
5352
                    Custom_List.Add(Custom);
5353
                    Custom = new Symbol_Custom();
5354
                }
5355
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5356

    
5357
                Custom = new Symbol_Custom();
5358
                Custom_List = new List<Symbol_Custom>();
5359

    
5360
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5361

    
5362
                List<SYMBOL_PUBLIC> symbol_Public;
5363

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

    
5389
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5390
        {
5391
            try
5392
            {
5393
                if (args.PromptResult != null)
5394
                {
5395
                    if (args.DialogResult.Value)
5396
                    {
5397
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5398

    
5399
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5400
                        _Encoder.Save(fs);
5401
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5402

    
5403
                        byte[] Img_byte = fs.ToArray();
5404

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

    
5426
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5427
        {
5428
            Canvas _canvas = new Canvas();
5429
            _canvas.Background = Brushes.White;
5430
            _canvas.Width = adorner_.BorderSize.Width;
5431
            _canvas.Height = adorner_.BorderSize.Height;
5432
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5433

    
5434
            BitmapEncoder encoder = new PngBitmapEncoder();
5435

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

    
5438
            DrawingVisual dv = new DrawingVisual();
5439

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

    
5443
            using (DrawingContext ctx = dv.RenderOpen())
5444
            {
5445
                VisualBrush vb = new VisualBrush(_canvas);
5446
                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)));
5447
            }
5448

    
5449
            try
5450
            {
5451
                renderBitmap.Render(dv);
5452

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

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

    
5489
        #region 캡쳐 기능
5490

    
5491
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5492
        {
5493
            if (x < 0)
5494
            {
5495
                width += x;
5496
                x = 0;
5497
            }
5498
            if (y < 0)
5499
            {
5500
                height += y;
5501
                y = 0;
5502

    
5503
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5504
            }
5505
            if (x + width > zoomAndPanCanvas.ActualWidth)
5506
            {
5507
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5508
            }
5509
            if (y + height > zoomAndPanCanvas.ActualHeight)
5510
            {
5511
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5512
            }
5513

    
5514
            byte[] pixels = CopyPixels(x, y, width, height);
5515

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

    
5518
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5519
        }
5520

    
5521
        public byte[] CopyPixels(int x, int y, int width, int height)
5522
        {
5523
            byte[] pixels = new byte[width * height * 4];
5524
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5525

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

    
5529
            return pixels;
5530
        }
5531

    
5532
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5533
        {
5534
            DrawingVisual drawingVisual = new DrawingVisual();
5535
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5536

    
5537
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5538
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5539
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5540
            drawingContext.Close();
5541

    
5542
            // 비트맵으로 변환합니다.
5543
            RenderTargetBitmap target =
5544
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5545
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5546

    
5547
            target.Render(drawingVisual);
5548
            return target;
5549
        }
5550

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

    
5560
        public string symbolname = null;
5561
        public bool symbolsvg = true;
5562
        public bool symbolpng = true;
5563

    
5564
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5565
        {
5566
            System.Drawing.Bitmap image = GetBitmap(source);
5567
            //흰색 제거
5568
            //image.MakeTransparent(System.Drawing.Color.White);
5569

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

    
5580
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5581

    
5582
            RadWindow CheckPop = new RadWindow();
5583
            //Alert check = new Alert(Msg);
5584

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

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

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

    
5625
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5626
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5627
            if (Item != null)
5628
            {
5629
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5630
            }
5631
            else
5632
            {
5633
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5634
            }
5635

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

    
5669
        public void Set_Capture()
5670
        {
5671
            double x = CanvasDrawingMouseDownPoint.X;
5672
            double y = CanvasDrawingMouseDownPoint.Y;
5673
            double width = dragCaptureBorder.Width;
5674
            double height = dragCaptureBorder.Height;
5675

    
5676
            if (width > 5 || height > 5)
5677
            {
5678
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5679
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5680
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5681
            }
5682
        }
5683

    
5684
        #endregion 캡쳐 기능
5685

    
5686
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5687
        {
5688
            multi_Undo_Data = new Multi_Undo_data();
5689

    
5690
            multi_Undo_Data.Markup = control;
5691

    
5692
            if ((control as IShapeControl) != null)
5693
            {
5694
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5695
            }
5696
            if ((control as IDashControl) != null)
5697
            {
5698
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5699
            }
5700
            if ((control as IPath) != null)
5701
            {
5702
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5703
            }
5704
            if ((control as UIElement) != null)
5705
            {
5706
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5707
            }
5708

    
5709
            return multi_Undo_Data;
5710
        }
5711

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

    
5731
        /// <summary>
5732
        /// convert inkcontrol to polygoncontrol
5733
        /// </summary>
5734
        public void ConvertInkControlToPolygon()
5735
        {
5736
            if (inkBoard.Strokes.Count > 0)
5737
            {
5738
                inkBoard.Strokes.ToList().ForEach(stroke =>
5739
                {
5740
                    InkToPath ip = new InkToPath();
5741

    
5742
                    List<Point> inkPointSet = new List<Point>();
5743
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5744

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

    
5757
                    if (pc.PointSet.Count > 0)
5758
                    {
5759
                        CreateCommand.Instance.Execute(pc);
5760
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5761
                    }
5762
                });
5763
                inkBoard.Strokes.Clear();
5764
            }
5765
        }
5766

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

    
5783
            return false;
5784
        }
5785

    
5786
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5787
        {
5788
            e.Effects = DragDropEffects.Copy;
5789
        }
5790

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

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

    
5801
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5802
        {
5803
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5804
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5805

    
5806
            ScaleImage(pageWidth, pageHeight);
5807
        }
5808

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

    
5820
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5821
        {
5822
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5823
        }
5824

    
5825
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5826
        {
5827
            var checkbox = (sender as CheckBox);
5828

    
5829
            if (checkbox != null)
5830
            {
5831
                if (checkbox.IsChecked.GetValueOrDefault())
5832
                {
5833
                    gridViewMarkup.SelectAll();
5834
                }
5835
                else
5836
                {
5837
                    gridViewMarkup.UnselectAll();
5838
                }
5839
            }
5840
        }
5841

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

    
5862
    public class testItem
5863
    {
5864
        public string Title { get; set; }
5865
    }
5866
}
클립보드 이미지 추가 (최대 크기: 500 MB)