프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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(MainWindow.CursorChange().StreamSource);
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(MainWindow.CursorChange().StreamSource);
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
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2102
                    SetCursor();
2103
                }
2104
            }
2105
            else
2106
            {
2107
            }
2108
        }
2109

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

    
2118
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2119

    
2120
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2121
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2122

    
2123
                if (Sync.IsChecked)
2124
                {
2125
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2126
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2127
                }
2128
            }
2129
        }
2130

    
2131
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2132

    
2133
        private EllipseGeometry hitArea = new EllipseGeometry();
2134

    
2135
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2136
        {
2137
            IsDrawing = false;
2138

    
2139
            if (mouseHandlingMode != MouseHandlingMode.None)
2140
            {
2141
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2142
                {
2143
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2144

    
2145
                    SetCursor();
2146

    
2147
                    switch (controlType)
2148
                    {
2149
                        case ControlType.None:
2150
                            break;
2151

    
2152
                        case ControlType.Rectangle:
2153
                            {
2154
                            }
2155
                            break;
2156

    
2157
                        case ControlType.PenControl:
2158
                            {
2159
                            }
2160
                            break;
2161

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

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

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

    
2207
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2208

    
2209
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2210
                            }
2211

    
2212
                            isDraggingSelectionRect = false;
2213
                            e.Handled = true;
2214
                            wasDragSelectionApplied = true;
2215
                        }
2216

    
2217
                        if (isLeftMouseButtonDownOnWindow)
2218
                        {
2219
                            isLeftMouseButtonDownOnWindow = false;
2220
                            this.ReleaseMouseCapture();
2221
                            e.Handled = true;
2222
                        }
2223

    
2224
                        if (!wasDragSelectionApplied)
2225
                        {
2226
                            init();
2227
                        }
2228
                    }
2229
                }
2230
                else if (e.RightButton == MouseButtonState.Pressed)
2231
                {
2232
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2233
                    SetCursor();
2234
                }
2235

    
2236
                zoomAndPanControl.ReleaseMouseCapture();
2237

    
2238
                e.Handled = true;
2239
            }
2240
            else
2241
            {
2242
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2243
                SetCursor();
2244
            }
2245

    
2246
            ///mouseButtonDown = MouseButton.Left;
2247
            //controlType = ControlType.SingleLine;
2248
        }
2249

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

    
2260
            double width = dragCaptureBorder.Width;
2261
            double height = dragCaptureBorder.Height;
2262

    
2263
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2264

    
2265
            if (x < 0)
2266
            {
2267
                width += x;
2268
                x = 0;
2269
            }
2270
            if (y < 0)
2271
            {
2272
                height += y;
2273
                y = 0;
2274

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

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

    
2295
            //GC.Collect();
2296

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

    
2309
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2310
        {
2311
            ///mouseButtonDown = MouseButton.Left;
2312
        }
2313

    
2314
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2315
        {
2316
            ///mouseButtonDown = MouseButton.Left;
2317
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2318
        }
2319

    
2320
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2321
        {
2322
        }
2323

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

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

    
2339
            Rect dragRect = new Rect(x, y, width, height);
2340
            ///dragRect.Inflate(width / 10, height / 10);
2341

    
2342
            foreach (var item in Items)
2343
            {
2344
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2345

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

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

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

    
2386
            //
2387
            // Determine x,y,width and height of the rect inverting the points if necessary.
2388
            //
2389

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

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

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

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

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

    
2473
            zoomAndPanControl.RotationAngle = rotate.Angle;
2474

    
2475
            if (!testPanel2.IsHidden)
2476
            {
2477
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2478
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2479
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2480
            }
2481

    
2482
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2483
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2484
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2485
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2486
            ViewerDataModel.Instance.Angle = rotate.Angle;
2487
        }
2488

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

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

    
2522
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2523
        }
2524

    
2525
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2526
        {
2527
            string Data_ = "";
2528

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

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

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

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

    
2602
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2603
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2604
                    UndoData.Markup_List.Add(multi_Undo_Data);
2605
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2606

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

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

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

    
2635
            ConvertInkControlToPolygon();
2636

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

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

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

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

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

    
2679
            double Ang = 0;
2680
            if (rotate.Angle != 0)
2681
            {
2682
                Ang = 360 - rotate.Angle;
2683
            }
2684

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

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

    
2710
            if (e.LeftButton == MouseButtonState.Pressed)
2711
            {
2712
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2713
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2714

    
2715
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2716
                SetCursor();
2717

    
2718
                if (!ViewerDataModel.Instance.IsPressCtrl)
2719
                {
2720
                    SelectionSet.Instance.UnSelect(this);
2721
                }
2722
            }
2723

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

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

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

    
2763
                    if (controlType == ControlType.None)
2764
                    {
2765
                        isLeftMouseButtonDownOnWindow = true;
2766
                    }
2767
                }
2768

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

    
2776
                /// 줌 모드 설정
2777
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2778
                {
2779
                    isLeftMouseButtonDownOnWindow = true;
2780
                }
2781

    
2782
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2783

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

    
2795
                    AdornerFinal final = null;
2796

    
2797
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2798
                    {
2799
                        /// 기존 selection 해제
2800
                        SelectionSet.Instance.UnSelect(this);
2801

    
2802
                        final = new AdornerFinal(control);
2803

    
2804
                        this.Control_Style(control);
2805

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

    
2831
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2832

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

    
2914
                        Control_Style(control);
2915

    
2916
                        final = new AdornerFinal(comment);
2917
                    }
2918

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

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

    
2976
                                    CreateCommand.Instance.Execute(currentControl);
2977

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

    
3001
                                        currentControl.CommentID = Commons.shortGuid();
3002
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3003
                                        currentControl.IsNew = true;
3004

    
3005
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3006

    
3007
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3008
                                    }
3009
                                }
3010
                            }
3011
                        }
3012
                        break;
3013

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

    
3025
                                    CreateCommand.Instance.Execute(currentControl);
3026

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

    
3039
                                    currentControl.CommentID = Commons.shortGuid();
3040
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3041
                                    currentControl.IsNew = true;
3042
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3043

    
3044
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3045
                                }
3046
                            }
3047
                        }
3048
                        break;
3049

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

    
3061
                                    CreateCommand.Instance.Execute(currentControl);
3062

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

    
3075
                                    currentControl.CommentID = Commons.shortGuid();
3076
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3077
                                    currentControl.IsNew = true;
3078
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3079

    
3080
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3081
                                }
3082
                            }
3083
                        }
3084
                        break;
3085

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

    
3097
                                    CreateCommand.Instance.Execute(currentControl);
3098

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

    
3111
                                    currentControl.CommentID = Commons.shortGuid();
3112
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3113
                                    currentControl.IsNew = true;
3114
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3115

    
3116
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3117
                                }
3118
                            }
3119
                        }
3120
                        break;
3121

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

    
3134
                                    CreateCommand.Instance.Execute(currentControl);
3135
                                    currentControl = null;
3136
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3137
                                }
3138
                                else
3139
                                {
3140
                                    currentControl = new RectangleControl
3141
                                    {
3142
                                        Background = new SolidColorBrush(Colors.Black),
3143
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3144
                                        ControlType = ControlType.Rectangle
3145
                                    };
3146

    
3147
                                    currentControl.CommentID = Commons.shortGuid();
3148
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3149
                                    currentControl.IsNew = true;
3150
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3151

    
3152
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3153
                                }
3154
                            }
3155
                        }
3156
                        break;
3157

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

    
3170
                                    CreateCommand.Instance.Execute(currentControl);
3171

    
3172
                                    currentControl = null;
3173

    
3174
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3175
                                }
3176
                                else
3177
                                {
3178
                                    currentControl = new RectCloudControl
3179
                                    {
3180
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3181
                                        ControlType = ControlType.RectCloud,
3182
                                        Background = new SolidColorBrush(Colors.Black)
3183
                                    };
3184

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

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

    
3206
                                    CreateCommand.Instance.Execute(currentControl);
3207

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

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

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

    
3247
                                        CreateCommand.Instance.Execute(currentControl);
3248

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

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

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

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

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

    
3308
                    case ControlType.PolygonControl:
3309
                        {
3310
                            if (currentControl is PolygonControl)
3311
                            {
3312
                                var control = currentControl as PolygonControl;
3313

    
3314
                                if (e.RightButton == MouseButtonState.Pressed)
3315
                                {
3316
                                    control.IsCompleted = true;
3317
                                }
3318

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

    
3331
                                    var firstPoint = control.PointSet.First();
3332
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3333
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3334
                                    control.PointSet.Add(firstPoint);
3335

    
3336
                                    control.ApplyOverViewData();
3337

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

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

    
3368
                    case ControlType.ChainLine:
3369
                        {
3370
                            if (currentControl is PolygonControl)
3371
                            {
3372
                                var control = currentControl as PolygonControl;
3373

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

    
3382
                                    CreateCommand.Instance.Execute(currentControl);
3383

    
3384
                                    currentControl = null;
3385
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3386
                                    return;
3387
                                }
3388

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

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

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

    
3440
                                    CreateCommand.Instance.Execute(currentControl);
3441

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

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

    
3484
                                    CreateCommand.Instance.Execute(currentControl);
3485

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

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

    
3544
                                        CreateCommand.Instance.Execute(currentControl);
3545

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

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

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

    
3590
                                    CreateCommand.Instance.Execute(currentControl);
3591

    
3592
                                    control.isTransOn = true;
3593
                                    var firstPoint = control.PointSet.First();
3594

    
3595
                                    control.PointSet.Add(firstPoint);
3596
                                    control.DrawingCloud();
3597
                                    control.ApplyOverViewData();
3598

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

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

    
3620
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3621
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3622

    
3623
                                    //}
3624
                                }
3625
                            }
3626
                        }
3627
                        break;
3628

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

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

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

    
3683
                                        currentControl.CommentID = Commons.shortGuid();
3684
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3685
                                        currentControl.IsNew = true;
3686
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3687

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

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

    
3711
                                    CreateCommand.Instance.Execute(currentControl);
3712
                                    currentControl = null;
3713

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

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

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

    
3765
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3766
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3767

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

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

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

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

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

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

    
3829
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3830
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3831
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3832

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

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

    
3858
                                    CreateCommand.Instance.Execute(currentControl);
3859

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

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

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

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

    
3889
                                    //}
3890
                                }
3891
                            }
3892
                        }
3893
                        break;
3894

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

    
3907
                                    CreateCommand.Instance.Execute(currentControl);
3908

    
3909
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3910

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

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

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

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

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

    
3977
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3978

    
3979
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3980

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

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

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

    
4028
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4029

    
4030
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4031
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4032
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4033
                                    (currentControl as ArrowTextControl).isFixed = true;
4034
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4035

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

    
4043
                                    //20180911 LJY
4044
                                    (currentControl as ArrowTextControl).isTrans = true;
4045

    
4046
                                    //}
4047
                                }
4048
                            }
4049
                        }
4050
                        break;
4051

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

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

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

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

    
4132
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4133
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4134
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4135
                                    (currentControl as ArrowTextControl).isFixed = true;
4136
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4137

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

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

    
4161
                                if (_sign == null)
4162
                                {
4163
                                    txtBatch.Visibility = Visibility.Collapsed;
4164
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4165
                                    controlType = ControlType.None;
4166

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

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

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

    
4200
                                    currentControl.CommentID = Commons.shortGuid();
4201
                                    currentControl.IsNew = true;
4202
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4203
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4204

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

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

    
4227
                                    CreateCommand.Instance.Execute(currentControl);
4228
                                    (currentControl as RectangleControl).ApplyOverViewData();
4229
                                    currentControl = null;
4230

    
4231
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4232

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

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

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

    
4274
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4275
                                }
4276
                                else
4277
                                {
4278
                                    currentControl = new SymControl
4279
                                    {
4280
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4281
                                        Background = new SolidColorBrush(Colors.Black),
4282
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4283
                                        ControlType = ControlType.Symbol
4284
                                    };
4285

    
4286
                                    currentControl.IsNew = true;
4287
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4288
                                    currentControl.CommentID = Commons.shortGuid();
4289
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4290

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

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

    
4313
                                    CreateCommand.Instance.Execute(currentControl);
4314
                                    currentControl = null;
4315

    
4316
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
4317
                                }
4318
                                else
4319
                                {
4320
                                    currentControl = new SymControlN
4321
                                    {
4322
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4323
                                        Background = new SolidColorBrush(Colors.Black),
4324
                                        STAMP = App.SystemInfo.STAMP,
4325
                                        ControlType = ControlType.Stamp
4326
                                    };
4327

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

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

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

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

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

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

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

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

    
4436
            stroke.DrawingAttributes.Color = Colors.Red;
4437
            stroke.DrawingAttributes.Width = 4;
4438
            stroke.DrawingAttributes.Height = 4;
4439

    
4440
            inkBoard.Strokes.Add(stroke);
4441
        }
4442

    
4443
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
4444
        {
4445
            ConsolidationMethod();
4446
        }
4447

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

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

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

    
4495
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
4496
            }
4497
        }
4498

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

    
4511
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4512
        {
4513
            TeamConsolidationMethod();
4514
        }
4515

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

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

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

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

    
4578
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4579
        {
4580
            UpdateMyMarkupList();
4581

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

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

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

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

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

    
4636
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4637
        {
4638
            SetCompareRect();
4639
        }
4640

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

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

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

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

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

    
4697
                if (ViewerDataModel.Instance.PageNumber == 0)
4698
                {
4699
                    ViewerDataModel.Instance.PageNumber = 1;
4700
                }
4701

    
4702
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4703
                {
4704
                }
4705
                else
4706
                {
4707
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4708
                }
4709

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

    
4718
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
4719

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

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

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

    
4752
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4753

    
4754
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4755
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4756
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4757

    
4758
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4759
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4760

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

    
4769
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4770
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4771
                            };
4772
                        }
4773
                    }
4774

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

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

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

    
4797
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4798
                }
4799
            }
4800
        }
4801

    
4802
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4803
        {
4804
            if (MarkupMode.IsChecked)
4805
            {
4806
                IsSyncPDFMode = true;
4807

    
4808
                var uri = CurrentRev.TO_VENDOR;
4809

    
4810
                if (ViewerDataModel.Instance.PageNumber == 0)
4811
                {
4812
                    ViewerDataModel.Instance.PageNumber = 1;
4813
                }
4814

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

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

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

    
4845
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4846

    
4847
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4848
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4849
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4850

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

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

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

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

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

    
4908
        private void RadButton_Click(object sender, RoutedEventArgs e)
4909
        {
4910
            gridViewHistory_Busy.IsBusy = true;
4911

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

    
4918
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
4919
                {
4920
                    if (ea.Error == null && ea.Result != null)
4921
                    {
4922
                        testPanel2.IsHidden = false;
4923

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

    
4940
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4941

    
4942
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4943

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

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

    
4959
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4960
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4961
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4962

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

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

    
4970
                    if (GetSyncMarkupInfoItemshandler != null)
4971
                    {
4972
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
4973
                    }
4974

    
4975
                    ClearCompareRect();
4976
                    SetCompareRect();
4977
                };
4978

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

    
4983
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4984
            }
4985
        }
4986

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

    
5010
        public void Sync_Event(VPRevision Currnet_Rev)
5011
        {
5012
            CurrentRev = Currnet_Rev;
5013

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

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

    
5036
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5037

    
5038
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5039

    
5040
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
5041

    
5042
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
5043
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
5044
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
5045

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

    
5056
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5057
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5058
                    zoomAndPanControl2.ApplyTemplate();
5059
                    zoomAndPanControl2.UpdateLayout();
5060

    
5061
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5062
                    {
5063
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5064
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5065
                    }
5066
                    //}
5067

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

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

    
5094
        private void Create_Symbol(object sender, RoutedEventArgs e)
5095
        {
5096
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5097

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

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

    
5136
        public int symbolselectindex = 0;
5137

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

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

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

    
5184
                                    System.Drawing.Bitmap image;
5185

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

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

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

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

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

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

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

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

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

    
5312
        private void DataBind()
5313
        {
5314
            try
5315
            {
5316
                Symbol_Custom Custom = new Symbol_Custom();
5317
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5318

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

    
5330
                Custom = new Symbol_Custom();
5331
                Custom_List = new List<Symbol_Custom>();
5332

    
5333
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5334

    
5335
                List<SYMBOL_PUBLIC> symbol_Public;
5336

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

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

    
5372
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5373
                        _Encoder.Save(fs);
5374
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5375

    
5376
                        byte[] Img_byte = fs.ToArray();
5377

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

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

    
5407
            BitmapEncoder encoder = new PngBitmapEncoder();
5408

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

    
5411
            DrawingVisual dv = new DrawingVisual();
5412

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

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

    
5422
            try
5423
            {
5424
                renderBitmap.Render(dv);
5425

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

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

    
5462
        #region 캡쳐 기능
5463

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

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

    
5487
            byte[] pixels = CopyPixels(x, y, width, height);
5488

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

    
5491
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5492
        }
5493

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

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

    
5502
            return pixels;
5503
        }
5504

    
5505
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5506
        {
5507
            DrawingVisual drawingVisual = new DrawingVisual();
5508
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5509

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

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

    
5520
            target.Render(drawingVisual);
5521
            return target;
5522
        }
5523

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

    
5533
        public string symbolname = null;
5534
        public bool symbolsvg = true;
5535
        public bool symbolpng = true;
5536

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

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

    
5553
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5554

    
5555
            RadWindow CheckPop = new RadWindow();
5556
            //Alert check = new Alert(Msg);
5557

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

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

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

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

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

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

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

    
5657
        #endregion 캡쳐 기능
5658

    
5659
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5660
        {
5661
            multi_Undo_Data = new Multi_Undo_data();
5662

    
5663
            multi_Undo_Data.Markup = control;
5664

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

    
5682
            return multi_Undo_Data;
5683
        }
5684

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

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

    
5715
                    List<Point> inkPointSet = new List<Point>();
5716
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5717

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

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

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

    
5756
            return false;
5757
        }
5758

    
5759
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5760
        {
5761
            e.Effects = DragDropEffects.Copy;
5762
        }
5763

    
5764
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5765
        {
5766
            e.Effects = DragDropEffects.Copy;
5767
        }
5768

    
5769
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5770
        {
5771
            e.Effects = DragDropEffects.None;
5772
        }
5773

    
5774
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
5775
        {
5776
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
5777
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
5778

    
5779
            ScaleImage(pageWidth, pageHeight);
5780
        }
5781

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

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

    
5798
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
5799
        {
5800
            var checkbox = (sender as CheckBox);
5801

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

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

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