프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 902faaea

이력 | 보기 | 이력해설 | 다운로드 (270 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
                App.splashString(ISplashMessage.MAINMENU_1);
484
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
485
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
486
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
487
                imageViewer_Compare = new Image();
488
                ViewerDataModel.Instance.Capture_Opacity = 0;
489
                da.From = 0.8;
490
                da.To = 0;
491
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
492
                da.AutoReverse = true;
493
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
494

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

    
504
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
505
        }
506

    
507
        private async Task DownloadOriginalFileAsync()
508
        {
509
            try
510
            {
511
                using (System.Net.WebClient client = new System.Net.WebClient())
512
                {
513
                    string instnaceFile = System.IO.Path.GetTempFileName().Replace(".pdf", ".tmp");
514
                    string downloadurl = GetOriginalPDFURL();
515

    
516
                    // canceltoken을 위해서 상위에 선언
517
                    var task = client.DownloadFileTaskAsync(new Uri(downloadurl), instnaceFile);
518

    
519
                    client.DownloadProgressChanged += (snd, evt) =>
520
                    {
521
                        ViewerDataModel.Instance.DownloadFileProgress = evt.ProgressPercentage;
522

    
523
                        //System.Diagnostics.Debug.WriteLine($"Download Progress {evt.ProgressPercentage}% {evt.BytesReceived}/{evt.TotalBytesToReceive}(Byte)");
524
                    };
525

    
526
                    await task;
527

    
528
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
529
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
530
                    ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
531
                }
532
            }
533
            catch (Exception ex)
534
            {
535
                Logger.sendResLog("DownloadOriginalFileAsync", ex.Message, 0);
536
            }
537
        }
538

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

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

    
554
            ////GC.Collect();
555
        }
556

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

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

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

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

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

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

    
615
            /// up to here
616

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

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

    
637
        private DispatcherTimer renderTesttimer;
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
            await MarkupLoadAsync(e.PageNumber);
653

    
654
            // 페이지 이미지 변경
655
            await PageChangingAsync(e.CurrentPage, e.PageNumber);
656
        }
657

    
658
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber)
659
        {
660
            CompareMode.IsChecked = false;
661
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
662

    
663
            #region 페이지가 벗어난 경우
664

    
665
            if (BalancePoint < 1)
666
            {
667
                BalancePoint = 1;
668
                ViewerDataModel.Instance.PageBalanceNumber = 0;
669
            }
670

    
671
            if (pageNavigator.PageCount < BalancePoint)
672
            {
673
                BalancePoint = pageNavigator.PageCount;
674
                ViewerDataModel.Instance.PageBalanceNumber = 0;
675
            }
676

    
677
            #endregion 페이지가 벗어난 경우
678

    
679
            ViewerDataModel.Instance.PageNumber = BalancePoint;
680

    
681
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
682
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
683
            var contentScale = zoomAndPanControl.ContentScale;
684

    
685
            #region 페이지 이미지 로딩 수정
686

    
687
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(changePageNumber);
688

    
689
            ScaleImage(pageWidth, pageHeight);
690

    
691
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
692
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
693

    
694
            zoomAndPanCanvas.Width = pageWidth;
695
            zoomAndPanCanvas.Height = pageHeight;
696

    
697
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
698
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
699

    
700
            inkBoard.Width = pageWidth;
701
            inkBoard.Height = pageHeight;
702

    
703
            #endregion 페이지 이미지 로딩 수정
704

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

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

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

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

    
753
                    ViewerDataModel.Instance.ImageViewPath_C = null;
754

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

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

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

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

    
794
            SearchFocusBorder.Visibility = Visibility.Collapsed;
795

    
796
            this.pageNavigator.ChangePage(changePageNumber);
797
        }
798

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

    
813
            var instanceMain = ViewerDataModel.Instance.SystemMain;
814

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

    
817
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
818
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
819

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

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

    
828
            //Point startPoint = new Point(15, 15);
829

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

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

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

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

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

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

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

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

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

    
852
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
853
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
854
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
855
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
856
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
857

    
858
            //symCtrl.ApplyTemplate();
859
            ////txtApproved.ApplyTemplate();
860
            ////txtCreator.ApplyTemplate();
861
            //txtOriginator.ApplyTemplate();
862
            //txtDate.ApplyTemplate();
863

    
864
            ////SetTextControl(txtApproved);
865
            ////SetTextControl(txtCreator);
866
            //SetTextControl(txtOriginator);
867
            //SetTextControl(txtDate);
868

    
869
            //multi_Undo_Data = new Multi_Undo_data();
870

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

    
879
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
880
            //UndoData.Markup_List.Add(multi_Undo_Data);
881

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

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

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

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

    
894
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
895

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

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

    
910
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
911
        {
912
            SymControlN result = null;
913

    
914
            try
915
            {
916
                double height = 80;
917
                double itemWidth = 180;
918

    
919
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
920
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
921
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
922
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
923

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

    
945
            return result;
946
        }
947

    
948
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
949
        {
950
            RectangleControl result = null;
951

    
952
            try
953
            {
954
                double height = 80;
955
                double itemWidth = 180;
956

    
957
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
958
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
959
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
960
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
961

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

    
988
            return result;
989
        }
990

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

    
995
            try
996
            {
997
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
998

    
999
                double startPositionX = parentRect.X;
1000

    
1001
                switch (textAlignment)
1002
                {
1003
                    case TextAlignment.Right:
1004
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1005
                        break;
1006

    
1007
                    case TextAlignment.Center:
1008
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1009
                        break;
1010
                }
1011

    
1012
                Point startPosition = new Point
1013
                {
1014
                    X = startPositionX,
1015
                    Y = positionY
1016
                };
1017

    
1018
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1019
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1020
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1021
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1022

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

    
1054
            return result;
1055
        }
1056

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

    
1067
        private async Task MarkupLoadAsync(int pageNumber)
1068
        {
1069
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1070
            stopwatch.Start();
1071

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

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

    
1078
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1079
            {
1080
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1081
                if (info != null)
1082
                {
1083
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1084
                    if (info.UserID == App.ViewInfo.UserID)
1085
                    {
1086
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
1087
                                        markup.MarkupInfoID, markup.ID);
1088
                        control.Visibility = Visibility.Hidden;
1089
                    }
1090
                    else
1091
                    {
1092
                        var control = await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
1093
                                                                markup.MarkupInfoID, markup.ID);
1094
                        control.Visibility = Visibility.Hidden;
1095
                    }
1096
                }
1097
            };
1098
            /// up to here
1099

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

    
1102
            /// fire selection event
1103
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1104
            this.gridViewMarkup.UnselectAll();
1105
            this.gridViewMarkup.Select(gridSelectionItem);
1106

    
1107
            if (!testPanel2.IsHidden)
1108
            {
1109
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1110
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1111
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1112

    
1113
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1114
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1115

    
1116
                foreach (var item in gridSelectionRevItem)
1117
                {
1118
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1119

    
1120
                    foreach (var markupitem in markupitems)
1121
                    {
1122
                        await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
1123
                    }
1124
                }
1125
            }
1126

    
1127
            SetCommentPages();
1128
        }
1129

    
1130
        public void SetCommentPages()
1131
        {
1132
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1133
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1134
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1135
            {
1136
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1137
                if (item.MarkupList != null)
1138
                {
1139
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1140
                    instance.UserName = item.UserName;
1141
                    instance.Depart = item.Depatment;
1142
                    instance.MarkupInfoID = item.MarkupInfoID;
1143
                    instance.IsSelected = true;
1144
                    instance.isConSolidation = item.Consolidate;
1145
                    instance.SetColor = item.DisplayColor;
1146
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1147
                    {
1148
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1149
                    }
1150
                    else
1151
                    {
1152
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1153
                    }
1154
                    _pages.Add(instance);
1155
                }
1156
            }
1157

    
1158
            this.pageNavigator.SetCommentList(_pages.ToList());
1159
        }
1160

    
1161
        public void MarkupitemViewUpdate(string markupinfo_id)
1162
        {
1163
            //db에 업데이트 한 list 를 view 에 업데이트
1164
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1165
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1166
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1167
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1168
            if (dbinfo.MarkupList.Count > 0)
1169
            {
1170
                if (viewinfo.MarkupList != null)
1171
                {
1172
                    viewinfo.MarkupList.Clear();
1173
                    viewinfo.MarkupList = null;
1174
                }
1175
                viewinfo.MarkupList = new List<MarkupItem>();
1176
                foreach (var item in dbinfo.MarkupList)
1177
                {
1178
                    viewinfo.MarkupList.Add(item);
1179
                }
1180
            }
1181
        }
1182

    
1183
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1184
        {
1185
            var instance = ViewerDataModel.Instance;
1186

    
1187
            if (instance.IsWheelPageChanage)
1188
            {
1189
                return;
1190
            }
1191

    
1192
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1193
            {
1194
                int changePage = 0;
1195

    
1196
                if (e.Delta > 0)
1197
                {
1198
                    if (0 < instance.ContentOffsetY)
1199
                    {
1200
                        Vector dragOffset = new Vector(0, e.Delta);
1201
                        MoveZoomAndPanControl(dragOffset);
1202
                    }
1203
                    //else
1204
                    //{
1205
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1206
                    //    {
1207
                    //        instance.IsWheelPageChanage = true;
1208
                    //        changePage -= 1;
1209
                    //    }
1210
                    //}
1211
                }
1212
                else if (e.Delta < 0)
1213
                {
1214
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1215
                    {
1216
                        Vector dragOffset = new Vector(0, e.Delta);
1217
                        MoveZoomAndPanControl(dragOffset);
1218
                    }
1219
                    //else
1220
                    //{
1221
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1222
                    //    {
1223
                    //        instance.IsWheelPageChanage = true;
1224
                    //        changePage += 1;
1225
                    //    }
1226
                    //}
1227
                }
1228

    
1229
                //if (changePage != 0)
1230
                //{
1231
                //    await Task.Factory.StartNew(() =>
1232
                //    {
1233
                //        double beforeScale = instance.ContentScale;
1234

    
1235
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1236

    
1237
                //        handler = (snd, evt) =>
1238
                //        {
1239
                //            /// 최상단으로 이전 zoomScale로 위치한다
1240
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1241
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1242
                //            instance.IsWheelPageChanage = false;
1243
                //            pageNavigator.PageChanged -= handler;
1244
                //        };
1245

    
1246
                //        pageNavigator.PageChanged += handler;
1247

    
1248
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1249
                //    });
1250

    
1251
                //}
1252
            }
1253
            else
1254
            {
1255
                e.Handled = true;
1256
                if (e.Delta > 0)
1257
                {
1258
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1259
                    ZoomIn(currentContentMousePoint);
1260
                }
1261
                else
1262
                {
1263
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1264
                    ZoomOut(currentContentMousePoint);
1265
                }
1266
            }
1267
        }
1268

    
1269
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1270
        {
1271
            e.Handled = true;
1272
            if (e.Delta > 0)
1273
            {
1274
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1275
                ZoomIn_Sync(currentContentMousePoint);
1276
            }
1277
            else
1278
            {
1279
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1280
                ZoomOut_Sync(currentContentMousePoint);
1281
            }
1282
        }
1283

    
1284
        #region ZoomIn & ZoomOut
1285

    
1286
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1287
        {
1288
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1289
                zoomAndPanControl.ContentZoomFocusY));
1290
        }
1291

    
1292
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1293
        {
1294
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1295
                zoomAndPanControl.ContentZoomFocusY));
1296
        }
1297

    
1298
        //강인구 추가 (줌 인아웃 수치 변경)
1299
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1300
        private void ZoomOut(Point contentZoomCenter)
1301
        {
1302
            if (zoomAndPanControl.ContentScale > 0.39)
1303
            {
1304
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1305
            }
1306
            else
1307
            {
1308
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1309
            }
1310

    
1311
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1312
            {
1313
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1314
            }
1315
        }
1316

    
1317
        private void ZoomIn(Point contentZoomCenter)
1318
        {
1319
            if (zoomAndPanControl.ContentScale > 0.19)
1320
            {
1321
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1322
            }
1323
            else
1324
            {
1325
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1326
            }
1327

    
1328
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1329
            {
1330
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1331
            }
1332
        }
1333

    
1334
        private void ZoomOut_Sync(Point contentZoomCenter)
1335
        {
1336
            if (zoomAndPanControl2.ContentScale > 0.39)
1337
            {
1338
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1339
            }
1340
            else
1341
            {
1342
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1343
            }
1344

    
1345
            if (Sync.IsChecked)
1346
            {
1347
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1348
            }
1349
        }
1350

    
1351
        private void ZoomIn_Sync(Point contentZoomCenter)
1352
        {
1353
            if (zoomAndPanControl2.ContentScale > 0.19)
1354
            {
1355
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1356
            }
1357
            else
1358
            {
1359
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1360
            }
1361

    
1362
            if (Sync.IsChecked)
1363
            {
1364
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1365
            }
1366
        }
1367

    
1368
        private void ZoomOut()
1369
        {
1370
            zoomAndPanControl.ContentScale -= 0.1;
1371
            //if (zoomAndPanControl2 != null)
1372
            //{
1373
            //    zoomAndPanControl2.ContentScale -= 0.1;
1374
            //}
1375
        }
1376

    
1377
        private void ZoomIn()
1378
        {
1379
            zoomAndPanControl.ContentScale += 0.1;
1380
            //if (zoomAndPanControl2 != null)
1381
            //{
1382
            //    zoomAndPanControl2.ContentScale += 0.1;
1383
            //}
1384
        }
1385

    
1386
        #endregion ZoomIn & ZoomOut
1387

    
1388
        private void init()
1389
        {
1390
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1391
            {
1392
                ControlList.Clear();
1393
                listBox.Items.Clear();
1394
                selected_item.Clear();
1395

    
1396
                (item as IMarkupCommonData).IsSelected = false;
1397
            }
1398
        }
1399

    
1400
        private HitTestResultBehavior MyCallback(HitTestResult result)
1401
        {
1402
            //this.cursor = Cursors.UpArrow;
1403
            var element = result.VisualHit;
1404
            while (element != null && !(element is CommentUserInfo))
1405
                element = VisualTreeHelper.GetParent(element);
1406

    
1407
            if (element == null)
1408
            {
1409
                return HitTestResultBehavior.Stop;
1410
            }
1411
            else
1412
            {
1413
                if (element is CommentUserInfo)
1414
                {
1415
                    if (!hitList.Contains(element))
1416
                    {
1417
                        hitList.Add((CommentUserInfo)element);
1418
                    }
1419
                    else
1420
                    {
1421
                        return HitTestResultBehavior.Stop;
1422
                    }
1423
                }
1424
            }
1425
            return HitTestResultBehavior.Continue;
1426
        }
1427

    
1428
        public void ReleaseSelectPath()
1429
        {
1430
            if (SelectionPath == null)
1431
            {
1432
                SelectionPath = new Path();
1433
                SelectionPath.Name = "";
1434
            }
1435
            if (SelectionPath.Name != "")
1436
            {
1437
                SelectionPath.Name = "None";
1438
            }
1439
            SelectionPath.Opacity = 0.01;
1440
            SelectionPath.RenderTransform = null;
1441
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1442
        }
1443

    
1444
        #region 컨트롤 초기화
1445

    
1446
        public void Control_Init(object control)
1447
        {
1448
            if (L_Size != 0 && (control as IPath) != null)
1449
            {
1450
                (control as IPath).LineSize = L_Size;
1451
                L_Size = 0;
1452
            }
1453

    
1454
            switch (control.GetType().Name)
1455
            {
1456
                case "RectangleControl":
1457
                    {
1458
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1459
                    }
1460
                    break;
1461

    
1462
                case "CircleControl":
1463
                    {
1464
                        (control as CircleControl).StrokeColor = Brushes.Red;
1465
                    }
1466
                    break;
1467

    
1468
                case "TriControl":
1469
                    {
1470
                        (control as TriControl).StrokeColor = Brushes.Red;
1471
                    }
1472
                    break;
1473

    
1474
                case "RectCloudControl":
1475
                    {
1476
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1477
                    }
1478
                    break;
1479

    
1480
                case "CloudControl":
1481
                    {
1482
                        (control as CloudControl).StrokeColor = Brushes.Red;
1483
                    }
1484
                    break;
1485

    
1486
                case "PolygonControl":
1487
                    {
1488
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1489
                    }
1490
                    break;
1491

    
1492
                case "ArcControl":
1493
                    {
1494
                        (control as ArcControl).StrokeColor = Brushes.Red;
1495
                    }
1496
                    break;
1497

    
1498
                case "ArrowArcControl":
1499
                    {
1500
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1501
                    }
1502
                    break;
1503

    
1504
                case "LineControl":
1505
                    {
1506
                        (control as LineControl).StrokeColor = Brushes.Red;
1507
                    }
1508
                    break;
1509

    
1510
                case "ArrowControl_Multi":
1511
                    {
1512
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1513
                    }
1514
                    break;
1515

    
1516
                case "TextControl":
1517
                    {
1518
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1519
                    }
1520
                    break;
1521

    
1522
                case "ArrowTextControl":
1523
                    {
1524
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1525
                    }
1526
                    break;
1527

    
1528
                case "InsideWhiteControl":
1529
                    {
1530
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1531
                    }
1532
                    break;
1533

    
1534
                case "OverlapWhiteControl":
1535
                    {
1536
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1537
                    }
1538
                    break;
1539

    
1540
                case "ClipWhiteControl":
1541
                    {
1542
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1543
                    }
1544
                    break;
1545

    
1546
                case "CoordinateControl":
1547
                    {
1548
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1549
                    }
1550
                    break;
1551
            }
1552
        }
1553

    
1554
        #endregion 컨트롤 초기화
1555

    
1556
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1557
        {
1558
            //Control_Init(e.Source);
1559
        }
1560

    
1561
        //private Window _dragdropWindow = null;
1562

    
1563
        [DllImport("user32.dll")]
1564
        [return: MarshalAs(UnmanagedType.Bool)]
1565
        internal static extern bool GetCursorPos(ref Win32Point pt);
1566

    
1567
        [StructLayout(LayoutKind.Sequential)]
1568
        internal struct Win32Point
1569
        {
1570
            public Int32 X;
1571
            public Int32 Y;
1572
        };
1573

    
1574
        /*
1575
       public string symbol_id = null;
1576
       public long symbol_group_id;
1577
       public int symbol_SelectedIndex;
1578
       public ImageSource symbol_img;
1579
       public string symbol_Data = null;
1580
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1581
       {
1582
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1583
               zoomAndPanCanvas.ActualHeight / 2));
1584

    
1585
               if (this._dragdropWindow != null)
1586
               {
1587
                   this._dragdropWindow.Close();
1588
                   this._dragdropWindow = null;
1589
               }
1590

    
1591
               symbol_id = id;
1592
               symbol_group_id = group_id;
1593
               symbol_SelectedIndex = SelectedIndex;
1594
               symbol_Data = Data_;
1595
               symbol_img = img;
1596

    
1597
               CreateDragDropWindow2(img);
1598
    }
1599

    
1600
    private void CreateDragDropWindow2(ImageSource image)
1601
        {
1602
            this._dragdropWindow = new Window();
1603
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1604
            _dragdropWindow.WindowStyle = WindowStyle.None;
1605
            _dragdropWindow.AllowsTransparency = true;
1606
            _dragdropWindow.AllowDrop = false;
1607
            _dragdropWindow.Background = null;
1608
            _dragdropWindow.IsHitTestVisible = false;
1609
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1610
            _dragdropWindow.Topmost = true;
1611
            _dragdropWindow.ShowInTaskbar = false;
1612

    
1613
            Rectangle r = new Rectangle();
1614
            r.Width = image.Width;
1615
            r.Height = image.Height;
1616
            r.Opacity = 0.5;
1617
            r.Fill = new ImageBrush(image);
1618
            this._dragdropWindow.Content = r;
1619

    
1620
            Win32Point w32Mouse = new Win32Point();
1621
            GetCursorPos(ref w32Mouse);
1622

    
1623
            //w32Mouse.X = getCurrentPoint.X;
1624
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1625
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1626
            this._dragdropWindow.Show();
1627
        }
1628

    
1629
         */
1630

    
1631
        public void MoveZoomAndPanControl(Vector dragOffset)
1632
        {
1633
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1634
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1635

    
1636
            if (Sync.IsChecked)
1637
            {
1638
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1639
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1640
            }
1641
        }
1642

    
1643
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1644
        {
1645
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1646
            {
1647
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1648

    
1649
                Point currentPos = e.GetPosition(rect);
1650

    
1651
                floatingTip.HorizontalOffset = currentPos.X + 20;
1652
                floatingTip.VerticalOffset = currentPos.Y;
1653
            }
1654

    
1655
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1656

    
1657
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1658
            {
1659
                SetCursor();
1660
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1661
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1662

    
1663
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1664

    
1665
                MoveZoomAndPanControl(dragOffset);
1666
            }
1667

    
1668
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1669
            {
1670
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1671
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1672
                SetCursor();
1673

    
1674
                if (currentControl != null)
1675
                {
1676
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1677
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1678
                    //강인구 추가
1679
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1680

    
1681
                    if ((currentControl as IPath) != null)
1682
                    {
1683
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1684
                    }
1685
                    if ((currentControl as LineControl) != null)
1686
                    {
1687
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1688
                    }
1689

    
1690
                    if ((currentControl as IShapeControl) != null)
1691
                    {
1692
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1693
                    }
1694
                    if ((currentControl as TextControl) != null)
1695
                    {
1696
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1697
                        {
1698
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1699
                        }
1700
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1701
                        {
1702
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1703
                        }
1704
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1705
                        {
1706
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1707
                        }
1708
                    }
1709
                    else if ((currentControl as ArrowTextControl) != null)
1710
                    {
1711
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1712
                        {
1713
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1714
                        }
1715
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1716
                        {
1717
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1718
                        }
1719
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1720
                        {
1721
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1722
                        }
1723
                    }
1724
                    else if ((currentControl as RectCloudControl) != null)
1725
                    {
1726
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1727
                    }
1728
                    else if ((currentControl as CloudControl) != null)
1729
                    {
1730
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1731
                    }
1732

    
1733
                    #region // 모든 컨트롤의 공통기능 제어
1734

    
1735
                    if (controlType != ControlType.PenControl)
1736
                    {
1737
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1738
                    }
1739

    
1740
                    #endregion // 모든 컨트롤의 공통기능 제어
1741

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

    
1744
                    switch (controlType)
1745
                    {
1746
                        case (ControlType.Coordinate):
1747
                            {
1748
                                var control = currentControl as CoordinateControl;
1749
                                if (control != null)
1750
                                {
1751
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1752
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1753
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1754
                                }
1755
                            }
1756
                            break;
1757

    
1758
                        case (ControlType.InsideWhite):
1759
                            {
1760
                                var control = currentControl as InsideWhiteControl;
1761
                                if (control != null)
1762
                                {
1763
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1764
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1765
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1766
                                    control.Paint = PaintSet.Fill;
1767
                                }
1768
                            }
1769
                            break;
1770

    
1771
                        case ControlType.OverlapWhite:
1772
                            {
1773
                                var control = currentControl as OverlapWhiteControl;
1774
                                if (control != null)
1775
                                {
1776
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1777
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1778
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1779
                                    control.Paint = PaintSet.Fill;
1780
                                }
1781
                            }
1782
                            break;
1783

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

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

    
1809
                        case ControlType.SingleLine:
1810
                        case ControlType.CancelLine:
1811
                        case ControlType.ArrowLine:
1812
                        case ControlType.TwinLine:
1813
                        case ControlType.DimLine:
1814
                            {
1815
                                var control = currentControl as LineControl;
1816
                                if (control != null)
1817
                                {
1818
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1819
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1820
                                }
1821
                            }
1822
                            break;
1823

    
1824
                        case ControlType.ArcLine:
1825
                            {
1826
                                var control = currentControl as ArcControl;
1827
                                if (control != null)
1828
                                {
1829
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1830
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1831
                                }
1832
                            }
1833
                            break;
1834

    
1835
                        case ControlType.ArcArrow:
1836
                            {
1837
                                var control = currentControl as ArrowArcControl;
1838
                                if (control != null)
1839
                                {
1840
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1841
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1842
                                }
1843
                            }
1844
                            break;
1845

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

    
1857
                        case ControlType.Circle:
1858
                            {
1859
                                var control = currentControl as CircleControl;
1860

    
1861
                                if (control != null)
1862
                                {
1863
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1864
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1865
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1866
                                }
1867
                            }
1868
                            break;
1869

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

    
1882
                        case ControlType.Triangle:
1883
                            {
1884
                                var control = currentControl as TriControl;
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.ImgControl:
1895
                            {
1896
                                var control = currentControl as ImgControl;
1897
                                if (control != null)
1898
                                {
1899
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1900
                                }
1901
                            }
1902
                            break;
1903

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

    
1914
                        case ControlType.ArrowTextControl:
1915
                        case ControlType.ArrowTransTextControl:
1916
                        case ControlType.ArrowTextBorderControl:
1917
                        case ControlType.ArrowTransTextBorderControl:
1918
                        case ControlType.ArrowTextCloudControl:
1919
                        case ControlType.ArrowTransTextCloudControl:
1920
                            {
1921
                                var control = currentControl as ArrowTextControl;
1922
                                if (control != null)
1923
                                {
1924
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1925
                                }
1926
                            }
1927
                            break;
1928

    
1929
                        case ControlType.PolygonControl:
1930
                        case ControlType.ChainLine:
1931
                            {
1932
                                var control = currentControl as PolygonControl;
1933
                                if (control != null)
1934
                                {
1935
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1936
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1937
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1938
                                }
1939
                            }
1940
                            break;
1941

    
1942
                        case ControlType.Sign:
1943
                            {
1944
                                var control = currentControl as SignControl;
1945
                                if (control != null)
1946
                                {
1947
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1948
                                }
1949
                            }
1950
                            break;
1951

    
1952
                        case ControlType.Symbol:
1953
                            {
1954
                                var control = currentControl as SymControl;
1955
                                if (control != null)
1956
                                {
1957
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1958
                                }
1959
                            }
1960
                            break;
1961

    
1962
                        case ControlType.Stamp:
1963
                            {
1964
                                var control = currentControl as SymControlN;
1965
                                if (control != null)
1966
                                {
1967
                                    if (control.STAMP != null)
1968
                                    {
1969
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1970
                                    }
1971
                                    else
1972
                                    {
1973
                                        currentControl = null;
1974
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
1975
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1976
                                    }
1977
                                }
1978
                            }
1979
                            break;
1980

    
1981
                        case ControlType.Rectangle:
1982
                        case ControlType.Mark:
1983
                            {
1984
                                var control = currentControl as RectangleControl;
1985
                                if (control != null)
1986
                                {
1987
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1988
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1989
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1990
                                }
1991
                            }
1992
                            break;
1993

    
1994
                        case ControlType.PenControl:
1995
                            {
1996
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1997
                                //inkBoard.Strokes.Add(stroke);
1998
                            }
1999
                            break;
2000

    
2001
                        default:
2002
                            break;
2003
                    }
2004

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

    
2007
                    if (ViewerDataModel.Instance.AngleVisibility == Visibility.Visible)
2008
                    {
2009
                        ViewerDataModel.Instance.Angle = currentControl.CommentAngle;
2010
                    }
2011
                }
2012
            }
2013
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2014
            {
2015
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2016
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2017
                SetCursor();
2018
                if (currentControl == null)
2019
                {
2020
                    switch (controlType)
2021
                    {
2022
                        case ControlType.PenControl:
2023
                            {
2024
                                if (inkBoard.Tag.ToString() == "Ink")
2025
                                {
2026
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2027
                                }
2028
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2029
                                {
2030
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2031
                                }
2032
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2033
                                {
2034
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2035
                                }
2036

    
2037
                                //inkBoard.Strokes.Add(stroke);
2038
                            }
2039
                            break;
2040
                    }
2041
                    return;
2042
                }
2043
            }
2044
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2045
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2046
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2047
            {
2048
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2049

    
2050
                if (isDraggingSelectionRect)
2051
                {
2052
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2053
                    e.Handled = true;
2054
                }
2055
                else if (isLeftMouseButtonDownOnWindow)
2056
                {
2057
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2058
                    double dragDistance = Math.Abs(dragDelta.Length);
2059

    
2060
                    if (dragDistance > DragThreshold)
2061
                    {
2062
                        isDraggingSelectionRect = true;
2063
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2064
                    }
2065

    
2066
                    e.Handled = true;
2067
                }
2068

    
2069
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2070
                {
2071
                }
2072
                else
2073
                {
2074
                    e.Handled = true;
2075
                }
2076
            }
2077
            /*
2078
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2079
            { //symbol
2080
                if(_dragdropWindow != null)
2081
                {
2082
                    Win32Point w32Mouse = new Win32Point();
2083
                    GetCursorPos(ref w32Mouse);
2084

    
2085
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2086
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2087
                }
2088
            }
2089
            */
2090
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2091
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2092
            {
2093
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2094
                if (control != null)
2095
                {
2096
                    this.cursor = Cursors.Hand;
2097
                    SetCursor();
2098
                }
2099
                else
2100
                {
2101
                    if (this.Cursor != Cursors.None)
2102
                    {
2103
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2104
                        SetCursor();
2105
                    }
2106
                }
2107
            }
2108
            else
2109
            {
2110
            }
2111
        }
2112

    
2113
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2114
        {
2115
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2116
            {
2117
                SetCursor();
2118
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2119
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2120

    
2121
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2122

    
2123
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2124
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2125

    
2126
                if (Sync.IsChecked)
2127
                {
2128
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2129
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2130
                }
2131
            }
2132
        }
2133

    
2134
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2135

    
2136
        private EllipseGeometry hitArea = new EllipseGeometry();
2137

    
2138
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2139
        {
2140
            IsDrawing = false;
2141

    
2142
            if (mouseHandlingMode != MouseHandlingMode.None)
2143
            {
2144
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2145
                {
2146
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2147

    
2148
                    SetCursor();
2149

    
2150
                    switch (controlType)
2151
                    {
2152
                        case ControlType.None:
2153
                            break;
2154

    
2155
                        case ControlType.Rectangle:
2156
                            {
2157
                            }
2158
                            break;
2159

    
2160
                        case ControlType.PenControl:
2161
                            {
2162
                            }
2163
                            break;
2164

    
2165
                        default:
2166
                            break;
2167
                    }
2168
                }
2169
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2170
                {
2171
                    if (isLeftMouseButtonDownOnWindow)
2172
                    {
2173
                        bool wasDragSelectionApplied = false;
2174

    
2175
                        if (isDraggingSelectionRect)
2176
                        {
2177
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2178
                            {
2179
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2180
                                mouseHandlingMode = MouseHandlingMode.None;
2181
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2182
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2183
                                Set_Symbol_Capture(endPoint);
2184
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2185
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2186
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2187
                            }
2188
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2189
                            {
2190
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2191
                                mouseHandlingMode = MouseHandlingMode.None;
2192
                                Set_Capture();
2193

    
2194
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2195
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2196
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2197
                            }
2198
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2199
                            {
2200
                                ApplyDragSelectionRect();
2201
                            }
2202
                            else
2203
                            {
2204
                                double x = Canvas.GetLeft(dragZoomBorder);
2205
                                double y = Canvas.GetTop(dragZoomBorder);
2206
                                double width = dragZoomBorder.Width;
2207
                                double height = dragZoomBorder.Height;
2208
                                Rect dragRect = new Rect(x, y, width, height);
2209

    
2210
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2211

    
2212
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2213
                            }
2214

    
2215
                            isDraggingSelectionRect = false;
2216
                            e.Handled = true;
2217
                            wasDragSelectionApplied = true;
2218
                        }
2219

    
2220
                        if (isLeftMouseButtonDownOnWindow)
2221
                        {
2222
                            isLeftMouseButtonDownOnWindow = false;
2223
                            this.ReleaseMouseCapture();
2224
                            e.Handled = true;
2225
                        }
2226

    
2227
                        if (!wasDragSelectionApplied)
2228
                        {
2229
                            init();
2230
                        }
2231
                    }
2232
                }
2233
                else if (e.RightButton == MouseButtonState.Pressed)
2234
                {
2235
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2236
                    SetCursor();
2237
                }
2238

    
2239
                zoomAndPanControl.ReleaseMouseCapture();
2240

    
2241
                e.Handled = true;
2242
            }
2243
            else
2244
            {
2245
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2246
                SetCursor();
2247
            }
2248

    
2249
            ///mouseButtonDown = MouseButton.Left;
2250
            //controlType = ControlType.SingleLine;
2251
        }
2252

    
2253
        public void Set_Symbol_Capture(Point endPoint)
2254
        {
2255
            double x = CanvasDrawingMouseDownPoint.X;
2256
            double y = CanvasDrawingMouseDownPoint.Y;
2257
            if (x > endPoint.X)
2258
            {
2259
                x = endPoint.X;
2260
                y = endPoint.Y;
2261
            }
2262

    
2263
            double width = dragCaptureBorder.Width;
2264
            double height = dragCaptureBorder.Height;
2265

    
2266
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2267

    
2268
            if (x < 0)
2269
            {
2270
                width += x;
2271
                x = 0;
2272
            }
2273
            if (y < 0)
2274
            {
2275
                height += y;
2276
                y = 0;
2277

    
2278
                width = (int)canvasImage.PixelWidth - x;
2279
            }
2280
            if (x + width > canvasImage.PixelWidth)
2281
            {
2282
                width = (int)canvasImage.PixelWidth - x;
2283
            }
2284
            if (y + height > canvasImage.PixelHeight)
2285
            {
2286
                height = (int)canvasImage.PixelHeight - y;
2287
            }
2288
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2289

    
2290
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2291
            var defaultBitmapImage = new BitmapImage();
2292
            defaultBitmapImage.BeginInit();
2293
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2294
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2295
            defaultBitmapImage.UriSource = new Uri(uri);
2296
            defaultBitmapImage.EndInit();
2297

    
2298
            //GC.Collect();
2299

    
2300
            if (defaultBitmapImage.IsDownloading)
2301
            {
2302
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2303
                {
2304
                    defaultBitmapImage.Freeze();
2305
                    //GC.Collect();
2306
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2307
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2308
                };
2309
            }
2310
        }
2311

    
2312
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2313
        {
2314
            ///mouseButtonDown = MouseButton.Left;
2315
        }
2316

    
2317
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2318
        {
2319
            ///mouseButtonDown = MouseButton.Left;
2320
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2321
        }
2322

    
2323
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2324
        {
2325
        }
2326

    
2327
        /// <summary>
2328
        /// select items by dragging
2329
        /// </summary>
2330
        private void ApplyDragSelectionRect()
2331
        {
2332
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2333

    
2334
            double x = Canvas.GetLeft(dragSelectionBorder);
2335
            double y = Canvas.GetTop(dragSelectionBorder);
2336
            double width = dragSelectionBorder.Width;
2337
            double height = dragSelectionBorder.Height;
2338
            Boolean Flag = false;
2339
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2340
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2341

    
2342
            Rect dragRect = new Rect(x, y, width, height);
2343
            ///dragRect.Inflate(width / 10, height / 10);
2344

    
2345
            foreach (var item in Items)
2346
            {
2347
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2348

    
2349
                if (Flag)
2350
                {
2351
                    adornerSet.Add(item);
2352
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2353
                    Control_Style(item);
2354
                }
2355
            }
2356
            if (adornerSet.Count > 0)
2357
            {
2358
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2359
                SelectLayer.Children.Add(final);
2360
            }
2361
        }
2362

    
2363
        private void InitDragSelectionRect(Point pt1, Point pt2)
2364
        {
2365
            //캡쳐 중
2366
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2367
            {
2368
                dragCaptureBorder.Visibility = Visibility.Visible;
2369
            }
2370
            //선택 중
2371
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2372
            {
2373
                dragSelectionBorder.Visibility = Visibility.Visible;
2374
            }
2375
            else
2376
            {
2377
                dragZoomBorder.Visibility = Visibility.Visible;
2378
            }
2379
            UpdateDragSelectionRect(pt1, pt2);
2380
        }
2381

    
2382
        /// <summary>
2383
        /// Update the position and size of the rectangle used for drag selection.
2384
        /// </summary>
2385
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2386
        {
2387
            double x, y, width, height;
2388

    
2389
            //
2390
            // Determine x,y,width and height of the rect inverting the points if necessary.
2391
            //
2392

    
2393
            if (pt2.X < pt1.X)
2394
            {
2395
                x = pt2.X;
2396
                width = pt1.X - pt2.X;
2397
            }
2398
            else
2399
            {
2400
                x = pt1.X;
2401
                width = pt2.X - pt1.X;
2402
            }
2403

    
2404
            if (pt2.Y < pt1.Y)
2405
            {
2406
                y = pt2.Y;
2407
                height = pt1.Y - pt2.Y;
2408
            }
2409
            else
2410
            {
2411
                y = pt1.Y;
2412
                height = pt2.Y - pt1.Y;
2413
            }
2414

    
2415
            //
2416
            // Update the coordinates of the rectangle used for drag selection.
2417
            //
2418
            //캡쳐 중
2419
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2420
            {
2421
                Canvas.SetLeft(dragCaptureBorder, x);
2422
                Canvas.SetTop(dragCaptureBorder, y);
2423
                dragCaptureBorder.Width = width;
2424
                dragCaptureBorder.Height = height;
2425
            }
2426
            //선택 중
2427
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2428
            {
2429
                Canvas.SetLeft(dragSelectionBorder, x);
2430
                Canvas.SetTop(dragSelectionBorder, y);
2431
                dragSelectionBorder.Width = width;
2432
                dragSelectionBorder.Height = height;
2433
            }
2434
            else
2435
            {
2436
                Canvas.SetLeft(dragZoomBorder, x);
2437
                Canvas.SetTop(dragZoomBorder, y);
2438
                dragZoomBorder.Width = width;
2439
                dragZoomBorder.Height = height;
2440
            }
2441
        }
2442

    
2443
        private void drawingPannelRotate(double angle)
2444
        {
2445
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2446
            rotate.Angle = angle;
2447
            var rotationNum = Math.Abs((rotate.Angle / 90));
2448

    
2449
            if (angle == 90 || angle == 270)
2450
            {
2451
                double emptySize = zoomAndPanCanvas.Width;
2452
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2453
                zoomAndPanCanvas.Height = emptySize;
2454
            }
2455
            if (angle == 0)
2456
            {
2457
                translate.X = 0;
2458
                translate.Y = 0;
2459
            }
2460
            else if (angle == 90)
2461
            {
2462
                translate.X = zoomAndPanCanvas.Width;
2463
                translate.Y = 0;
2464
            }
2465
            else if (angle == 180)
2466
            {
2467
                translate.X = zoomAndPanCanvas.Width;
2468
                translate.Y = zoomAndPanCanvas.Height;
2469
            }
2470
            else
2471
            {
2472
                translate.X = 0;
2473
                translate.Y = zoomAndPanCanvas.Height;
2474
            }
2475

    
2476
            zoomAndPanControl.RotationAngle = rotate.Angle;
2477

    
2478
            if (!testPanel2.IsHidden)
2479
            {
2480
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2481
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2482
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2483
            }
2484

    
2485
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2486
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2487
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2488
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2489
            ViewerDataModel.Instance.Angle = rotate.Angle;
2490
        }
2491

    
2492
        private void syncPannelRotate(double angle)
2493
        {
2494
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2495
            rotate.Angle = angle;
2496
            var rotationNum = Math.Abs((rotate.Angle / 90));
2497

    
2498
            if (angle == 90 || angle == 270)
2499
            {
2500
                double emptySize = zoomAndPanCanvas2.Width;
2501
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2502
                zoomAndPanCanvas2.Height = emptySize;
2503
            }
2504
            if (angle == 0)
2505
            {
2506
                translate2.X = 0;
2507
                translate2.Y = 0;
2508
            }
2509
            else if (angle == 90)
2510
            {
2511
                translate2.X = zoomAndPanCanvas2.Width;
2512
                translate2.Y = 0;
2513
            }
2514
            else if (angle == 180)
2515
            {
2516
                translate2.X = zoomAndPanCanvas2.Width;
2517
                translate2.Y = zoomAndPanCanvas2.Height;
2518
            }
2519
            else
2520
            {
2521
                translate2.X = 0;
2522
                translate2.Y = zoomAndPanCanvas2.Height;
2523
            }
2524

    
2525
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2526
        }
2527

    
2528
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2529
        {
2530
            string Data_ = "";
2531

    
2532
            try
2533
            {
2534
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2535
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2536
                if (Data_ != null || Data_ != "")
2537
                {
2538
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2539
                }
2540
                else
2541
                {
2542
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2543
                }
2544

    
2545
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2546
                //{
2547
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2548
                //    STATE = 0,
2549
                //};
2550
                if (Data_ != null)
2551
                {
2552
                    Image img = new Image();
2553
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2554
                    if (Data_.Contains(".svg"))
2555
                    {
2556
                        byte[] imageData = null;
2557
                        DrawingImage image = null;
2558
                        using (System.Net.WebClient web = new System.Net.WebClient())
2559
                        {
2560
                            imageData = web.DownloadData(new Uri(Data_));
2561
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2562
                            image = SvgReader.Load(stream);
2563
                        }
2564
                        img.Source = image;
2565
                    }
2566
                    else
2567
                    {
2568
                        img.Source = new BitmapImage(new Uri(Data_));
2569
                    }
2570

    
2571
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2572
                    {
2573
                        PointSet = new List<Point>(),
2574
                        FilePath = Data_,
2575
                        ImageData = img.Source,
2576
                        StartPoint = canvasZoomPanningMouseDownPoint,
2577
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2578
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2579
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2580
                        canvasZoomPanningMouseDownPoint.Y),
2581
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2582
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2583
                    };
2584

    
2585
                    currentControl.PointSet = new List<Point>
2586
                                        {
2587
                                            currentControl.StartPoint,
2588
                                            currentControl.LeftBottomPoint,
2589
                                            currentControl.EndPoint,
2590
                                            currentControl.TopRightPoint,
2591
                                        };
2592
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2593
                    UndoData = new Undo_data()
2594
                    {
2595
                        IsUndo = false,
2596
                        Event = Event_Type.Create,
2597
                        EventTime = DateTime.Now,
2598
                        Markup_List = new List<Multi_Undo_data>()
2599
                    };
2600
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2601
                    {
2602
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2603
                    });
2604

    
2605
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2606
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2607
                    UndoData.Markup_List.Add(multi_Undo_Data);
2608
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2609

    
2610
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2611
                    currentControl.CommentID = Commons.shortGuid();
2612
                    currentControl.SymbolID = id;
2613
                    currentControl.GroupID = group_id;
2614
                    currentControl.ApplyTemplate();
2615
                    currentControl.SetImage();
2616

    
2617
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2618
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2619
                    SelectLayer.Children.Add(final);
2620
                }
2621
            }
2622
            catch (Exception ex)
2623
            {
2624
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2625
            }
2626
        }
2627

    
2628
        private async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2629
        {
2630
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2631
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2632
            {
2633
                set_option.Value = double.Parse(set_option.ContentText);
2634
                //set_option.Focusable = false;
2635
                zoomAndPanControl.Focus();
2636
            }
2637

    
2638
            ConvertInkControlToPolygon();
2639

    
2640
            ///TODO:
2641
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2642
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2643

    
2644
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2645
            {
2646
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2647
            }
2648
            /// up to here
2649

    
2650
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2651
            {
2652
                if (item as ArrowTextControl != null)
2653
                {
2654
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2655
                }
2656
                else if (item as TextControl != null)
2657
                {
2658
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2659
                }
2660
            }
2661

    
2662
            //if (currentControl != null)
2663
            {
2664
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2665
                if (text_item_ != null)
2666
                {
2667
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2668
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2669
                    (text_item_ as TextControl).IsEditingMode = false;
2670
                    currentControl = null;
2671
                }
2672

    
2673
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2674
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2675
                {
2676
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2677
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2678
                    currentControl = null;
2679
                }
2680
            }
2681

    
2682
            double Ang = 0;
2683
            if (rotate.Angle != 0)
2684
            {
2685
                Ang = 360 - rotate.Angle;
2686
            }
2687

    
2688
            if (e.OriginalSource is System.Windows.Controls.Image)
2689
            {
2690
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2691
            }
2692
            /*
2693
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2694
            {
2695
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2696
                if(symbol_id != null)
2697
                {
2698
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2699
                }
2700
            }
2701

    
2702
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2703
            {
2704
                if (this._dragdropWindow != null)
2705
                {
2706
                    this._dragdropWindow.Close();
2707
                    this._dragdropWindow = null;
2708
                    symbol_id = null;
2709
                }
2710
            }
2711
            */
2712

    
2713
            if (e.LeftButton == MouseButtonState.Pressed)
2714
            {
2715
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2716
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2717

    
2718
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2719
                SetCursor();
2720

    
2721
                if (!ViewerDataModel.Instance.IsPressCtrl)
2722
                {
2723
                    SelectionSet.Instance.UnSelect(this);
2724
                }
2725
            }
2726

    
2727
            if (e.MiddleButton == MouseButtonState.Pressed)
2728
            {
2729
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2730
                cursor = Cursors.SizeAll;
2731
                SetCursor();
2732
            }
2733
            if (e.RightButton == MouseButtonState.Pressed)
2734
            {
2735
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2736
                cursor = Cursors.SizeAll;
2737
                SetCursor();
2738
            }
2739
            else if (e.XButton1 == MouseButtonState.Pressed)
2740
            {
2741
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2742
                {
2743
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2744
                }
2745

    
2746
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2747
            }
2748
            else if (e.XButton2 == MouseButtonState.Pressed)
2749
            {
2750
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2751
                {
2752
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2753
                }
2754
            }
2755

    
2756
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2757
            {
2758
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2759
                {
2760
                    if (SelectLayer.Children.Count == 0)
2761
                    {
2762
                        isLeftMouseButtonDownOnWindow = true;
2763
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2764
                    }
2765

    
2766
                    if (controlType == ControlType.None)
2767
                    {
2768
                        isLeftMouseButtonDownOnWindow = true;
2769
                    }
2770
                }
2771

    
2772
                /// 캡쳐 모드 설정
2773
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2774
                {
2775
                    dragCaptureBorder.Visibility = Visibility.Visible;
2776
                    isLeftMouseButtonDownOnWindow = true;
2777
                }
2778

    
2779
                /// 줌 모드 설정
2780
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2781
                {
2782
                    isLeftMouseButtonDownOnWindow = true;
2783
                }
2784

    
2785
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2786

    
2787
                if (control == null)
2788
                {
2789
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2790
                }
2791
                else
2792
                {
2793
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2794
                    {
2795
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2796
                    }
2797

    
2798
                    AdornerFinal final = null;
2799

    
2800
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2801
                    {
2802
                        /// 기존 selection 해제
2803
                        SelectionSet.Instance.UnSelect(this);
2804

    
2805
                        final = new AdornerFinal(control);
2806

    
2807
                        this.Control_Style(control);
2808

    
2809
                        if ((control as IPath) != null)
2810
                        {
2811
                            if ((control as IPath).LineSize != 0)
2812
                            {
2813
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2814
                            }
2815
                        }
2816
                        if ((control as IShapeControl) != null)
2817
                        {
2818
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2819
                            {
2820
                                ViewerDataModel.Instance.checkHatchShape = true;
2821
                            }
2822
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2823
                            {
2824
                                ViewerDataModel.Instance.checkFillShape = true;
2825
                            }
2826
                            else
2827
                            {
2828
                                ViewerDataModel.Instance.checkHatchShape = false;
2829
                                ViewerDataModel.Instance.checkFillShape = false;
2830
                            }
2831
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2832
                        }
2833

    
2834
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2835

    
2836
                        if ((control as TextControl) != null)
2837
                        {
2838
                            if (!((control as TextControl).EnableEditing))
2839
                            {
2840
                                (control as TextControl).EnableEditing = true;
2841
                            }
2842
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2843
                            {
2844
                                ViewerDataModel.Instance.checkTextStyle = true;
2845
                            }
2846
                            else
2847
                            {
2848
                                ViewerDataModel.Instance.checkTextStyle = false;
2849
                            }
2850
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2851
                            {
2852
                                ViewerDataModel.Instance.checkTextWeight = true;
2853
                            }
2854
                            else
2855
                            {
2856
                                ViewerDataModel.Instance.checkTextWeight = false;
2857
                            }
2858
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2859
                            {
2860
                                ViewerDataModel.Instance.checkUnderLine = true;
2861
                            }
2862
                            else
2863
                            {
2864
                                ViewerDataModel.Instance.checkUnderLine = false;
2865
                            }
2866
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2867
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2868
                        }
2869
                        else if ((control as ArrowTextControl) != null)
2870
                        {
2871
                            if (!((control as ArrowTextControl).EnableEditing))
2872
                            {
2873
                                (control as ArrowTextControl).EnableEditing = true;
2874
                            }
2875
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2876
                            {
2877
                                ViewerDataModel.Instance.checkTextStyle = true;
2878
                            }
2879
                            else
2880
                            {
2881
                                ViewerDataModel.Instance.checkTextStyle = false;
2882
                            }
2883
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2884
                            {
2885
                                ViewerDataModel.Instance.checkTextWeight = true;
2886
                            }
2887
                            else
2888
                            {
2889
                                ViewerDataModel.Instance.checkTextWeight = false;
2890
                            }
2891
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2892
                            {
2893
                                ViewerDataModel.Instance.checkUnderLine = true;
2894
                            }
2895
                            else
2896
                            {
2897
                                ViewerDataModel.Instance.checkUnderLine = false;
2898
                            }
2899
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2900
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2901
                        }
2902
                        else if ((control as RectCloudControl) != null)
2903
                        {
2904
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2905
                        }
2906
                        else if ((control as CloudControl) != null)
2907
                        {
2908
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2909
                        }
2910
                    }
2911
                    else
2912
                    {
2913
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2914
                        SelectionSet.Instance.UnSelect(this);
2915
                        comment.Add(control);
2916

    
2917
                        Control_Style(control);
2918

    
2919
                        final = new AdornerFinal(comment);
2920
                    }
2921

    
2922
                    if (final != null)
2923
                    {
2924
                        this.SelectLayer.Children.Add(final);
2925
                    }
2926
                }
2927
            }
2928
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2929
            {
2930
                init();
2931
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2932
                if (cursor != Cursors.SizeAll)
2933
                {
2934
                    cursor = Cursors.Cross;
2935
                    SetCursor();
2936
                }
2937
                bool init_user = false;
2938
                foreach (var user in gridViewMarkup.Items)
2939
                {
2940
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2941
                    {
2942
                        init_user = true;
2943
                    }
2944
                }
2945
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2946
                {
2947
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
2948
                    RadWindow.Alert(new DialogParameters
2949
                    {
2950
                        Owner = Application.Current.MainWindow,
2951
                        Theme = new VisualStudio2013Theme(),
2952
                        Header = "Info",
2953
                        Content = "Existing comments already existed. Select from the user list first",
2954
                    });
2955
                    return;
2956
                }
2957
                else
2958
                {
2959
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2960
                    if (item != null)
2961
                    {
2962
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2963
                    }
2964
                }
2965

    
2966
                switch (controlType)
2967
                {
2968
                    case ControlType.Coordinate:
2969
                        {
2970
                            if (e.LeftButton == MouseButtonState.Pressed)
2971
                            {
2972
                                if (currentControl is CoordinateControl)
2973
                                {
2974
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2975
                                    {
2976
                                        return;
2977
                                    }
2978

    
2979
                                    CreateCommand.Instance.Execute(currentControl);
2980

    
2981
                                    currentControl = null;
2982
                                    this.cursor = Cursors.Arrow;
2983
                                }
2984
                                else
2985
                                {
2986
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2987
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2988
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2989
                                    {
2990
                                        currentControl = null;
2991
                                        this.cursor = Cursors.Arrow;
2992
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2993
                                        return;
2994
                                    }
2995
                                    else
2996
                                    {
2997
                                        currentControl = new CoordinateControl
2998
                                        {
2999
                                            Background = new SolidColorBrush(Colors.Black),
3000
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3001
                                            ControlType = ControlType.Coordinate
3002
                                        };
3003

    
3004
                                        currentControl.CommentID = Commons.shortGuid();
3005
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3006
                                        currentControl.IsNew = true;
3007

    
3008
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3009

    
3010
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3011
                                    }
3012
                                }
3013
                            }
3014
                        }
3015
                        break;
3016

    
3017
                    case ControlType.InsideWhite:
3018
                        {
3019
                            if (e.LeftButton == MouseButtonState.Pressed)
3020
                            {
3021
                                if (currentControl is InsideWhiteControl)
3022
                                {
3023
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3024
                                    {
3025
                                        return;
3026
                                    }
3027

    
3028
                                    CreateCommand.Instance.Execute(currentControl);
3029

    
3030
                                    currentControl = null;
3031
                                    this.cursor = Cursors.Arrow;
3032
                                }
3033
                                else
3034
                                {
3035
                                    currentControl = new InsideWhiteControl
3036
                                    {
3037
                                        Background = new SolidColorBrush(Colors.Black),
3038
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3039
                                        ControlType = ControlType.InsideWhite
3040
                                    };
3041

    
3042
                                    currentControl.CommentID = Commons.shortGuid();
3043
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3044
                                    currentControl.IsNew = true;
3045
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3046

    
3047
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3048
                                }
3049
                            }
3050
                        }
3051
                        break;
3052

    
3053
                    case ControlType.OverlapWhite:
3054
                        {
3055
                            if (e.LeftButton == MouseButtonState.Pressed)
3056
                            {
3057
                                if (currentControl is OverlapWhiteControl)
3058
                                {
3059
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3060
                                    {
3061
                                        return;
3062
                                    }
3063

    
3064
                                    CreateCommand.Instance.Execute(currentControl);
3065

    
3066
                                    currentControl = null;
3067
                                    this.cursor = Cursors.Arrow;
3068
                                }
3069
                                else
3070
                                {
3071
                                    currentControl = new OverlapWhiteControl
3072
                                    {
3073
                                        Background = new SolidColorBrush(Colors.Black),
3074
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3075
                                        ControlType = ControlType.OverlapWhite
3076
                                    };
3077

    
3078
                                    currentControl.CommentID = Commons.shortGuid();
3079
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3080
                                    currentControl.IsNew = true;
3081
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3082

    
3083
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3084
                                }
3085
                            }
3086
                        }
3087
                        break;
3088

    
3089
                    case ControlType.ClipWhite:
3090
                        {
3091
                            if (e.LeftButton == MouseButtonState.Pressed)
3092
                            {
3093
                                if (currentControl is ClipWhiteControl)
3094
                                {
3095
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3096
                                    {
3097
                                        return;
3098
                                    }
3099

    
3100
                                    CreateCommand.Instance.Execute(currentControl);
3101

    
3102
                                    currentControl = null;
3103
                                    this.cursor = Cursors.Arrow;
3104
                                }
3105
                                else
3106
                                {
3107
                                    currentControl = new ClipWhiteControl
3108
                                    {
3109
                                        Background = new SolidColorBrush(Colors.Black),
3110
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3111
                                        ControlType = ControlType.ClipWhite
3112
                                    };
3113

    
3114
                                    currentControl.CommentID = Commons.shortGuid();
3115
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3116
                                    currentControl.IsNew = true;
3117
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3118

    
3119
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3120
                                }
3121
                            }
3122
                        }
3123
                        break;
3124

    
3125
                    case ControlType.Rectangle:
3126
                        {
3127
                            if (e.LeftButton == MouseButtonState.Pressed)
3128
                            {
3129
                                if (currentControl is RectangleControl)
3130
                                {
3131
                                    //20180906 LJY TEST IsRotationDrawingEnable
3132
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3133
                                    {
3134
                                        return;
3135
                                    }
3136

    
3137
                                    CreateCommand.Instance.Execute(currentControl);
3138
                                    currentControl = null;
3139
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3140
                                }
3141
                                else
3142
                                {
3143
                                    currentControl = new RectangleControl
3144
                                    {
3145
                                        Background = new SolidColorBrush(Colors.Black),
3146
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3147
                                        ControlType = ControlType.Rectangle
3148
                                    };
3149

    
3150
                                    currentControl.CommentID = Commons.shortGuid();
3151
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3152
                                    currentControl.IsNew = true;
3153
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3154

    
3155
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3156
                                }
3157
                            }
3158
                        }
3159
                        break;
3160

    
3161
                    case ControlType.RectCloud:
3162
                        {
3163
                            if (e.LeftButton == MouseButtonState.Pressed)
3164
                            {
3165
                                if (currentControl is RectCloudControl)
3166
                                {
3167
                                    //20180906 LJY TEST IsRotationDrawingEnable
3168
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3169
                                    {
3170
                                        return;
3171
                                    }
3172

    
3173
                                    CreateCommand.Instance.Execute(currentControl);
3174

    
3175
                                    currentControl = null;
3176

    
3177
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3178
                                }
3179
                                else
3180
                                {
3181
                                    currentControl = new RectCloudControl
3182
                                    {
3183
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3184
                                        ControlType = ControlType.RectCloud,
3185
                                        Background = new SolidColorBrush(Colors.Black)
3186
                                    };
3187

    
3188
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3189
                                    currentControl.CommentID = Commons.shortGuid();
3190
                                    currentControl.IsNew = true;
3191
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3192
                                }
3193
                            }
3194
                        }
3195
                        break;
3196

    
3197
                    case ControlType.Circle:
3198
                        {
3199
                            if (e.LeftButton == MouseButtonState.Pressed)
3200
                            {
3201
                                if (currentControl is CircleControl)
3202
                                {
3203
                                    //20180906 LJY TEST IsRotationDrawingEnable
3204
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3205
                                    {
3206
                                        return;
3207
                                    }
3208

    
3209
                                    CreateCommand.Instance.Execute(currentControl);
3210

    
3211
                                    currentControl = null;
3212
                                }
3213
                                else
3214
                                {
3215
                                    currentControl = new CircleControl
3216
                                    {
3217
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3218
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3219
                                        Background = new SolidColorBrush(Colors.Black)
3220
                                    };
3221

    
3222
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3223
                                    currentControl.CommentID = Commons.shortGuid();
3224
                                    currentControl.IsNew = true;
3225
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3226
                                }
3227
                            }
3228
                        }
3229
                        break;
3230

    
3231
                    case ControlType.Triangle:
3232
                        {
3233
                            if (e.LeftButton == MouseButtonState.Pressed)
3234
                            {
3235
                                if (currentControl is TriControl)
3236
                                {
3237
                                    var content = currentControl as TriControl;
3238
                                    if (content.MidPoint == new Point(0, 0))
3239
                                    {
3240
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3241
                                    }
3242
                                    else
3243
                                    {
3244
                                        //20180906 LJY TEST IsRotationDrawingEnable
3245
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3246
                                        {
3247
                                            return;
3248
                                        }
3249

    
3250
                                        CreateCommand.Instance.Execute(currentControl);
3251

    
3252
                                        currentControl = null;
3253
                                    }
3254
                                }
3255
                                else
3256
                                {
3257
                                    currentControl = new TriControl
3258
                                    {
3259
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3260
                                        Background = new SolidColorBrush(Colors.Black),
3261
                                    };
3262

    
3263
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3264
                                    currentControl.CommentID = Commons.shortGuid();
3265
                                    currentControl.IsNew = true;
3266
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3267
                                }
3268
                            }
3269
                        }
3270
                        break;
3271

    
3272
                    case ControlType.CancelLine:
3273
                    case ControlType.SingleLine:
3274
                    case ControlType.ArrowLine:
3275
                    case ControlType.TwinLine:
3276
                    case ControlType.DimLine:
3277
                        {
3278
                            if (e.LeftButton == MouseButtonState.Pressed)
3279
                            {
3280
                                if (currentControl is LineControl)
3281
                                {
3282
                                    //20180906 LJY TEST IsRotationDrawingEnable
3283
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3284
                                    {
3285
                                        return;
3286
                                    }
3287

    
3288
                                    CreateCommand.Instance.Execute(currentControl);
3289
                                    currentControl = null;
3290
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3291
                                }
3292
                                else
3293
                                {
3294
                                    currentControl = new LineControl
3295
                                    {
3296
                                        ControlType = this.controlType,
3297
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3298
                                        Background = new SolidColorBrush(Colors.Black)
3299
                                    };
3300

    
3301
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3302
                                    currentControl.CommentID = Commons.shortGuid();
3303
                                    currentControl.IsNew = true;
3304
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3305
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3306
                                }
3307
                            }
3308
                        }
3309
                        break;
3310

    
3311
                    case ControlType.PolygonControl:
3312
                        {
3313
                            if (currentControl is PolygonControl)
3314
                            {
3315
                                var control = currentControl as PolygonControl;
3316

    
3317
                                if (e.RightButton == MouseButtonState.Pressed)
3318
                                {
3319
                                    control.IsCompleted = true;
3320
                                }
3321

    
3322
                                if (!control.IsCompleted)
3323
                                {
3324
                                    control.PointSet.Add(control.EndPoint);
3325
                                }
3326
                                else
3327
                                {
3328
                                    //20180906 LJY TEST IsRotationDrawingEnable
3329
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3330
                                    {
3331
                                        return;
3332
                                    }
3333

    
3334
                                    var firstPoint = control.PointSet.First();
3335
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3336
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3337
                                    control.PointSet.Add(firstPoint);
3338

    
3339
                                    control.ApplyOverViewData();
3340

    
3341
                                    CreateCommand.Instance.Execute(currentControl);
3342
                                    control.UpdateControl();
3343
                                    currentControl = null;
3344
                                }
3345
                            }
3346
                            else
3347
                            {
3348
                                if (e.LeftButton == MouseButtonState.Pressed)
3349
                                {
3350
                                    currentControl = new PolygonControl
3351
                                    {
3352
                                        PointSet = new List<Point>(),
3353
                                    };
3354

    
3355
                                    var polygonControl = (currentControl as PolygonControl);
3356
                                    currentControl.CommentID = Commons.shortGuid();
3357
                                    currentControl.IsNew = true;
3358
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3359
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3360
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3361
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3362
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3363
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3364
                                    polygonControl.ApplyTemplate();
3365
                                    polygonControl.Visibility = Visibility.Visible;
3366
                                }
3367
                            }
3368
                        }
3369
                        break;
3370

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

    
3377
                                if (e.RightButton == MouseButtonState.Pressed)
3378
                                {
3379
                                    //20180906 LJY TEST IsRotationDrawingEnable
3380
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3381
                                    {
3382
                                        return;
3383
                                    }
3384

    
3385
                                    CreateCommand.Instance.Execute(currentControl);
3386

    
3387
                                    currentControl = null;
3388
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3389
                                    return;
3390
                                }
3391

    
3392
                                if (!control.IsCompleted)
3393
                                {
3394
                                    control.PointSet.Add(control.EndPoint);
3395
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3396
                                }
3397
                            }
3398
                            else
3399
                            {
3400
                                if (e.LeftButton == MouseButtonState.Pressed)
3401
                                {
3402
                                    MainAngle.Visibility = Visibility.Visible;
3403
                                    currentControl = new PolygonControl
3404
                                    {
3405
                                        PointSet = new List<Point>(),
3406
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3407
                                        ControlType = ControlType.ChainLine,
3408
                                        DashSize = ViewerDataModel.Instance.DashSize,
3409
                                        LineSize = ViewerDataModel.Instance.LineSize,
3410
                                        //PointC = new StylusPointSet()
3411
                                    };
3412

    
3413
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3414
                                    //{
3415
                                    var polygonControl = (currentControl as PolygonControl);
3416
                                    currentControl.CommentID = Commons.shortGuid();
3417
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3418
                                    currentControl.IsNew = true;
3419
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3420
                                    //currentControl.OnApplyTemplate();
3421
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3422
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3423
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3424
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3425
                                    //}
3426
                                }
3427
                            }
3428
                        }
3429
                        break;
3430

    
3431
                    case ControlType.ArcLine:
3432
                        {
3433
                            if (e.LeftButton == MouseButtonState.Pressed)
3434
                            {
3435
                                if (currentControl is ArcControl)
3436
                                {
3437
                                    //20180906 LJY TEST IsRotationDrawingEnable
3438
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3439
                                    {
3440
                                        return;
3441
                                    }
3442

    
3443
                                    CreateCommand.Instance.Execute(currentControl);
3444

    
3445
                                    currentControl = null;
3446
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3447
                                }
3448
                                else
3449
                                {
3450
                                    currentControl = new ArcControl
3451
                                    {
3452
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3453
                                        Background = new SolidColorBrush(Colors.Black)
3454
                                    };
3455
                                    currentControl.CommentID = Commons.shortGuid();
3456
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3457
                                    currentControl.IsNew = true;
3458
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3459
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3460
                                }
3461
                            }
3462
                            else if (e.RightButton == MouseButtonState.Pressed)
3463
                            {
3464
                                if (currentControl != null)
3465
                                {
3466
                                    (currentControl as ArcControl).setClock();
3467
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3468
                                }
3469
                            }
3470
                        }
3471
                        break;
3472

    
3473
                    case ControlType.ArcArrow:
3474
                        {
3475
                            if (e.LeftButton == MouseButtonState.Pressed)
3476
                            {
3477
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3478
                                //{
3479
                                if (currentControl is ArrowArcControl)
3480
                                {
3481
                                    //20180906 LJY TEST IsRotationDrawingEnable
3482
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3483
                                    {
3484
                                        return;
3485
                                    }
3486

    
3487
                                    CreateCommand.Instance.Execute(currentControl);
3488

    
3489
                                    currentControl = null;
3490
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3491
                                }
3492
                                else
3493
                                {
3494
                                    currentControl = new ArrowArcControl
3495
                                    {
3496
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3497
                                        Background = new SolidColorBrush(Colors.Black)
3498
                                    };
3499
                                    currentControl.CommentID = Commons.shortGuid();
3500
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3501
                                    currentControl.IsNew = true;
3502
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3503
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3504
                                }
3505
                                //}
3506
                            }
3507
                            else if (e.RightButton == MouseButtonState.Pressed)
3508
                            {
3509
                                if (currentControl != null)
3510
                                {
3511
                                    (currentControl as ArrowArcControl).setClock();
3512
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3513
                                    //(currentControl as ArcControl).ApplyTemplate();
3514
                                }
3515
                            }
3516
                        }
3517
                        break;
3518

    
3519
                    case ControlType.ArrowMultiLine:
3520
                        {
3521
                            if (e.LeftButton == MouseButtonState.Pressed)
3522
                            {
3523
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3524
                                //{
3525
                                if (currentControl is ArrowControl_Multi)
3526
                                {
3527
                                    var content = currentControl as ArrowControl_Multi;
3528
                                    if (content.MiddlePoint == new Point(0, 0))
3529
                                    {
3530
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3531
                                        {
3532
                                            content.MiddlePoint = content.EndPoint;
3533
                                        }
3534
                                        else
3535
                                        {
3536
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3537
                                        }
3538
                                    }
3539
                                    else
3540
                                    {
3541
                                        //20180906 LJY TEST IsRotationDrawingEnable
3542
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3543
                                        {
3544
                                            return;
3545
                                        }
3546

    
3547
                                        CreateCommand.Instance.Execute(currentControl);
3548

    
3549
                                        currentControl = null;
3550
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3551
                                    }
3552
                                }
3553
                                else
3554
                                {
3555
                                    currentControl = new ArrowControl_Multi
3556
                                    {
3557
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3558
                                        Background = new SolidColorBrush(Colors.Black)
3559
                                    };
3560
                                    currentControl.CommentID = Commons.shortGuid();
3561
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3562
                                    currentControl.IsNew = true;
3563
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3564
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3565
                                }
3566
                                //}
3567
                            }
3568
                        }
3569
                        break;
3570

    
3571
                    case ControlType.PolygonCloud:
3572
                        {
3573
                            if (currentControl is CloudControl)
3574
                            {
3575
                                var control = currentControl as CloudControl;
3576
                                if (e.RightButton == MouseButtonState.Pressed)
3577
                                {
3578
                                    control.IsCompleted = true;
3579
                                }
3580

    
3581
                                if (!control.IsCompleted)
3582
                                {
3583
                                    control.PointSet.Add(control.EndPoint);
3584
                                }
3585
                                else
3586
                                {
3587
                                    //20180906 LJY TEST IsRotationDrawingEnable
3588
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3589
                                    {
3590
                                        return;
3591
                                    }
3592

    
3593
                                    CreateCommand.Instance.Execute(currentControl);
3594

    
3595
                                    control.isTransOn = true;
3596
                                    var firstPoint = control.PointSet.First();
3597

    
3598
                                    control.PointSet.Add(firstPoint);
3599
                                    control.DrawingCloud();
3600
                                    control.ApplyOverViewData();
3601

    
3602
                                    currentControl = null;
3603
                                }
3604
                            }
3605
                            else
3606
                            {
3607
                                if (e.LeftButton == MouseButtonState.Pressed)
3608
                                {
3609
                                    currentControl = new CloudControl
3610
                                    {
3611
                                        PointSet = new List<Point>(),
3612
                                        PointC = new StylusPointSet()
3613
                                    };
3614

    
3615
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3616
                                    //{
3617
                                    var polygonControl = (currentControl as CloudControl);
3618
                                    currentControl.CommentID = Commons.shortGuid();
3619
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3620
                                    currentControl.IsNew = true;
3621
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3622

    
3623
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3624
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3625

    
3626
                                    //}
3627
                                }
3628
                            }
3629
                        }
3630
                        break;
3631

    
3632
                    case ControlType.ImgControl:
3633
                        {
3634
                            if (e.LeftButton == MouseButtonState.Pressed)
3635
                            {
3636
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3637
                                //{
3638
                                if (currentControl is ImgControl)
3639
                                {
3640
                                    //20180906 LJY TEST IsRotationDrawingEnable
3641
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3642
                                    {
3643
                                        return;
3644
                                    }
3645

    
3646
                                    CreateCommand.Instance.Execute(currentControl);
3647
                                    controlType = ControlType.ImgControl;
3648
                                    currentControl = null;
3649
                                }
3650
                                else
3651
                                {
3652
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3653
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3654
                                    {
3655
                                        Image img = new Image();
3656
                                        if (filename.Contains(".svg"))
3657
                                        {
3658
                                            byte[] imageData = null;
3659
                                            DrawingImage image = null;
3660
                                            using (System.Net.WebClient web = new System.Net.WebClient())
3661
                                            {
3662
                                                imageData = web.DownloadData(new Uri(filename));
3663
                                                System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3664
                                                image = SvgReader.Load(stream);
3665
                                            }
3666
                                            img.Source = image;
3667
                                        }
3668
                                        else
3669
                                        {
3670
                                            img.Source = new BitmapImage(new Uri(filename));
3671
                                        }
3672

    
3673
                                        currentControl = new ImgControl
3674
                                        {
3675
                                            Background = new SolidColorBrush(Colors.Black),
3676
                                            PointSet = new List<Point>(),
3677
                                            FilePath = filename,
3678
                                            ImageData = img.Source,
3679
                                            StartPoint = CanvasDrawingMouseDownPoint,
3680
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3681
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3682
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3683
                                            ControlType = ControlType.ImgControl
3684
                                        };
3685

    
3686
                                        currentControl.CommentID = Commons.shortGuid();
3687
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3688
                                        currentControl.IsNew = true;
3689
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3690

    
3691
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3692
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3693
                                    }
3694
                                }
3695
                                //}
3696
                            }
3697
                        }
3698
                        break;
3699

    
3700
                    case ControlType.Date:
3701
                        {
3702
                            if (e.LeftButton == MouseButtonState.Pressed)
3703
                            {
3704
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3705
                                //{
3706
                                if (currentControl is DateControl)
3707
                                {
3708
                                    //20180906 LJY TEST IsRotationDrawingEnable
3709
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3710
                                    {
3711
                                        return;
3712
                                    }
3713

    
3714
                                    CreateCommand.Instance.Execute(currentControl);
3715
                                    currentControl = null;
3716

    
3717
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3718
                                    {
3719
                                        controlType = ControlType.None;
3720
                                        IsSwingMode = false;
3721
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3722
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3723
                                        mouseHandlingMode = MouseHandlingMode.None;
3724
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3725
                                        txtBatch.Visibility = Visibility.Collapsed;
3726
                                    }
3727
                                }
3728
                                else
3729
                                {
3730
                                    currentControl = new DateControl
3731
                                    {
3732
                                        StartPoint = CanvasDrawingMouseDownPoint,
3733
                                        Background = new SolidColorBrush(Colors.Black)
3734
                                    };
3735
                                    currentControl.CommentID = Commons.shortGuid();
3736
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3737
                                    currentControl.IsNew = true;
3738
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3739

    
3740
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3741
                                    if (currentControl is ImgControl)
3742
                                    {
3743
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3744
                                    }
3745
                                }
3746
                                //}
3747
                            }
3748
                        }
3749
                        break;
3750

    
3751
                    case ControlType.TextControl:
3752
                        {
3753
                            if (e.LeftButton == MouseButtonState.Pressed)
3754
                            {
3755
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3756
                                {
3757
                                    currentControl = new TextControl
3758
                                    {
3759
                                        ControlType = controlType
3760
                                    };
3761
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3762
                                    currentControl.CommentID = Commons.shortGuid();
3763
                                    currentControl.IsNew = true;
3764
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3765
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3766
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3767

    
3768
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3769
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3770

    
3771
                                    (currentControl as TextControl).ControlType_No = 0;
3772
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3773
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3774
                                    (currentControl as TextControl).ApplyTemplate();
3775
                                    (currentControl as TextControl).Base_TextBox.Focus();
3776
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3777
                                    CreateCommand.Instance.Execute(currentControl);
3778
                                }
3779
                            }
3780
                        }
3781
                        break;
3782

    
3783
                    case ControlType.TextBorder:
3784
                        {
3785
                            if (e.LeftButton == MouseButtonState.Pressed)
3786
                            {
3787
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3788
                                {
3789
                                    currentControl = new TextControl
3790
                                    {
3791
                                        ControlType = controlType
3792
                                    };
3793

    
3794
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3795
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3796
                                    currentControl.CommentID = Commons.shortGuid();
3797
                                    currentControl.IsNew = true;
3798
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3799
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3800
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3801
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3802

    
3803
                                    (currentControl as TextControl).ControlType_No = 1;
3804
                                    (currentControl as TextControl).CommentAngle = Ang;
3805
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3806
                                    (currentControl as TextControl).ApplyTemplate();
3807
                                    (currentControl as TextControl).Base_TextBox.Focus();
3808
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3809
                                    CreateCommand.Instance.Execute(currentControl);
3810
                                }
3811
                            }
3812
                        }
3813
                        break;
3814

    
3815
                    case ControlType.TextCloud:
3816
                        {
3817
                            if (e.LeftButton == MouseButtonState.Pressed)
3818
                            {
3819
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3820
                                {
3821
                                    currentControl = new TextControl
3822
                                    {
3823
                                        ControlType = controlType
3824
                                    };
3825

    
3826
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3827
                                    currentControl.CommentID = Commons.shortGuid();
3828
                                    currentControl.IsNew = true;
3829
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3830
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3831

    
3832
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3833
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3834
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3835

    
3836
                                    (currentControl as TextControl).CommentAngle = Ang;
3837
                                    (currentControl as TextControl).ControlType_No = 2;
3838
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3839
                                    (currentControl as TextControl).ApplyTemplate();
3840
                                    (currentControl as TextControl).Base_TextBox.Focus();
3841
                                    CreateCommand.Instance.Execute(currentControl);
3842
                                    (currentControl as TextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3843
                                    //currentControl = null;
3844
                                }
3845
                            }
3846
                        }
3847
                        break;
3848

    
3849
                    case ControlType.ArrowTextControl:
3850
                        {
3851
                            if (e.LeftButton == MouseButtonState.Pressed)
3852
                            {
3853
                                if (currentControl is ArrowTextControl)
3854
                                {
3855
                                    //20180906 LJY TEST IsRotationDrawingEnable
3856
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3857
                                    {
3858
                                        return;
3859
                                    }
3860

    
3861
                                    CreateCommand.Instance.Execute(currentControl);
3862

    
3863
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3864
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3865
                                    (currentControl as ArrowTextControl).IsNew = false;
3866
                                    currentControl = null;
3867
                                }
3868
                                else
3869
                                {
3870
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3871
                                    //{
3872
                                    currentControl = new ArrowTextControl();
3873
                                    currentControl.CommentID = Commons.shortGuid();
3874
                                    currentControl.IsNew = true;
3875
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3876
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3877

    
3878
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3879
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3880
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3881
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3882
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3883

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

    
3887
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3888
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3889
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3890
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3891

    
3892
                                    //}
3893
                                }
3894
                            }
3895
                        }
3896
                        break;
3897

    
3898
                    case ControlType.ArrowTransTextControl:
3899
                        {
3900
                            if (e.LeftButton == MouseButtonState.Pressed)
3901
                            {
3902
                                if (currentControl is ArrowTextControl)
3903
                                {
3904
                                    //20180906 LJY TEST IsRotationDrawingEnable
3905
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3906
                                    {
3907
                                        return;
3908
                                    }
3909

    
3910
                                    CreateCommand.Instance.Execute(currentControl);
3911

    
3912
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3913

    
3914
                                    currentControl.IsNew = false;
3915
                                    currentControl = null;
3916
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3917
                                }
3918
                                else
3919
                                {
3920
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3921
                                    //{
3922
                                    currentControl = new ArrowTextControl()
3923
                                    {
3924
                                        ControlType = ControlType.ArrowTransTextControl
3925
                                    };
3926
                                    currentControl.CommentID = Commons.shortGuid();
3927
                                    currentControl.IsNew = true;
3928
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3929
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3930
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3931
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3932
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3933
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3934
                                    (currentControl as ArrowTextControl).isFixed = true;
3935
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3936

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

    
3940
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3941
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3942
                                    (currentControl as ArrowTextControl).isTrans = true;
3943
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3944
                                }
3945
                            }
3946
                        }
3947
                        break;
3948

    
3949
                    case ControlType.ArrowTextBorderControl:
3950
                        {
3951
                            if (e.LeftButton == MouseButtonState.Pressed)
3952
                            {
3953
                                if (currentControl is ArrowTextControl)
3954
                                {
3955
                                    //20180906 LJY TEST IsRotationDrawingEnable
3956
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3957
                                    {
3958
                                        return;
3959
                                    }
3960

    
3961
                                    CreateCommand.Instance.Execute(currentControl);
3962
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3963
                                    currentControl.IsNew = false;
3964
                                    currentControl = null;
3965
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3966
                                }
3967
                                else
3968
                                {
3969
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3970
                                    //{
3971
                                    currentControl = new ArrowTextControl()
3972
                                    {
3973
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3974
                                    };
3975
                                    currentControl.CommentID = Commons.shortGuid();
3976
                                    currentControl.IsNew = true;
3977
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3978
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3979

    
3980
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3981

    
3982
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3983

    
3984
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3985
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3986
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3987
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
3988
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3989
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
3990
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3991
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3992
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3993
                                    //}
3994
                                }
3995
                            }
3996
                        }
3997
                        break;
3998

    
3999
                    case ControlType.ArrowTransTextBorderControl:
4000
                        {
4001
                            if (e.LeftButton == MouseButtonState.Pressed)
4002
                            {
4003
                                if (currentControl is ArrowTextControl)
4004
                                {
4005
                                    //20180906 LJY TEST IsRotationDrawingEnable
4006
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4007
                                    {
4008
                                        return;
4009
                                    }
4010
                                    CreateCommand.Instance.Execute(currentControl);
4011
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4012
                                    currentControl.IsNew = false;
4013
                                    currentControl = null;
4014

    
4015
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4016
                                }
4017
                                else
4018
                                {
4019
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4020
                                    //{
4021
                                    currentControl = new ArrowTextControl()
4022
                                    {
4023
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4024
                                        ControlType = ControlType.ArrowTransTextBorderControl
4025
                                    };
4026
                                    currentControl.CommentID = Commons.shortGuid();
4027
                                    currentControl.IsNew = true;
4028
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4029
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4030

    
4031
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4032

    
4033
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4034
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4035
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4036
                                    (currentControl as ArrowTextControl).isFixed = true;
4037
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4038

    
4039
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4040
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4041
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4042
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4043
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4044
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4045

    
4046
                                    //20180911 LJY
4047
                                    (currentControl as ArrowTextControl).isTrans = true;
4048

    
4049
                                    //}
4050
                                }
4051
                            }
4052
                        }
4053
                        break;
4054

    
4055
                    case ControlType.ArrowTextCloudControl:
4056
                        {
4057
                            if (e.LeftButton == MouseButtonState.Pressed)
4058
                            {
4059
                                if (currentControl is ArrowTextControl)
4060
                                {
4061
                                    //20180906 LJY TEST IsRotationDrawingEnable
4062
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4063
                                    {
4064
                                        return;
4065
                                    }
4066
                                    CreateCommand.Instance.Execute(currentControl);
4067
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4068
                                    currentControl.IsNew = false;
4069
                                    currentControl = null;
4070
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4071
                                }
4072
                                else
4073
                                {
4074
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4075
                                    //{
4076
                                    currentControl = new ArrowTextControl()
4077
                                    {
4078
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
4079
                                    };
4080
                                    currentControl.CommentID = Commons.shortGuid();
4081
                                    currentControl.IsNew = true;
4082
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4083
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4084

    
4085
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4086
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4087
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4088
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4089
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4090
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4091
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4092
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4093

    
4094
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4095
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4096
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4097
                                    //}
4098
                                }
4099
                            }
4100
                        }
4101
                        break;
4102

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

    
4135
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4136
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4137
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4138
                                    (currentControl as ArrowTextControl).isFixed = true;
4139
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4140

    
4141
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4142
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4143
                                    (currentControl as ArrowTextControl).SetFontFamily(new FontFamily(this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.Text));
4144
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4145
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4146
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4147

    
4148
                                    //20180911 LJY
4149
                                    (currentControl as ArrowTextControl).isTrans = true;
4150
                                    //}
4151
                                }
4152
                            }
4153
                        }
4154
                        break;
4155
                    //강인구 추가
4156
                    case ControlType.Sign:
4157
                        {
4158
                            if (e.LeftButton == MouseButtonState.Pressed)
4159
                            {
4160
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4161
                                //{
4162
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4163

    
4164
                                if (_sign == null)
4165
                                {
4166
                                    txtBatch.Visibility = Visibility.Collapsed;
4167
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4168
                                    controlType = ControlType.None;
4169

    
4170
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4171
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4172
                                    return;
4173
                                }
4174

    
4175
                                if (currentControl is SignControl)
4176
                                {
4177
                                    //20180906 LJY TEST IsRotationDrawingEnable
4178
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4179
                                    {
4180
                                        return;
4181
                                    }
4182

    
4183
                                    CreateCommand.Instance.Execute(currentControl);
4184
                                    currentControl = null;
4185
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4186
                                    {
4187
                                        txtBatch.Text = "Place Date";
4188
                                        controlType = ControlType.Date;
4189
                                    }
4190
                                }
4191
                                else
4192
                                {
4193
                                    currentControl = new SignControl
4194
                                    {
4195
                                        Background = new SolidColorBrush(Colors.Black),
4196
                                        UserNumber = App.ViewInfo.UserID,
4197
                                        ProjectNO = App.ViewInfo.ProjectNO,
4198
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4199
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4200
                                        ControlType = ControlType.Sign
4201
                                    };
4202

    
4203
                                    currentControl.CommentID = Commons.shortGuid();
4204
                                    currentControl.IsNew = true;
4205
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4206
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4207

    
4208
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4209
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4210
                                }
4211
                                //}
4212
                            }
4213
                        }
4214
                        break;
4215

    
4216
                    case ControlType.Mark:
4217
                        {
4218
                            if (e.LeftButton == MouseButtonState.Pressed)
4219
                            {
4220
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4221
                                //{
4222
                                if (currentControl is RectangleControl)
4223
                                {
4224
                                    //20180906 LJY TEST IsRotationDrawingEnable
4225
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4226
                                    {
4227
                                        return;
4228
                                    }
4229

    
4230
                                    CreateCommand.Instance.Execute(currentControl);
4231
                                    (currentControl as RectangleControl).ApplyOverViewData();
4232
                                    currentControl = null;
4233

    
4234
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4235

    
4236
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4237
                                    {
4238
                                        txtBatch.Text = "Place Signature";
4239
                                        controlType = ControlType.Sign;
4240
                                    }
4241
                                }
4242
                                else
4243
                                {
4244
                                    currentControl = new RectangleControl
4245
                                    {
4246
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4247
                                        Background = new SolidColorBrush(Colors.Black),
4248
                                        ControlType = ControlType.Mark,
4249
                                        Paint = PaintSet.Fill
4250
                                    };
4251

    
4252
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4253
                                    currentControl.CommentID = Commons.shortGuid();
4254
                                    currentControl.IsNew = true;
4255
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4256
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4257
                                }
4258
                                //}
4259
                            }
4260
                        }
4261
                        break;
4262

    
4263
                    case ControlType.Symbol:
4264
                        {
4265
                            if (e.LeftButton == MouseButtonState.Pressed)
4266
                            {
4267
                                if (currentControl is SymControl)
4268
                                {
4269
                                    //20180906 LJY TEST IsRotationDrawingEnable
4270
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4271
                                    {
4272
                                        return;
4273
                                    }
4274
                                    CreateCommand.Instance.Execute(currentControl);
4275
                                    currentControl = null;
4276

    
4277
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4278
                                }
4279
                                else
4280
                                {
4281
                                    currentControl = new SymControl
4282
                                    {
4283
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4284
                                        Background = new SolidColorBrush(Colors.Black),
4285
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4286
                                        ControlType = ControlType.Symbol
4287
                                    };
4288

    
4289
                                    currentControl.IsNew = true;
4290
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4291
                                    currentControl.CommentID = Commons.shortGuid();
4292
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4293

    
4294
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4295
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4296
                                }
4297
                                //}
4298
                            }
4299
                        }
4300
                        break;
4301

    
4302
                    case ControlType.Stamp:
4303
                        {
4304
                            if (e.LeftButton == MouseButtonState.Pressed)
4305
                            {
4306
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4307
                                //{
4308
                                if (currentControl is SymControlN)
4309
                                {
4310
                                    //20180906 LJY TEST IsRotationDrawingEnable
4311
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4312
                                    {
4313
                                        return;
4314
                                    }
4315

    
4316
                                    CreateCommand.Instance.Execute(currentControl);
4317
                                    currentControl = null;
4318

    
4319
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4320
                                }
4321
                                else
4322
                                {
4323
                                    currentControl = new SymControlN
4324
                                    {
4325
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4326
                                        Background = new SolidColorBrush(Colors.Black),
4327
                                        STAMP = App.SystemInfo.STAMP,
4328
                                        ControlType = ControlType.Stamp
4329
                                    };
4330

    
4331
                                    currentControl.IsNew = true;
4332
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4333
                                    currentControl.CommentID = Commons.shortGuid();
4334
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4335
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4336
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4337
                                }
4338
                                //}
4339
                            }
4340
                        }
4341
                        break;
4342

    
4343
                    case ControlType.PenControl:
4344
                        {
4345
                            if (inkBoard.Tag.ToString() == "Ink")
4346
                            {
4347
                                inkBoard.IsEnabled = true;
4348
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4349
                            }
4350
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4351
                            {
4352
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4353
                            }
4354
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4355
                            {
4356
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4357
                            }
4358
                            IsDrawing = true;
4359
                            return;
4360
                        }
4361
                    default:
4362
                        if (currentControl != null)
4363
                        {
4364
                            currentControl.CommentID = null;
4365
                            currentControl.IsNew = false;
4366
                        }
4367
                        break;
4368
                }
4369

    
4370
                if (currentControl != null)
4371
                {
4372
                    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4373
                }
4374
            }
4375
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4376
            {
4377
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4378
                {
4379
                    bool mouseOff = false;
4380
                    foreach (var item in SelectLayer.Children)
4381
                    {
4382
                        if (item is AdornerFinal)
4383
                        {
4384
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4385
                            if (over != null)
4386
                            {
4387
                                mouseOff = true;
4388
                            }
4389
                        }
4390
                    }
4391

    
4392
                    if (!mouseOff)
4393
                    {
4394
                        SelectionSet.Instance.UnSelect(this);
4395
                    }
4396
                }
4397
                zoomAndPanControl.CaptureMouse();
4398
                e.Handled = true;
4399
            }
4400
        }
4401

    
4402
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4403
        {
4404
            ///mouseButtonDown = e.ChangedButton;
4405
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4406
        }
4407

    
4408
        private void RemoveLineStroke(Point P)
4409
        {
4410
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4411
            if (control != null)
4412
            {
4413
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4414
            }
4415
        }
4416

    
4417
        private void RemovePointStroke(Point P)
4418
        {
4419
            foreach (Stroke hits in inkBoard.Strokes)
4420
            {
4421
                foreach (StylusPoint sty in hits.StylusPoints)
4422
                {
4423
                }
4424
                if (hits.HitTest(P))
4425
                {
4426
                    inkBoard.Strokes.Remove(hits);
4427
                    return;
4428
                }
4429
            }
4430
        }
4431

    
4432
        private void StartNewStroke(Point P)
4433
        {
4434
            strokePoints = new StylusPointCollection();
4435
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4436
            strokePoints.Add(segment1Start);
4437
            stroke = new Stroke(strokePoints);
4438

    
4439
            stroke.DrawingAttributes.Color = Colors.Red;
4440
            stroke.DrawingAttributes.Width = 4;
4441
            stroke.DrawingAttributes.Height = 4;
4442

    
4443
            inkBoard.Strokes.Add(stroke);
4444
        }
4445

    
4446
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4447
        {
4448
            ConsolidationMethod();
4449
        }
4450

    
4451
        /// <summary>
4452
        /// execute TeamConsolidationCommand
4453
        /// </summary>
4454
        public void TeamConsolidationMethod()
4455
        {
4456
            this.UpdateMyMarkupList();
4457
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4458
            {
4459
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4460
            }
4461
            else
4462
            {
4463
                ViewerDataModel.Instance.IsConsolidate = true;
4464
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4465

    
4466
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4467
                {
4468
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4469
                    {
4470
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4471
                        return;
4472
                    }
4473
                }
4474
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4475
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4476
                {
4477
                    MarkupInfoList.Add(item);
4478
                }
4479
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4480
            }
4481
        }
4482

    
4483
        public void ConsolidationMethod()
4484
        {
4485
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4486
            {
4487
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4488
            }
4489
            else
4490
            {
4491
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4492
                foreach (var item in this.gridViewMarkup.SelectedItems)
4493
                {
4494
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4495
                }
4496
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4497

    
4498
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4499
            }
4500
        }
4501

    
4502
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4503
        {
4504
            if (App.ViewInfo != null)
4505
            {
4506
                btnConsolidate = (sender as RadRibbonButton);
4507
                if (!App.ViewInfo.NewCommentPermission)
4508
                {
4509
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4510
                }
4511
            }
4512
        }
4513

    
4514
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4515
        {
4516
            TeamConsolidationMethod();
4517
        }
4518

    
4519
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4520
        {
4521
            btnTeamConsolidate = sender as RadRibbonButton;
4522
            if (App.ViewInfo != null)
4523
            {
4524
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4525
                {
4526
                    if (btnConsolidate != null)
4527
                    {
4528
                        btnConsolidate.Visibility = Visibility.Collapsed;
4529
                    }
4530

    
4531
                    if (!App.ViewInfo.NewCommentPermission)
4532
                    {
4533
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4534
                    }
4535
                }
4536
                else
4537
                {
4538
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4539
                }
4540
            }
4541
        }
4542

    
4543
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4544
        {
4545
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4546
            if (item != null)
4547
            {
4548
                if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4549
                {
4550
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4551
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4552
                }
4553
                else
4554
                {
4555
                    DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4556
                }
4557
            }
4558
            else
4559
            {
4560
                //Consolidate 가 없는 경우
4561
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4562
            }
4563
        }
4564

    
4565
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4566
        {
4567
            btnFinalPDF = sender as RadRibbonButton;
4568
            if (App.ViewInfo != null)
4569
            {
4570
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4571
                {
4572
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4573
                    if (btnConsolidate != null)
4574
                    {
4575
                        btnConsolidate.Visibility = Visibility.Collapsed;
4576
                    }
4577
                }
4578
            }
4579
        }
4580

    
4581
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4582
        {
4583
            UpdateMyMarkupList();
4584

    
4585
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4586
            {
4587
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4588
            }
4589
            else
4590
            {
4591
                ViewerDataModel.Instance.IsConsolidate = true;
4592
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4593
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4594

    
4595
                string project_no = App.ViewInfo.ProjectNO;
4596
                string doc_id = _DocInfo.ID;
4597
                string user_id = App.ViewInfo.UserID;
4598
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4599
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4600
                {
4601
                    markupInfoItems.Add(item);
4602
                }
4603
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4604
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4605
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4606
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4607

    
4608
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4609
                if (item2 != null)
4610
                {
4611
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4612

    
4613
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4614
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4615
                }
4616
                else
4617
                {
4618
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4619
                }
4620
            }
4621
        }
4622

    
4623
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4624
        {
4625
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4626
#if Hyosung
4627
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4628
#else
4629
            if (App.ViewInfo != null)
4630
            {
4631
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4632
                {
4633
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4634
                }
4635
            }
4636
#endif
4637
        }
4638

    
4639
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4640
        {
4641
            SetCompareRect();
4642
        }
4643

    
4644
        private void Sync_Click(object sender, RoutedEventArgs e)
4645
        {
4646
            if (Sync.IsChecked)
4647
            {
4648
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4649
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4650
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4651
            }
4652
        }
4653

    
4654
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4655
        {
4656
            if (UserList.IsChecked)
4657
            {
4658
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4659
            }
4660
            else
4661
            {
4662
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4663
            }
4664
        }
4665

    
4666
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4667
        {
4668
            if (BalanceMode.IsChecked)
4669
            {
4670
                ViewerDataModel.Instance.PageBalanceMode = true;
4671
            }
4672
            else
4673
            {
4674
                ViewerDataModel.Instance.PageBalanceMode = false;
4675
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4676
            }
4677
        }
4678

    
4679
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4680
        {
4681
            //초기화
4682
            testPanel2.IsHidden = true;
4683
            ViewerDataModel.Instance.PageBalanceMode = false;
4684
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4685
            ViewerDataModel.Instance.PageNumber = 0;
4686
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4687
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4688
            UserList.IsChecked = false;
4689
            BalanceMode.IsChecked = false;
4690
        }
4691

    
4692
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4693
        {
4694
            if ((sender as System.Windows.Controls.Control).Tag != null)
4695
            {
4696
                //Compare 초기화
4697
                CompareMode.IsChecked = false;
4698
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4699

    
4700
                if (ViewerDataModel.Instance.PageNumber == 0)
4701
                {
4702
                    ViewerDataModel.Instance.PageNumber = 1;
4703
                }
4704

    
4705
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4706
                {
4707
                }
4708
                else
4709
                {
4710
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4711
                }
4712

    
4713
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4714
                {
4715
                }
4716
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4717
                {
4718
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4719
                }
4720

    
4721
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4722

    
4723
                if (!testPanel2.IsHidden)
4724
                {
4725
                    if (IsSyncPDFMode)
4726
                    {
4727
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4728
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4729

    
4730
                        if (pdfpath.IsDownloading)
4731
                        {
4732
                            pdfpath.DownloadCompleted += (ex, arg) =>
4733
                            {
4734
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4735
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4736
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4737
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4738
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4739
                            };
4740
                        }
4741
                        else
4742
                        {
4743
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4744
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4745
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4746

    
4747
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4748
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4749
                        }
4750
                    }
4751
                    else
4752
                    {
4753
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4754

    
4755
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4756

    
4757
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4758
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4759
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4760

    
4761
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4762
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4763

    
4764
                        if (defaultBitmapImage_Compare.IsDownloading)
4765
                        {
4766
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4767
                            {
4768
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4769
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4770
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4771

    
4772
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4773
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4774
                            };
4775
                        }
4776
                    }
4777

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

    
4782
                    foreach (var item in gridSelectionRevItem)
4783
                    {
4784
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList();
4785
                        foreach (var markupitem in markupitems)
4786
                        {
4787
                            await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4788
                        }
4789
                    }
4790

    
4791
                    //강인구 추가
4792
                    zoomAndPanControl2.ZoomTo(new Rect
4793
                    {
4794
                        X = 0,
4795
                        Y = 0,
4796
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4797
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4798
                    });
4799

    
4800
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4801
                }
4802
            }
4803
        }
4804

    
4805
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4806
        {
4807
            if (MarkupMode.IsChecked)
4808
            {
4809
                IsSyncPDFMode = true;
4810

    
4811
                var uri = CurrentRev.TO_VENDOR;
4812

    
4813
                if (ViewerDataModel.Instance.PageNumber == 0)
4814
                {
4815
                    ViewerDataModel.Instance.PageNumber = 1;
4816
                }
4817

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

    
4822
                if (pdfpath.IsDownloading)
4823
                {
4824
                    pdfpath.DownloadCompleted += (ex, arg) =>
4825
                    {
4826
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4827
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4828
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4829
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4830
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4831
                    };
4832
                }
4833
                else
4834
                {
4835
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4836
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4837
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4838

    
4839
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4840
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4841
                }
4842
            }
4843
            else
4844
            {
4845
                IsSyncPDFMode = false;
4846
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4847

    
4848
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4849

    
4850
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4851
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4852
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4853

    
4854
                if (defaultBitmapImage_Compare.IsDownloading)
4855
                {
4856
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4857
                    {
4858
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4859
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4860
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4861
                    };
4862
                }
4863
                zoomAndPanControl2.ApplyTemplate();
4864
                zoomAndPanControl2.UpdateLayout();
4865
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4866
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4867
            }
4868
        }
4869

    
4870
        /// <summary>
4871
        /// Compare된 영역을 초기화
4872
        /// </summary>
4873
        private void ClearCompareRect()
4874
        {
4875
            da.From = 1;
4876
            da.To = 1;
4877
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4878
            da.AutoReverse = false;
4879
            canvas_compareBorder.Children.Clear();
4880
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4881
        }
4882

    
4883
        /// <summary>
4884
        /// 문서 Comprare
4885
        /// </summary>
4886
        private void SetCompareRect()
4887
        {
4888
            if (CompareMode.IsChecked)
4889
            {
4890
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4891
                {
4892
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4893
                }
4894
                if (ViewerDataModel.Instance.PageNumber == 0)
4895
                {
4896
                    ViewerDataModel.Instance.PageNumber = 1;
4897
                }
4898

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

    
4903
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4904
            }
4905
            else
4906
            {
4907
                ClearCompareRect();
4908
            }
4909
        }
4910

    
4911
        private void RadButton_Click(object sender, RoutedEventArgs e)
4912
        {
4913
            gridViewHistory_Busy.IsBusy = true;
4914

    
4915
            RadButton instance = sender as RadButton;
4916
            if (instance.CommandParameter != null)
4917
            {
4918
                CurrentRev = instance.CommandParameter as VPRevision;
4919
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
4920

    
4921
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4922
                {
4923
                    if (ea.Error == null && ea.Result != null)
4924
                    {
4925
                        testPanel2.IsHidden = false;
4926

    
4927
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4928
                        foreach (var info in ea.Result)
4929
                        {
4930
                            if (info.UserID == App.ViewInfo.UserID)
4931
                            {
4932
                                info.userDelete = true;
4933
                                info.DisplayColor = "FFFF0000";
4934
                            }
4935
                            else
4936
                            {
4937
                                info.userDelete = false;
4938
                            }
4939
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4940
                        }
4941
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4942

    
4943
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4944

    
4945
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4946

    
4947
                        var defaultBitmapImage_Compare = ImageSourceHelper.GetDownloadImage(uri);
4948
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4949
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4950
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4951
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4952
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4953

    
4954
                        zoomAndPanControl2.ApplyTemplate();
4955
                        zoomAndPanControl2.UpdateLayout();
4956
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4957
                        {
4958
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4959
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4960
                        }
4961

    
4962
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4963
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4964
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4965

    
4966
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4967
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4968
                        gridViewHistory_Busy.IsBusy = false;
4969
                    }
4970

    
4971
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4972

    
4973
                    if (GetSyncMarkupInfoItemshandler != null)
4974
                    {
4975
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4976
                    }
4977

    
4978
                    ClearCompareRect();
4979
                    SetCompareRect();
4980
                };
4981

    
4982
                /// 중복 실행이 발생하여 수정함.
4983
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
4984
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4985

    
4986
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4987
            }
4988
        }
4989

    
4990
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4991
        {
4992
            try
4993
            {
4994
                if (sender is RadButton)
4995
                {
4996
                    if ((sender as RadButton).Tag != null)
4997
                    {
4998
                        var url = (sender as RadButton).Tag.ToString();
4999
                        System.Diagnostics.Process.Start(url);
5000
                    }
5001
                    else
5002
                    {
5003
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5004
                    }
5005
                }
5006
            }
5007
            catch (Exception ex)
5008
            {
5009
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5010
            }
5011
        }
5012

    
5013
        public void Sync_Event(VPRevision Currnet_Rev)
5014
        {
5015
            CurrentRev = Currnet_Rev;
5016

    
5017
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5018
            {
5019
                if (ea.Error == null && ea.Result != null)
5020
                {
5021
                    testPanel2.IsHidden = false;
5022

    
5023
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5024
                    foreach (var info in ea.Result)
5025
                    {
5026
                        if (info.UserID == App.ViewInfo.UserID)
5027
                        {
5028
                            info.userDelete = true;
5029
                            info.DisplayColor = "FFFF0000";
5030
                        }
5031
                        else
5032
                        {
5033
                            info.userDelete = false;
5034
                        }
5035
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5036
                    }
5037
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5038

    
5039
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5040

    
5041
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5042

    
5043
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5044

    
5045
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5046
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5047
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5048

    
5049
                    if (defaultBitmapImage_Compare.IsDownloading)
5050
                    {
5051
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
5052
                        {
5053
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5054
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5055
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5056
                        };
5057
                    }
5058

    
5059
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5060
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5061
                    zoomAndPanControl2.ApplyTemplate();
5062
                    zoomAndPanControl2.UpdateLayout();
5063

    
5064
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5065
                    {
5066
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5067
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5068
                    }
5069
                    //}
5070

    
5071
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5072
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5073
                    gridViewHistory_Busy.IsBusy = false;
5074
                }
5075
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5076
            };
5077
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5078
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5079
        }
5080

    
5081
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5082
        {
5083
            if (sender is Image)
5084
            {
5085
                if ((sender as Image).Tag != null)
5086
                {
5087
                    var pdfUrl = (sender as Image).Tag.ToString();
5088
                    System.Diagnostics.Process.Start(pdfUrl);
5089
                }
5090
                else
5091
                {
5092
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5093
                }
5094
            }
5095
        }
5096

    
5097
        private void Create_Symbol(object sender, RoutedEventArgs e)
5098
        {
5099
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5100

    
5101
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5102
            {
5103
                DialogMessage_Alert("Please Select Controls", "Alert");
5104
            }
5105
            else //선택된 것이 있으면
5106
            {
5107
                string MarkupData = "";
5108
                adorner_ = new AdornerFinal();
5109

    
5110
                foreach (var item in SelectLayer.Children)
5111
                {
5112
                    if (item.GetType().Name == "AdornerFinal")
5113
                    {
5114
                        adorner_ = (item as Controls.AdornerFinal);
5115
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5116
                        {
5117
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5118
                            {
5119
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5120
                                MarkupData += markupReturn.ConvertData;
5121
                            }
5122
                        }
5123
                    }
5124
                }
5125
                DialogParameters parameters = new DialogParameters()
5126
                {
5127
                    Owner = Application.Current.MainWindow,
5128
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5129
                    DefaultPromptResultValue = "Custom State",
5130
                    Content = "Name :",
5131
                    Header = "Insert Custom Symbol Name",
5132
                    Theme = new VisualStudio2013Theme(),
5133
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5134
                };
5135
                RadWindow.Prompt(parameters);
5136
            }
5137
        }
5138

    
5139
        public int symbolselectindex = 0;
5140

    
5141
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5142
        {
5143
            //Save save = new Save();
5144
            try
5145
            {
5146
                string svgfilename = null;
5147
                if (symbolname != null)
5148
                {
5149
                    if (symbolpng == true || symbolsvg == true)
5150
                    {
5151
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5152
                        string guid = Commons.shortGuid();
5153

    
5154
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5155
                        //Check_Uri.UriCheck();
5156
                        fileUploader.RunCompleted += (ex, arg) =>
5157
                        {
5158
                            filename = arg.Result;
5159
                            if (symbolpng == true)
5160
                            {
5161
                                if (filename != null)
5162
                                {
5163
                                    if (symbolselectindex == 0)
5164
                                    {
5165
                                        SymbolSave(symbolname, filename, data);
5166
                                    }
5167
                                    else
5168
                                    {
5169
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5170
                                    }
5171
                                    DataBind();
5172
                                }
5173
                            }
5174

    
5175
                            if (symbolsvg == true)
5176
                            {
5177
                                try
5178
                                {
5179
                                    var defaultBitmapImage = new BitmapImage();
5180
                                    defaultBitmapImage.BeginInit();
5181
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5182
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5183
                                    Check_Uri.UriCheck(filename);
5184
                                    defaultBitmapImage.UriSource = new Uri(filename);
5185
                                    defaultBitmapImage.EndInit();
5186

    
5187
                                    System.Drawing.Bitmap image;
5188

    
5189
                                    if (defaultBitmapImage.IsDownloading)
5190
                                    {
5191
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5192
                                        {
5193
                                            defaultBitmapImage.Freeze();
5194
                                            image = GetBitmap(defaultBitmapImage);
5195
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5196
                                            Process potrace = new Process
5197
                                            {
5198
                                                StartInfo = new ProcessStartInfo
5199
                                                {
5200
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5201
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5202
                                                    RedirectStandardInput = true,
5203
                                                    RedirectStandardOutput = true,
5204
                                                    RedirectStandardError = true,
5205
                                                    UseShellExecute = false,
5206
                                                    CreateNoWindow = true,
5207
                                                    WindowStyle = ProcessWindowStyle.Hidden
5208
                                                },
5209
                                            };
5210

    
5211
                                            StringBuilder svgBuilder = new StringBuilder();
5212
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5213
                                            {
5214
                                                svgBuilder.AppendLine(e2.Data);
5215
                                            };
5216

    
5217
                                            potrace.EnableRaisingEvents = true;
5218
                                            potrace.Start();
5219
                                            potrace.Exited += (sender, e) =>
5220
                                            {
5221
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5222
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5223
                                                Check_Uri.UriCheck(svgfilename);
5224
                                                if (symbolselectindex == 0)
5225
                                                {
5226
                                                    SymbolSave(symbolname, svgfilename, data);
5227
                                                }
5228
                                                else
5229
                                                {
5230
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5231
                                                }
5232

    
5233
                                                DataBind();
5234
                                            };
5235
                                            potrace.WaitForExit();
5236
                                        };
5237
                                    }
5238
                                    else
5239
                                    {
5240
                                        //GC.Collect();
5241
                                    }
5242
                                }
5243
                                catch (Exception ee)
5244
                                {
5245
                                    DialogMessage_Alert("" + ee, "Alert");
5246
                                }
5247
                            }
5248
                        };
5249
                    }
5250
                }
5251
            }
5252
            catch (Exception e)
5253
            {
5254
                //DialogMessage_Alert(e + "", "Alert");
5255
            }
5256
        }
5257

    
5258
        public void SymbolSave(string Name, string Url, string Data)
5259
        {
5260
            try
5261
            {
5262
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5263
                {
5264
                    ID = Commons.shortGuid(),
5265
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5266
                    NAME = Name,
5267
                    IMAGE_URL = Url,
5268
                    DATA = Data
5269
                };
5270

    
5271
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5272
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5273
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5274
            }
5275
            catch (Exception)
5276
            {
5277
                throw;
5278
            }
5279
        }
5280

    
5281
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5282
        {
5283
            try
5284
            {
5285
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5286
                {
5287
                    ID = Commons.shortGuid(),
5288
                    DEPARTMENT = Department,
5289
                    NAME = Name,
5290
                    IMAGE_URL = Url,
5291
                    DATA = Data
5292
                };
5293
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5294
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5295
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5296
            }
5297
            catch (Exception)
5298
            {
5299
                throw;
5300
            }
5301
        }
5302

    
5303
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5304
        {
5305
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5306
            DataBind();
5307
        }
5308

    
5309
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5310
        {
5311
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5312
            DataBind();
5313
        }
5314

    
5315
        private void DataBind()
5316
        {
5317
            try
5318
            {
5319
                Symbol_Custom Custom = new Symbol_Custom();
5320
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5321

    
5322
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5323
                foreach (var item in symbol_Private)
5324
                {
5325
                    Custom.Name = item.NAME;
5326
                    Custom.ImageUri = item.IMAGE_URL;
5327
                    Custom.ID = item.ID;
5328
                    Custom_List.Add(Custom);
5329
                    Custom = new Symbol_Custom();
5330
                }
5331
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5332

    
5333
                Custom = new Symbol_Custom();
5334
                Custom_List = new List<Symbol_Custom>();
5335

    
5336
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5337

    
5338
                List<SYMBOL_PUBLIC> symbol_Public;
5339

    
5340
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5341
                {
5342
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5343
                }
5344
                else
5345
                {
5346
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5347
                }
5348
                foreach (var item in symbol_Public)
5349
                {
5350
                    Custom.Name = item.NAME;
5351
                    Custom.ImageUri = item.IMAGE_URL;
5352
                    Custom.ID = item.ID;
5353
                    Custom_List.Add(Custom);
5354
                    Custom = new Symbol_Custom();
5355
                }
5356
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5357
                BaseClient.Close();
5358
            }
5359
            catch (Exception e)
5360
            {
5361
                //DialogMessage_Alert("DataBind", "Alert");
5362
            }
5363
        }
5364

    
5365
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5366
        {
5367
            try
5368
            {
5369
                if (args.PromptResult != null)
5370
                {
5371
                    if (args.DialogResult.Value)
5372
                    {
5373
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5374

    
5375
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5376
                        _Encoder.Save(fs);
5377
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5378

    
5379
                        byte[] Img_byte = fs.ToArray();
5380

    
5381
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
5382
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5383
                        Check_Uri.UriCheck(filename);
5384
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5385
                        {
5386
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5387
                        }
5388
                        else
5389
                        {
5390
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5391
                        }
5392
                        DataBind();
5393
                    }
5394
                }
5395
            }
5396
            catch (Exception ex)
5397
            {
5398
                DialogMessage_Alert("" + ex, "Alert");
5399
            }
5400
        }
5401

    
5402
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5403
        {
5404
            Canvas _canvas = new Canvas();
5405
            _canvas.Background = Brushes.White;
5406
            _canvas.Width = adorner_.BorderSize.Width;
5407
            _canvas.Height = adorner_.BorderSize.Height;
5408
            await MarkupParser.ParseAsync(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
5409

    
5410
            BitmapEncoder encoder = new PngBitmapEncoder();
5411

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

    
5414
            DrawingVisual dv = new DrawingVisual();
5415

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

    
5419
            using (DrawingContext ctx = dv.RenderOpen())
5420
            {
5421
                VisualBrush vb = new VisualBrush(_canvas);
5422
                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)));
5423
            }
5424

    
5425
            try
5426
            {
5427
                renderBitmap.Render(dv);
5428

    
5429
                //GC.Collect();
5430
                GC.WaitForPendingFinalizers();
5431
                //GC.Collect();
5432
                // encode png data
5433
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5434
                // puch rendered bitmap into it
5435
                pngEncoder.Interlace = PngInterlaceOption.Off;
5436
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5437
                return pngEncoder;
5438
            }
5439
            catch //(Exception ex)
5440
            {
5441
                return null;
5442
            }
5443
        }
5444

    
5445
        public void DialogMessage_Alert(string content, string header)
5446
        {
5447
            DialogParameters parameters = new DialogParameters()
5448
            {
5449
                Owner = this.ParentOfType<MainWindow>(),
5450
                Content = new TextBlock()
5451
                {
5452
                    MinWidth = 400,
5453
                    FontSize = 11,
5454
                    Text = content,
5455
                    TextWrapping = System.Windows.TextWrapping.Wrap
5456
                },
5457
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5458
                Header = header,
5459
                Theme = new VisualStudio2013Theme(),
5460
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5461
            };
5462
            RadWindow.Alert(parameters);
5463
        }
5464

    
5465
        #region 캡쳐 기능
5466

    
5467
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5468
        {
5469
            if (x < 0)
5470
            {
5471
                width += x;
5472
                x = 0;
5473
            }
5474
            if (y < 0)
5475
            {
5476
                height += y;
5477
                y = 0;
5478

    
5479
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5480
            }
5481
            if (x + width > zoomAndPanCanvas.ActualWidth)
5482
            {
5483
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5484
            }
5485
            if (y + height > zoomAndPanCanvas.ActualHeight)
5486
            {
5487
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5488
            }
5489

    
5490
            byte[] pixels = CopyPixels(x, y, width, height);
5491

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

    
5494
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5495
        }
5496

    
5497
        public byte[] CopyPixels(int x, int y, int width, int height)
5498
        {
5499
            byte[] pixels = new byte[width * height * 4];
5500
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5501

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

    
5505
            return pixels;
5506
        }
5507

    
5508
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5509
        {
5510
            DrawingVisual drawingVisual = new DrawingVisual();
5511
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5512

    
5513
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5514
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5515
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5516
            drawingContext.Close();
5517

    
5518
            // 비트맵으로 변환합니다.
5519
            RenderTargetBitmap target =
5520
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5521
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5522

    
5523
            target.Render(drawingVisual);
5524
            return target;
5525
        }
5526

    
5527
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5528
        {
5529
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5530
            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);
5531
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5532
            bmp.UnlockBits(data);
5533
            return bmp;
5534
        }
5535

    
5536
        public string symbolname = null;
5537
        public bool symbolsvg = true;
5538
        public bool symbolpng = true;
5539

    
5540
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5541
        {
5542
            System.Drawing.Bitmap image = GetBitmap(source);
5543
            //흰색 제거
5544
            //image.MakeTransparent(System.Drawing.Color.White);
5545

    
5546
            var imageStream = new System.IO.MemoryStream();
5547
            byte[] imageBytes = null;
5548
            using (imageStream)
5549
            {
5550
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5551
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5552
                imageStream.Position = 0;
5553
                imageBytes = imageStream.ToArray();
5554
            }
5555

    
5556
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5557

    
5558
            RadWindow CheckPop = new RadWindow();
5559
            //Alert check = new Alert(Msg);
5560

    
5561
            CheckPop = new RadWindow
5562
            {
5563
                MinWidth = 400,
5564
                MinHeight = 100,
5565
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5566
                Header = "Alert",
5567
                Content = symbolPrompt,
5568
                //DialogResult =
5569
                ResizeMode = System.Windows.ResizeMode.NoResize,
5570
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5571
                IsTopmost = true,
5572
            };
5573
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5574
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5575
            CheckPop.ShowDialog();
5576

    
5577
            /*
5578
            DialogParameters parameters = new DialogParameters()
5579
            {
5580
                Owner = Application.Current.MainWindow,
5581
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5582
                DefaultPromptResultValue = "Custom State",
5583
                Content = "Name :",
5584
                Header = "Insert Custom Symbol Name",
5585
                Theme = new VisualStudio2013Theme(),
5586
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5587
            };
5588
            RadWindow.Prompt(parameters);
5589
            */
5590
        }
5591

    
5592
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5593
        {
5594
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5595
            KCOMDataModel.DataModel.CHECK_LIST check_;
5596
            string Result = streamToBase64.ImageToBase64(source);
5597
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5598
            string projectno = App.ViewInfo.ProjectNO;
5599
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5600

    
5601
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5602
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5603
            if (Item != null)
5604
            {
5605
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5606
            }
5607
            else
5608
            {
5609
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5610
            }
5611

    
5612
            if (Item == null)
5613
            {
5614
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5615
                {
5616
                    ID = Commons.shortGuid(),
5617
                    USER_ID = App.ViewInfo.UserID,
5618
                    IMAGE_URL = Result,
5619
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5620
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5621
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5622
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5623
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5624
                    STATUS = "False",
5625
                    CREATE_TIME = DateTime.Now,
5626
                    UPDATE_TIME = DateTime.Now,
5627
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5628
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5629
                };
5630
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5631
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5632
                //this.BaseClient.AddCheckList(projectno, check_);
5633
            }
5634
            else
5635
            {
5636
                Item.IMAGE_URL = Result;
5637
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5638
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5639
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5640
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5641
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5642
            }
5643
        }
5644

    
5645
        public void Set_Capture()
5646
        {
5647
            double x = CanvasDrawingMouseDownPoint.X;
5648
            double y = CanvasDrawingMouseDownPoint.Y;
5649
            double width = dragCaptureBorder.Width;
5650
            double height = dragCaptureBorder.Height;
5651

    
5652
            if (width > 5 || height > 5)
5653
            {
5654
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5655
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5656
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5657
            }
5658
        }
5659

    
5660
        #endregion 캡쳐 기능
5661

    
5662
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5663
        {
5664
            multi_Undo_Data = new Multi_Undo_data();
5665

    
5666
            multi_Undo_Data.Markup = control;
5667

    
5668
            if ((control as IShapeControl) != null)
5669
            {
5670
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5671
            }
5672
            if ((control as IDashControl) != null)
5673
            {
5674
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5675
            }
5676
            if ((control as IPath) != null)
5677
            {
5678
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5679
            }
5680
            if ((control as UIElement) != null)
5681
            {
5682
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5683
            }
5684

    
5685
            return multi_Undo_Data;
5686
        }
5687

    
5688
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
5689
        {
5690
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5691
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5692
            {
5693
                if (items.UserID == Select_ID)
5694
                {
5695
                    foreach (var item in items.MarkupList)
5696
                    {
5697
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5698
                        {
5699
                            await MarkupParser.ParseExAsync(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "",
5700
                                 items.MarkupInfoID, Commons.shortGuid());
5701
                        }
5702
                    }
5703
                }
5704
            }
5705
        }
5706

    
5707
        /// <summary>
5708
        /// convert inkcontrol to polygoncontrol
5709
        /// </summary>
5710
        public void ConvertInkControlToPolygon()
5711
        {
5712
            if (inkBoard.Strokes.Count > 0)
5713
            {
5714
                inkBoard.Strokes.ToList().ForEach(stroke =>
5715
                {
5716
                    InkToPath ip = new InkToPath();
5717

    
5718
                    List<Point> inkPointSet = new List<Point>();
5719
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5720

    
5721
                    PolygonControl pc = new PolygonControl()
5722
                    {
5723
                        CommentAngle = 0,
5724
                        PointSet = inkPointSet,
5725
                        ControlType = ControlType.Ink
5726
                    };
5727
                    pc.StartPoint = inkPointSet[0];
5728
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5729
                    pc.LineSize = 3;
5730
                    pc.CommentID = Commons.shortGuid();
5731
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5732

    
5733
                    if (pc.PointSet.Count > 0)
5734
                    {
5735
                        CreateCommand.Instance.Execute(pc);
5736
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5737
                    }
5738
                });
5739
                inkBoard.Strokes.Clear();
5740
            }
5741
        }
5742

    
5743
        /// <summary>
5744
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5745
        /// </summary>
5746
        /// <author>ingu</author>
5747
        /// <date>2018.06.05</date>
5748
        /// <param name="getPoint"></param>
5749
        /// <returns></returns>
5750
        private bool IsGetoutpoint(Point getPoint)
5751
        {
5752
            if (getPoint == new Point())
5753
            {
5754
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5755
                currentControl = null;
5756
                return true;
5757
            }
5758

    
5759
            return false;
5760
        }
5761

    
5762
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5763
        {
5764
            e.Effects = DragDropEffects.Copy;
5765
        }
5766

    
5767
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5768
        {
5769
            e.Effects = DragDropEffects.Copy;
5770
        }
5771

    
5772
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5773
        {
5774
            e.Effects = DragDropEffects.None;
5775
        }
5776

    
5777
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5778
        {
5779
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5780
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5781

    
5782
            ScaleImage(pageWidth, pageHeight);
5783
        }
5784

    
5785
        /// <summary>
5786
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
5787
        /// </summary>
5788
        /// <param name="pageWidth">원본 사이즈</param>
5789
        /// <param name="pageHeight">원본 사이즈</param>
5790
        /// <returns></returns>
5791
        private void ScaleImage(double pageWidth, double pageHeight)
5792
        {
5793
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
5794
        }
5795

    
5796
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5797
        {
5798
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5799
        }
5800

    
5801
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5802
        {
5803
            var checkbox = (sender as CheckBox);
5804

    
5805
            if (checkbox != null)
5806
            {
5807
                if (checkbox.IsChecked.GetValueOrDefault())
5808
                {
5809
                    gridViewMarkup.SelectAll();
5810
                }
5811
                else
5812
                {
5813
                    gridViewMarkup.UnselectAll();
5814
                }
5815
            }
5816
        }
5817

    
5818
        /*
5819
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5820
        {
5821
            try
5822
            {
5823
                if (e.Data.GetDataPresent(typeof(string)))
5824
                {
5825
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5826
                    string dragData = e.Data.GetData(typeof(string)) as string;
5827
                    Move_Symbol(sender, dragData);
5828
                }
5829
            }
5830
            catch (Exception ex)
5831
            {
5832
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5833
            }
5834
        }
5835
        */
5836
    }
5837

    
5838
    public class testItem
5839
    {
5840
        public string Title { get; set; }
5841
    }
5842
}
클립보드 이미지 추가 (최대 크기: 500 MB)