프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ ed705a3d

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
154
        /// <summary>
155
        /// Set to 'true' when the left mouse-button is down.
156
        /// </summary>
157
        public bool isLeftMouseButtonDownOnWindow = false;
158

    
159
        public InkPresenter _InkBoard = null;
160
        private Stroke stroke;
161
        private Boolean IsDrawing = false;
162
        private StylusPointCollection strokePoints;
163

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

    
167
        private Point Sync_Offset_Point;
168

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

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

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

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

    
213
        public bool IsSyncPDFMode { get; set; }
214

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

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

    
240
        #endregion 프로퍼티
241

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

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

    
255
            //lstSymbolPrivate.ItemsSource = testItems;
256

    
257
            this.Loaded += MainMenu_Loaded;
258
        }
259

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

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

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

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

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

    
297
            return uri;
298
        }
299

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

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

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

    
341
            return false;
342
        }
343

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

    
367
            return false;
368
        }
369

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

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

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

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

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

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

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

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

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

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

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

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

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

    
481
            if (App.ParameterMode)
482
            {
483

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

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

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

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

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

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

    
526
        string instnaceFile;
527
        string downloadurl;
528

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

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

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

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

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

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

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

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

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

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

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

    
617
            /// up to here
618

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

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

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

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

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

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

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

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

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

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

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

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

    
684
            ViewerDataModel.Instance.PageNumber = BalancePoint;
685

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

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

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

    
694
            ScaleImage(pageWidth, pageHeight);
695

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

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

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

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

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

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

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

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

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

    
758
                    ViewerDataModel.Instance.ImageViewPath_C = null;
759

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

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

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

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

    
799
            SearchFocusBorder.Visibility = Visibility.Collapsed;
800

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

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

    
818
            var instanceMain = ViewerDataModel.Instance.SystemMain;
819

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
874
            //multi_Undo_Data = new Multi_Undo_data();
875

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

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

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

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

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

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

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

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

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

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

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

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

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

    
950
            return result;
951
        }
952

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

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

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

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

    
993
            return result;
994
        }
995

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

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

    
1004
                double startPositionX = parentRect.X;
1005

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

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

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

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

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

    
1059
            return result;
1060
        }
1061

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

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

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

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

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

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

    
1108
            };
1109
            /// up to here
1110

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

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

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

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

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

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

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

    
1143
            SetCommentPages(cts);
1144
        }
1145

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

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

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

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

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

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

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

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

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

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

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

    
1268
                //        pageNavigator.PageChanged += handler;
1269

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

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

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

    
1306
        #region ZoomIn & ZoomOut
1307

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

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

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

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

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

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

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

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

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

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

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

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

    
1408
        #endregion ZoomIn & ZoomOut
1409

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

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

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

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

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

    
1466
        #region 컨트롤 초기화
1467

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1576
        #endregion 컨트롤 초기화
1577

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

    
1583
        //private Window _dragdropWindow = null;
1584

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

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

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

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

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

    
1619
               CreateDragDropWindow2(img);
1620
    }
1621

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

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

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

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

    
1651
         */
1652

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

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

    
1665
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1666
        {
1667
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1668
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1669
            //if(this.txtBatch.Visibility == Visibility.Visible)
1670
            {
1671
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1672

    
1673
                Point currentPos = e.GetPosition(rect);
1674

    
1675
                floatingTip.HorizontalOffset = currentPos.X + 20;
1676
                floatingTip.VerticalOffset = currentPos.Y;
1677
            }
1678

    
1679
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1680

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

    
1687
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1688

    
1689
                MoveZoomAndPanControl(dragOffset);
1690
            }
1691

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

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

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

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

    
1757
                    #region // 모든 컨트롤의 공통기능 제어
1758

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

    
1764
                    #endregion // 모든 컨트롤의 공통기능 제어
1765

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

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

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

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

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

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

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

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

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

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

    
1881
                        case ControlType.Circle:
1882
                            {
1883
                                var control = currentControl as CircleControl;
1884

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

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

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

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

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

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

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

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

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

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

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

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

    
2025
                        default:
2026
                            break;
2027
                    }
2028

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

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

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

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

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

    
2090
                    e.Handled = true;
2091
                }
2092

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

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

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

    
2145
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2146

    
2147
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2148
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2149

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

    
2158
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2159

    
2160
        private EllipseGeometry hitArea = new EllipseGeometry();
2161

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

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

    
2172
                    SetCursor();
2173

    
2174
                    switch (controlType)
2175
                    {
2176
                        case ControlType.None:
2177
                            break;
2178

    
2179
                        case ControlType.Rectangle:
2180
                            {
2181
                            }
2182
                            break;
2183

    
2184
                        case ControlType.PenControl:
2185
                            {
2186
                            }
2187
                            break;
2188

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

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

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

    
2234
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2235

    
2236
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2237
                            }
2238

    
2239
                            isDraggingSelectionRect = false;
2240
                            e.Handled = true;
2241
                            wasDragSelectionApplied = true;
2242
                        }
2243

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

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

    
2263
                zoomAndPanControl.ReleaseMouseCapture();
2264

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

    
2273
            ///mouseButtonDown = MouseButton.Left;
2274
            //controlType = ControlType.SingleLine;
2275
        }
2276

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

    
2287
            double width = dragCaptureBorder.Width;
2288
            double height = dragCaptureBorder.Height;
2289

    
2290
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2291

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

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

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

    
2322
            //GC.Collect();
2323

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

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

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

    
2347
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2348
        {
2349
        }
2350

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2500
            zoomAndPanControl.RotationAngle = rotate.Angle;
2501

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

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

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

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

    
2549
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2550
        }
2551

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

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

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

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

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

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

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

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

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

    
2662
            ConvertInkControlToPolygon();
2663

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

    
2668
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2669
            {
2670
                DeleteCommand.Instance.Execute(new[] { text_item });
2671
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2672
            }
2673
            /// up to here
2674

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

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

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

    
2707
            double Ang = 0;
2708
            if (rotate.Angle != 0)
2709
            {
2710
                Ang = 360 - rotate.Angle;
2711
            }
2712

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

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

    
2738
            if (e.LeftButton == MouseButtonState.Pressed)
2739
            {
2740
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2741
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2742

    
2743
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2744
                SetCursor();
2745

    
2746
                if (!ViewerDataModel.Instance.IsPressCtrl)
2747
                {
2748
                    SelectionSet.Instance.UnSelect(this);
2749
                }
2750
            }
2751

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

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

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

    
2791
                    if (controlType == ControlType.None)
2792
                    {
2793
                        isLeftMouseButtonDownOnWindow = true;
2794
                    }
2795
                }
2796

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

    
2804
                /// 줌 모드 설정
2805
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2806
                {
2807
                    isLeftMouseButtonDownOnWindow = true;
2808
                }
2809

    
2810
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2811

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

    
2823
                    AdornerFinal final = null;
2824

    
2825
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2826
                    {
2827
                        /// 기존 selection 해제
2828
                        SelectionSet.Instance.UnSelect(this);
2829

    
2830
                        final = new AdornerFinal(control);
2831

    
2832
                        this.Control_Style(control);
2833

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

    
2859
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2860

    
2861
                        if ((control as TextControl) != null)
2862
                        {
2863
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2864

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

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

    
2946
                        Control_Style(control);
2947

    
2948
                        final = new AdornerFinal(comment);
2949
                    }
2950

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

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

    
3008
                                    CreateCommand.Instance.Execute(currentControl);
3009

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

    
3033
                                        currentControl.CommentID = Commons.shortGuid();
3034
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3035
                                        currentControl.IsNew = true;
3036

    
3037
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3038

    
3039
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3040
                                    }
3041
                                }
3042
                            }
3043
                        }
3044
                        break;
3045

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

    
3057
                                    CreateCommand.Instance.Execute(currentControl);
3058

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

    
3071
                                    currentControl.CommentID = Commons.shortGuid();
3072
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3073
                                    currentControl.IsNew = true;
3074
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3075

    
3076
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3077
                                }
3078
                            }
3079
                        }
3080
                        break;
3081

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

    
3093
                                    CreateCommand.Instance.Execute(currentControl);
3094

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

    
3107
                                    currentControl.CommentID = Commons.shortGuid();
3108
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3109
                                    currentControl.IsNew = true;
3110
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3111

    
3112
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3113
                                }
3114
                            }
3115
                        }
3116
                        break;
3117

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

    
3129
                                    CreateCommand.Instance.Execute(currentControl);
3130

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

    
3143
                                    currentControl.CommentID = Commons.shortGuid();
3144
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3145
                                    currentControl.IsNew = true;
3146
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3147

    
3148
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3149
                                }
3150
                            }
3151
                        }
3152
                        break;
3153

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

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

    
3179
                                    currentControl.CommentID = Commons.shortGuid();
3180
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3181
                                    currentControl.IsNew = true;
3182
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3183

    
3184
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3185
                                }
3186
                            }
3187
                        }
3188
                        break;
3189

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

    
3202
                                    CreateCommand.Instance.Execute(currentControl);
3203

    
3204
                                    currentControl = null;
3205

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

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

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

    
3238
                                    CreateCommand.Instance.Execute(currentControl);
3239

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

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

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

    
3279
                                        CreateCommand.Instance.Execute(currentControl);
3280

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

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

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

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

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

    
3340
                    case ControlType.PolygonControl:
3341
                        {
3342
                            if (currentControl is PolygonControl)
3343
                            {
3344
                                var control = currentControl as PolygonControl;
3345

    
3346
                                if (e.RightButton == MouseButtonState.Pressed)
3347
                                {
3348
                                    control.IsCompleted = true;
3349
                                }
3350

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

    
3363
                                    var firstPoint = control.PointSet.First();
3364
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3365
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3366
                                    control.PointSet.Add(firstPoint);
3367

    
3368
                                    control.ApplyOverViewData();
3369

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

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

    
3400
                    case ControlType.ChainLine:
3401
                        {
3402
                            if (currentControl is PolygonControl)
3403
                            {
3404
                                var control = currentControl as PolygonControl;
3405

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

    
3414
                                    CreateCommand.Instance.Execute(currentControl);
3415

    
3416
                                    currentControl = null;
3417
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3418
                                    return;
3419
                                }
3420

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

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

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

    
3472
                                    CreateCommand.Instance.Execute(currentControl);
3473

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

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

    
3516
                                    CreateCommand.Instance.Execute(currentControl);
3517

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

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

    
3576
                                        CreateCommand.Instance.Execute(currentControl);
3577

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

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

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

    
3622
                                    CreateCommand.Instance.Execute(currentControl);
3623

    
3624
                                    control.isTransOn = true;
3625
                                    var firstPoint = control.PointSet.First();
3626

    
3627
                                    control.PointSet.Add(firstPoint);
3628
                                    control.DrawingCloud();
3629
                                    control.ApplyOverViewData();
3630

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

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

    
3652
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3653
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3654

    
3655
                                    //}
3656
                                }
3657
                            }
3658
                        }
3659
                        break;
3660

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

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

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

    
3715
                                        currentControl.CommentID = Commons.shortGuid();
3716
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3717
                                        currentControl.IsNew = true;
3718
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3719

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

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

    
3743
                                    CreateCommand.Instance.Execute(currentControl);
3744
                                    currentControl = null;
3745

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

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

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

    
3797
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3798
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3799

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

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

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

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

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

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

    
3861
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3862
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3863
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3864

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

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

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

    
3892
                                    CreateCommand.Instance.Execute(currentControl);
3893
                                    try
3894
                                    {
3895
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3896
                                    }
3897
                                    catch (Exception ex)
3898
                                    {
3899
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3900
                                    }
3901

    
3902
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3903
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3904
                                    (currentControl as ArrowTextControl).IsNew = false;
3905
                                    currentControl = null;
3906
                                }
3907
                                else
3908
                                {
3909
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3910
                                    //{
3911
                                    currentControl = new ArrowTextControl()
3912
                                    {
3913
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3914
                                    };
3915

    
3916
                                    currentControl.CommentID = Commons.shortGuid();
3917
                                    currentControl.IsNew = true;
3918
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3919
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3920

    
3921
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3922
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3923
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3924
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3925
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3926

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

    
3930
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3931
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3932
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3933
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3934

    
3935
                                    //}
3936
                                }
3937
                            }
3938
                        }
3939
                        break;
3940

    
3941
                    case ControlType.ArrowTransTextControl:
3942
                        {
3943
                            if (e.LeftButton == MouseButtonState.Pressed)
3944
                            {
3945
                                if (currentControl is ArrowTextControl)
3946
                                {
3947
                                    //20180906 LJY TEST IsRotationDrawingEnable
3948
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3949
                                    {
3950
                                        return;
3951
                                    }
3952

    
3953
                                    CreateCommand.Instance.Execute(currentControl);
3954

    
3955
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3956

    
3957
                                    currentControl.IsNew = false;
3958
                                    currentControl = null;
3959
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3960
                                }
3961
                                else
3962
                                {
3963
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3964
                                    //{
3965
                                    currentControl = new ArrowTextControl()
3966
                                    {
3967
                                        ControlType = ControlType.ArrowTransTextControl,
3968
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3969
                                    };
3970
                                    currentControl.CommentID = Commons.shortGuid();
3971
                                    currentControl.IsNew = true;
3972
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3973
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3974
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3975
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3976
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3977
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3978
                                    (currentControl as ArrowTextControl).isFixed = true;
3979
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3980

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

    
3984
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3985
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3986
                                    (currentControl as ArrowTextControl).isTrans = true;
3987
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3988
                                }
3989
                            }
3990
                        }
3991
                        break;
3992

    
3993
                    case ControlType.ArrowTextBorderControl:
3994
                        {
3995
                            if (e.LeftButton == MouseButtonState.Pressed)
3996
                            {
3997
                                if (currentControl is ArrowTextControl)
3998
                                {
3999
                                    //20180906 LJY TEST IsRotationDrawingEnable
4000
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4001
                                    {
4002
                                        return;
4003
                                    }
4004

    
4005
                                    CreateCommand.Instance.Execute(currentControl);
4006
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4007
                                    currentControl.IsNew = false;
4008
                                    currentControl = null;
4009
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4010
                                }
4011
                                else
4012
                                {
4013
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4014
                                    //{
4015
                                    currentControl = new ArrowTextControl()
4016
                                    {
4017
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4018
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4019
                                    };
4020
                                    currentControl.CommentID = Commons.shortGuid();
4021
                                    currentControl.IsNew = true;
4022
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4023
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4024

    
4025
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4026

    
4027
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4028

    
4029
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4030
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4031
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4032
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4033
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4034
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4035
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4036
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4037
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4038
                                    //}
4039
                                }
4040
                            }
4041
                        }
4042
                        break;
4043

    
4044
                    case ControlType.ArrowTransTextBorderControl:
4045
                        {
4046
                            if (e.LeftButton == MouseButtonState.Pressed)
4047
                            {
4048
                                if (currentControl is ArrowTextControl)
4049
                                {
4050
                                    //20180906 LJY TEST IsRotationDrawingEnable
4051
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4052
                                    {
4053
                                        return;
4054
                                    }
4055
                                    CreateCommand.Instance.Execute(currentControl);
4056
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4057
                                    currentControl.IsNew = false;
4058
                                    currentControl = null;
4059

    
4060
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4061
                                }
4062
                                else
4063
                                {
4064
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4065
                                    //{
4066
                                    currentControl = new ArrowTextControl()
4067
                                    {
4068
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4069
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4070
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4071
                                    };
4072
                                    
4073
                                    currentControl.CommentID = Commons.shortGuid();
4074
                                    currentControl.IsNew = true;
4075
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4076
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4077

    
4078
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4079

    
4080
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4081
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4082
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4083
                                    (currentControl as ArrowTextControl).isFixed = true;
4084
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4085

    
4086
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4087
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4088
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4089
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4090
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4091
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4092

    
4093
                                    //20180911 LJY
4094
                                    (currentControl as ArrowTextControl).isTrans = true;
4095

    
4096
                                    //}
4097
                                }
4098
                            }
4099
                        }
4100
                        break;
4101

    
4102
                    case ControlType.ArrowTextCloudControl:
4103
                        {
4104
                            if (e.LeftButton == MouseButtonState.Pressed)
4105
                            {
4106
                                if (currentControl is ArrowTextControl)
4107
                                {
4108
                                    //20180906 LJY TEST IsRotationDrawingEnable
4109
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4110
                                    {
4111
                                        return;
4112
                                    }
4113
                                    CreateCommand.Instance.Execute(currentControl);
4114
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4115
                                    currentControl.IsNew = false;
4116
                                    currentControl = null;
4117
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4118
                                }
4119
                                else
4120
                                {
4121
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4122
                                    //{
4123
                                    currentControl = new ArrowTextControl()
4124
                                    {
4125
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4126
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4127
                                    };
4128
                                    currentControl.CommentID = Commons.shortGuid();
4129
                                    currentControl.IsNew = true;
4130
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4131
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4132

    
4133
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4134
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4135
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4136
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4137
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4138
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4139
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4140
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4141

    
4142
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4143
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4144
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4145
                                    //}
4146
                                }
4147
                            }
4148
                        }
4149
                        break;
4150

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

    
4184
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4185
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4186
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4187
                                    (currentControl as ArrowTextControl).isFixed = true;
4188
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4189

    
4190
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4191
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4192
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4193
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4194
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4195
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4196

    
4197
                                    //20180911 LJY
4198
                                    (currentControl as ArrowTextControl).isTrans = true;
4199
                                    //}
4200
                                }
4201
                            }
4202
                        }
4203
                        break;
4204
                    //강인구 추가
4205
                    case ControlType.Sign:
4206
                        {
4207
                            if (e.LeftButton == MouseButtonState.Pressed)
4208
                            {
4209
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4210
                                //{
4211
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4212

    
4213
                                if (_sign == null)
4214
                                {
4215
                                    txtBatch.Visibility = Visibility.Collapsed;
4216
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4217
                                    controlType = ControlType.None;
4218

    
4219
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4220
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4221
                                    return;
4222
                                }
4223

    
4224
                                if (currentControl is SignControl)
4225
                                {
4226
                                    //20180906 LJY TEST IsRotationDrawingEnable
4227
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4228
                                    {
4229
                                        return;
4230
                                    }
4231

    
4232
                                    CreateCommand.Instance.Execute(currentControl);
4233
                                    currentControl = null;
4234
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4235
                                    {
4236
                                        txtBatch.Text = "Place Date";
4237
                                        controlType = ControlType.Date;
4238
                                    }
4239
                                }
4240
                                else
4241
                                {
4242
                                    currentControl = new SignControl
4243
                                    {
4244
                                        Background = new SolidColorBrush(Colors.Black),
4245
                                        UserNumber = App.ViewInfo.UserID,
4246
                                        ProjectNO = App.ViewInfo.ProjectNO,
4247
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4248
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4249
                                        ControlType = ControlType.Sign
4250
                                    };
4251

    
4252
                                    currentControl.CommentID = Commons.shortGuid();
4253
                                    currentControl.IsNew = true;
4254
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4255
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4256

    
4257
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4258
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4259
                                }
4260
                                //}
4261
                            }
4262
                        }
4263
                        break;
4264

    
4265
                    case ControlType.Mark:
4266
                        {
4267
                            if (e.LeftButton == MouseButtonState.Pressed)
4268
                            {
4269
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4270
                                //{
4271
                                if (currentControl is RectangleControl)
4272
                                {
4273
                                    //20180906 LJY TEST IsRotationDrawingEnable
4274
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4275
                                    {
4276
                                        return;
4277
                                    }
4278

    
4279
                                    CreateCommand.Instance.Execute(currentControl);
4280
                                    (currentControl as RectangleControl).ApplyOverViewData();
4281
                                    currentControl = null;
4282

    
4283
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4284

    
4285
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4286
                                    {
4287
                                        txtBatch.Text = "Place Signature";
4288
                                        controlType = ControlType.Sign;
4289
                                    }
4290
                                }
4291
                                else
4292
                                {
4293
                                    currentControl = new RectangleControl
4294
                                    {
4295
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4296
                                        Background = new SolidColorBrush(Colors.Black),
4297
                                        ControlType = ControlType.Mark,
4298
                                        Paint = PaintSet.Fill
4299
                                    };
4300

    
4301
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4302
                                    currentControl.CommentID = Commons.shortGuid();
4303
                                    currentControl.IsNew = true;
4304
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4305
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4306
                                }
4307
                                //}
4308
                            }
4309
                        }
4310
                        break;
4311

    
4312
                    case ControlType.Symbol:
4313
                        {
4314
                            if (e.LeftButton == MouseButtonState.Pressed)
4315
                            {
4316
                                if (currentControl is SymControl)
4317
                                {
4318
                                    //20180906 LJY TEST IsRotationDrawingEnable
4319
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4320
                                    {
4321
                                        return;
4322
                                    }
4323
                                    CreateCommand.Instance.Execute(currentControl);
4324
                                    currentControl = null;
4325

    
4326
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4327
                                }
4328
                                else
4329
                                {
4330
                                    currentControl = new SymControl
4331
                                    {
4332
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4333
                                        Background = new SolidColorBrush(Colors.Black),
4334
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4335
                                        ControlType = ControlType.Symbol
4336
                                    };
4337

    
4338
                                    currentControl.IsNew = true;
4339
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4340
                                    currentControl.CommentID = Commons.shortGuid();
4341
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4342

    
4343
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4344
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4345
                                }
4346
                                //}
4347
                            }
4348
                        }
4349
                        break;
4350

    
4351
                    case ControlType.Stamp:
4352
                        {
4353
                            if (e.LeftButton == MouseButtonState.Pressed)
4354
                            {
4355
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4356
                                //{
4357
                                if (currentControl is SymControlN)
4358
                                {
4359
                                    //20180906 LJY TEST IsRotationDrawingEnable
4360
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4361
                                    {
4362
                                        return;
4363
                                    }
4364

    
4365
                                    CreateCommand.Instance.Execute(currentControl);
4366
                                    currentControl = null;
4367

    
4368
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4369
                                }
4370
                                else
4371
                                {
4372
                                    currentControl = new SymControlN
4373
                                    {
4374
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4375
                                        Background = new SolidColorBrush(Colors.Black),
4376
                                        STAMP = App.SystemInfo.STAMP,
4377
                                        ControlType = ControlType.Stamp
4378
                                    };
4379

    
4380
                                    currentControl.IsNew = true;
4381
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4382
                                    currentControl.CommentID = Commons.shortGuid();
4383
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4384
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4385
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4386
                                }
4387
                                //}
4388
                            }
4389
                        }
4390
                        break;
4391

    
4392
                    case ControlType.PenControl:
4393
                        {
4394
                            if (inkBoard.Tag.ToString() == "Ink")
4395
                            {
4396
                                inkBoard.IsEnabled = true;
4397
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4398
                            }
4399
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4400
                            {
4401
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4402
                            }
4403
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4404
                            {
4405
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4406
                            }
4407
                            IsDrawing = true;
4408
                            return;
4409
                        }
4410
                    default:
4411
                        if (currentControl != null)
4412
                        {
4413
                            currentControl.CommentID = null;
4414
                            currentControl.IsNew = false;
4415
                        }
4416
                        break;
4417
                }
4418

    
4419
             
4420
                if (currentControl is ArrowTextControl)
4421
                {
4422
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4423
                    {
4424
                        var control = snd as ArrowTextControl;
4425

    
4426
                        if (string.IsNullOrEmpty(control.ArrowText))
4427
                        {
4428
                            DeleteCommand.Instance.Execute(new [] { control });
4429
                        }
4430
                    };
4431

    
4432
                }
4433

    
4434
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4435
                {
4436
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4437
                    {
4438
                        MacroHelper.MacroAction();
4439
                    }
4440
                    //if (currentControl.ControlType)
4441
                    //txtBatch.Text = "Draw a TextBox";
4442
                    //controlType = ControlType.ArrowTextBorderControl;
4443
                }
4444

    
4445
                //if (currentControl != null)
4446
                //{
4447
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4448
                //}
4449
            }
4450
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4451
            {
4452
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4453
             
4454

    
4455
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4456
                {
4457
                    bool mouseOff = false;
4458
                    foreach (var item in SelectLayer.Children)
4459
                    {
4460
                        if (item is AdornerFinal)
4461
                        {
4462
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4463
                            if (over != null)
4464
                            {
4465
                                mouseOff = true;
4466
                            }
4467
                        }
4468
                    }
4469

    
4470
                    if (!mouseOff)
4471
                    {
4472
                        SelectionSet.Instance.UnSelect(this);
4473
                    }
4474
                }
4475
                zoomAndPanControl.CaptureMouse();
4476
                e.Handled = true;
4477
            }
4478
        }
4479

    
4480
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4481
        {
4482
            ///mouseButtonDown = e.ChangedButton;
4483
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4484
        }
4485

    
4486
        private void RemoveLineStroke(Point P)
4487
        {
4488
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4489
            if (control != null)
4490
            {
4491
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4492
            }
4493
        }
4494

    
4495
        private void RemovePointStroke(Point P)
4496
        {
4497
            foreach (Stroke hits in inkBoard.Strokes)
4498
            {
4499
                foreach (StylusPoint sty in hits.StylusPoints)
4500
                {
4501
                }
4502
                if (hits.HitTest(P))
4503
                {
4504
                    inkBoard.Strokes.Remove(hits);
4505
                    return;
4506
                }
4507
            }
4508
        }
4509

    
4510
        private void StartNewStroke(Point P)
4511
        {
4512
            strokePoints = new StylusPointCollection();
4513
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4514
            strokePoints.Add(segment1Start);
4515
            stroke = new Stroke(strokePoints);
4516

    
4517
            stroke.DrawingAttributes.Color = Colors.Red;
4518
            stroke.DrawingAttributes.Width = 4;
4519
            stroke.DrawingAttributes.Height = 4;
4520

    
4521
            inkBoard.Strokes.Add(stroke);
4522
        }
4523

    
4524
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4525
        {
4526
            ConsolidationMethod();
4527
        }
4528

    
4529
        /// <summary>
4530
        /// execute TeamConsolidationCommand
4531
        /// </summary>
4532
        public void TeamConsolidationMethod()
4533
        {
4534
            this.UpdateMyMarkupList();
4535
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4536
            {
4537
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4538
            }
4539
            else
4540
            {
4541
                ViewerDataModel.Instance.IsConsolidate = true;
4542
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4543

    
4544
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4545
                {
4546
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4547
                    {
4548
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4549
                        return;
4550
                    }
4551
                }
4552
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4553
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4554
                {
4555
                    MarkupInfoList.Add(item);
4556
                }
4557
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4558
            }
4559
        }
4560

    
4561
        public void ConsolidationMethod()
4562
        {
4563
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4564
            {
4565
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4566
            }
4567
            else
4568
            {
4569
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4570
                foreach (var item in this.gridViewMarkup.SelectedItems)
4571
                {
4572
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4573
                }
4574
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4575

    
4576
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4577
            }
4578
        }
4579

    
4580
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4581
        {
4582
            if (App.ViewInfo != null)
4583
            {
4584
                btnConsolidate = (sender as RadRibbonButton);
4585
                if (!App.ViewInfo.NewCommentPermission)
4586
                {
4587
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4588
                }
4589
            }
4590
        }
4591

    
4592
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4593
        {
4594
            TeamConsolidationMethod();
4595
        }
4596

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

    
4609
                    if (!App.ViewInfo.NewCommentPermission)
4610
                    {
4611
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4612
                    }
4613
                }
4614
                else
4615
                {
4616
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4617
                }
4618
            }
4619
        }
4620

    
4621
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4622
        {
4623
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4624
            if (item != null)
4625
            {
4626
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4627
                {
4628
                    //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4629
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4630
                }
4631
                else
4632
                {
4633
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4634
                }
4635
            }
4636
            else
4637
            {
4638
                //Consolidate 가 없는 경우
4639
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4640
            }
4641
        }
4642

    
4643
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4644
        {
4645
            btnFinalPDF = sender as RadRibbonButton;
4646
            if (App.ViewInfo != null)
4647
            {
4648
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4649
                {
4650
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4651
                    if (btnConsolidate != null)
4652
                    {
4653
                        btnConsolidate.Visibility = Visibility.Collapsed;
4654
                    }
4655
                }
4656
            }
4657
        }
4658

    
4659
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4660
        {
4661
            UpdateMyMarkupList();
4662

    
4663
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4664
            {
4665
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4666
            }
4667
            else
4668
            {
4669
                ViewerDataModel.Instance.IsConsolidate = true;
4670
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4671
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4672

    
4673
                string project_no = App.ViewInfo.ProjectNO;
4674
                string doc_id = _DocInfo.ID;
4675
                string user_id = App.ViewInfo.UserID;
4676
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4677
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4678
                {
4679
                    markupInfoItems.Add(item);
4680
                }
4681
                //Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4682
                //Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4683
                //Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4684

    
4685
                this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems);
4686

    
4687
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4688

    
4689
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4690
                if (item2 != null)
4691
                {
4692
                    //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4693

    
4694
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4695
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4696
                }
4697
                else
4698
                {
4699
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4700
                }
4701
            }
4702
        }
4703

    
4704
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4705
        {
4706
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4707
#if Hyosung
4708
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4709
#else
4710
            if (App.ViewInfo != null)
4711
            {
4712
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4713
                {
4714
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4715
                }
4716
            }
4717
#endif
4718
        }
4719

    
4720
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4721
        {
4722
            SetCompareRect();
4723
        }
4724

    
4725
        private void Sync_Click(object sender, RoutedEventArgs e)
4726
        {
4727
            if (Sync.IsChecked)
4728
            {
4729
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4730
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4731
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4732
            }
4733
        }
4734

    
4735
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4736
        {
4737
            if (UserList.IsChecked)
4738
            {
4739
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4740
            }
4741
            else
4742
            {
4743
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4744
            }
4745
        }
4746

    
4747
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4748
        {
4749
            if (BalanceMode.IsChecked)
4750
            {
4751
                ViewerDataModel.Instance.PageBalanceMode = true;
4752
            }
4753
            else
4754
            {
4755
                ViewerDataModel.Instance.PageBalanceMode = false;
4756
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4757
            }
4758
        }
4759

    
4760
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4761
        {
4762
            //초기화
4763
            testPanel2.IsHidden = true;
4764
            ViewerDataModel.Instance.PageBalanceMode = false;
4765
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4766
            ViewerDataModel.Instance.PageNumber = 0;
4767
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4768
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4769
            UserList.IsChecked = false;
4770
            BalanceMode.IsChecked = false;
4771
        }
4772

    
4773
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4774
        {
4775
            if ((sender as System.Windows.Controls.Control).Tag != null)
4776
            {
4777
                //Compare 초기화
4778
                CompareMode.IsChecked = false;
4779
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4780

    
4781
                if (ViewerDataModel.Instance.PageNumber == 0)
4782
                {
4783
                    ViewerDataModel.Instance.PageNumber = 1;
4784
                }
4785

    
4786
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4787
                {
4788
                }
4789
                else
4790
                {
4791
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4792
                }
4793

    
4794
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4795
                {
4796
                }
4797
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4798
                {
4799
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4800
                }
4801

    
4802
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4803

    
4804
                if (!testPanel2.IsHidden)
4805
                {
4806
                    if (IsSyncPDFMode)
4807
                    {
4808
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4809
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4810

    
4811
                        if (pdfpath.IsDownloading)
4812
                        {
4813
                            pdfpath.DownloadCompleted += (ex, arg) =>
4814
                            {
4815
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4816
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4817
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4818
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4819
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4820
                            };
4821
                        }
4822
                        else
4823
                        {
4824
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4825
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4826
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4827

    
4828
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4829
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4830
                        }
4831
                    }
4832
                    else
4833
                    {
4834
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4835

    
4836
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4837

    
4838
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4839
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4840
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4841

    
4842
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4843
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4844

    
4845
                        if (defaultBitmapImage_Compare.IsDownloading)
4846
                        {
4847
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4848
                            {
4849
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4850
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4851
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4852

    
4853
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4854
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4855
                            };
4856
                        }
4857
                    }
4858
                   
4859
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4860
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4861
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4862

    
4863
                    foreach (var item in gridSelectionRevItem)
4864
                    {
4865
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4866
                        foreach (var markupitem in markupitems)
4867
                        {
4868
                            await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
4869
                        }
4870
                    }
4871

    
4872
                    //강인구 추가
4873
                    zoomAndPanControl2.ZoomTo(new Rect
4874
                    {
4875
                        X = 0,
4876
                        Y = 0,
4877
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4878
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4879
                    });
4880

    
4881
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4882
                }
4883
            }
4884
        }
4885

    
4886
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
4887
        {
4888
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
4889

    
4890
            double translateX = 0;
4891
            double translateY = 0;
4892
            double angle = rotate2.Angle;
4893

    
4894
            if (direction == 1)
4895
            {
4896
                if (angle < 270)
4897
                {
4898
                    angle += 90;
4899
                }
4900
                else
4901
                {
4902
                    angle = 0;
4903
                }
4904
            }
4905
            else
4906
            {
4907
                if (angle > 0)
4908
                {
4909
                    angle -= 90;
4910
                }
4911
                else
4912
                {
4913
                    angle = 270;
4914
                }
4915
            }
4916
            zoomAndPanControl2.RotationAngle = angle;
4917
            zoomAndPanControl2.ScaleToFit();
4918

    
4919
            //if (angle == 90 || angle == 270)
4920
            //{
4921
                double emptySize = zoomAndPanCanvas2.Width;
4922
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
4923
                zoomAndPanCanvas2.Height = emptySize;
4924
            //}
4925

    
4926
            if (angle == 90)
4927
            {
4928
                translateX = zoomAndPanCanvas2.Width;
4929
                translateY = 0;
4930
            }
4931
            else if (angle == 180)
4932
            {
4933
                translateX = zoomAndPanCanvas2.Width;
4934
                translateY = zoomAndPanCanvas2.Height;
4935
            }
4936
            else if (angle == 270)
4937
            {
4938
                translateX = 0;
4939
                translateY = zoomAndPanCanvas2.Height;
4940
            }
4941
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
4942
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
4943
            translate2.X = translateX;
4944
            translate2.Y = translateY;
4945
            rotate2.Angle = angle;
4946
            //translate2CompareBorder.X = translateX;
4947
            //translate2CompareBorder.Y = translateY;
4948
            //rotate2CompareBorder.Angle = angle;
4949

    
4950
        }
4951

    
4952
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4953
        {
4954
            if (MarkupMode.IsChecked)
4955
            {
4956
                IsSyncPDFMode = true;
4957

    
4958
                var uri = CurrentRev.TO_VENDOR;
4959

    
4960
                if (ViewerDataModel.Instance.PageNumber == 0)
4961
                {
4962
                    ViewerDataModel.Instance.PageNumber = 1;
4963
                }
4964

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

    
4969
                if (pdfpath.IsDownloading)
4970
                {
4971
                    pdfpath.DownloadCompleted += (ex, arg) =>
4972
                    {
4973
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4974
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4975
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4976
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4977
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4978
                    };
4979
                }
4980
                else
4981
                {
4982
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4983
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4984
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4985

    
4986
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4987
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4988
                }
4989
            }
4990
            else
4991
            {
4992
                IsSyncPDFMode = false;
4993
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4994

    
4995
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4996

    
4997
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4998
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4999
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5000

    
5001
                if (defaultBitmapImage_Compare.IsDownloading)
5002
                {
5003
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5004
                    {
5005
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5006
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5007
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5008
                    };
5009
                }
5010
                zoomAndPanControl2.ApplyTemplate();
5011
                zoomAndPanControl2.UpdateLayout();
5012
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5013
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5014
            }
5015
        }
5016

    
5017
        /// <summary>
5018
        /// Compare된 영역을 초기화
5019
        /// </summary>
5020
        private void ClearCompareRect()
5021
        {
5022
            da.From = 1;
5023
            da.To = 1;
5024
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5025
            da.AutoReverse = false;
5026
            canvas_compareBorder.Children.Clear();
5027
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5028
        }
5029

    
5030
        /// <summary>
5031
        /// 문서 Comprare
5032
        /// </summary>
5033
        private void SetCompareRect()
5034
        {
5035
            canvas_compareBorder.Children.Clear();
5036

    
5037
            if (CompareMode.IsChecked)
5038
            {
5039
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5040
                {
5041
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5042
                }
5043
                if (ViewerDataModel.Instance.PageNumber == 0)
5044
                {
5045
                    ViewerDataModel.Instance.PageNumber = 1;
5046
                }
5047

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

    
5050
                /// 비교대상원본, 비교할 대상
5051
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO,  CurrentRev.DOCUMENT_ID, _ViewInfo.DocumentItemID,  ViewerDataModel.Instance.PageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5052
            }
5053
            else
5054
            {
5055
                canvas_compareBorder.Visibility = Visibility.Hidden;
5056
                ClearCompareRect();
5057
            }
5058
        }
5059

    
5060
        private void RadButton_Click(object sender, RoutedEventArgs e)
5061
        {
5062
            gridViewHistory_Busy.IsBusy = true;
5063

    
5064
            RadButton instance = sender as RadButton;
5065
            if (instance.CommandParameter != null)
5066
            {
5067
                CurrentRev = instance.CommandParameter as VPRevision;
5068
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5069

    
5070
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5071
                {
5072
                    if (ea.Error == null && ea.Result != null)
5073
                    {
5074
                        testPanel2.IsHidden = false;
5075

    
5076
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5077
                        foreach (var info in ea.Result)
5078
                        {
5079
                            if (info.UserID == App.ViewInfo.UserID)
5080
                            {
5081
                                info.userDelete = true;
5082
                                info.DisplayColor = "#FFFF0000";
5083
                            }
5084
                            else
5085
                            {
5086
                                info.userDelete = false;
5087
                            }
5088
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5089
                        }
5090
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5091

    
5092
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5093

    
5094
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5095

    
5096
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
5097
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5098
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5099
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5100
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
5101
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
5102

    
5103
                        zoomAndPanControl2.ApplyTemplate();
5104
                        zoomAndPanControl2.UpdateLayout();
5105

    
5106
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5107
                        {
5108
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5109
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5110
                        }
5111

    
5112
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5113
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5114
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5115

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

    
5119
                        zoomAndPanControl.ScaleToFit();
5120
                        zoomAndPanControl2.ScaleToFit();
5121

    
5122
                        gridViewHistory_Busy.IsBusy = false;
5123
                    }
5124

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

    
5127
                    if (GetSyncMarkupInfoItemshandler != null)
5128
                    {
5129
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5130
                    }
5131

    
5132
                    //ClearCompareRect();
5133
                    SetCompareRect();
5134
                };
5135

    
5136
                /// 중복 실행이 발생하여 수정함.
5137
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5138
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5139

    
5140
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5141
            }
5142
        }
5143

    
5144
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5145
        {
5146
            try
5147
            {
5148
                if (sender is RadButton)
5149
                {
5150
                    if ((sender as RadButton).Tag != null)
5151
                    {
5152
                        var url = (sender as RadButton).Tag.ToString();
5153
                        System.Diagnostics.Process.Start(url);
5154
                    }
5155
                    else
5156
                    {
5157
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5158
                    }
5159
                }
5160
            }
5161
            catch (Exception ex)
5162
            {
5163
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5164
            }
5165
        }
5166

    
5167
        public void Sync_Event(VPRevision Currnet_Rev)
5168
        {
5169
            CurrentRev = Currnet_Rev;
5170

    
5171
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5172
            {
5173
                if (ea.Error == null && ea.Result != null)
5174
                {
5175
                    testPanel2.IsHidden = false;
5176

    
5177
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5178
                    foreach (var info in ea.Result)
5179
                    {
5180
                        if (info.UserID == App.ViewInfo.UserID)
5181
                        {
5182
                            info.userDelete = true;
5183
                            info.DisplayColor = "FFFF0000";
5184
                        }
5185
                        else
5186
                        {
5187
                            info.userDelete = false;
5188
                        }
5189
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5190
                    }
5191
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5192

    
5193
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5194

    
5195
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5196

    
5197
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5198

    
5199
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5200
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5201
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5202

    
5203
                    if (defaultBitmapImage_Compare.IsDownloading)
5204
                    {
5205
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5206
                        {
5207
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5208
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5209
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5210
                        };
5211
                    }
5212

    
5213
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5214
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5215
                    zoomAndPanControl2.ApplyTemplate();
5216
                    zoomAndPanControl2.UpdateLayout();
5217

    
5218
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5219
                    {
5220
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5221
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5222
                    }
5223
                    //}
5224

    
5225
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5226
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5227
                    gridViewHistory_Busy.IsBusy = false;
5228
                }
5229
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5230
            };
5231
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5232
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5233
        }
5234

    
5235
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5236
        {
5237
            if (sender is Image)
5238
            {
5239
                if ((sender as Image).Tag != null)
5240
                {
5241
                    var pdfUrl = (sender as Image).Tag.ToString();
5242
                    System.Diagnostics.Process.Start(pdfUrl);
5243
                }
5244
                else
5245
                {
5246
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5247
                }
5248
            }
5249
        }
5250

    
5251
        private void Create_Symbol(object sender, RoutedEventArgs e)
5252
        {
5253
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5254

    
5255
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5256
            {
5257
                DialogMessage_Alert("Please Select Controls", "Alert");
5258
            }
5259
            else //선택된 것이 있으면
5260
            {
5261
                string MarkupData = "";
5262
                adorner_ = new AdornerFinal();
5263

    
5264
                foreach (var item in SelectLayer.Children)
5265
                {
5266
                    if (item.GetType().Name == "AdornerFinal")
5267
                    {
5268
                        adorner_ = (item as Controls.AdornerFinal);
5269
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5270
                        {
5271
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5272
                            {
5273
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5274
                                MarkupData += markupReturn.ConvertData;
5275
                            }
5276
                        }
5277
                    }
5278
                }
5279
                DialogParameters parameters = new DialogParameters()
5280
                {
5281
                    Owner = Application.Current.MainWindow,
5282
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5283
                    DefaultPromptResultValue = "Custom State",
5284
                    Content = "Name :",
5285
                    Header = "Insert Custom Symbol Name",
5286
                    Theme = new VisualStudio2013Theme(),
5287
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5288
                };
5289
                RadWindow.Prompt(parameters);
5290
            }
5291
        }
5292

    
5293
        public int symbolselectindex = 0;
5294

    
5295
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5296
        {
5297
            //Save save = new Save();
5298
            try
5299
            {
5300
                string svgfilename = null;
5301
                if (symbolname != null)
5302
                {
5303
                    if (symbolpng == true || symbolsvg == true)
5304
                    {
5305
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5306
                        string guid = Commons.shortGuid();
5307

    
5308
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5309
                        //Check_Uri.UriCheck();
5310
                        fileUploader.RunCompleted += (ex, arg) =>
5311
                        {
5312
                            filename = arg.Result;
5313
                            if (symbolpng == true)
5314
                            {
5315
                                if (filename != null)
5316
                                {
5317
                                    if (symbolselectindex == 0)
5318
                                    {
5319
                                        SymbolSave(symbolname, filename, data);
5320
                                    }
5321
                                    else
5322
                                    {
5323
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5324
                                    }
5325
                                    DataBind();
5326
                                }
5327
                            }
5328

    
5329
                            if (symbolsvg == true)
5330
                            {
5331
                                try
5332
                                {
5333
                                    var defaultBitmapImage = new BitmapImage();
5334
                                    defaultBitmapImage.BeginInit();
5335
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5336
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5337
                                    Check_Uri.UriCheck(filename);
5338
                                    defaultBitmapImage.UriSource = new Uri(filename);
5339
                                    defaultBitmapImage.EndInit();
5340

    
5341
                                    System.Drawing.Bitmap image;
5342

    
5343
                                    if (defaultBitmapImage.IsDownloading)
5344
                                    {
5345
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5346
                                        {
5347
                                            defaultBitmapImage.Freeze();
5348
                                            image = GetBitmap(defaultBitmapImage);
5349
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5350
                                            Process potrace = new Process
5351
                                            {
5352
                                                StartInfo = new ProcessStartInfo
5353
                                                {
5354
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5355
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5356
                                                    RedirectStandardInput = true,
5357
                                                    RedirectStandardOutput = true,
5358
                                                    RedirectStandardError = true,
5359
                                                    UseShellExecute = false,
5360
                                                    CreateNoWindow = true,
5361
                                                    WindowStyle = ProcessWindowStyle.Hidden
5362
                                                },
5363
                                            };
5364

    
5365
                                            StringBuilder svgBuilder = new StringBuilder();
5366
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5367
                                            {
5368
                                                svgBuilder.AppendLine(e2.Data);
5369
                                            };
5370

    
5371
                                            potrace.EnableRaisingEvents = true;
5372
                                            potrace.Start();
5373
                                            potrace.Exited += (sender, e) =>
5374
                                            {
5375
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5376
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5377
                                                Check_Uri.UriCheck(svgfilename);
5378
                                                if (symbolselectindex == 0)
5379
                                                {
5380
                                                    SymbolSave(symbolname, svgfilename, data);
5381
                                                }
5382
                                                else
5383
                                                {
5384
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5385
                                                }
5386

    
5387
                                                DataBind();
5388
                                            };
5389
                                            potrace.WaitForExit();
5390
                                        };
5391
                                    }
5392
                                    else
5393
                                    {
5394
                                        //GC.Collect();
5395
                                    }
5396
                                }
5397
                                catch (Exception ee)
5398
                                {
5399
                                    DialogMessage_Alert("" + ee, "Alert");
5400
                                }
5401
                            }
5402
                        };
5403
                    }
5404
                }
5405
            }
5406
            catch (Exception e)
5407
            {
5408
                //DialogMessage_Alert(e + "", "Alert");
5409
            }
5410
        }
5411

    
5412
        public void SymbolSave(string Name, string Url, string Data)
5413
        {
5414
            try
5415
            {
5416
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5417
                {
5418
                    ID = Commons.shortGuid(),
5419
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5420
                    NAME = Name,
5421
                    IMAGE_URL = Url,
5422
                    DATA = Data
5423
                };
5424

    
5425
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5426
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5427
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5428
            }
5429
            catch (Exception)
5430
            {
5431
                throw;
5432
            }
5433
        }
5434

    
5435
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5436
        {
5437
            try
5438
            {
5439
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5440
                {
5441
                    ID = Commons.shortGuid(),
5442
                    DEPARTMENT = Department,
5443
                    NAME = Name,
5444
                    IMAGE_URL = Url,
5445
                    DATA = Data
5446
                };
5447
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5448
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5449
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5450
            }
5451
            catch (Exception)
5452
            {
5453
                throw;
5454
            }
5455
        }
5456

    
5457
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5458
        {
5459
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5460
            DataBind();
5461
        }
5462

    
5463
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5464
        {
5465
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5466
            DataBind();
5467
        }
5468

    
5469
        private void DataBind()
5470
        {
5471
            try
5472
            {
5473
                Symbol_Custom Custom = new Symbol_Custom();
5474
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5475

    
5476
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5477
                foreach (var item in symbol_Private)
5478
                {
5479
                    Custom.Name = item.NAME;
5480
                    Custom.ImageUri = item.IMAGE_URL;
5481
                    Custom.ID = item.ID;
5482
                    Custom_List.Add(Custom);
5483
                    Custom = new Symbol_Custom();
5484
                }
5485
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5486

    
5487
                Custom = new Symbol_Custom();
5488
                Custom_List = new List<Symbol_Custom>();
5489

    
5490
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5491

    
5492
                List<SYMBOL_PUBLIC> symbol_Public;
5493

    
5494
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5495
                {
5496
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5497
                }
5498
                else
5499
                {
5500
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5501
                }
5502
                foreach (var item in symbol_Public)
5503
                {
5504
                    Custom.Name = item.NAME;
5505
                    Custom.ImageUri = item.IMAGE_URL;
5506
                    Custom.ID = item.ID;
5507
                    Custom_List.Add(Custom);
5508
                    Custom = new Symbol_Custom();
5509
                }
5510
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5511
                BaseClient.Close();
5512
            }
5513
            catch (Exception e)
5514
            {
5515
                //DialogMessage_Alert("DataBind", "Alert");
5516
            }
5517
        }
5518

    
5519
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5520
        {
5521
            try
5522
            {
5523
                if (args.PromptResult != null)
5524
                {
5525
                    if (args.DialogResult.Value)
5526
                    {
5527
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5528

    
5529
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5530
                        _Encoder.Save(fs);
5531
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5532

    
5533
                        byte[] Img_byte = fs.ToArray();
5534

    
5535
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5536
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5537
                        Check_Uri.UriCheck(filename);
5538
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5539
                        {
5540
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5541
                        }
5542
                        else
5543
                        {
5544
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5545
                        }
5546
                        DataBind();
5547
                    }
5548
                }
5549
            }
5550
            catch (Exception ex)
5551
            {
5552
                DialogMessage_Alert("" + ex, "Alert");
5553
            }
5554
        }
5555

    
5556
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5557
        {
5558
            Canvas _canvas = new Canvas();
5559
            _canvas.Background = Brushes.White;
5560
            _canvas.Width = adorner_.BorderSize.Width;
5561
            _canvas.Height = adorner_.BorderSize.Height;
5562
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5563

    
5564
            BitmapEncoder encoder = new PngBitmapEncoder();
5565

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

    
5568
            DrawingVisual dv = new DrawingVisual();
5569

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

    
5573
            using (DrawingContext ctx = dv.RenderOpen())
5574
            {
5575
                VisualBrush vb = new VisualBrush(_canvas);
5576
                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)));
5577
            }
5578

    
5579
            try
5580
            {
5581
                renderBitmap.Render(dv);
5582

    
5583
                GC.Collect(2);
5584
                GC.WaitForPendingFinalizers();
5585
                //GC.Collect();
5586
                // encode png data
5587
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5588
                // puch rendered bitmap into it
5589
                pngEncoder.Interlace = PngInterlaceOption.Off;
5590
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5591
                return pngEncoder;
5592
            }
5593
            catch //(Exception ex)
5594
            {
5595
                return null;
5596
            }
5597
        }
5598

    
5599
        public void DialogMessage_Alert(string content, string header)
5600
        {
5601
            App.splashScreen.Close();
5602

    
5603
            DialogParameters parameters = new DialogParameters()
5604
            {
5605
                Owner = this.ParentOfType<MainWindow>(),
5606
                Content = new TextBlock()
5607
                {
5608
                    MinWidth = 400,
5609
                    FontSize = 11,
5610
                    Text = content,
5611
                    TextWrapping = System.Windows.TextWrapping.Wrap
5612
                },
5613
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5614
                Header = header,
5615
                Theme = new VisualStudio2013Theme(),
5616
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5617
            };
5618
            RadWindow.Alert(parameters);
5619
        }
5620

    
5621
        #region 캡쳐 기능
5622

    
5623
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5624
        {
5625
            if (x < 0)
5626
            {
5627
                width += x;
5628
                x = 0;
5629
            }
5630
            if (y < 0)
5631
            {
5632
                height += y;
5633
                y = 0;
5634

    
5635
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5636
            }
5637
            if (x + width > zoomAndPanCanvas.ActualWidth)
5638
            {
5639
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5640
            }
5641
            if (y + height > zoomAndPanCanvas.ActualHeight)
5642
            {
5643
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5644
            }
5645

    
5646
            byte[] pixels = CopyPixels(x, y, width, height);
5647

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

    
5650
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5651
        }
5652

    
5653
        public byte[] CopyPixels(int x, int y, int width, int height)
5654
        {
5655
            byte[] pixels = new byte[width * height * 4];
5656
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5657

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

    
5661
            return pixels;
5662
        }
5663

    
5664
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5665
        {
5666
            DrawingVisual drawingVisual = new DrawingVisual();
5667
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5668

    
5669
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5670
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5671
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5672
            drawingContext.Close();
5673

    
5674
            // 비트맵으로 변환합니다.
5675
            RenderTargetBitmap target =
5676
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5677
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5678

    
5679
            target.Render(drawingVisual);
5680
            return target;
5681
        }
5682

    
5683
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5684
        {
5685
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5686
            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);
5687
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5688
            bmp.UnlockBits(data);
5689
            return bmp;
5690
        }
5691

    
5692
        public string symbolname = null;
5693
        public bool symbolsvg = true;
5694
        public bool symbolpng = true;
5695

    
5696
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5697
        {
5698
            System.Drawing.Bitmap image = GetBitmap(source);
5699
            //흰색 제거
5700
            //image.MakeTransparent(System.Drawing.Color.White);
5701

    
5702
            var imageStream = new System.IO.MemoryStream();
5703
            byte[] imageBytes = null;
5704
            using (imageStream)
5705
            {
5706
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5707
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5708
                imageStream.Position = 0;
5709
                imageBytes = imageStream.ToArray();
5710
            }
5711

    
5712
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5713

    
5714
            RadWindow CheckPop = new RadWindow();
5715
            //Alert check = new Alert(Msg);
5716

    
5717
            CheckPop = new RadWindow
5718
            {
5719
                MinWidth = 400,
5720
                MinHeight = 100,
5721
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5722
                Header = "Alert",
5723
                Content = symbolPrompt,
5724
                //DialogResult =
5725
                ResizeMode = System.Windows.ResizeMode.NoResize,
5726
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5727
                IsTopmost = true,
5728
            };
5729
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5730
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5731
            CheckPop.ShowDialog();
5732

    
5733
            /*
5734
            DialogParameters parameters = new DialogParameters()
5735
            {
5736
                Owner = Application.Current.MainWindow,
5737
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5738
                DefaultPromptResultValue = "Custom State",
5739
                Content = "Name :",
5740
                Header = "Insert Custom Symbol Name",
5741
                Theme = new VisualStudio2013Theme(),
5742
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5743
            };
5744
            RadWindow.Prompt(parameters);
5745
            */
5746
        }
5747

    
5748
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5749
        {
5750
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5751
            KCOMDataModel.DataModel.CHECK_LIST check_;
5752
            string Result = streamToBase64.ImageToBase64(source);
5753
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5754
            string projectno = App.ViewInfo.ProjectNO;
5755
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5756

    
5757
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5758
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5759
            if (Item != null)
5760
            {
5761
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5762
            }
5763
            else
5764
            {
5765
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5766
            }
5767

    
5768
            if (Item == null)
5769
            {
5770
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5771
                {
5772
                    ID = Commons.shortGuid(),
5773
                    USER_ID = App.ViewInfo.UserID,
5774
                    IMAGE_URL = Result,
5775
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5776
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5777
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5778
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5779
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5780
                    STATUS = "False",
5781
                    CREATE_TIME = DateTime.Now,
5782
                    UPDATE_TIME = DateTime.Now,
5783
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5784
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5785
                };
5786
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5787
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5788
                this.BaseClient.AddCheckList(projectno, check_);
5789
            }
5790
            else
5791
            {
5792
                Item.IMAGE_URL = Result;
5793
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5794
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5795
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5796
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5797
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5798
            }
5799
        }
5800

    
5801
        public void Set_Capture()
5802
        {
5803
            double x = CanvasDrawingMouseDownPoint.X;
5804
            double y = CanvasDrawingMouseDownPoint.Y;
5805
            double width = dragCaptureBorder.Width;
5806
            double height = dragCaptureBorder.Height;
5807

    
5808
            if (width > 5 || height > 5)
5809
            {
5810
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5811
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5812
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5813
            }
5814
        }
5815

    
5816
        #endregion 캡쳐 기능
5817

    
5818
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5819
        {
5820
            multi_Undo_Data = new Multi_Undo_data();
5821

    
5822
            multi_Undo_Data.Markup = control;
5823

    
5824
            if ((control as IShapeControl) != null)
5825
            {
5826
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5827
            }
5828
            if ((control as IDashControl) != null)
5829
            {
5830
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5831
            }
5832
            if ((control as IPath) != null)
5833
            {
5834
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5835
            }
5836
            if ((control as UIElement) != null)
5837
            {
5838
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5839
            }
5840

    
5841
            return multi_Undo_Data;
5842
        }
5843

    
5844
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5845
        {
5846
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
5847
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5848
            {
5849
                if (items.MarkupInfoID == Select_ID)
5850
                {
5851
                    foreach (var item in items.MarkupList)
5852
                    {
5853
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5854
                        {
5855
                            await MarkupParser.ParseExAsync(ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
5856
                                 items.MarkupInfoID, Commons.shortGuid());
5857
                        }
5858
                    }
5859
                }
5860
            }
5861
        }
5862

    
5863
        /// <summary>
5864
        /// convert inkcontrol to polygoncontrol
5865
        /// </summary>
5866
        public void ConvertInkControlToPolygon()
5867
        {
5868
            if (inkBoard.Strokes.Count > 0)
5869
            {
5870
                inkBoard.Strokes.ToList().ForEach(stroke =>
5871
                {
5872
                    InkToPath ip = new InkToPath();
5873

    
5874
                    List<Point> inkPointSet = new List<Point>();
5875
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5876

    
5877
                    PolygonControl pc = new PolygonControl()
5878
                    {
5879
                        CommentAngle = 0,
5880
                        PointSet = inkPointSet,
5881
                        ControlType = ControlType.Ink
5882
                    };
5883
                    pc.StartPoint = inkPointSet[0];
5884
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5885
                    pc.LineSize = 3;
5886
                    pc.CommentID = Commons.shortGuid();
5887
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5888

    
5889
                    if (pc.PointSet.Count > 0)
5890
                    {
5891
                        CreateCommand.Instance.Execute(pc);
5892
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5893
                    }
5894
                });
5895
                inkBoard.Strokes.Clear();
5896
            }
5897
        }
5898

    
5899
        /// <summary>
5900
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5901
        /// </summary>
5902
        /// <author>ingu</author>
5903
        /// <date>2018.06.05</date>
5904
        /// <param name="getPoint"></param>
5905
        /// <returns></returns>
5906
        private bool IsGetoutpoint(Point getPoint)
5907
        {
5908
            if (getPoint == new Point())
5909
            {
5910
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5911
                currentControl = null;
5912
                return true;
5913
            }
5914

    
5915
            return false;
5916
        }
5917

    
5918
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5919
        {
5920
            e.Effects = DragDropEffects.Copy;
5921
        }
5922

    
5923
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5924
        {
5925
            e.Effects = DragDropEffects.Copy;
5926
        }
5927

    
5928
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5929
        {
5930
            e.Effects = DragDropEffects.None;
5931
        }
5932

    
5933
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5934
        {
5935
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5936
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5937

    
5938
            ScaleImage(pageWidth, pageHeight);
5939
        }
5940

    
5941
        /// <summary>
5942
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5943
        /// </summary>
5944
        /// <param name="pageWidth">원본 사이즈</param>
5945
        /// <param name="pageHeight">원본 사이즈</param>
5946
        /// <returns></returns>
5947
        private void ScaleImage(double pageWidth, double pageHeight)
5948
        {
5949
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5950
        }
5951

    
5952
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5953
        {
5954
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5955
        }
5956

    
5957
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5958
        {
5959
            var checkbox = (sender as CheckBox);
5960

    
5961
            if (checkbox != null)
5962
            {
5963
                if (checkbox.IsChecked.GetValueOrDefault())
5964
                {
5965
                    gridViewMarkup.SelectAll();
5966
                }
5967
                else
5968
                {
5969
                    gridViewMarkup.UnselectAll();
5970
                }
5971
            }
5972
        }
5973

    
5974
        /*
5975
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5976
        {
5977
            try
5978
            {
5979
                if (e.Data.GetDataPresent(typeof(string)))
5980
                {
5981
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5982
                    string dragData = e.Data.GetData(typeof(string)) as string;
5983
                    Move_Symbol(sender, dragData);
5984
                }
5985
            }
5986
            catch (Exception ex)
5987
            {
5988
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5989
            }
5990
        }
5991
        */
5992
    }
5993

    
5994
    public class testItem
5995
    {
5996
        public string Title { get; set; }
5997
    }
5998
}
클립보드 이미지 추가 (최대 크기: 500 MB)