프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 9380813b

이력 | 보기 | 이력해설 | 다운로드 (286 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 System;
16
using System.Collections.Generic;
17
using System.Diagnostics;
18
using System.Linq;
19
using System.Reflection;
20
using System.Runtime.InteropServices;
21
using System.Text;
22
using System.Threading;
23
using System.Threading.Tasks;
24
using System.Web;
25
using System.Windows;
26
using System.Windows.Controls;
27
using System.Windows.Ink;
28
using System.Windows.Input;
29
using System.Windows.Media;
30
using System.Windows.Media.Imaging;
31
using System.Windows.Shapes;
32
using System.Windows.Threading;
33
using Telerik.Windows.Controls;
34
using Telerik.Windows.Data;
35
//using static KCOM.TempFile;
36

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

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

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

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

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

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

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

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

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

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

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

    
119
        private BitmapFrame tempPageImage =null;
120

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

    
131
        /// <summary>
132
        ///  문서의 마우스 위치
133
        /// </summary>
134
        public Point CanvasDrawingMouseDownPoint;
135

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

    
151
        public string Filename_ { get; set; }
152
        public double L_Size = 0;
153
        public AdornerFinal adorner_;
154
        public Multi_Undo_data multi_Undo_Data;
155
        public string Symbol_ID = "";
156

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

    
162
        public InkPresenter _InkBoard = null;
163
        private Stroke stroke;
164
        private Boolean IsDrawing = false;
165
        private StylusPointCollection strokePoints;
166

    
167
        //StylusPointCollection erasePoints;
168
        private RenderTargetBitmap canvasImage;
169

    
170
        private Point Sync_Offset_Point;
171

    
172
        //강인구 테스트
173
        private Path _SelectionPath { get; set; }
174

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

    
191
        private System.Windows.Controls.Image _imageViewer { get; set; }
192

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

    
216
        public bool IsSyncPDFMode { get; set; }
217

    
218
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
219

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

    
243
        #endregion 프로퍼티
244

    
245
        public MainMenu()
246
        {
247
            //App.splashString(ISplashMessage.MAINMENU_0);
248
            InitializeComponent();
249

    
250
            tempPageImage = BitmapFrame.Create(new Uri(@"pack://application:,,,/KCOM;component/Resources/Images/ExtImage/blank.png"), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
251
            //List<testItem> testItems = new List<testItem>
252
            //{
253
            //    new testItem{Title = "test1"},
254
            //    new testItem{Title = "test2"},
255
            //    new testItem{Title = "test3"},
256
            //    new testItem{Title = "test4"},
257
            //};
258

    
259
            //lstSymbolPrivate.ItemsSource = testItems;
260

    
261
            this.Loaded += MainMenu_Loaded;
262
        }
263

    
264
        public class TempDt
265
        {
266
            public int PageNumber { get; set; }
267
            public string CommentID { get; set; }
268
            public string ConvertData { get; set; }
269
            public int DATA_TYPE { get; set; }
270
            public string MarkupInfoID { get; set; }
271
            public int IsUpdate { get; set; }
272
        }
273

    
274
        private List<TempDt> tempDtList = new List<TempDt>();
275

    
276
        public void SetCursor()
277
        {
278
            this.Cursor = cursor;
279
        }
280

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

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

    
301
            return uri;
302
        }
303

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

    
322
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
323

    
324
            if (!string.IsNullOrWhiteSpace(directUri))
325
            {
326
                uri = string.Format(directUri, filename);
327
            }
328
            else
329
            {
330
                string sFolder = sDocumentID.All(char.IsDigit) ? (Convert.ToUInt64(sDocumentID) / 100).ToString() : (sDocumentID.Length >= 5 ? sDocumentID.Substring(0, 5) : sDocumentID);
331
                if (userData.COMPANY != "EXT")
332
                {
333
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sFolder, sDocumentID, filename);
334
                }
335
                else
336
                {
337
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, sDocumentID, filename);
338
                }
339
                uri = uri.Replace(".png", "");
340
            }
341

    
342
            return uri;
343
        }
344

    
345
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
346
        {
347
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
348
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
349
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
350
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
351
            {
352
                return true;
353
            }
354

    
355
            return false;
356
        }
357

    
358
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
359
        {
360
            if (rotate.Angle == 90 || rotate.Angle == 270)
361
            {
362
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
363
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
364
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
365
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
366
                {
367
                    return true;
368
                }
369
            }
370
            else
371
            {
372
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
373
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
374
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
375
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
376
                {
377
                    return true;
378
                }
379
            }
380

    
381
            return false;
382
        }
383

    
384
        public void DeleteItem(MarkupInfoItem item)
385
        {
386
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
387
            {
388
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
389
            }
390

    
391
            ViewerDataModel.Instance._markupInfoList.Remove(item);
392

    
393
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
394
            {
395
                ViewerDataModel.Instance.MarkupControls.Remove(a);
396
            });
397

    
398
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
399
            {
400
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
401
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
402
                null, Event_Type.Delete, a.CommentID, null);
403
            });
404

    
405
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
406
            {
407
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
408
                //임시파일에서도 삭제
409
                //TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
410
            });
411

    
412
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
413

    
414
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
415
            {
416
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
417
                {
418
                    var infoId = Commons.shortGuid();
419
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
420
                    {
421
                        CreateTime = DateTime.Now,
422
                        Depatment = userData.DEPARTMENT,
423
                        UpdateTime = DateTime.Now,
424
                        DisplayColor = "#FFFF0000",
425
                        UserID = userData.ID,
426
                        UserName = userData.NAME,
427
                        PageCount = 1,
428
                        Description = "",
429
                        MarkupInfoID = infoId,
430
                        MarkupList = null,
431
                        MarkupVersionID = Commons.shortGuid(),
432
                        Consolidate = 0,
433
                        PartConsolidate = 0,
434
                        userDelete = true,
435
                        AvoidConsolidate = 0,
436
                        IsPreviewUser = true
437
                    };
438
                    App.Custom_ViewInfoId = infoId;
439
                }
440
            }
441
            //Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
442
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
443
        }
444

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

    
475
                        Button content = (sender as Button);
476
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
477

    
478
                        DeleteItem(item);
479
                    }
480
                }
481
            };
482
            RadWindow.Confirm(parameters);
483
        }
484

    
485
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
486

    
487
        private static Timer timer;
488
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
489

    
490
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
491
        {
492
            //InitializeComponent();
493
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
494

    
495
            if (App.ParameterMode)
496
            {
497

    
498
                App.splashString(ISplashMessage.MAINMENU_1);
499
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
500
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
501
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
502

    
503
                imageViewer_Compare = new Image();
504
                ViewerDataModel.Instance.Capture_Opacity = 0;
505
                da.From = 0.8;
506
                da.To = 0;
507
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
508
                da.AutoReverse = true;
509
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
510

    
511
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
512
                {
513
                    this.SymbolPane.Visibility = Visibility.Collapsed;
514
                    this.FavoritePane.Visibility = Visibility.Collapsed;
515
                    this.drawingRotateCanvas.IsHitTestVisible = false;
516
                }
517
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
518
            }
519

    
520
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
521
        }
522

    
523
        private void DownloadOriginalFile()
524
        {
525
            #region 임시파일 다운로드
526
            instnaceFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "MARKUS", System.IO.Path.GetRandomFileName().Split('.')[0] + ".pdf");
527
       
528
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
529

    
530
            bool isRestDownload = Convert.ToBoolean(CommonLib.Common.GetConfigString("DocumentDownloadPath", "IsRest", "False"));
531

    
532

    
533
            if (!string.IsNullOrWhiteSpace(directUri))
534
            {
535
                if (directUri.ToLower() == "full")
536
                {
537
                    downloadurl = this._DocInfo.ORIGINAL_FILE;
538
                }
539
                else
540
                {
541
                    isRestDownload = true;
542
                    filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
543

    
544
                    downloadurl = string.Format(directUri, filename);
545
                }
546
             }
547
            else
548
            {
549
                downloadurl = GetOriginalPDFURL();
550
            }
551

    
552
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
553
            
554
            string endpoint = Common.Commons.shortGuid() + "file";
555
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
556
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
557
            wcfServer.Start();
558
            
559
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
560
            #endregion
561
        }
562

    
563
        string instnaceFile;
564
        string downloadurl;
565

    
566
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
567
        {
568
            try
569
            {
570
                Dispatcher.BeginInvoke((Action)delegate ()
571
                {
572
                    if ((sender as IIpc.WcfServer).IsOpen)
573
                    {
574
                        ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress;
575
                    }
576

    
577
                });
578

    
579
                if ((sender as IIpc.WcfServer).IsOpen)
580
                {
581
                    if (e.IsFinish)
582
                    {
583
                        ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
584
                        ViewerDataModel.Instance.IsDownloadOriginal = true;
585
                        (sender as IIpc.WcfServer).Stop();
586
                        (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
587
                    }
588
                }
589
            }
590
            catch (Exception ex)
591
            {
592
                throw;
593
            }
594
        }
595

    
596
        //private void timercallback(Object o)
597
        //{
598
        //    Stopwatch sw = new Stopwatch();
599
        //    sw.Start();
600
        //    TempFile.TempFileAdd();
601
        //    sw.Stop();
602

    
603
        //    Dispatcher.InvokeAsync(new Action(delegate
604
        //    {
605
        //        if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
606
        //        {
607
        //            timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
608
        //        }
609
        //    }));
610

    
611
        //    ////GC.Collect();
612
        //}
613

    
614
        /// <summary>
615
        /// update my markuplist
616
        ///  - update existing markup data if already exist
617
        ///  - add new markup data if control is new
618
        /// </summary>
619
        public void UpdateMyMarkupList()
620
        {
621
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
622

    
623
            /// add or update markup list
624
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
625
            {
626
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
627

    
628
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
629
                if (exist != null) //신규 추가 된 코멘트
630
                {
631
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
632
                    {
633
                        exist.Data = root.ConvertData;
634
                        exist.IsUpdate = true;
635
                    }
636
                }
637
                else if (root.CommentID != null)
638
                {
639
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
640
                    {
641
                        ID = control.CommentID,
642
                        Data = root.ConvertData,
643
                        Data_Type = root.DATA_TYPE,
644
                        MarkupInfoID = App.Custom_ViewInfoId,
645
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
646
                        Symbol_ID = control.SymbolID,
647
                        //Group_ID = control.GroupID,
648
                    });
649
                }
650
            }
651

    
652
            //if (this.pageNavigator.CurrentPage != null)
653
            //{
654
            //    /// delete markup list
655
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
656

    
657
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
658
            //                   where (markup.PageNumber == iPageNo)
659
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
660
            //                   select markup).ToList();
661

    
662
            //    foreach (var markup in deleted)
663
            //    {
664
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
665
            //    }
666
            //}
667
            //else
668
            //{
669
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
670
            //}
671

    
672
            /// up to here
673

    
674
            //if (modified)
675
            //{
676
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
677
            //    {
678
            //        ComingNewBieEnd = true;
679
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
680
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
681
            //        gridViewMarkup.ItemsSource = null;
682
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
683
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
684

    
685
            //        GroupDescriptor descriptor = new GroupDescriptor();
686
            //        descriptor.Member = "Depatment";
687
            //        descriptor.DisplayContent = "DEPT";
688
            //        descriptor.SortDirection = ListSortDirection.Ascending;
689
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
690
            //    }
691
            //}
692
        }
693

    
694
        /// <summary>
695
        /// start page changing
696
        ///  - save controls if page is modified
697
        ///  - starting download page image
698
        /// </summary>
699
        /// <param name="sender"></param>
700
        /// <param name="e"></param>
701
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
702
        {
703
            System.Diagnostics.Debug.WriteLine("pageNavigator PageChanging");
704
            //    await PageLoadAsync(e.CurrentPage,e.PageNumber);
705
            //}
706
            //private async Task PageLoadAsync(DOCPAGE page, int PageNo)
707
            //{
708
            DOCPAGE page = e.CurrentPage;
709
            int PageNo = e.PageNumber;
710

    
711
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
712

    
713
            // 페이지 이미지 변경
714

    
715
            /// 컨트롤을 새로 생성한다.
716
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
717
            ViewerDataModel.Instance.ImageViewWidth = 1;
718
            ViewerDataModel.Instance.ImageViewHeight = 1;
719

    
720
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
721
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
722
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
723

    
724
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
725
            
726
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
727

    
728
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
729

    
730
            //var markupLoadTask = MarkupLoadAsync(page.PAGE_NUMBER, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
731

    
732
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
733
        }
734

    
735
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
736
        {
737
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
738

    
739
            #region 페이지가 벗어난 경우
740

    
741
            if (BalancePoint < 1)
742
            {
743
                BalancePoint = 1;
744
                ViewerDataModel.Instance.PageBalanceNumber = 0;
745
            }
746

    
747
            if (pageNavigator.PageCount < BalancePoint)
748
            {
749
                BalancePoint = pageNavigator.PageCount;
750
                ViewerDataModel.Instance.PageBalanceNumber = 0;
751
            }
752

    
753
            #endregion 페이지가 벗어난 경우
754

    
755
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
756

    
757
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
758
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
759
            var contentScale = zoomAndPanControl.ContentScale;
760

    
761
            #region 페이지 이미지 로딩 수정
762
            
763

    
764
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
765

    
766
            if(token.IsCancellationRequested)
767
            {
768
                return;
769
            }
770

    
771
            ScaleImage(pageWidth, pageHeight);
772

    
773
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
774
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
775

    
776
            zoomAndPanCanvas.Width = pageWidth;
777
            zoomAndPanCanvas.Height = pageHeight;
778

    
779
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
780
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
781

    
782
            inkBoard.Width = pageWidth;
783
            inkBoard.Height = pageHeight;
784

    
785
            #endregion 페이지 이미지 로딩 수정
786

    
787
            if (!testPanel2.IsHidden)
788
            {
789
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
790
                //PDF모드일때 잠시 대기(강인구)
791
                if (IsSyncPDFMode)
792
                {
793
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
794
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
795

    
796
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
797
                    if (pdfpath.IsDownloading)
798
                    {
799
                        pdfpath.DownloadCompleted += (ex, arg) =>
800
                        {
801
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
802
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
803
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
804
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
805
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
806
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
807
                        };
808
                    }
809
                    else
810
                    {
811
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
812
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
813
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
814
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
815

    
816
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
817
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
818
                    }
819
                }
820
                else
821
                {
822
                    Logger.sendCheckLog("Compare Image Download", 1);
823
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
824
                    ComparePageLoad(compareImageUri,false);
825
                }
826

    
827
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
828
            }
829

    
830
            SearchFocusBorder.Visibility = Visibility.Collapsed;
831

    
832
            this.pageNavigator.ChangePage(changePageNumber);
833
        }
834

    
835
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
836
        {
837
            /// 현재 보고 있는 VP와 같은 크기로 로딩
838
            ViewerDataModel.Instance.ImageViewPath_C = null;
839

    
840
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
841
            {
842
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
843
            }
844
            else
845
            {
846
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
847
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
848
            }
849

    
850
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
851
            {
852
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
853
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
854
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
855
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
856

    
857
                zoomAndPanControl.ZoomTo(new Rect
858
                {
859
                    X = 0,
860
                    Y = 0,
861
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
862
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
863
                });
864

    
865
                if (Sync.IsChecked)
866
                {
867
                    Sync_Click(null, new RoutedEventArgs());
868
                }
869

    
870
                if (CompareMode.IsChecked)
871
                {
872
                    SyncCompare_Click(null, new RoutedEventArgs());
873
                }
874
            }
875
        }
876

    
877
        /// <summary>
878
        /// called after page is changed
879
        /// </summary>
880
        /// <param name="sender"></param>
881
        /// <param name="e"></param>
882
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
883
        {
884
            //if (zoomAndPanCanvas.Width.IsNaN())
885
            //{
886
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
887
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
888
            //    );
889
            //}
890

    
891
            var instanceMain = ViewerDataModel.Instance.SystemMain;
892

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

    
895
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
896
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
897

    
898
            instanceMain.dzTopMenu.rotateOffSet = 0;
899
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
900
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
901

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

    
906
            //Point startPoint = new Point(15, 15);
907

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

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

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

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

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

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

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

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

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

    
930
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
931
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
932
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
933
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
934
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
935

    
936
            //symCtrl.ApplyTemplate();
937
            ////txtApproved.ApplyTemplate();
938
            ////txtCreator.ApplyTemplate();
939
            //txtOriginator.ApplyTemplate();
940
            //txtDate.ApplyTemplate();
941

    
942
            ////SetTextControl(txtApproved);
943
            ////SetTextControl(txtCreator);
944
            //SetTextControl(txtOriginator);
945
            //SetTextControl(txtDate);
946

    
947
            //multi_Undo_Data = new Multi_Undo_data();
948

    
949
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
950
            //{
951
            //    IsUndo = false,
952
            //    Event = Event_Type.Create,
953
            //    EventTime = DateTime.Now,
954
            //    Markup_List = new List<Multi_Undo_data>()
955
            //};
956

    
957
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
958
            //UndoData.Markup_List.Add(multi_Undo_Data);
959

    
960
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
961
            ////UndoData.Markup_List.Add(multi_Undo_Data);
962

    
963
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
964
            ////UndoData.Markup_List.Add(multi_Undo_Data);
965

    
966
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
967
            //UndoData.Markup_List.Add(multi_Undo_Data);
968

    
969
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
970
            //UndoData.Markup_List.Add(multi_Undo_Data);
971

    
972
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
973

    
974
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
975
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
976
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
977
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
978
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
979
        }
980

    
981
        private void SetTextControl(TextControl textControl)
982
        {
983
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
984
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
985
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
986
        }
987

    
988
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
989
        {
990
            SymControlN result = null;
991

    
992
            try
993
            {
994
                double height = 80;
995
                double itemWidth = 180;
996

    
997
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
998
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
999
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1000
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1001

    
1002
                result = new SymControlN
1003
                {
1004
                    CommentID = Commons.shortGuid(),
1005
                    MarkupInfoID = markupInfoId,
1006
                    UserID = userId,
1007
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1008
                    StartPoint = startPoint,
1009
                    EndPoint = endPoint,
1010
                    CommentAngle = 0,
1011
                    LeftBottomPoint = leftBottomPoint,
1012
                    TopRightPoint = topRightPoint,
1013
                    Opacity = 1,
1014
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
1015
                    Memo = null
1016
                };
1017
            }
1018
            catch (Exception ex)
1019
            {
1020
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1021
            }
1022

    
1023
            return result;
1024
        }
1025

    
1026
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
1027
        {
1028
            RectangleControl result = null;
1029

    
1030
            try
1031
            {
1032
                double height = 80;
1033
                double itemWidth = 180;
1034

    
1035
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1036
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
1037
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1038
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1039

    
1040
                result = new RectangleControl
1041
                {
1042
                    CommentID = Commons.shortGuid(),
1043
                    MarkupInfoID = markupInfoId,
1044
                    LineSize = 5,
1045
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
1046
                    StartPoint = startPoint,
1047
                    EndPoint = endPoint,
1048
                    CommentAngle = 0,
1049
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1050
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1051
                    FillColor = null,
1052
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1053
                    Opacity = 1,
1054
                    LeftBottomPoint = leftBottomPoint,
1055
                    TopRightPoint = topRightPoint,
1056
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1057
                    UserID = userId,
1058
                    Memo = null
1059
                };
1060
            }
1061
            catch (Exception ex)
1062
            {
1063
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1064
            }
1065

    
1066
            return result;
1067
        }
1068

    
1069
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1070
        {
1071
            TextControl result = null;
1072

    
1073
            try
1074
            {
1075
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1076

    
1077
                double startPositionX = parentRect.X;
1078

    
1079
                switch (textAlignment)
1080
                {
1081
                    case TextAlignment.Right:
1082
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1083
                        break;
1084

    
1085
                    case TextAlignment.Center:
1086
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1087
                        break;
1088
                }
1089

    
1090
                Point startPosition = new Point
1091
                {
1092
                    X = startPositionX,
1093
                    Y = positionY
1094
                };
1095

    
1096
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1097
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1098
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1099
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1100

    
1101
                result = new TextControl
1102
                {
1103
                    CommentID = Commons.shortGuid(),
1104
                    MarkupInfoID = markupInfoId,
1105
                    Text = Text,
1106
                    StartPoint = startPoint,
1107
                    EndPoint = endPoint,
1108
                    CanvasX = startPosition.X,
1109
                    CanvasY = startPosition.Y,
1110
                    BoxWidth = txtSize.Width,
1111
                    BoxHeight = txtSize.Height,
1112
                    ControlType_No = 0,
1113
                    LineSize = new Thickness(5),
1114
                    TextSize = fontSize,
1115
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1116
                    FontSize = 10,
1117
                    UserID = userId,
1118
                    IsHighLight = false,
1119
                    CommentAngle = 0,
1120
                    PointSet = new List<Point>(),
1121
                    Opacity = 1,
1122
                    IsSelected = false,
1123
                    TextFamily = new FontFamily("Tahoma"),
1124
                    TextStyle = FontStyles.Normal,
1125
                    TextWeight = FontWeights.Bold
1126
                };
1127
            }
1128
            catch (Exception ex)
1129
            {
1130
            }
1131

    
1132
            return result;
1133
        }
1134

    
1135
        public static Size ShapeMeasure(UIElement e)
1136
        {
1137
            // Measured Size is bounded to be less than maxSize
1138
            Size maxSize = new Size(
1139
                 double.PositiveInfinity,
1140
                 double.PositiveInfinity);
1141
            e.Measure(maxSize);
1142
            return e.DesiredSize;
1143
        }
1144

    
1145
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1146
        {
1147
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1148
            stopwatch.Start();
1149

    
1150
            /// 컨트롤을 새로 생성한다.
1151
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1152
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1153

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

    
1156
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1157
            {
1158
                if (cts.IsCancellationRequested)
1159
                {
1160
                    return;
1161
                }
1162

    
1163
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1164
                if (info != null)
1165
                {
1166
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1167
                    if (info.UserID == App.ViewInfo.UserID)
1168
                    {
1169
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1170
                                        markup.MarkupInfoID, markup.ID);
1171
                        control.Visibility = Visibility.Hidden;
1172
                    }
1173
                    else
1174
                    {
1175
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1176
                                                                markup.MarkupInfoID, markup.ID);
1177
                        control.Visibility = Visibility.Hidden;
1178
                    }
1179
                }
1180
            };
1181
            /// up to here
1182

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

    
1185
            /// fire selection event
1186
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1187
            this.gridViewMarkup.UnselectAll();
1188
            this.gridViewMarkup.Select(gridSelectionItem);
1189

    
1190
            if (!testPanel2.IsHidden)
1191
            {
1192
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1193
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1194
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1195

    
1196
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1197
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1198

    
1199
                foreach (var item in gridSelectionRevItem)
1200
                {
1201
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1202

    
1203
                    foreach (var markupitem in markupitems)
1204
                    {
1205
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1206

    
1207
                        //if (cts.IsCancellationRequested)
1208
                        //{
1209
                        //    return;
1210
                        //}
1211
                    }
1212
                }
1213
            }
1214

    
1215
            SetCommentPages(cts);
1216
        }
1217

    
1218
        public void SetCommentPages(CancellationToken? cts)
1219
        {
1220
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1221
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1222
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1223
            {
1224
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1225
                if (item.MarkupList != null)
1226
                {
1227
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1228
                    instance.UserName = item.UserName;
1229
                    instance.Depart = item.Depatment;
1230
                    instance.MarkupInfoID = item.MarkupInfoID;
1231
                    instance.IsSelected = true;
1232
                    instance.isConSolidation = item.Consolidate;
1233
                    instance.SetColor = item.DisplayColor;
1234
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1235
                    {
1236
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1237
                    }
1238
                    else
1239
                    {
1240
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1241
                    }
1242
                    _pages.Add(instance);
1243
                }
1244

    
1245
                if (cts != null)
1246
                {
1247
                    if (cts.Value.IsCancellationRequested)
1248
                        return;
1249
                }
1250
            }
1251

    
1252
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1253
        }
1254

    
1255
        public void MarkupitemViewUpdate(string markupinfo_id)
1256
        {
1257
            //db에 업데이트 한 list 를 view 에 업데이트
1258
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1259
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1260
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1261
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1262
            if (dbinfo.MarkupList.Count > 0)
1263
            {
1264
                if (viewinfo.MarkupList != null)
1265
                {
1266
                    viewinfo.MarkupList.Clear();
1267
                    viewinfo.MarkupList = null;
1268
                }
1269

    
1270
                viewinfo.MarkupList = new List<MarkupItem>();
1271
                foreach (var item in dbinfo.MarkupList)
1272
                {
1273
                    System.Diagnostics.Debug.WriteLine(item.ID);
1274
                    viewinfo.MarkupList.Add(item);
1275
                }
1276
            }
1277
        }
1278

    
1279
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1280
        {
1281
            var instance = ViewerDataModel.Instance;
1282

    
1283
            if (instance.IsWheelPageChanage)
1284
            {
1285
                return;
1286
            }
1287

    
1288
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1289
            {
1290
                int changePage = 0;
1291

    
1292
                if (e.Delta > 0)
1293
                {
1294
                    if (0 < instance.ContentOffsetY)
1295
                    {
1296
                        Vector dragOffset = new Vector(0, e.Delta);
1297
                        MoveZoomAndPanControl(dragOffset);
1298
                    }
1299
                    //else
1300
                    //{
1301
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1302
                    //    {
1303
                    //        instance.IsWheelPageChanage = true;
1304
                    //        changePage -= 1;
1305
                    //    }
1306
                    //}
1307
                }
1308
                else if (e.Delta < 0)
1309
                {
1310
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1311
                    {
1312
                        Vector dragOffset = new Vector(0, e.Delta);
1313
                        MoveZoomAndPanControl(dragOffset);
1314
                    }
1315
                    //else
1316
                    //{
1317
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1318
                    //    {
1319
                    //        instance.IsWheelPageChanage = true;
1320
                    //        changePage += 1;
1321
                    //    }
1322
                    //}
1323
                }
1324

    
1325
                //if (changePage != 0)
1326
                //{
1327
                //    await Task.Factory.StartNew(() =>
1328
                //    {
1329
                //        double beforeScale = instance.ContentScale;
1330

    
1331
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1332

    
1333
                //        handler = (snd, evt) =>
1334
                //        {
1335
                //            /// 최상단으로 이전 zoomScale로 위치한다
1336
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1337
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1338
                //            instance.IsWheelPageChanage = false;
1339
                //            pageNavigator.PageChanged -= handler;
1340
                //        };
1341

    
1342
                //        pageNavigator.PageChanged += handler;
1343

    
1344
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1345
                //    });
1346

    
1347
                //}
1348
            }
1349
            else
1350
            {
1351
                e.Handled = true;
1352
                if (e.Delta > 0)
1353
                {
1354
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1355
                    ZoomIn(currentContentMousePoint);
1356
                }
1357
                else
1358
                {
1359
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1360
                    ZoomOut(currentContentMousePoint);
1361
                }
1362
            }
1363
        }
1364

    
1365
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1366
        {
1367
            e.Handled = true;
1368
            if (e.Delta > 0)
1369
            {
1370
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1371
                ZoomIn_Sync(currentContentMousePoint);
1372
            }
1373
            else
1374
            {
1375
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1376
                ZoomOut_Sync(currentContentMousePoint);
1377
            }
1378
        }
1379

    
1380
        #region ZoomIn & ZoomOut
1381

    
1382
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1383
        {
1384
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1385
                zoomAndPanControl.ContentZoomFocusY));
1386
        }
1387

    
1388
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1389
        {
1390
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1391
                zoomAndPanControl.ContentZoomFocusY));
1392
        }
1393

    
1394
        //강인구 추가 (줌 인아웃 수치 변경)
1395
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1396
        private void ZoomOut(Point contentZoomCenter)
1397
        {
1398
            if (zoomAndPanControl.ContentScale > 0.39)
1399
            {
1400
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1401
            }
1402
            else
1403
            {
1404
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1405
            }
1406

    
1407
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1408
            {
1409
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1410
            }
1411
        }
1412

    
1413
        private void ZoomIn(Point contentZoomCenter)
1414
        {
1415
            if (zoomAndPanControl.ContentScale > 0.19)
1416
            {
1417
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1418
            }
1419
            else
1420
            {
1421
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1422
            }
1423

    
1424
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1425
            {
1426
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1427
            }
1428
        }
1429

    
1430
        private void ZoomOut_Sync(Point contentZoomCenter)
1431
        {
1432
            if (zoomAndPanControl2.ContentScale > 0.39)
1433
            {
1434
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1435
            }
1436
            else
1437
            {
1438
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1439
            }
1440

    
1441
            if (Sync.IsChecked)
1442
            {
1443
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1444
            }
1445
        }
1446

    
1447
        private void ZoomIn_Sync(Point contentZoomCenter)
1448
        {
1449
            if (zoomAndPanControl2.ContentScale > 0.19)
1450
            {
1451
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1452
            }
1453
            else
1454
            {
1455
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1456
            }
1457

    
1458
            if (Sync.IsChecked)
1459
            {
1460
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1461
            }
1462
        }
1463

    
1464
        private void ZoomOut()
1465
        {
1466
            zoomAndPanControl.ContentScale -= 0.1;
1467
            //if (zoomAndPanControl2 != null)
1468
            //{
1469
            //    zoomAndPanControl2.ContentScale -= 0.1;
1470
            //}
1471
        }
1472

    
1473
        private void ZoomIn()
1474
        {
1475
            zoomAndPanControl.ContentScale += 0.1;
1476
            //if (zoomAndPanControl2 != null)
1477
            //{
1478
            //    zoomAndPanControl2.ContentScale += 0.1;
1479
            //}
1480
        }
1481

    
1482
        #endregion ZoomIn & ZoomOut
1483

    
1484
        public void init()
1485
        {
1486
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1487
            {
1488
                ControlList.Clear();
1489
                listBox.Items.Clear();
1490
                selected_item.Clear();
1491

    
1492
                (item as IMarkupCommonData).IsSelected = false;
1493
            }
1494
        }
1495

    
1496
        private HitTestResultBehavior MyCallback(HitTestResult result)
1497
        {
1498
            //this.cursor = Cursors.UpArrow;
1499
            var element = result.VisualHit;
1500
            while (element != null && !(element is CommentUserInfo))
1501
                element = VisualTreeHelper.GetParent(element);
1502

    
1503
            if (element == null)
1504
            {
1505
                return HitTestResultBehavior.Stop;
1506
            }
1507
            else
1508
            {
1509
                if (element is CommentUserInfo)
1510
                {
1511
                    if (!hitList.Contains(element))
1512
                    {
1513
                        hitList.Add((CommentUserInfo)element);
1514
                    }
1515
                    else
1516
                    {
1517
                        return HitTestResultBehavior.Stop;
1518
                    }
1519
                }
1520
            }
1521
            return HitTestResultBehavior.Continue;
1522
        }
1523

    
1524
        public void ReleaseSelectPath()
1525
        {
1526
            if (SelectionPath == null)
1527
            {
1528
                SelectionPath = new Path();
1529
                SelectionPath.Name = "";
1530
            }
1531
            if (SelectionPath.Name != "")
1532
            {
1533
                SelectionPath.Name = "None";
1534
            }
1535
            SelectionPath.Opacity = 0.01;
1536
            SelectionPath.RenderTransform = null;
1537
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1538
        }
1539

    
1540
        #region 컨트롤 초기화
1541

    
1542
        public void Control_Init(object control)
1543
        {
1544
            if (L_Size != 0 && (control as IPath) != null)
1545
            {
1546
                (control as IPath).LineSize = L_Size;
1547
                L_Size = 0;
1548
            }
1549

    
1550
            switch (control.GetType().Name)
1551
            {
1552
                case "RectangleControl":
1553
                    {
1554
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1555
                    }
1556
                    break;
1557

    
1558
                case "CircleControl":
1559
                    {
1560
                        (control as CircleControl).StrokeColor = Brushes.Red;
1561
                    }
1562
                    break;
1563

    
1564
                case "TriControl":
1565
                    {
1566
                        (control as TriControl).StrokeColor = Brushes.Red;
1567
                    }
1568
                    break;
1569

    
1570
                case "RectCloudControl":
1571
                    {
1572
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1573
                    }
1574
                    break;
1575

    
1576
                case "CloudControl":
1577
                    {
1578
                        (control as CloudControl).StrokeColor = Brushes.Red;
1579
                    }
1580
                    break;
1581

    
1582
                case "PolygonControl":
1583
                    {
1584
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1585
                    }
1586
                    break;
1587

    
1588
                case "ArcControl":
1589
                    {
1590
                        (control as ArcControl).StrokeColor = Brushes.Red;
1591
                    }
1592
                    break;
1593

    
1594
                case "ArrowArcControl":
1595
                    {
1596
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1597
                    }
1598
                    break;
1599

    
1600
                case "LineControl":
1601
                    {
1602
                        (control as LineControl).StrokeColor = Brushes.Red;
1603
                    }
1604
                    break;
1605

    
1606
                case "ArrowControl_Multi":
1607
                    {
1608
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1609
                    }
1610
                    break;
1611

    
1612
                case "TextControl":
1613
                    {
1614
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1615
                    }
1616
                    break;
1617

    
1618
                case "ArrowTextControl":
1619
                    {
1620
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1621
                    }
1622
                    break;
1623

    
1624
                case "InsideWhiteControl":
1625
                    {
1626
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1627
                    }
1628
                    break;
1629

    
1630
                case "OverlapWhiteControl":
1631
                    {
1632
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1633
                    }
1634
                    break;
1635

    
1636
                case "ClipWhiteControl":
1637
                    {
1638
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1639
                    }
1640
                    break;
1641

    
1642
                case "CoordinateControl":
1643
                    {
1644
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1645
                    }
1646
                    break;
1647
            }
1648
        }
1649

    
1650
        #endregion 컨트롤 초기화
1651

    
1652
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1653
        {
1654
            //Control_Init(e.Source);
1655
        }
1656

    
1657
        //private Window _dragdropWindow = null;
1658

    
1659
        [DllImport("user32.dll")]
1660
        [return: MarshalAs(UnmanagedType.Bool)]
1661
        internal static extern bool GetCursorPos(ref Win32Point pt);
1662

    
1663
        [StructLayout(LayoutKind.Sequential)]
1664
        internal struct Win32Point
1665
        {
1666
            public Int32 X;
1667
            public Int32 Y;
1668
        };
1669

    
1670
        /*
1671
       public string symbol_id = null;
1672
       public long symbol_group_id;
1673
       public int symbol_SelectedIndex;
1674
       public ImageSource symbol_img;
1675
       public string symbol_Data = null;
1676
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1677
       {
1678
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1679
               zoomAndPanCanvas.ActualHeight / 2));
1680

    
1681
               if (this._dragdropWindow != null)
1682
               {
1683
                   this._dragdropWindow.Close();
1684
                   this._dragdropWindow = null;
1685
               }
1686

    
1687
               symbol_id = id;
1688
               symbol_group_id = group_id;
1689
               symbol_SelectedIndex = SelectedIndex;
1690
               symbol_Data = Data_;
1691
               symbol_img = img;
1692

    
1693
               CreateDragDropWindow2(img);
1694
    }
1695

    
1696
    private void CreateDragDropWindow2(ImageSource image)
1697
        {
1698
            this._dragdropWindow = new Window();
1699
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1700
            _dragdropWindow.WindowStyle = WindowStyle.None;
1701
            _dragdropWindow.AllowsTransparency = true;
1702
            _dragdropWindow.AllowDrop = false;
1703
            _dragdropWindow.Background = null;
1704
            _dragdropWindow.IsHitTestVisible = false;
1705
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1706
            _dragdropWindow.Topmost = true;
1707
            _dragdropWindow.ShowInTaskbar = false;
1708

    
1709
            Rectangle r = new Rectangle();
1710
            r.Width = image.Width;
1711
            r.Height = image.Height;
1712
            r.Opacity = 0.5;
1713
            r.Fill = new ImageBrush(image);
1714
            this._dragdropWindow.Content = r;
1715

    
1716
            Win32Point w32Mouse = new Win32Point();
1717
            GetCursorPos(ref w32Mouse);
1718

    
1719
            //w32Mouse.X = getCurrentPoint.X;
1720
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1721
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1722
            this._dragdropWindow.Show();
1723
        }
1724

    
1725
         */
1726

    
1727
        public void MoveZoomAndPanControl(Vector dragOffset)
1728
        {
1729
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1730
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1731

    
1732
            if (Sync.IsChecked)
1733
            {
1734
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1735
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1736
            }
1737
        }
1738

    
1739
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1740
        {
1741
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1742
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1743
            //if(this.txtBatch.Visibility == Visibility.Visible)
1744
            {
1745
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1746

    
1747
                Point currentPos = e.GetPosition(rect);
1748

    
1749
                floatingTip.HorizontalOffset = currentPos.X + 20;
1750
                floatingTip.VerticalOffset = currentPos.Y;
1751
            }
1752

    
1753
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1754

    
1755
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1756
            {
1757
                SetCursor();
1758
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1759
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1760

    
1761
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1762

    
1763
                MoveZoomAndPanControl(dragOffset);
1764
            }
1765

    
1766
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1767
            {
1768
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1769
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1770
                SetCursor();
1771

    
1772
                if (currentControl != null)
1773
                {
1774
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1775
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1776
                    //강인구 추가
1777
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1778

    
1779
                    if ((currentControl as IPath) != null)
1780
                    {
1781
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1782
                    }
1783
                    if ((currentControl as LineControl) != null)
1784
                    {
1785
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1786
                    }
1787

    
1788
                    if ((currentControl as IShapeControl) != null)
1789
                    {
1790
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1791
                    }
1792
                    if ((currentControl as TextControl) != null)
1793
                    {
1794
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1795
                        {
1796
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1797
                        }
1798
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1799
                        {
1800
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1801
                        }
1802
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1803
                        {
1804
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1805
                        }
1806
                    }
1807
                    else if ((currentControl as ArrowTextControl) != null)
1808
                    {
1809
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1810
                        {
1811
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1812
                        }
1813
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1814
                        {
1815
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1816
                        }
1817
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1818
                        {
1819
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1820
                        }
1821
                    }
1822
                    else if ((currentControl as RectCloudControl) != null)
1823
                    {
1824
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1825
                    }
1826
                    else if ((currentControl as CloudControl) != null)
1827
                    {
1828
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1829
                    }
1830

    
1831
                    #region // 모든 컨트롤의 공통기능 제어
1832

    
1833
                    if (controlType != ControlType.PenControl)
1834
                    {
1835
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1836
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1837
                    }
1838

    
1839
                    #endregion // 모든 컨트롤의 공통기능 제어
1840

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

    
1843
                    switch (controlType)
1844
                    {
1845
                        case (ControlType.Coordinate):
1846
                            {
1847
                                var control = currentControl as CoordinateControl;
1848
                                if (control != null)
1849
                                {
1850
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1851
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1852
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1853
                                }
1854
                            }
1855
                            break;
1856

    
1857
                        case (ControlType.InsideWhite):
1858
                            {
1859
                                var control = currentControl as InsideWhiteControl;
1860
                                if (control != null)
1861
                                {
1862
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1863
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1864
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1865
                                    control.Paint = PaintSet.Fill;
1866
                                }
1867
                            }
1868
                            break;
1869

    
1870
                        case ControlType.OverlapWhite:
1871
                            {
1872
                                var control = currentControl as OverlapWhiteControl;
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
                                    control.Paint = PaintSet.Fill;
1879
                                }
1880
                            }
1881
                            break;
1882

    
1883
                        case ControlType.ClipWhite:
1884
                            {
1885
                                var control = currentControl as ClipWhiteControl;
1886
                                if (control != null)
1887
                                {
1888
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1889
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1890
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1891
                                    control.Paint = PaintSet.Fill;
1892
                                }
1893
                            }
1894
                            break;
1895

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

    
1908
                        case ControlType.SingleLine:
1909
                        case ControlType.CancelLine:
1910
                        case ControlType.ArrowLine:
1911
                        case ControlType.TwinLine:
1912
                        case ControlType.DimLine:
1913
                            {
1914
                                var control = currentControl as LineControl;
1915
                                if (control != null)
1916
                                {
1917
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1918
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1919
                                }
1920
                            }
1921
                            break;
1922

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

    
1934
                        case ControlType.ArcArrow:
1935
                            {
1936
                                var control = currentControl as ArrowArcControl;
1937
                                if (control != null)
1938
                                {
1939
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1940
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1941
                                }
1942
                            }
1943
                            break;
1944

    
1945
                        case ControlType.ArrowMultiLine:
1946
                            {
1947
                                var control = currentControl as ArrowControl_Multi;
1948
                                if (control != null)
1949
                                {
1950
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1951
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1952
                                }
1953
                            }
1954
                            break;
1955

    
1956
                        case ControlType.Circle:
1957
                            {
1958
                                var control = currentControl as CircleControl;
1959

    
1960
                                if (control != null)
1961
                                {
1962
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1963
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1964
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1965
                                }
1966
                            }
1967
                            break;
1968

    
1969
                        case ControlType.PolygonCloud:
1970
                            {
1971
                                var control = currentControl as CloudControl;
1972
                                if (control != null)
1973
                                {
1974
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1975
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1976
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1977
                                }
1978
                            }
1979
                            break;
1980

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

    
1993
                        case ControlType.ImgControl:
1994
                            {
1995
                                var control = currentControl as ImgControl;
1996
                                if (control != null)
1997
                                {
1998
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1999
                                }
2000
                            }
2001
                            break;
2002

    
2003
                        case ControlType.Date:
2004
                            {
2005
                                var control = currentControl as DateControl;
2006
                                if (control != null)
2007
                                {
2008
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2009
                                }
2010
                            }
2011
                            break;
2012

    
2013
                        case ControlType.ArrowTextControl:
2014
                        case ControlType.ArrowTransTextControl:
2015
                        case ControlType.ArrowTextBorderControl:
2016
                        case ControlType.ArrowTransTextBorderControl:
2017
                        case ControlType.ArrowTextCloudControl:
2018
                        case ControlType.ArrowTransTextCloudControl:
2019
                            {
2020
                                var control = currentControl as ArrowTextControl;
2021
                                if (control != null)
2022
                                {
2023
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2024
                                }
2025
                            }
2026
                            break;
2027

    
2028
                        case ControlType.PolygonControl:
2029
                        case ControlType.ChainLine:
2030
                            {
2031
                                var control = currentControl as PolygonControl;
2032
                                if (control != null)
2033
                                {
2034
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2035
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2036
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2037
                                }
2038
                            }
2039
                            break;
2040

    
2041
                        case ControlType.Sign:
2042
                            {
2043
                                var control = currentControl as SignControl;
2044
                                if (control != null)
2045
                                {
2046
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2047
                                }
2048
                            }
2049
                            break;
2050

    
2051
                        case ControlType.Symbol:
2052
                            {
2053
                                var control = currentControl as SymControl;
2054
                                if (control != null)
2055
                                {
2056
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2057
                                }
2058
                            }
2059
                            break;
2060

    
2061
                        case ControlType.Stamp:
2062
                            {
2063
                                var control = currentControl as SymControlN;
2064
                                if (control != null)
2065
                                {
2066
                                    if (control.STAMP != null)
2067
                                    {
2068
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2069
                                    }
2070
                                    else
2071
                                    {
2072
                                        currentControl = null;
2073
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2074
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2075
                                    }
2076
                                }
2077
                            }
2078
                            break;
2079

    
2080
                        case ControlType.Rectangle:
2081
                        case ControlType.Mark:
2082
                            {
2083
                                var control = currentControl as RectangleControl;
2084
                                if (control != null)
2085
                                {
2086
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2087
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2088
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2089
                                }
2090
                            }
2091
                            break;
2092

    
2093
                        case ControlType.PenControl:
2094
                            {
2095
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2096
                                //inkBoard.Strokes.Add(stroke);
2097
                            }
2098
                            break;
2099

    
2100
                        default:
2101
                            break;
2102
                    }
2103

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

    
2106
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2107
                    {
2108
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2109
                    }
2110
                }
2111
            }
2112
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2113
            {
2114
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2115
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2116
                SetCursor();
2117
                if (currentControl == null)
2118
                {
2119
                    switch (controlType)
2120
                    {
2121
                        case ControlType.PenControl:
2122
                            {
2123
                                if (inkBoard.Tag.ToString() == "Ink")
2124
                                {
2125
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2126
                                }
2127
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2128
                                {
2129
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2130
                                }
2131
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2132
                                {
2133
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2134
                                }
2135

    
2136
                                //inkBoard.Strokes.Add(stroke);
2137
                            }
2138
                            break;
2139
                    }
2140
                    return;
2141
                }
2142
            }
2143
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2144
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2145
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2146
            {
2147
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2148

    
2149
                if (isDraggingSelectionRect)
2150
                {
2151
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2152
                    e.Handled = true;
2153
                }
2154
                else if (isLeftMouseButtonDownOnWindow)
2155
                {
2156
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2157
                    double dragDistance = Math.Abs(dragDelta.Length);
2158

    
2159
                    if (dragDistance > DragThreshold)
2160
                    {
2161
                        isDraggingSelectionRect = true;
2162
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2163
                    }
2164

    
2165
                    e.Handled = true;
2166
                }
2167

    
2168
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2169
                {
2170
                }
2171
                else
2172
                {
2173
                    e.Handled = true;
2174
                }
2175
            }
2176
            /*
2177
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2178
            { //symbol
2179
                if(_dragdropWindow != null)
2180
                {
2181
                    Win32Point w32Mouse = new Win32Point();
2182
                    GetCursorPos(ref w32Mouse);
2183

    
2184
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2185
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2186
                }
2187
            }
2188
            */
2189
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2190
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2191
            {
2192
                //var comment = drawingRotateCanvas.FindDistanceComment(getCurrentPoint);
2193

    
2194

    
2195
                //if (comment != null)
2196
                //{
2197
                //    comment.IsMouseEnter = true;
2198

    
2199
                //    if (enterMouse != comment)
2200
                //    {
2201
                //        if (enterMouse != null)
2202
                //            enterMouse.IsSelected = false;
2203

    
2204
                //        enterMouse = comment;
2205
                //    }
2206
                //}
2207
                //else
2208
                //{
2209
                //    if(enterMouse != null)
2210
                //        enterMouse.IsSelected = false;
2211
                //}
2212

    
2213

    
2214
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2215
                if (control != null)
2216
                {
2217
                    this.cursor = Cursors.Hand;
2218
                    SetCursor();
2219
                }
2220
                else
2221
                {
2222
                    if (this.Cursor != Cursors.None)
2223
                    {
2224
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2225
                        SetCursor();
2226
                    }
2227
                }
2228
            }
2229
            else
2230
            {
2231
                
2232
            }
2233
        }
2234

    
2235
        private CommentUserInfo enterMouse = null;
2236

    
2237
        private object IntersectsControls(Point mousePosition,Canvas drawingRotateCanvas)
2238
        {
2239
            object result = null;
2240

    
2241
            // 검색할 정사각형의 크기 및 반경 설정
2242
            double squareSize = 1;
2243
            Rect searchRect = new Rect(
2244
                mousePosition.X - squareSize,
2245
                mousePosition.Y - squareSize,
2246
                squareSize * 2,
2247
                squareSize * 2
2248
            );
2249

    
2250
            foreach (CommentUserInfo child in drawingRotateCanvas.ChildrenOfType<CommentUserInfo>())
2251
            {
2252
                if (child is CommentUserInfo comment)
2253
                {
2254
                    // 검색 영역과 Rectangle의 경계가 겹치는지 확인합니다.
2255
                    if (searchRect.IntersectsWith(child.ItemRect))
2256
                    {
2257
                        child.IsMouseEnter = true;
2258
                        result = (object)child;
2259
                        // Geometry를 적용하거나 원하는 작업을 수행합니다.
2260
                        // 예: rectangle.Fill = new SolidColorBrush(Colors.Red);
2261
                    }
2262
                    else
2263
                    {
2264
                        child.IsMouseEnter = false;
2265
                    }
2266
                }
2267
            }
2268

    
2269
            return result;
2270
        }
2271

    
2272
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2273
        {
2274
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2275
            {
2276
                SetCursor();
2277
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2278
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2279

    
2280
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2281

    
2282
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2283
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2284

    
2285
                if (Sync.IsChecked)
2286
                {
2287
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2288
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2289
                }
2290
            }
2291
        }
2292

    
2293
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2294

    
2295
        private EllipseGeometry hitArea = new EllipseGeometry();
2296

    
2297
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2298
        {
2299
            IsDrawing = false;
2300

    
2301
            if (mouseHandlingMode != MouseHandlingMode.None)
2302
            {
2303
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2304
                {
2305
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2306

    
2307
                    SetCursor();
2308

    
2309
                    switch (controlType)
2310
                    {
2311
                        case ControlType.None:
2312
                            break;
2313

    
2314
                        case ControlType.Rectangle:
2315
                            {
2316
                            }
2317
                            break;
2318

    
2319
                        case ControlType.PenControl:
2320
                            {
2321
                            }
2322
                            break;
2323

    
2324
                        default:
2325
                            break;
2326
                    }
2327
                }
2328
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2329
                {
2330
                    if (isLeftMouseButtonDownOnWindow)
2331
                    {
2332
                        bool wasDragSelectionApplied = false;
2333

    
2334
                        if (isDraggingSelectionRect)
2335
                        {
2336
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2337
                            {
2338
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2339
                                mouseHandlingMode = MouseHandlingMode.None;
2340
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2341
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2342
                                Set_Symbol_Capture(endPoint);
2343
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2344
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2345
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2346
                            }
2347
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2348
                            {
2349
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2350
                                mouseHandlingMode = MouseHandlingMode.None;
2351
                                Set_Capture();
2352

    
2353
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2354
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2355
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2356
                            }
2357
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2358
                            {
2359
                                ApplyDragSelectionRect();
2360
                            }
2361
                            else
2362
                            {
2363
                                double x = Canvas.GetLeft(dragZoomBorder);
2364
                                double y = Canvas.GetTop(dragZoomBorder);
2365
                                double width = dragZoomBorder.Width;
2366
                                double height = dragZoomBorder.Height;
2367
                                Rect dragRect = new Rect(x, y, width, height);
2368

    
2369
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2370

    
2371
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2372
                            }
2373

    
2374
                            isDraggingSelectionRect = false;
2375
                            e.Handled = true;
2376
                            wasDragSelectionApplied = true;
2377
                        }
2378

    
2379
                        if (isLeftMouseButtonDownOnWindow)
2380
                        {
2381
                            isLeftMouseButtonDownOnWindow = false;
2382
                            this.ReleaseMouseCapture();
2383
                            e.Handled = true;
2384
                        }
2385

    
2386
                        if (!wasDragSelectionApplied)
2387
                        {
2388
                            init();
2389
                        }
2390
                    }
2391
                }
2392
                else if (e.RightButton == MouseButtonState.Pressed)
2393
                {
2394
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2395
                    SetCursor();
2396
                }
2397

    
2398
                zoomAndPanControl.ReleaseMouseCapture();
2399

    
2400
                e.Handled = true;
2401
            }
2402
            else
2403
            {
2404
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2405
                SetCursor();
2406
            }
2407

    
2408
            ///mouseButtonDown = MouseButton.Left;
2409
            //controlType = ControlType.SingleLine;
2410
        }
2411

    
2412
        public void Set_Symbol_Capture(Point endPoint)
2413
        {
2414
            double x = CanvasDrawingMouseDownPoint.X;
2415
            double y = CanvasDrawingMouseDownPoint.Y;
2416
            if (x > endPoint.X)
2417
            {
2418
                x = endPoint.X;
2419
                y = endPoint.Y;
2420
            }
2421

    
2422
            double width = dragCaptureBorder.Width;
2423
            double height = dragCaptureBorder.Height;
2424

    
2425
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2426

    
2427
            if (x < 0)
2428
            {
2429
                width += x;
2430
                x = 0;
2431
            }
2432
            if (y < 0)
2433
            {
2434
                height += y;
2435
                y = 0;
2436

    
2437
                width = (int)canvasImage.PixelWidth - x;
2438
            }
2439
            if (x + width > canvasImage.PixelWidth)
2440
            {
2441
                width = (int)canvasImage.PixelWidth - x;
2442
            }
2443
            if (y + height > canvasImage.PixelHeight)
2444
            {
2445
                height = (int)canvasImage.PixelHeight - y;
2446
            }
2447
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2448

    
2449
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2450
            var defaultBitmapImage = new BitmapImage();
2451
            defaultBitmapImage.BeginInit();
2452
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2453
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2454
            defaultBitmapImage.UriSource = new Uri(uri);
2455
            defaultBitmapImage.EndInit();
2456

    
2457
            //GC.Collect();
2458

    
2459
            if (defaultBitmapImage.IsDownloading)
2460
            {
2461
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2462
                {
2463
                    defaultBitmapImage.Freeze();
2464
                    //GC.Collect();
2465
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2466
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2467
                };
2468
            }
2469
        }
2470

    
2471
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2472
        {
2473
            ///mouseButtonDown = MouseButton.Left;
2474
        }
2475

    
2476
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2477
        {
2478
            ///mouseButtonDown = MouseButton.Left;
2479
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2480
        }
2481

    
2482
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2483
        {
2484
        }
2485

    
2486
        /// <summary>
2487
        /// select items by dragging
2488
        /// </summary>
2489
        private void ApplyDragSelectionRect()
2490
        {
2491
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2492

    
2493
            double x = Canvas.GetLeft(dragSelectionBorder);
2494
            double y = Canvas.GetTop(dragSelectionBorder);
2495
            double width = dragSelectionBorder.Width;
2496
            double height = dragSelectionBorder.Height;
2497
            Boolean Flag = false;
2498
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2499
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2500

    
2501
            Rect dragRect = new Rect(x, y, width, height);
2502
            ///dragRect.Inflate(width / 10, height / 10);
2503

    
2504
            foreach (var item in Items)
2505
            {
2506
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2507

    
2508
                if (Flag)
2509
                {
2510
                    adornerSet.Add(item);
2511
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2512
                    Control_Style(item);
2513
                }
2514
            }
2515
            if (adornerSet.Count > 0)
2516
            {
2517
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2518
                SelectLayer.Children.Add(final);
2519
            }
2520
        }
2521

    
2522
        private void InitDragSelectionRect(Point pt1, Point pt2)
2523
        {
2524
            //캡쳐 중
2525
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2526
            {
2527
                dragCaptureBorder.Visibility = Visibility.Visible;
2528
            }
2529
            //선택 중
2530
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2531
            {
2532
                dragSelectionBorder.Visibility = Visibility.Visible;
2533
            }
2534
            else
2535
            {
2536
                dragZoomBorder.Visibility = Visibility.Visible;
2537
            }
2538
            UpdateDragSelectionRect(pt1, pt2);
2539
        }
2540

    
2541
        /// <summary>
2542
        /// Update the position and size of the rectangle used for drag selection.
2543
        /// </summary>
2544
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2545
        {
2546
            double x, y, width, height;
2547

    
2548
            //
2549
            // Determine x,y,width and height of the rect inverting the points if necessary.
2550
            //
2551

    
2552
            if (pt2.X < pt1.X)
2553
            {
2554
                x = pt2.X;
2555
                width = pt1.X - pt2.X;
2556
            }
2557
            else
2558
            {
2559
                x = pt1.X;
2560
                width = pt2.X - pt1.X;
2561
            }
2562

    
2563
            if (pt2.Y < pt1.Y)
2564
            {
2565
                y = pt2.Y;
2566
                height = pt1.Y - pt2.Y;
2567
            }
2568
            else
2569
            {
2570
                y = pt1.Y;
2571
                height = pt2.Y - pt1.Y;
2572
            }
2573

    
2574
            //
2575
            // Update the coordinates of the rectangle used for drag selection.
2576
            //
2577
            //캡쳐 중
2578
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2579
            {
2580
                Canvas.SetLeft(dragCaptureBorder, x);
2581
                Canvas.SetTop(dragCaptureBorder, y);
2582
                dragCaptureBorder.Width = width;
2583
                dragCaptureBorder.Height = height;
2584
            }
2585
            //선택 중
2586
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2587
            {
2588
                Canvas.SetLeft(dragSelectionBorder, x);
2589
                Canvas.SetTop(dragSelectionBorder, y);
2590
                dragSelectionBorder.Width = width;
2591
                dragSelectionBorder.Height = height;
2592
            }
2593
            else
2594
            {
2595
                Canvas.SetLeft(dragZoomBorder, x);
2596
                Canvas.SetTop(dragZoomBorder, y);
2597
                dragZoomBorder.Width = width;
2598
                dragZoomBorder.Height = height;
2599
            }
2600
        }
2601

    
2602
        private void drawingPannelRotate(double angle)
2603
        {
2604
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2605
            rotate.Angle = angle;
2606
            var rotationNum = Math.Abs((rotate.Angle / 90));
2607

    
2608
            if (angle == 90 || angle == 270)
2609
            {
2610
                double emptySize = zoomAndPanCanvas.Width;
2611
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2612
                zoomAndPanCanvas.Height = emptySize;
2613
            }
2614
            if (angle == 0)
2615
            {
2616
                translate.X = 0;
2617
                translate.Y = 0;
2618
            }
2619
            else if (angle == 90)
2620
            {
2621
                translate.X = zoomAndPanCanvas.Width;
2622
                translate.Y = 0;
2623
            }
2624
            else if (angle == 180)
2625
            {
2626
                translate.X = zoomAndPanCanvas.Width;
2627
                translate.Y = zoomAndPanCanvas.Height;
2628
            }
2629
            else
2630
            {
2631
                translate.X = 0;
2632
                translate.Y = zoomAndPanCanvas.Height;
2633
            }
2634

    
2635
            zoomAndPanControl.RotationAngle = rotate.Angle;
2636

    
2637
            if (!testPanel2.IsHidden)
2638
            {
2639
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2640
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2641
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2642
            }
2643

    
2644
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2645
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2646
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2647
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2648
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2649
        }
2650

    
2651
        private void syncPannelRotate(double angle)
2652
        {
2653
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2654
            rotate.Angle = angle;
2655
            var rotationNum = Math.Abs((rotate.Angle / 90));
2656

    
2657
            if (angle == 90 || angle == 270)
2658
            {
2659
                double emptySize = zoomAndPanCanvas2.Width;
2660
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2661
                zoomAndPanCanvas2.Height = emptySize;
2662
            }
2663
            if (angle == 0)
2664
            {
2665
                translate2.X = 0;
2666
                translate2.Y = 0;
2667
            }
2668
            else if (angle == 90)
2669
            {
2670
                translate2.X = zoomAndPanCanvas2.Width;
2671
                translate2.Y = 0;
2672
            }
2673
            else if (angle == 180)
2674
            {
2675
                translate2.X = zoomAndPanCanvas2.Width;
2676
                translate2.Y = zoomAndPanCanvas2.Height;
2677
            }
2678
            else
2679
            {
2680
                translate2.X = 0;
2681
                translate2.Y = zoomAndPanCanvas2.Height;
2682
            }
2683

    
2684
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2685
        }
2686

    
2687
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2688
        {
2689
            string Data_ = "";
2690

    
2691
            try
2692
            {
2693
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2694
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2695
                if (Data_ != null || Data_ != "")
2696
                {
2697
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2698
                }
2699
                else
2700
                {
2701
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2702
                }
2703

    
2704
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2705
                //{
2706
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2707
                //    STATE = 0,
2708
                //};
2709
                if (Data_ != null)
2710
                {
2711
                    Image img = new Image();
2712
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2713
                    if (Data_.Contains(".svg"))
2714
                    {
2715
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2716
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2717
                    }
2718
                    else
2719
                    {
2720
                        img.Source = new BitmapImage(new Uri(Data_));
2721
                    }
2722

    
2723
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2724
                    {
2725
                        PointSet = new List<Point>(),
2726
                        FilePath = Data_,
2727
                        ImageData = img.Source,
2728
                        StartPoint = canvasZoomPanningMouseDownPoint,
2729
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2730
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2731
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2732
                        canvasZoomPanningMouseDownPoint.Y),
2733
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2734
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2735
                    };
2736

    
2737
                    currentControl.PointSet = new List<Point>
2738
                                        {
2739
                                            currentControl.StartPoint,
2740
                                            currentControl.LeftBottomPoint,
2741
                                            currentControl.EndPoint,
2742
                                            currentControl.TopRightPoint,
2743
                                        };
2744
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2745
                    UndoData = new Undo_data()
2746
                    {
2747
                        IsUndo = false,
2748
                        Event = Event_Type.Create,
2749
                        EventTime = DateTime.Now,
2750
                        Markup_List = new List<Multi_Undo_data>()
2751
                    };
2752
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2753
                    {
2754
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2755
                    });
2756

    
2757
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2758
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2759
                    UndoData.Markup_List.Add(multi_Undo_Data);
2760
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2761

    
2762
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2763
                    currentControl.CommentID = Commons.shortGuid();
2764
                    currentControl.SymbolID = id;
2765
                    currentControl.GroupID = group_id;
2766
                    currentControl.ApplyTemplate();
2767
                    currentControl.SetImage();
2768

    
2769
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2770
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2771
                    SelectLayer.Children.Add(final);
2772
                }
2773
            }
2774
            catch (Exception ex)
2775
            {
2776
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2777
            }
2778
        }
2779

    
2780
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2781
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2782
        {
2783
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2784
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2785
            {
2786
                set_option.Value = double.Parse(set_option.ContentText);
2787
                //set_option.Focusable = false;
2788
                zoomAndPanControl.Focus();
2789
            }
2790

    
2791
            ConvertInkControlToPolygon();
2792

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

    
2797
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2798
            {
2799
                DeleteCommand.Instance.Execute(new[] { text_item });
2800
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2801
            }
2802

    
2803
            /// up to here
2804

    
2805
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2806
            {
2807
                if (item as ArrowTextControl != null)
2808
                {
2809
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2810
                }
2811
                else if (item as TextControl != null)
2812
                {
2813
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2814
                }
2815
            }
2816

    
2817
            //if (currentControl != null)
2818
            {
2819
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2820
                if (text_item_ != null)
2821
                {
2822
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2823
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2824
                    (text_item_ as TextControl).IsEditingMode = false;
2825
                    currentControl = null;
2826
                }
2827

    
2828
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2829
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2830
                {
2831
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2832
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2833
                    currentControl = null;
2834
                }
2835
            }
2836

    
2837
            double Ang = 0;
2838
            if (rotate.Angle != 0)
2839
            {
2840
                Ang = 360 - rotate.Angle;
2841
            }
2842

    
2843
            if (e.OriginalSource is System.Windows.Controls.Image)
2844
            {
2845
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2846
            }
2847
            /*
2848
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2849
            {
2850
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2851
                if(symbol_id != null)
2852
                {
2853
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2854
                }
2855
            }
2856

    
2857
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2858
            {
2859
                if (this._dragdropWindow != null)
2860
                {
2861
                    this._dragdropWindow.Close();
2862
                    this._dragdropWindow = null;
2863
                    symbol_id = null;
2864
                }
2865
            }
2866
            */
2867

    
2868
            if (e.LeftButton == MouseButtonState.Pressed)
2869
            {
2870
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2871
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2872

    
2873
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2874
                SetCursor();
2875

    
2876
                if (!ViewerDataModel.Instance.IsPressCtrl)
2877
                {
2878
                    SelectionSet.Instance.UnSelect(this);
2879
                }
2880
            }
2881

    
2882
            if (e.MiddleButton == MouseButtonState.Pressed)
2883
            {
2884
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2885
                cursor = Cursors.SizeAll;
2886
                SetCursor();
2887
            }
2888
            if (e.RightButton == MouseButtonState.Pressed)
2889
            {
2890
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2891
                cursor = Cursors.SizeAll;
2892
                SetCursor();
2893
            }
2894
            else if (e.XButton1 == MouseButtonState.Pressed)
2895
            {
2896
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2897
                {
2898
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2899
                }
2900

    
2901
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2902
            }
2903
            else if (e.XButton2 == MouseButtonState.Pressed)
2904
            {
2905
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2906
                {
2907
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2908
                }
2909
            }
2910

    
2911
            bool isArrowTextEdit = false;
2912

    
2913
            if (currentControl is ArrowTextControl textControl)
2914
            {
2915
                if (textControl.IsEditingMode)
2916
                    isArrowTextEdit = true;
2917
            }
2918

    
2919
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2920
            {
2921
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2922
                {
2923
                    if (SelectLayer.Children.Count == 0)
2924
                    {
2925
                        isLeftMouseButtonDownOnWindow = true;
2926
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2927
                    }
2928

    
2929
                    if (controlType == ControlType.None)
2930
                    {
2931
                        isLeftMouseButtonDownOnWindow = true;
2932
                    }
2933
                }
2934

    
2935
                /// 캡쳐 모드 설정
2936
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2937
                {
2938
                    dragCaptureBorder.Visibility = Visibility.Visible;
2939
                    isLeftMouseButtonDownOnWindow = true;
2940
                }
2941

    
2942
                /// 줌 모드 설정
2943
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2944
                {
2945
                    isLeftMouseButtonDownOnWindow = true;
2946
                }
2947

    
2948
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2949

    
2950
                if (control == null)
2951
                {
2952
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2953
                }
2954
                else
2955
                {
2956
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2957
                    {
2958
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2959
                    }
2960

    
2961
                    AdornerFinal final = null;
2962

    
2963
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2964
                    {
2965
                        /// 기존 selection 해제
2966
                        SelectionSet.Instance.UnSelect(this);
2967

    
2968
                        final = new AdornerFinal(control);
2969

    
2970
                        this.Control_Style(control);
2971

    
2972
                        if ((control as IPath) != null)
2973
                        {
2974
                            if ((control as IPath).LineSize != 0)
2975
                            {
2976
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2977
                            }
2978
                        }
2979
                        if ((control as IShapeControl) != null)
2980
                        {
2981
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2982
                            {
2983
                                ViewerDataModel.Instance.checkHatchShape = true;
2984
                            }
2985
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2986
                            {
2987
                                ViewerDataModel.Instance.checkFillShape = true;
2988
                            }
2989
                            else
2990
                            {
2991
                                ViewerDataModel.Instance.checkHatchShape = false;
2992
                                ViewerDataModel.Instance.checkFillShape = false;
2993
                            }
2994
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2995
                        }
2996

    
2997
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2998

    
2999
                        if ((control as TextControl) != null)
3000
                        {
3001
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
3002

    
3003
                            if (!((control as TextControl).EnableEditing))
3004
                            {
3005
                                (control as TextControl).EnableEditing = true;
3006
                            }
3007
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
3008
                            {
3009
                                ViewerDataModel.Instance.checkTextStyle = true;
3010
                            }
3011
                            else
3012
                            {
3013
                                ViewerDataModel.Instance.checkTextStyle = false;
3014
                            }
3015
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
3016
                            {
3017
                                ViewerDataModel.Instance.checkTextWeight = true;
3018
                            }
3019
                            else
3020
                            {
3021
                                ViewerDataModel.Instance.checkTextWeight = false;
3022
                            }
3023
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
3024
                            {
3025
                                ViewerDataModel.Instance.checkUnderLine = true;
3026
                            }
3027
                            else
3028
                            {
3029
                                ViewerDataModel.Instance.checkUnderLine = false;
3030
                            }
3031
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
3032
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
3033
                        }
3034
                        else if ((control as ArrowTextControl) != null)
3035
                        {
3036
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
3037

    
3038
                            if (!((control as ArrowTextControl).EnableEditing))
3039
                            {
3040
                                (control as ArrowTextControl).EnableEditing = true;
3041
                            }
3042
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
3043
                            {
3044
                                ViewerDataModel.Instance.checkTextStyle = true;
3045
                            }
3046
                            else
3047
                            {
3048
                                ViewerDataModel.Instance.checkTextStyle = false;
3049
                            }
3050
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
3051
                            {
3052
                                ViewerDataModel.Instance.checkTextWeight = true;
3053
                            }
3054
                            else
3055
                            {
3056
                                ViewerDataModel.Instance.checkTextWeight = false;
3057
                            }
3058
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
3059
                            {
3060
                                ViewerDataModel.Instance.checkUnderLine = true;
3061
                            }
3062
                            else
3063
                            {
3064
                                ViewerDataModel.Instance.checkUnderLine = false;
3065
                            }
3066
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
3067
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
3068
                        }
3069
                        else if ((control as RectCloudControl) != null)
3070
                        {
3071
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
3072
                        }
3073
                        else if ((control as CloudControl) != null)
3074
                        {
3075
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3076
                        }
3077
                    }
3078
                    else
3079
                    {
3080
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3081
                        SelectionSet.Instance.UnSelect(this);
3082
                        comment.Add(control);
3083

    
3084
                        Control_Style(control);
3085

    
3086
                        final = new AdornerFinal(comment);
3087
                    }
3088

    
3089
                    if (final != null)
3090
                    {
3091
                        this.SelectLayer.Children.Add(final);
3092
                    }
3093
                }
3094
            }
3095
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3096
            {
3097

    
3098

    
3099
                init();
3100
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3101
                if (cursor != Cursors.SizeAll)
3102
                {
3103
                    cursor = Cursors.Cross;
3104
                    SetCursor();
3105
                }
3106
                bool init_user = false;
3107
                foreach (var user in gridViewMarkup.Items)
3108
                {
3109
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3110
                    {
3111
                        init_user = true;
3112
                    }
3113
                }
3114
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3115
                {
3116
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3117
                    RadWindow.Alert(new DialogParameters
3118
                    {
3119
                        Owner = Application.Current.MainWindow,
3120
                        Theme = new VisualStudio2013Theme(),
3121
                        Header = "Info",
3122
                        Content = "Existing comments already existed. Select from the user list first",
3123
                    });
3124
                    return;
3125
                }
3126
                else
3127
                {
3128
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3129
                    if (item != null)
3130
                    {
3131
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3132
                    }
3133
                }
3134
                
3135
                switch (controlType)
3136
                {
3137
                    case ControlType.Coordinate:
3138
                        {
3139
                            if (e.LeftButton == MouseButtonState.Pressed)
3140
                            {
3141
                                if (currentControl is CoordinateControl)
3142
                                {
3143
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3144
                                    {
3145
                                        return;
3146
                                    }
3147

    
3148
                                    CreateCommand.Instance.Execute(currentControl);
3149

    
3150
                                    currentControl = null;
3151
                                    this.cursor = Cursors.Arrow;
3152
                                }
3153
                                else
3154
                                {
3155
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3156
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3157
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3158
                                    {
3159
                                        currentControl = null;
3160
                                        this.cursor = Cursors.Arrow;
3161
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3162
                                        return;
3163
                                    }
3164
                                    else
3165
                                    {
3166
                                        currentControl = new CoordinateControl
3167
                                        {
3168
                                            Background = new SolidColorBrush(Colors.Black),
3169
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3170
                                            ControlType = ControlType.Coordinate
3171
                                        };
3172

    
3173
                                        currentControl.CommentID = Commons.shortGuid();
3174
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3175
                                        currentControl.IsNew = true;
3176

    
3177
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3178

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

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

    
3197
                                    CreateCommand.Instance.Execute(currentControl);
3198

    
3199
                                    currentControl = null;
3200
                                    this.cursor = Cursors.Arrow;
3201
                                }
3202
                                else
3203
                                {
3204
                                    currentControl = new InsideWhiteControl
3205
                                    {
3206
                                        Background = new SolidColorBrush(Colors.Black),
3207
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3208
                                        ControlType = ControlType.InsideWhite
3209
                                    };
3210

    
3211
                                    currentControl.CommentID = Commons.shortGuid();
3212
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3213
                                    currentControl.IsNew = true;
3214
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3215

    
3216
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3217
                                }
3218
                            }
3219
                        }
3220
                        break;
3221

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

    
3233
                                    CreateCommand.Instance.Execute(currentControl);
3234

    
3235
                                    currentControl = null;
3236
                                    this.cursor = Cursors.Arrow;
3237
                                }
3238
                                else
3239
                                {
3240
                                    currentControl = new OverlapWhiteControl
3241
                                    {
3242
                                        Background = new SolidColorBrush(Colors.Black),
3243
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3244
                                        ControlType = ControlType.OverlapWhite
3245
                                    };
3246

    
3247
                                    currentControl.CommentID = Commons.shortGuid();
3248
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3249
                                    currentControl.IsNew = true;
3250
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3251

    
3252
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3253
                                }
3254
                            }
3255
                        }
3256
                        break;
3257

    
3258
                    case ControlType.ClipWhite:
3259
                        {
3260
                            if (e.LeftButton == MouseButtonState.Pressed)
3261
                            {
3262
                                if (currentControl is ClipWhiteControl)
3263
                                {
3264
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3265
                                    {
3266
                                        return;
3267
                                    }
3268

    
3269
                                    CreateCommand.Instance.Execute(currentControl);
3270

    
3271
                                    currentControl = null;
3272
                                    this.cursor = Cursors.Arrow;
3273
                                }
3274
                                else
3275
                                {
3276
                                    currentControl = new ClipWhiteControl
3277
                                    {
3278
                                        Background = new SolidColorBrush(Colors.Black),
3279
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3280
                                        ControlType = ControlType.ClipWhite
3281
                                    };
3282

    
3283
                                    currentControl.CommentID = Commons.shortGuid();
3284
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3285
                                    currentControl.IsNew = true;
3286
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3287

    
3288
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3289
                                }
3290
                            }
3291
                        }
3292
                        break;
3293

    
3294
                    case ControlType.Rectangle:
3295
                        {
3296
                            if (e.LeftButton == MouseButtonState.Pressed)
3297
                            {
3298
                                if (currentControl is RectangleControl)
3299
                                {
3300
                                    //20180906 LJY TEST IsRotationDrawingEnable
3301
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3302
                                    {
3303
                                        return;
3304
                                    }
3305

    
3306
                                    CreateCommand.Instance.Execute(currentControl);
3307
                                    currentControl = null;
3308
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3309
                                }
3310
                                else
3311
                                {
3312
                                    currentControl = new RectangleControl
3313
                                    {
3314
                                        Background = new SolidColorBrush(Colors.Black),
3315
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3316
                                        ControlType = ControlType.Rectangle
3317
                                    };
3318

    
3319
                                    currentControl.CommentID = Commons.shortGuid();
3320
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3321
                                    currentControl.IsNew = true;
3322
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3323

    
3324
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3325
                                }
3326
                            }
3327
                        }
3328
                        break;
3329

    
3330
                    case ControlType.RectCloud:
3331
                        {
3332
                            if (e.LeftButton == MouseButtonState.Pressed)
3333
                            {
3334
                                if (currentControl is RectCloudControl)
3335
                                {
3336
                                    //20180906 LJY TEST IsRotationDrawingEnable
3337
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3338
                                    {
3339
                                        return;
3340
                                    }
3341

    
3342
                                    CreateCommand.Instance.Execute(currentControl);
3343

    
3344
                                    currentControl = null;
3345

    
3346
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3347
                                }
3348
                                else
3349
                                {
3350
                                    currentControl = new RectCloudControl
3351
                                    {
3352
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3353
                                        ControlType = ControlType.RectCloud,
3354
                                        Background = new SolidColorBrush(Colors.Black)
3355
                                    };
3356

    
3357
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3358
                                    currentControl.CommentID = Commons.shortGuid();
3359
                                    currentControl.IsNew = true;
3360
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3361
                                }
3362
                            }
3363
                        }
3364
                        break;
3365

    
3366
                    case ControlType.Circle:
3367
                        {
3368
                            if (e.LeftButton == MouseButtonState.Pressed)
3369
                            {
3370
                                if (currentControl is CircleControl)
3371
                                {
3372
                                    //20180906 LJY TEST IsRotationDrawingEnable
3373
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3374
                                    {
3375
                                        return;
3376
                                    }
3377

    
3378
                                    CreateCommand.Instance.Execute(currentControl);
3379

    
3380
                                    currentControl = null;
3381
                                }
3382
                                else
3383
                                {
3384
                                    currentControl = new CircleControl
3385
                                    {
3386
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3387
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3388
                                        Background = new SolidColorBrush(Colors.Black)
3389
                                    };
3390

    
3391
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3392
                                    currentControl.CommentID = Commons.shortGuid();
3393
                                    currentControl.IsNew = true;
3394
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3395
                                }
3396
                            }
3397
                        }
3398
                        break;
3399

    
3400
                    case ControlType.Triangle:
3401
                        {
3402
                            if (e.LeftButton == MouseButtonState.Pressed)
3403
                            {
3404
                                if (currentControl is TriControl)
3405
                                {
3406
                                    var content = currentControl as TriControl;
3407
                                    if (content.MidPoint == new Point(0, 0))
3408
                                    {
3409
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3410
                                    }
3411
                                    else
3412
                                    {
3413
                                        //20180906 LJY TEST IsRotationDrawingEnable
3414
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3415
                                        {
3416
                                            return;
3417
                                        }
3418

    
3419
                                        CreateCommand.Instance.Execute(currentControl);
3420

    
3421
                                        currentControl = null;
3422
                                    }
3423
                                }
3424
                                else
3425
                                {
3426
                                    currentControl = new TriControl
3427
                                    {
3428
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3429
                                        Background = new SolidColorBrush(Colors.Black),
3430
                                    };
3431

    
3432
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3433
                                    currentControl.CommentID = Commons.shortGuid();
3434
                                    currentControl.IsNew = true;
3435
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3436
                                }
3437
                            }
3438
                        }
3439
                        break;
3440

    
3441
                    case ControlType.CancelLine:
3442
                    case ControlType.SingleLine:
3443
                    case ControlType.ArrowLine:
3444
                    case ControlType.TwinLine:
3445
                    case ControlType.DimLine:
3446
                        {
3447
                            if (e.LeftButton == MouseButtonState.Pressed)
3448
                            {
3449
                                if (currentControl is LineControl)
3450
                                {
3451
                                    //20180906 LJY TEST IsRotationDrawingEnable
3452
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3453
                                    {
3454
                                        return;
3455
                                    }
3456

    
3457
                                    CreateCommand.Instance.Execute(currentControl);
3458
                                    currentControl = null;
3459
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3460
                                }
3461
                                else
3462
                                {
3463
                                    currentControl = new LineControl
3464
                                    {
3465
                                        ControlType = this.controlType,
3466
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3467
                                        Background = new SolidColorBrush(Colors.Black)
3468
                                    };
3469

    
3470
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3471
                                    currentControl.CommentID = Commons.shortGuid();
3472
                                    currentControl.IsNew = true;
3473
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3474
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3475
                                }
3476
                            }
3477
                        }
3478
                        break;
3479

    
3480
                    case ControlType.PolygonControl:
3481
                        {
3482
                            if (currentControl is PolygonControl)
3483
                            {
3484
                                var control = currentControl as PolygonControl;
3485

    
3486
                                if (e.RightButton == MouseButtonState.Pressed)
3487
                                {
3488
                                    control.IsCompleted = true;
3489
                                }
3490

    
3491
                                if (!control.IsCompleted)
3492
                                {
3493
                                    control.PointSet.Add(control.EndPoint);
3494
                                }
3495
                                else
3496
                                {
3497
                                    //20180906 LJY TEST IsRotationDrawingEnable
3498
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3499
                                    {
3500
                                        return;
3501
                                    }
3502

    
3503
                                    var firstPoint = control.PointSet.First();
3504
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3505
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3506
                                    control.PointSet.Add(firstPoint);
3507

    
3508
                                    control.ApplyOverViewData();
3509

    
3510
                                    CreateCommand.Instance.Execute(currentControl);
3511
                                    control.UpdateControl();
3512
                                    currentControl = null;
3513
                                }
3514
                            }
3515
                            else
3516
                            {
3517
                                if (e.LeftButton == MouseButtonState.Pressed)
3518
                                {
3519
                                    currentControl = new PolygonControl
3520
                                    {
3521
                                        PointSet = new List<Point>(),
3522
                                    };
3523

    
3524
                                    var polygonControl = (currentControl as PolygonControl);
3525
                                    currentControl.CommentID = Commons.shortGuid();
3526
                                    currentControl.IsNew = true;
3527
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3528
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3529
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3530
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3531
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3532
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3533
                                    polygonControl.ApplyTemplate();
3534
                                    polygonControl.Visibility = Visibility.Visible;
3535
                                }
3536
                            }
3537
                        }
3538
                        break;
3539

    
3540
                    case ControlType.ChainLine:
3541
                        {
3542
                            if (currentControl is PolygonControl)
3543
                            {
3544
                                var control = currentControl as PolygonControl;
3545

    
3546
                                if (e.RightButton == MouseButtonState.Pressed)
3547
                                {
3548
                                    //20180906 LJY TEST IsRotationDrawingEnable
3549
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3550
                                    {
3551
                                        return;
3552
                                    }
3553

    
3554
                                    CreateCommand.Instance.Execute(currentControl);
3555

    
3556
                                    currentControl = null;
3557
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3558
                                    return;
3559
                                }
3560

    
3561
                                if (!control.IsCompleted)
3562
                                {
3563
                                    control.PointSet.Add(control.EndPoint);
3564
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3565
                                }
3566
                            }
3567
                            else
3568
                            {
3569
                                if (e.LeftButton == MouseButtonState.Pressed)
3570
                                {
3571
                                    MainAngle.Visibility = Visibility.Visible;
3572
                                    currentControl = new PolygonControl
3573
                                    {
3574
                                        PointSet = new List<Point>(),
3575
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3576
                                        ControlType = ControlType.ChainLine,
3577
                                        DashSize = ViewerDataModel.Instance.DashSize,
3578
                                        LineSize = ViewerDataModel.Instance.LineSize,
3579
                                        //PointC = new StylusPointSet()
3580
                                    };
3581

    
3582
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3583
                                    //{
3584
                                    var polygonControl = (currentControl as PolygonControl);
3585
                                    currentControl.CommentID = Commons.shortGuid();
3586
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3587
                                    currentControl.IsNew = true;
3588
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3589
                                    //currentControl.OnApplyTemplate();
3590
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3591
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3592
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3593
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3594
                                    //}
3595
                                }
3596
                            }
3597
                        }
3598
                        break;
3599

    
3600
                    case ControlType.ArcLine:
3601
                        {
3602
                            if (e.LeftButton == MouseButtonState.Pressed)
3603
                            {
3604
                                if (currentControl is ArcControl)
3605
                                {
3606
                                    //20180906 LJY TEST IsRotationDrawingEnable
3607
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3608
                                    {
3609
                                        return;
3610
                                    }
3611

    
3612
                                    CreateCommand.Instance.Execute(currentControl);
3613

    
3614
                                    currentControl = null;
3615
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3616
                                }
3617
                                else
3618
                                {
3619
                                    currentControl = new ArcControl
3620
                                    {
3621
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3622
                                        Background = new SolidColorBrush(Colors.Black)
3623
                                    };
3624
                                    currentControl.CommentID = Commons.shortGuid();
3625
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3626
                                    currentControl.IsNew = true;
3627
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3628
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3629
                                }
3630
                            }
3631
                            else if (e.RightButton == MouseButtonState.Pressed)
3632
                            {
3633
                                if (currentControl != null)
3634
                                {
3635
                                    (currentControl as ArcControl).setClock();
3636
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3637
                                }
3638
                            }
3639
                        }
3640
                        break;
3641

    
3642
                    case ControlType.ArcArrow:
3643
                        {
3644
                            if (e.LeftButton == MouseButtonState.Pressed)
3645
                            {
3646
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3647
                                //{
3648
                                if (currentControl is ArrowArcControl)
3649
                                {
3650
                                    //20180906 LJY TEST IsRotationDrawingEnable
3651
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3652
                                    {
3653
                                        return;
3654
                                    }
3655

    
3656
                                    CreateCommand.Instance.Execute(currentControl);
3657

    
3658
                                    currentControl = null;
3659
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3660
                                }
3661
                                else
3662
                                {
3663
                                    currentControl = new ArrowArcControl
3664
                                    {
3665
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3666
                                        Background = new SolidColorBrush(Colors.Black)
3667
                                    };
3668
                                    currentControl.CommentID = Commons.shortGuid();
3669
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3670
                                    currentControl.IsNew = true;
3671
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3672
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3673
                                }
3674
                                //}
3675
                            }
3676
                            else if (e.RightButton == MouseButtonState.Pressed)
3677
                            {
3678
                                if (currentControl != null)
3679
                                {
3680
                                    (currentControl as ArrowArcControl).setClock();
3681
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3682
                                    //(currentControl as ArcControl).ApplyTemplate();
3683
                                }
3684
                            }
3685
                        }
3686
                        break;
3687

    
3688
                    case ControlType.ArrowMultiLine:
3689
                        {
3690
                            if (e.LeftButton == MouseButtonState.Pressed)
3691
                            {
3692
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3693
                                //{
3694
                                if (currentControl is ArrowControl_Multi)
3695
                                {
3696
                                    var content = currentControl as ArrowControl_Multi;
3697
                                    if (content.MiddlePoint == new Point(0, 0))
3698
                                    {
3699
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3700
                                        {
3701
                                            content.MiddlePoint = content.EndPoint;
3702
                                        }
3703
                                        else
3704
                                        {
3705
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3706
                                        }
3707
                                    }
3708
                                    else
3709
                                    {
3710
                                        //20180906 LJY TEST IsRotationDrawingEnable
3711
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3712
                                        {
3713
                                            return;
3714
                                        }
3715

    
3716
                                        CreateCommand.Instance.Execute(currentControl);
3717

    
3718
                                        currentControl = null;
3719
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3720
                                    }
3721
                                }
3722
                                else
3723
                                {
3724
                                    currentControl = new ArrowControl_Multi
3725
                                    {
3726
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3727
                                        Background = new SolidColorBrush(Colors.Black)
3728
                                    };
3729
                                    currentControl.CommentID = Commons.shortGuid();
3730
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3731
                                    currentControl.IsNew = true;
3732
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3733
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3734
                                }
3735
                                //}
3736
                            }
3737
                        }
3738
                        break;
3739

    
3740
                    case ControlType.PolygonCloud:
3741
                        {
3742
                            if (currentControl is CloudControl)
3743
                            {
3744
                                var control = currentControl as CloudControl;
3745
                                if (e.RightButton == MouseButtonState.Pressed)
3746
                                {
3747
                                    control.IsCompleted = true;
3748
                                }
3749

    
3750
                                if (!control.IsCompleted)
3751
                                {
3752
                                    control.PointSet.Add(control.EndPoint);
3753
                                }
3754
                                else
3755
                                {
3756
                                    //20180906 LJY TEST IsRotationDrawingEnable
3757
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3758
                                    {
3759
                                        return;
3760
                                    }
3761

    
3762
                                    CreateCommand.Instance.Execute(currentControl);
3763

    
3764
                                    control.isTransOn = true;
3765
                                    var firstPoint = control.PointSet.First();
3766

    
3767
                                    control.PointSet.Add(firstPoint);
3768
                                    control.DrawingCloud();
3769
                                    control.ApplyOverViewData();
3770

    
3771
                                    currentControl = null;
3772
                                }
3773
                            }
3774
                            else
3775
                            {
3776
                                if (e.LeftButton == MouseButtonState.Pressed)
3777
                                {
3778
                                    currentControl = new CloudControl
3779
                                    {
3780
                                        PointSet = new List<Point>(),
3781
                                        PointC = new StylusPointSet()
3782
                                    };
3783

    
3784
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3785
                                    //{
3786
                                    var polygonControl = (currentControl as CloudControl);
3787
                                    currentControl.CommentID = Commons.shortGuid();
3788
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3789
                                    currentControl.IsNew = true;
3790
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3791

    
3792
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3793
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3794

    
3795
                                    //}
3796
                                }
3797
                            }
3798
                        }
3799
                        break;
3800

    
3801
                    case ControlType.ImgControl:
3802
                        {
3803
                            if (e.LeftButton == MouseButtonState.Pressed)
3804
                            {
3805
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3806
                                //{
3807
                                if (currentControl is ImgControl)
3808
                                {
3809
                                    //20180906 LJY TEST IsRotationDrawingEnable
3810
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3811
                                    {
3812
                                        return;
3813
                                    }
3814

    
3815
                                    CreateCommand.Instance.Execute(currentControl);
3816
                                    controlType = ControlType.ImgControl;
3817
                                    currentControl = null;
3818
                                }
3819
                                else
3820
                                {
3821
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3822
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3823
                                    {
3824
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3825
                                        UriBuilder uri = new UriBuilder(filename);
3826
                                        uri.Host = downloadUri.Host;
3827
                                        uri.Port = downloadUri.Port;
3828

    
3829
                                        Image img = new Image();
3830
                                        if (filename.Contains(".svg"))
3831
                                        {
3832
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3833
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3834
                                        }
3835
                                        else
3836
                                        {
3837
                                            img.Source = new BitmapImage(uri.Uri);
3838
                                        }
3839

    
3840
                                        currentControl = new ImgControl
3841
                                        {
3842
                                            Background = new SolidColorBrush(Colors.Black),
3843
                                            PointSet = new List<Point>(),
3844
                                            FilePath = uri.Uri.ToString(),
3845
                                            ImageData = img.Source,
3846
                                            StartPoint = CanvasDrawingMouseDownPoint,
3847
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3848
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3849
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3850
                                            ControlType = ControlType.ImgControl
3851
                                        };
3852

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

    
3858
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3859
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3860
                                    }
3861
                                }
3862
                                //}
3863
                            }
3864
                        }
3865
                        break;
3866

    
3867
                    case ControlType.Date:
3868
                        {
3869
                            if (e.LeftButton == MouseButtonState.Pressed)
3870
                            {
3871
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3872
                                //{
3873
                                if (currentControl is DateControl)
3874
                                {
3875
                                    //20180906 LJY TEST IsRotationDrawingEnable
3876
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3877
                                    {
3878
                                        return;
3879
                                    }
3880

    
3881
                                    CreateCommand.Instance.Execute(currentControl);
3882
                                    currentControl = null;
3883

    
3884
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3885
                                    { 
3886
                                        controlType = ControlType.None;
3887
                                        IsSwingMode = false;
3888
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3889
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3890
                                        mouseHandlingMode = MouseHandlingMode.None;
3891
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3892
                                        txtBatch.Visibility = Visibility.Collapsed;
3893
                                    }
3894
                                }
3895
                                else
3896
                                {
3897
                                    currentControl = new DateControl
3898
                                    {
3899
                                        StartPoint = CanvasDrawingMouseDownPoint,
3900
                                        Background = new SolidColorBrush(Colors.Black)
3901
                                    };
3902
                                    currentControl.CommentID = Commons.shortGuid();
3903
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3904
                                    currentControl.IsNew = true;
3905
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3906

    
3907
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3908
                                    if (currentControl is ImgControl)
3909
                                    {
3910
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3911
                                    }
3912
                                }
3913
                                //}
3914
                            }
3915
                        }
3916
                        break;
3917

    
3918
                    case ControlType.TextControl:
3919
                        {
3920
                            if (e.LeftButton == MouseButtonState.Pressed)
3921
                            {
3922
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3923
                                {
3924
                                    currentControl = new TextControl
3925
                                    {
3926
                                        ControlType = controlType
3927
                                    };
3928
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3929
                                    currentControl.CommentID = Commons.shortGuid();
3930
                                    currentControl.IsNew = true;
3931
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3932
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3933
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3934

    
3935
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3936
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3937

    
3938
                                    (currentControl as TextControl).ControlType_No = 0;
3939
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3940
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3941
                                    (currentControl as TextControl).ApplyTemplate();
3942
                                    (currentControl as TextControl).Base_TextBox.Focus();
3943
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3944

    
3945
                                    if(previousControl == null)
3946
                                    {
3947
                                        previousControl = currentControl as TextControl;
3948
                                    }
3949
                                    else
3950
                                    {
3951
                                        var vPreviousControl = previousControl as TextControl;
3952
                                        if (string.IsNullOrEmpty(vPreviousControl.Text))
3953
                                        {
3954
                                            DeleteCommand.Instance.Execute(new[] { previousControl });
3955
                                            previousControl = null;
3956
                                        }
3957
                                        else
3958
                                        {
3959
                                            previousControl = currentControl as TextControl;
3960
                                        }
3961
                                    }
3962
                                    CreateCommand.Instance.Execute(currentControl);
3963
                                    if (previousControl == null)
3964
                                        previousControl = currentControl;
3965
                                }
3966
                            }
3967
                        }
3968
                        break;
3969

    
3970
                    case ControlType.TextBorder:
3971
                        {
3972
                            if (e.LeftButton == MouseButtonState.Pressed)
3973
                            {
3974
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3975
                                {
3976
                                    currentControl = new TextControl
3977
                                    {
3978
                                        ControlType = controlType
3979
                                    };
3980

    
3981
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3982
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3983
                                    currentControl.CommentID = Commons.shortGuid();
3984
                                    currentControl.IsNew = true;
3985
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3986
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3987
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3988
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3989

    
3990
                                    (currentControl as TextControl).ControlType_No = 1;
3991
                                    (currentControl as TextControl).CommentAngle = Ang;
3992
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3993
                                    (currentControl as TextControl).ApplyTemplate();
3994
                                    (currentControl as TextControl).Base_TextBox.Focus();
3995
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3996
                                    CreateCommand.Instance.Execute(currentControl);
3997
                                }
3998
                            }
3999
                        }
4000
                        break;
4001

    
4002
                    case ControlType.TextCloud:
4003
                        {
4004
                            if (e.LeftButton == MouseButtonState.Pressed)
4005
                            {
4006
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4007
                                {
4008
                                    currentControl = new TextControl
4009
                                    {
4010
                                        ControlType = controlType
4011
                                    };
4012

    
4013
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
4014
                                    currentControl.CommentID = Commons.shortGuid();
4015
                                    currentControl.IsNew = true;
4016
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4017
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4018

    
4019
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4020
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
4021
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
4022

    
4023
                                    (currentControl as TextControl).CommentAngle = Ang;
4024
                                    (currentControl as TextControl).ControlType_No = 2;
4025
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
4026
                                    (currentControl as TextControl).ApplyTemplate();
4027

    
4028
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4029

    
4030
                                    (currentControl as TextControl).Base_TextBox.Focus();
4031
                                    CreateCommand.Instance.Execute(currentControl);
4032
                                    
4033
                                    //currentControl = null;
4034
                                }
4035
                            }
4036
                        }
4037
                        break;
4038

    
4039
                    case ControlType.ArrowTextControl:
4040
                        {
4041
                            if (e.LeftButton == MouseButtonState.Pressed)
4042
                            {
4043
                                if (currentControl is ArrowTextControl)
4044
                                {
4045
                                    //20180906 LJY TEST IsRotationDrawingEnable
4046
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4047
                                    {
4048
                                        return;
4049
                                    }
4050

    
4051
                                    CreateCommand.Instance.Execute(currentControl);
4052

    
4053
                                    try
4054
                                    {
4055
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
4056
                                        {
4057
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4058
                                        }
4059
                                    }
4060
                                    catch (Exception ex)
4061
                                    {
4062
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4063
                                    }
4064

    
4065
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4066
                                    (currentControl as ArrowTextControl).EnableEditing = false;
4067
                                    (currentControl as ArrowTextControl).IsNew = false;
4068
                                    currentControl = null;
4069
                                }
4070
                                else
4071
                                {
4072
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4073
                                    //{
4074
                                    currentControl = new ArrowTextControl()
4075
                                    {
4076
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4077
                                    };
4078

    
4079
                                    currentControl.CommentID = Commons.shortGuid();
4080
                                    currentControl.IsNew = true;
4081
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4082

    
4083
                                    try
4084
                                    {
4085
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4086
                                    }
4087
                                    catch (Exception ex)
4088
                                    {
4089
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4090
                                    }
4091

    
4092
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4093
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4094
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4095
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4096
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4097

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

    
4101
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4102
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4103
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4104
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4105

    
4106
                                    //}
4107
                                }
4108
                            }
4109
                        }
4110
                        break;
4111

    
4112
                    case ControlType.ArrowTransTextControl:
4113
                        {
4114
                            if (e.LeftButton == MouseButtonState.Pressed)
4115
                            {
4116
                                if (currentControl is ArrowTextControl)
4117
                                {
4118
                                    //20180906 LJY TEST IsRotationDrawingEnable
4119
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4120
                                    {
4121
                                        return;
4122
                                    }
4123

    
4124
                                    CreateCommand.Instance.Execute(currentControl);
4125

    
4126
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4127

    
4128
                                    currentControl.IsNew = false;
4129
                                    currentControl = null;
4130
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4131
                                }
4132
                                else
4133
                                {
4134
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4135
                                    //{
4136
                                    currentControl = new ArrowTextControl()
4137
                                    {
4138
                                        ControlType = ControlType.ArrowTransTextControl,
4139
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4140
                                    };
4141
                                    currentControl.CommentID = Commons.shortGuid();
4142
                                    currentControl.IsNew = true;
4143
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4144
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4145
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4146
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4147
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4148
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4149
                                    (currentControl as ArrowTextControl).isFixed = true;
4150
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4151

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

    
4155
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4156
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4157
                                    (currentControl as ArrowTextControl).isTrans = true;
4158
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4159
                                }
4160
                            }
4161
                        }
4162
                        break;
4163

    
4164
                    case ControlType.ArrowTextBorderControl:
4165
                        {
4166
                            if (e.LeftButton == MouseButtonState.Pressed)
4167
                            {
4168
                                if (currentControl is ArrowTextControl)
4169
                                {
4170
                                    //20180906 LJY TEST IsRotationDrawingEnable
4171
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4172
                                    {
4173
                                        return;
4174
                                    }
4175

    
4176
                                    CreateCommand.Instance.Execute(currentControl);
4177
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4178
                                    currentControl.IsNew = false;
4179
                                    currentControl = null;
4180
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4181
                                }
4182
                                else
4183
                                {
4184
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4185
                                    //{
4186
                                    currentControl = new ArrowTextControl()
4187
                                    {
4188
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4189
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4190
                                    };
4191
                                    currentControl.CommentID = Commons.shortGuid();
4192
                                    currentControl.IsNew = true;
4193
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4194
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4195

    
4196
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4197

    
4198
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4199

    
4200
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4201
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4202
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4203
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4204
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4205
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4206
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4207
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4208
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4209
                                    //}
4210
                                }
4211
                            }
4212
                        }
4213
                        break;
4214

    
4215
                    case ControlType.ArrowTransTextBorderControl:
4216
                        {
4217
                            if (e.LeftButton == MouseButtonState.Pressed)
4218
                            {
4219
                                if (currentControl is ArrowTextControl)
4220
                                {
4221
                                    //20180906 LJY TEST IsRotationDrawingEnable
4222
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4223
                                    {
4224
                                        return;
4225
                                    }
4226
                                    CreateCommand.Instance.Execute(currentControl);
4227
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4228
                                    currentControl.IsNew = false;
4229
                                    currentControl = null;
4230

    
4231
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4232
                                }
4233
                                else
4234
                                {
4235
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4236
                                    //{
4237
                                    currentControl = new ArrowTextControl()
4238
                                    {
4239
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4240
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4241
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4242
                                    };
4243
                                    
4244
                                    currentControl.CommentID = Commons.shortGuid();
4245
                                    currentControl.IsNew = true;
4246
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4247
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4248

    
4249
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4250

    
4251
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4252
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4253
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4254
                                    (currentControl as ArrowTextControl).isFixed = true;
4255
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4256

    
4257
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4258
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4259
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4260
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4261
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4262
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4263

    
4264
                                    //20180911 LJY
4265
                                    (currentControl as ArrowTextControl).isTrans = true;
4266

    
4267
                                    //}
4268
                                }
4269
                            }
4270
                        }
4271
                        break;
4272

    
4273
                    case ControlType.ArrowTextCloudControl:
4274
                        {
4275
                            if (e.LeftButton == MouseButtonState.Pressed)
4276
                            {
4277
                                if (currentControl is ArrowTextControl)
4278
                                {
4279
                                    //20180906 LJY TEST IsRotationDrawingEnable
4280
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4281
                                    {
4282
                                        return;
4283
                                    }
4284
                                    CreateCommand.Instance.Execute(currentControl);
4285
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4286
                                    currentControl.IsNew = false;
4287
                                    currentControl = null;
4288
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4289
                                }
4290
                                else
4291
                                {
4292
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4293
                                    //{
4294
                                    currentControl = new ArrowTextControl()
4295
                                    {
4296
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4297
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4298
                                        ControlType = ControlType.ArrowTextCloudControl
4299
                                    };
4300
                                    currentControl.CommentID = Commons.shortGuid();
4301
                                    currentControl.IsNew = true;
4302
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4303
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4304

    
4305
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4306
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4307
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4308
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4309
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4310
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4311
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4312
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4313

    
4314
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4315
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4316
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4317
                                    //}
4318
                                }
4319
                            }
4320
                        }
4321
                        break;
4322

    
4323
                    case ControlType.ArrowTransTextCloudControl:
4324
                        {
4325
                            if (e.LeftButton == MouseButtonState.Pressed)
4326
                            {
4327
                                if (currentControl is ArrowTextControl)
4328
                                {
4329
                                    //20180906 LJY TEST IsRotationDrawingEnable
4330
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4331
                                    {
4332
                                        return;
4333
                                    }
4334
                                    CreateCommand.Instance.Execute(currentControl);
4335
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4336
                                    currentControl.IsNew = false;
4337
                                    currentControl = null;
4338
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4339
                                }
4340
                                else
4341
                                {
4342
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4343
                                    //{
4344
                                    currentControl = new ArrowTextControl()
4345
                                    {
4346
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4347
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4348
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4349
                                    };
4350
                                    currentControl.CommentID = Commons.shortGuid();
4351
                                    currentControl.IsNew = true;
4352
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4353
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4354
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4355

    
4356
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4357
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4358
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4359
                                    (currentControl as ArrowTextControl).isFixed = true;
4360
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4361

    
4362
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4363
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4364
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4365
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4366
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4367
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4368

    
4369
                                    //20180911 LJY
4370
                                    (currentControl as ArrowTextControl).isTrans = true;
4371
                                    //}
4372
                                }
4373
                            }
4374
                        }
4375
                        break;
4376
                    //강인구 추가
4377
                    case ControlType.Sign:
4378
                        {
4379
                            if (e.LeftButton == MouseButtonState.Pressed)
4380
                            {
4381
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4382
                                //{
4383
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4384

    
4385
                                if (_sign == null)
4386
                                {
4387
                                    txtBatch.Visibility = Visibility.Collapsed;
4388
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4389
                                    controlType = ControlType.None;
4390

    
4391
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4392
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4393
                                    return;
4394
                                }
4395
                                else
4396
                                {
4397
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4398
                                    {
4399
                                        Application.Current.Resources.Add("UserSign", _sign);
4400
                                    }
4401
                                    else
4402
                                    {
4403
                                        Application.Current.Resources["UserSign"] = _sign;
4404
                                    }
4405
                                }
4406

    
4407
                                if (currentControl is SignControl)
4408
                                {
4409
                                    //20180906 LJY TEST IsRotationDrawingEnable
4410
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4411
                                    {
4412
                                        return;
4413
                                    }
4414

    
4415
                                    CreateCommand.Instance.Execute(currentControl);
4416
                                    currentControl = null;
4417
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4418
                                    {
4419
                                        txtBatch.Text = "Place Date";
4420
                                        controlType = ControlType.Date;
4421
                                    }
4422
                                }
4423
                                else
4424
                                {
4425
                                    currentControl = new SignControl
4426
                                    {
4427
                                        Background = new SolidColorBrush(Colors.Black),
4428
                                        UserNumber = App.ViewInfo.UserID,
4429
                                        ProjectNO = App.ViewInfo.ProjectNO,
4430
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4431
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4432
                                        ControlType = ControlType.Sign
4433
                                    };
4434

    
4435
                                    currentControl.CommentID = Commons.shortGuid();
4436
                                    currentControl.IsNew = true;
4437
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4438
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4439

    
4440
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4441
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4442
                                }
4443
                                //}
4444
                            }
4445
                        }
4446
                        break;
4447

    
4448
                    case ControlType.Mark:
4449
                        {
4450
                            if (e.LeftButton == MouseButtonState.Pressed)
4451
                            {
4452
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4453
                                //{
4454
                                if (currentControl is RectangleControl)
4455
                                {
4456
                                    //20180906 LJY TEST IsRotationDrawingEnable
4457
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4458
                                    {
4459
                                        return;
4460
                                    }
4461

    
4462
                                    CreateCommand.Instance.Execute(currentControl);
4463
                                    (currentControl as RectangleControl).ApplyOverViewData();
4464
                                    currentControl = null;
4465

    
4466
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4467

    
4468
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4469
                                    {
4470
                                        txtBatch.Text = "Place Signature";
4471
                                        controlType = ControlType.Sign;
4472
                                    }
4473
                                }
4474
                                else
4475
                                {
4476
                                    currentControl = new RectangleControl
4477
                                    {
4478
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4479
                                        Background = new SolidColorBrush(Colors.Black),
4480
                                        ControlType = ControlType.Mark,
4481
                                        Paint = PaintSet.Fill
4482
                                    };
4483

    
4484
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4485
                                    currentControl.CommentID = Commons.shortGuid();
4486
                                    currentControl.IsNew = true;
4487
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4488
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4489
                                }
4490
                                //}
4491
                            }
4492
                        }
4493
                        break;
4494

    
4495
                    case ControlType.Symbol:
4496
                        {
4497
                            if (e.LeftButton == MouseButtonState.Pressed)
4498
                            {
4499
                                if (currentControl is SymControl)
4500
                                {
4501
                                    //20180906 LJY TEST IsRotationDrawingEnable
4502
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4503
                                    {
4504
                                        return;
4505
                                    }
4506
                                    CreateCommand.Instance.Execute(currentControl);
4507
                                    currentControl = null;
4508

    
4509
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4510
                                }
4511
                                else
4512
                                {
4513
                                    currentControl = new SymControl
4514
                                    {
4515
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4516
                                        Background = new SolidColorBrush(Colors.Black),
4517
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4518
                                        ControlType = ControlType.Symbol
4519
                                    };
4520

    
4521
                                    currentControl.IsNew = true;
4522
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4523
                                    currentControl.CommentID = Commons.shortGuid();
4524
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4525

    
4526
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4527
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4528
                                }
4529
                                //}
4530
                            }
4531
                        }
4532
                        break;
4533

    
4534
                    case ControlType.Stamp:
4535
                        {
4536
                            if (e.LeftButton == MouseButtonState.Pressed)
4537
                            {
4538
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4539
                                //{
4540
                                if (currentControl is SymControlN)
4541
                                {
4542
                                    //20180906 LJY TEST IsRotationDrawingEnable
4543
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4544
                                    {
4545
                                        return;
4546
                                    }
4547

    
4548
                                    CreateCommand.Instance.Execute(currentControl);
4549
                                    currentControl = null;
4550

    
4551
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4552
                                }
4553
                                else
4554
                                {
4555
                                    currentControl = new SymControlN
4556
                                    {
4557
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4558
                                        Background = new SolidColorBrush(Colors.Black),
4559
                                        STAMP = App.SystemInfo.STAMP,
4560
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4561
                                        ControlType = ControlType.Stamp
4562
                                    };
4563

    
4564
                                    currentControl.IsNew = true;
4565
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4566
                                    currentControl.CommentID = Commons.shortGuid();
4567
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4568
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4569
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4570
                                }
4571
                                //}
4572
                            }
4573
                        }
4574
                        break;
4575

    
4576
                    case ControlType.PenControl:
4577
                        {
4578
                            if (inkBoard.Tag.ToString() == "Ink")
4579
                            {
4580
                                inkBoard.IsEnabled = true;
4581
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4582
                            }
4583
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4584
                            {
4585
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4586
                            }
4587
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4588
                            {
4589
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4590
                            }
4591
                            IsDrawing = true;
4592
                            return;
4593
                        }
4594
                    default:
4595
                        if (currentControl != null)
4596
                        {
4597
                            currentControl.CommentID = null;
4598
                            currentControl.IsNew = false;
4599
                        }
4600
                        break;
4601
                }
4602

    
4603
                try
4604
                {
4605
                    if (currentControl is ITextControl)
4606
                    {
4607
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4608

    
4609
                        if(textBox.Count() > 0)
4610
                        {
4611
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4612
                            specialcharRemove.Attach(textBox.First());
4613
                        }
4614
                        else
4615
                        {
4616

    
4617
                        }
4618

    
4619
                    }
4620
                }
4621
                catch (Exception ex)
4622
                {
4623
                    System.Diagnostics.Debug.WriteLine(ex);
4624

    
4625
                }
4626

    
4627
                if (currentControl is ArrowTextControl)
4628
                {
4629
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4630
                    {
4631
                        var control = snd as ArrowTextControl;
4632

    
4633
                        if (string.IsNullOrEmpty(control.ArrowText))
4634
                        {
4635
                            DeleteCommand.Instance.Execute(new [] { control });
4636
                        }
4637
                    };
4638

    
4639
                }
4640

    
4641
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4642
                {
4643
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4644
                    {
4645
                        MacroHelper.MacroAction();
4646
                    }
4647
                    //if (currentControl.ControlType)
4648
                    //txtBatch.Text = "Draw a TextBox";
4649
                    //controlType = ControlType.ArrowTextBorderControl;
4650
                }
4651

    
4652
                //if (currentControl != null)
4653
                //{
4654
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4655
                //}
4656
            }
4657
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4658
            {
4659
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4660
             
4661

    
4662
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4663
                {
4664
                    bool mouseOff = false;
4665
                    foreach (var item in SelectLayer.Children)
4666
                    {
4667
                        if (item is AdornerFinal)
4668
                        {
4669
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4670
                            if (over != null)
4671
                            {
4672
                                mouseOff = true;
4673
                            }
4674
                        }
4675
                    }
4676

    
4677
                    if (!mouseOff)
4678
                    {
4679
                        SelectionSet.Instance.UnSelect(this);
4680
                    }
4681
                }
4682
                zoomAndPanControl.CaptureMouse();
4683
                e.Handled = true;
4684
            }
4685

    
4686
        }
4687

    
4688
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4689
        {
4690
            ///mouseButtonDown = e.ChangedButton;
4691
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4692
        }
4693

    
4694
        private void RemoveLineStroke(Point P)
4695
        {
4696
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4697
            if (control != null)
4698
            {
4699
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4700
            }
4701
        }
4702

    
4703
        private void RemovePointStroke(Point P)
4704
        {
4705
            foreach (Stroke hits in inkBoard.Strokes)
4706
            {
4707
                foreach (StylusPoint sty in hits.StylusPoints)
4708
                {
4709
                }
4710
                if (hits.HitTest(P))
4711
                {
4712
                    inkBoard.Strokes.Remove(hits);
4713
                    return;
4714
                }
4715
            }
4716
        }
4717

    
4718
        private void StartNewStroke(Point P)
4719
        {
4720
            strokePoints = new StylusPointCollection();
4721
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4722
            strokePoints.Add(segment1Start);
4723
            stroke = new Stroke(strokePoints);
4724

    
4725
            stroke.DrawingAttributes.Color = Colors.Red;
4726
            stroke.DrawingAttributes.Width = 4;
4727
            stroke.DrawingAttributes.Height = 4;
4728

    
4729
            inkBoard.Strokes.Add(stroke);
4730
        }
4731

    
4732
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4733
        {
4734
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4735
            //// update mylist and gridview
4736
            //this.UpdateMyMarkupList();
4737

    
4738
            //bool result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4739

    
4740
            //if (result)
4741
            //{
4742
            btnFinalPDF.IsEnabled = false;
4743
            btnConsolidate.IsEnabled = false;
4744
            var result = await  ConsolidationMethod();
4745

    
4746
            if(result)
4747
            {
4748
                 var consolidateItem = ViewerDataModel.Instance._markupInfoList.Where(x => x.Consolidate == 1 && x.AvoidConsolidate == 0);
4749

    
4750
                if(consolidateItem?.Count() > 0)
4751
                {
4752
                    gridViewMarkup.Select(consolidateItem);
4753
                }
4754
            }
4755
            else
4756
            {
4757
                btnFinalPDF.IsEnabled = true;
4758
                btnConsolidate.IsEnabled = true;
4759
            }
4760
        }
4761

    
4762
        /// <summary>
4763
        /// execute TeamConsolidationCommand
4764
        /// </summary>
4765
        public void TeamConsolidationMethod2()
4766
        {
4767
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4768
            {
4769
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4770
            }
4771
            else
4772
            {
4773

    
4774
                ViewerDataModel.Instance.IsConsolidate = true;
4775
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4776
                // update mylist and gridview
4777
        
4778
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4779
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4780
                ViewerDataModel.Instance.IsConsolidate = false;
4781
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4782
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4783
                {
4784
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4785
                    {
4786
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4787
                        return;
4788
                    }
4789
                }
4790
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4791
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4792
                {
4793
                    MarkupInfoList.Add(item);
4794
                }
4795

    
4796
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4797
            }
4798
        }
4799
        public async void TeamConsolidationMethod()
4800
        {
4801
            bool result = false;
4802

    
4803
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4804
            {
4805
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4806
            }
4807
            else
4808
            {
4809
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4810
                {
4811
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4812
                    {
4813
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4814
                    }
4815
                }
4816

    
4817
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4818

    
4819
                if (isSave)
4820
                {
4821
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4822

    
4823
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4824
                     
4825
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4826
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4827
                    {
4828
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4829
                    }
4830

    
4831
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4832
                    result = true;
4833
                }
4834
            }
4835
        }
4836

    
4837
        public async Task<bool> ConsolidationMethod()
4838
        {
4839
            bool result = false;
4840

    
4841
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4842
            {
4843
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4844
            }
4845
            else
4846
            {
4847
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4848

    
4849
                if (isSave)
4850
                {
4851
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4852
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4853

    
4854
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4855
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4856
                    {
4857
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4858
                    }
4859
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4860

    
4861
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4862
                }
4863
            }
4864

    
4865
            return result;
4866
        }
4867

    
4868
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4869
        {
4870
            if (App.ViewInfo != null)
4871
            {
4872
                btnConsolidate = (sender as RadRibbonButton);
4873
                if (!App.ViewInfo.NewCommentPermission)
4874
                {
4875
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4876
                }
4877
            }
4878
        }
4879

    
4880
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4881
        {
4882
            TeamConsolidationMethod();
4883
        }
4884

    
4885
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4886
        {
4887
            btnTeamConsolidate = sender as RadRibbonButton;
4888
            if (App.ViewInfo != null)
4889
            {
4890
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4891
                {
4892
                    if (btnConsolidate != null)
4893
                    {
4894
                        btnConsolidate.Visibility = Visibility.Collapsed;
4895
                    }
4896

    
4897
                    if (!App.ViewInfo.NewCommentPermission)
4898
                    {
4899
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4900
                    }
4901
                }
4902
                else
4903
                {
4904
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4905
                }
4906
            }
4907
        }
4908

    
4909
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4910
        {
4911
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4912
            // update mylist and gridview
4913
            this.UpdateMyMarkupList();
4914

    
4915
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4916

    
4917
            if(!result)
4918
            {
4919

    
4920
            }
4921
            else
4922
            {
4923
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4924

    
4925
                if (item != null)
4926
                {
4927
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4928
                    {
4929
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4930

    
4931
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4932

    
4933
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4934
                    }
4935
                    else
4936
                    {
4937
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4938
                    }
4939
                }
4940
                else
4941
                {
4942
                    //Consolidate 가 없는 경우
4943
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4944
                }
4945
            }
4946

    
4947
        }
4948

    
4949
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4950
        {
4951
            btnFinalPDF = sender as RadRibbonButton;
4952
            if (App.ViewInfo != null)
4953
            {
4954
                //btnFinalPDF.IsEnabled = false;
4955

    
4956
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4957
                {
4958
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4959
                    if (btnConsolidate != null)
4960
                    {
4961
                        btnConsolidate.Visibility = Visibility.Collapsed;
4962
                    }
4963
                }
4964
            }
4965
        }
4966

    
4967
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4968
        {
4969
            //UpdateMyMarkupList();
4970

    
4971
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4972
            {
4973
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4974
            }
4975
            else
4976
            {
4977
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4978
                //{
4979
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4980
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4981
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4982

    
4983
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4984
                //// update mylist and gridview
4985
                //this.UpdateMyMarkupList();
4986

    
4987
                //var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommand(this);
4988

    
4989
                Mouse.SetCursor(Cursors.Wait);
4990

    
4991
                bool result = await ConsolidationMethod();
4992

    
4993
                //System.Threading.Thread.Sleep(500);
4994

    
4995
                if (result)
4996
                {
4997
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4998

    
4999
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
5000
                    if (item2 != null)
5001
                    {
5002
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
5003
                        {
5004
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
5005

    
5006
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
5007
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
5008

    
5009
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
5010

    
5011
                            Mouse.SetCursor(Cursors.Arrow);
5012
                        }
5013
                        else
5014
                        {
5015
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
5016
                        }
5017
                    }
5018
                    else
5019
                    {
5020
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
5021
                    }
5022
                }
5023
                else
5024
                {
5025
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
5026
                }
5027

    
5028
                Mouse.SetCursor(Cursors.Arrow);
5029
            }
5030
        }
5031

    
5032
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
5033
        {
5034
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
5035
#if Hyosung
5036
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5037
#else
5038

    
5039
            //btnConsolidateFinalPDF.IsEnabled = false;
5040

    
5041
            if (App.ViewInfo != null)
5042
            {
5043
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
5044
                {
5045
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
5046
                }
5047
            }
5048
#endif
5049
        }
5050

    
5051
        private void btnColorList_Click(object sender, RoutedEventArgs e)
5052
        {
5053

    
5054
        }
5055

    
5056
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
5057
        {
5058
            SetCompareRect();
5059
        }
5060

    
5061
        private void Sync_Click(object sender, RoutedEventArgs e)
5062
        {
5063
            if (Sync.IsChecked)
5064
            {
5065
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
5066
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
5067
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5068
            }
5069
        }
5070

    
5071
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
5072
        {
5073
            if (UserList.IsChecked)
5074
            {
5075
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
5076
            }
5077
            else
5078
            {
5079
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5080
            }
5081
        }
5082

    
5083
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
5084
        {
5085
            if (BalanceMode.IsChecked)
5086
            {
5087
                ViewerDataModel.Instance.PageBalanceMode = true;
5088
            }
5089
            else
5090
            {
5091
                ViewerDataModel.Instance.PageBalanceMode = false;
5092
                ViewerDataModel.Instance.PageBalanceNumber = 0;
5093
            }
5094
        }
5095

    
5096
        private void SyncExit_Click(object sender, RoutedEventArgs e)
5097
        {
5098
            //초기화
5099
            testPanel2.IsHidden = true;
5100
            ViewerDataModel.Instance.PageBalanceMode = false;
5101
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5102
            ViewerDataModel.Instance.SyncPageNumber = 0;
5103
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5104
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5105
            UserList.IsChecked = false;
5106
            BalanceMode.IsChecked = false;
5107
        }
5108

    
5109
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5110
        {
5111
            if ((sender as System.Windows.Controls.Control).Tag != null)
5112
            {
5113
                //Compare 초기화
5114
                CompareMode.IsChecked = false;
5115
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5116
                
5117
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5118
                {
5119
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5120
                }
5121

    
5122
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5123
                {
5124
                }
5125
                else
5126
                {
5127
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5128
                }
5129

    
5130
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5131
                {
5132
                }
5133
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5134
                {
5135
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5136
                }
5137

    
5138
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5139

    
5140
                if (!testPanel2.IsHidden)
5141
                {
5142
                    if (IsSyncPDFMode)
5143
                    {
5144
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5145
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5146

    
5147
                        if (pdfpath.IsDownloading)
5148
                        {
5149
                            pdfpath.DownloadCompleted += (ex, arg) =>
5150
                            {
5151
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5152
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5153
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5154
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5155
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5156
                            };
5157
                        }
5158
                        else
5159
                        {
5160
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5161
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5162
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5163

    
5164
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5165
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5166
                        }
5167
                    }
5168
                    else
5169
                    {
5170
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5171

    
5172
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5173
                        ComparePageLoad(uri, isOriginalSize);
5174
                    }
5175
                   
5176
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5177
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5178
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5179

    
5180
                    foreach (var item in gridSelectionRevItem)
5181
                    {
5182
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5183
                        foreach (var markupitem in markupitems)
5184
                        {
5185
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5186
                        }
5187
                    }
5188

    
5189
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5190
                }
5191
            }
5192
        }
5193

    
5194
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5195
        {
5196
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5197

    
5198
            double translateX = 0;
5199
            double translateY = 0;
5200
            double angle = rotate2.Angle;
5201

    
5202
            if (direction == 1)
5203
            {
5204
                if (angle < 270)
5205
                {
5206
                    angle += 90;
5207
                }
5208
                else
5209
                {
5210
                    angle = 0;
5211
                }
5212
            }
5213
            else
5214
            {
5215
                if (angle > 0)
5216
                {
5217
                    angle -= 90;
5218
                }
5219
                else
5220
                {
5221
                    angle = 270;
5222
                }
5223
            }
5224
            zoomAndPanControl2.RotationAngle = angle;
5225
            zoomAndPanControl2.ScaleToFit();
5226

    
5227
            //if (angle == 90 || angle == 270)
5228
            //{
5229
                double emptySize = zoomAndPanCanvas2.Width;
5230
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5231
                zoomAndPanCanvas2.Height = emptySize;
5232
            //}
5233

    
5234
            if (angle == 90)
5235
            {
5236
                translateX = zoomAndPanCanvas2.Width;
5237
                translateY = 0;
5238
            }
5239
            else if (angle == 180)
5240
            {
5241
                translateX = zoomAndPanCanvas2.Width;
5242
                translateY = zoomAndPanCanvas2.Height;
5243
            }
5244
            else if (angle == 270)
5245
            {
5246
                translateX = 0;
5247
                translateY = zoomAndPanCanvas2.Height;
5248
            }
5249
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5250
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5251
            translate2.X = translateX;
5252
            translate2.Y = translateY;
5253
            rotate2.Angle = angle;
5254
            //translate2CompareBorder.X = translateX;
5255
            //translate2CompareBorder.Y = translateY;
5256
            //rotate2CompareBorder.Angle = angle;
5257

    
5258
        }
5259

    
5260
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5261
        {
5262
            if (MarkupMode.IsChecked)
5263
            {
5264
                IsSyncPDFMode = true;
5265

    
5266
                var uri = CurrentRev.TO_VENDOR;
5267

    
5268
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5269
                {
5270
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5271
                }
5272

    
5273
                //PDF모드 잠시 대기(강인구)
5274
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5275
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5276

    
5277
                if (pdfpath.IsDownloading)
5278
                {
5279
                    pdfpath.DownloadCompleted += (ex, arg) =>
5280
                    {
5281
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5282
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5283
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5284
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5285
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5286
                    };
5287
                }
5288
                else
5289
                {
5290
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5291
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5292
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5293

    
5294
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5295
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5296
                }
5297
            }
5298
            else
5299
            {
5300
                IsSyncPDFMode = false;
5301
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5302

    
5303
                ComparePageLoad(uri,false);
5304

    
5305
                zoomAndPanControl2.ApplyTemplate();
5306
                zoomAndPanControl2.UpdateLayout();
5307
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5308
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5309
            }
5310
        }
5311

    
5312
        /// <summary>
5313
        /// Compare된 영역을 초기화
5314
        /// </summary>
5315
        private void ClearCompareRect()
5316
        {
5317
            da.From = 1;
5318
            da.To = 1;
5319
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5320
            da.AutoReverse = false;
5321
            canvas_compareBorder.Children.Clear();
5322
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5323
        }
5324

    
5325
        /// <summary>
5326
        /// 문서 Comprare
5327
        /// </summary>
5328
        private void SetCompareRect()
5329
        {
5330
            canvas_compareBorder.Children.Clear();
5331

    
5332
            if (CompareMode.IsChecked)
5333
            {
5334
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5335
                {
5336
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5337
                }
5338
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5339
                {
5340
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5341
                }
5342

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

    
5345
                /// 비교대상원본, 비교할 대상
5346
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5347
            }
5348
            else
5349
            {
5350
                canvas_compareBorder.Visibility = Visibility.Hidden;
5351
                ClearCompareRect();
5352
            }
5353
        }
5354

    
5355
        private void btnSync_Click(object sender, RoutedEventArgs e)
5356
        {
5357
            gridViewHistory_Busy.IsBusy = true;
5358

    
5359
            RadButton instance = sender as RadButton;
5360
            if (instance.CommandParameter != null)
5361
            {
5362
                CurrentRev = instance.CommandParameter as VPRevision;
5363
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5364

    
5365
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5366
                {
5367
                    if (ea.Error == null && ea.Result != null)
5368
                    {
5369
                        testPanel2.IsHidden = false;
5370

    
5371
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5372
                        foreach (var info in ea.Result)
5373
                        {
5374
                            if (info.UserID == App.ViewInfo.UserID)
5375
                            {
5376
                                info.userDelete = true;
5377
                                info.DisplayColor = "#FFFF0000";
5378
                            }
5379
                            else
5380
                            {
5381
                                info.userDelete = false;
5382
                            }
5383
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5384
                        }
5385
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5386

    
5387
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5388
                        ComparePageLoad(uri,false);
5389

    
5390
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5391

    
5392
                        zoomAndPanControl2.ApplyTemplate();
5393
                        zoomAndPanControl2.UpdateLayout();
5394

    
5395
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5396
                        {
5397
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5398
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5399
                        }
5400

    
5401
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5402
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5403
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5404

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

    
5408
                        zoomAndPanControl.ScaleToFit();
5409
                        zoomAndPanControl2.ScaleToFit();
5410

    
5411
                        gridViewHistory_Busy.IsBusy = false;
5412
                    }
5413

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

    
5416
                    if (GetSyncMarkupInfoItemshandler != null)
5417
                    {
5418
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5419
                    }
5420

    
5421
                    //ClearCompareRect();
5422
                    SetCompareRect();
5423
                };
5424

    
5425
                /// 중복 실행이 발생하여 수정함.
5426
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5427
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5428

    
5429
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5430
            }
5431
        }
5432

    
5433
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5434
        {
5435
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5436
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5437

    
5438
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5439
        }
5440

    
5441
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5442
        {
5443
            try
5444
            {
5445
                if (sender is RadButton)
5446
                {
5447
                    if ((sender as RadButton).Tag != null)
5448
                    {
5449
                        var url = (sender as RadButton).Tag.ToString();
5450
                        System.Diagnostics.Process.Start(url);
5451
                    }
5452
                    else
5453
                    {
5454
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5455
                    }
5456
                }
5457
            }
5458
            catch (Exception ex)
5459
            {
5460
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5461
            }
5462
        }
5463

    
5464
        public void Sync_Event(VPRevision Currnet_Rev)
5465
        {
5466
            CurrentRev = Currnet_Rev;
5467

    
5468
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5469
            {
5470
                if (ea.Error == null && ea.Result != null)
5471
                {
5472
                    testPanel2.IsHidden = false;
5473

    
5474
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5475
                    foreach (var info in ea.Result)
5476
                    {
5477
                        if (info.UserID == App.ViewInfo.UserID)
5478
                        {
5479
                            info.userDelete = true;
5480
                            info.DisplayColor = "#FFFF0000";
5481
                        }
5482
                        else
5483
                        {
5484
                            info.userDelete = false;
5485
                        }
5486
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5487
                    }
5488
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5489

    
5490
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5491

    
5492
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5493

    
5494
                    ComparePageLoad(uri,false);
5495

    
5496
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5497
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5498
                    zoomAndPanControl2.ApplyTemplate();
5499
                    zoomAndPanControl2.UpdateLayout();
5500

    
5501
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5502
                    {
5503
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5504
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5505
                    }
5506
                    //}
5507
                    
5508
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5509
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5510
                    gridViewHistory_Busy.IsBusy = false;
5511
                }
5512
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5513
            };
5514
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5515
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5516
        }
5517

    
5518
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5519
        {
5520
            if (sender is Image)
5521
            {
5522
                if ((sender as Image).Tag != null)
5523
                {
5524
                    var pdfUrl = (sender as Image).Tag.ToString();
5525
                    System.Diagnostics.Process.Start(pdfUrl);
5526
                }
5527
                else
5528
                {
5529
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5530
                }
5531
            }
5532
        }
5533

    
5534
        private void Create_Symbol(object sender, RoutedEventArgs e)
5535
        {
5536
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5537

    
5538
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5539
            {
5540
                DialogMessage_Alert("Please Select Controls", "Alert");
5541
            }
5542
            else //선택된 것이 있으면
5543
            {
5544
                string MarkupData = "";
5545
                adorner_ = new AdornerFinal();
5546

    
5547
                foreach (var item in SelectLayer.Children)
5548
                {
5549
                    if (item.GetType().Name == "AdornerFinal")
5550
                    {
5551
                        adorner_ = (item as Controls.AdornerFinal);
5552
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5553
                        {
5554
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5555
                            {
5556
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5557
                                MarkupData += markupReturn.ConvertData;
5558
                            }
5559
                        }
5560
                    }
5561
                }
5562
                DialogParameters parameters = new DialogParameters()
5563
                {
5564
                    Owner = Application.Current.MainWindow,
5565
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5566
                    DefaultPromptResultValue = "Custom State",
5567
                    Content = "Name :",
5568
                    Header = "Insert Custom Symbol Name",
5569
                    Theme = new VisualStudio2013Theme(),
5570
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5571
                };
5572
                RadWindow.Prompt(parameters);
5573
            }
5574
        }
5575

    
5576
        public int symbolselectindex = 0;
5577

    
5578
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5579
        {
5580
            //Save save = new Save();
5581
            try
5582
            {
5583
                string svgfilename = null;
5584
                if (symbolname != null)
5585
                {
5586
                    if (symbolpng == true || symbolsvg == true)
5587
                    {
5588
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5589
                        string guid = Commons.shortGuid();
5590

    
5591
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5592
                        //Check_Uri.UriCheck();
5593
                        fileUploader.RunCompleted += (ex, arg) =>
5594
                        {
5595
                            filename = arg.Result;
5596
                            if (symbolpng == true)
5597
                            {
5598
                                if (filename != null)
5599
                                {
5600
                                    if (symbolselectindex == 0)
5601
                                    {
5602
                                        SymbolSave(symbolname, filename, data);
5603
                                    }
5604
                                    else
5605
                                    {
5606
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5607
                                    }
5608
                                    DataBind();
5609
                                }
5610
                            }
5611

    
5612
                            if (symbolsvg == true)
5613
                            {
5614
                                try
5615
                                {
5616
                                    var defaultBitmapImage = new BitmapImage();
5617
                                    defaultBitmapImage.BeginInit();
5618
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5619
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5620
                                    Check_Uri.UriCheck(filename);
5621
                                    defaultBitmapImage.UriSource = new Uri(filename);
5622
                                    defaultBitmapImage.EndInit();
5623

    
5624
                                    System.Drawing.Bitmap image;
5625

    
5626
                                    if (defaultBitmapImage.IsDownloading)
5627
                                    {
5628
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5629
                                        {
5630
                                            defaultBitmapImage.Freeze();
5631
                                            image = GetBitmap(defaultBitmapImage);
5632
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5633
                                            Process potrace = new Process
5634
                                            {
5635
                                                StartInfo = new ProcessStartInfo
5636
                                                {
5637
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5638
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5639
                                                    RedirectStandardInput = true,
5640
                                                    RedirectStandardOutput = true,
5641
                                                    RedirectStandardError = true,
5642
                                                    UseShellExecute = false,
5643
                                                    CreateNoWindow = true,
5644
                                                    WindowStyle = ProcessWindowStyle.Hidden
5645
                                                },
5646
                                            };
5647

    
5648
                                            StringBuilder svgBuilder = new StringBuilder();
5649
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5650
                                            {
5651
                                                svgBuilder.AppendLine(e2.Data);
5652
                                            };
5653

    
5654
                                            potrace.EnableRaisingEvents = true;
5655
                                            potrace.Start();
5656
                                            potrace.Exited += (sender, e) =>
5657
                                            {
5658
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5659
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5660
                                                Check_Uri.UriCheck(svgfilename);
5661
                                                if (symbolselectindex == 0)
5662
                                                {
5663
                                                    SymbolSave(symbolname, svgfilename, data);
5664
                                                }
5665
                                                else
5666
                                                {
5667
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5668
                                                }
5669

    
5670
                                                DataBind();
5671
                                            };
5672
                                            potrace.WaitForExit();
5673
                                        };
5674
                                    }
5675
                                    else
5676
                                    {
5677
                                        //GC.Collect();
5678
                                    }
5679
                                }
5680
                                catch (Exception ee)
5681
                                {
5682
                                    DialogMessage_Alert("" + ee, "Alert");
5683
                                }
5684
                            }
5685
                        };
5686
                    }
5687
                }
5688
            }
5689
            catch (Exception e)
5690
            {
5691
                //DialogMessage_Alert(e + "", "Alert");
5692
            }
5693
        }
5694

    
5695
        public void SymbolSave(string Name, string Url, string Data)
5696
        {
5697
            try
5698
            {
5699
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5700
                {
5701
                    ID = Commons.shortGuid(),
5702
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5703
                    NAME = Name,
5704
                    IMAGE_URL = Url,
5705
                    DATA = Data
5706
                };
5707

    
5708
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5709
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5710
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5711
            }
5712
            catch (Exception)
5713
            {
5714
                throw;
5715
            }
5716
        }
5717

    
5718
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5719
        {
5720
            try
5721
            {
5722
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5723
                {
5724
                    ID = Commons.shortGuid(),
5725
                    DEPARTMENT = Department,
5726
                    NAME = Name,
5727
                    IMAGE_URL = Url,
5728
                    DATA = Data
5729
                };
5730
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5731
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5732
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5733
            }
5734
            catch (Exception)
5735
            {
5736
                throw;
5737
            }
5738
        }
5739

    
5740
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5741
        {
5742
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5743
            DataBind();
5744
        }
5745

    
5746
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5747
        {
5748
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5749
            DataBind();
5750
        }
5751

    
5752
        private void DataBind()
5753
        {
5754
            try
5755
            {
5756
                Symbol_Custom Custom = new Symbol_Custom();
5757
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5758

    
5759
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5760
                foreach (var item in symbol_Private)
5761
                {
5762
                    Custom.Name = item.NAME;
5763
                    Custom.ImageUri = item.IMAGE_URL;
5764
                    Custom.ID = item.ID;
5765
                    Custom_List.Add(Custom);
5766
                    Custom = new Symbol_Custom();
5767
                }
5768
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5769

    
5770
                Custom = new Symbol_Custom();
5771
                Custom_List = new List<Symbol_Custom>();
5772

    
5773
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5774

    
5775
                List<SYMBOL_PUBLIC> symbol_Public;
5776

    
5777
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5778
                {
5779
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5780
                }
5781
                else
5782
                {
5783
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5784
                }
5785
                foreach (var item in symbol_Public)
5786
                {
5787
                    Custom.Name = item.NAME;
5788
                    Custom.ImageUri = item.IMAGE_URL;
5789
                    Custom.ID = item.ID;
5790
                    Custom_List.Add(Custom);
5791
                    Custom = new Symbol_Custom();
5792
                }
5793
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5794
                BaseClient.Close();
5795
            }
5796
            catch (Exception e)
5797
            {
5798
                //DialogMessage_Alert("DataBind", "Alert");
5799
            }
5800
        }
5801

    
5802
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5803
        {
5804
            try
5805
            {
5806
                if (args.PromptResult != null)
5807
                {
5808
                    if (args.DialogResult.Value)
5809
                    {
5810
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5811

    
5812
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5813
                        _Encoder.Save(fs);
5814
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5815

    
5816
                        byte[] Img_byte = fs.ToArray();
5817

    
5818
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5819
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5820
                        Check_Uri.UriCheck(filename);
5821
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5822
                        {
5823
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5824
                        }
5825
                        else
5826
                        {
5827
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5828
                        }
5829
                        DataBind();
5830
                    }
5831
                }
5832
            }
5833
            catch (Exception ex)
5834
            {
5835
                DialogMessage_Alert("" + ex, "Alert");
5836
            }
5837
        }
5838

    
5839
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5840
        {
5841
            Canvas _canvas = new Canvas();
5842
            _canvas.Background = Brushes.White;
5843
            _canvas.Width = adorner_.BorderSize.Width;
5844
            _canvas.Height = adorner_.BorderSize.Height;
5845
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5846

    
5847
            BitmapEncoder encoder = new PngBitmapEncoder();
5848

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

    
5851
            DrawingVisual dv = new DrawingVisual();
5852

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

    
5856
            using (DrawingContext ctx = dv.RenderOpen())
5857
            {
5858
                VisualBrush vb = new VisualBrush(_canvas);
5859
                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)));
5860
            }
5861

    
5862
            try
5863
            {
5864
                renderBitmap.Render(dv);
5865

    
5866
                GC.Collect(2);
5867
                GC.WaitForPendingFinalizers();
5868
                //GC.Collect();
5869
                // encode png data
5870
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5871
                // puch rendered bitmap into it
5872
                pngEncoder.Interlace = PngInterlaceOption.Off;
5873
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5874
                return pngEncoder;
5875
            }
5876
            catch //(Exception ex)
5877
            {
5878
                return null;
5879
            }
5880
        }
5881

    
5882
        public void DialogMessage_Alert(string content, string header)
5883
        {
5884
            App.splashScreen.Close();
5885
            App.FileLogger.Error(content + " " + header);
5886

    
5887
            DialogParameters parameters = new DialogParameters()
5888
            {
5889
                Owner = this.ParentOfType<MainWindow>(),
5890
                Content = new TextBlock()
5891
                {
5892
                    MinWidth = 400,
5893
                    FontSize = 11,
5894
                    Text = content,
5895
                    TextWrapping = System.Windows.TextWrapping.Wrap
5896
                },
5897
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5898
                Header = header,
5899
                Theme = new VisualStudio2013Theme(),
5900
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5901
            };
5902
            RadWindow.Alert(parameters);
5903
        }
5904

    
5905
        #region 캡쳐 기능
5906

    
5907
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5908
        {
5909
            if (x < 0)
5910
            {
5911
                width += x;
5912
                x = 0;
5913
            }
5914
            if (y < 0)
5915
            {
5916
                height += y;
5917
                y = 0;
5918

    
5919
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5920
            }
5921
            if (x + width > zoomAndPanCanvas.ActualWidth)
5922
            {
5923
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5924
            }
5925
            if (y + height > zoomAndPanCanvas.ActualHeight)
5926
            {
5927
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5928
            }
5929

    
5930
            byte[] pixels = CopyPixels(x, y, width, height);
5931

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

    
5934
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5935
        }
5936

    
5937
        public byte[] CopyPixels(int x, int y, int width, int height)
5938
        {
5939
            byte[] pixels = new byte[width * height * 4];
5940
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5941

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

    
5945
            return pixels;
5946
        }
5947

    
5948
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5949
        {
5950
            DrawingVisual drawingVisual = new DrawingVisual();
5951
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5952

    
5953
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5954
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5955
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5956
            drawingContext.Close();
5957

    
5958
            // 비트맵으로 변환합니다.
5959
            RenderTargetBitmap target =
5960
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5961
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5962

    
5963
            target.Render(drawingVisual);
5964
            return target;
5965
        }
5966

    
5967
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5968
        {
5969
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5970
            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);
5971
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5972
            bmp.UnlockBits(data);
5973
            return bmp;
5974
        }
5975

    
5976
        public string symbolname = null;
5977
        public bool symbolsvg = true;
5978
        public bool symbolpng = true;
5979

    
5980
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5981
        {
5982
            System.Drawing.Bitmap image = GetBitmap(source);
5983
            //흰색 제거
5984
            //image.MakeTransparent(System.Drawing.Color.White);
5985

    
5986
            var imageStream = new System.IO.MemoryStream();
5987
            byte[] imageBytes = null;
5988
            using (imageStream)
5989
            {
5990
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5991
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5992
                imageStream.Position = 0;
5993
                imageBytes = imageStream.ToArray();
5994
            }
5995

    
5996
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5997

    
5998
            RadWindow CheckPop = new RadWindow();
5999
            //Alert check = new Alert(Msg);
6000

    
6001
            CheckPop = new RadWindow
6002
            {
6003
                MinWidth = 400,
6004
                MinHeight = 100,
6005
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6006
                Header = "Alert",
6007
                Content = symbolPrompt,
6008
                //DialogResult =
6009
                ResizeMode = System.Windows.ResizeMode.NoResize,
6010
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
6011
                IsTopmost = true,
6012
            };
6013
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
6014
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
6015
            CheckPop.ShowDialog();
6016

    
6017
            /*
6018
            DialogParameters parameters = new DialogParameters()
6019
            {
6020
                Owner = Application.Current.MainWindow,
6021
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
6022
                DefaultPromptResultValue = "Custom State",
6023
                Content = "Name :",
6024
                Header = "Insert Custom Symbol Name",
6025
                Theme = new VisualStudio2013Theme(),
6026
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
6027
            };
6028
            RadWindow.Prompt(parameters);
6029
            */
6030
        }
6031

    
6032
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
6033
        {
6034
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
6035
            KCOMDataModel.DataModel.CHECK_LIST check_;
6036
            string Result = streamToBase64.ImageToBase64(source);
6037
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
6038
            string projectno = App.ViewInfo.ProjectNO;
6039
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
6040

    
6041
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
6042
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
6043
            if (Item != null)
6044
            {
6045
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
6046
            }
6047
            else
6048
            {
6049
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
6050
            }
6051

    
6052
            if (Item == null)
6053
            {
6054
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
6055
                {
6056
                    ID = Commons.shortGuid(),
6057
                    USER_ID = App.ViewInfo.UserID,
6058
                    IMAGE_URL = Result,
6059
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
6060
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
6061
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
6062
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
6063
                    PROJECT_NO = App.ViewInfo.ProjectNO,
6064
                    STATUS = "False",
6065
                    CREATE_TIME = DateTime.Now,
6066
                    UPDATE_TIME = DateTime.Now,
6067
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
6068
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
6069
                };
6070
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
6071
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
6072
                this.BaseClient.AddCheckList(projectno, check_);
6073
            }
6074
            else
6075
            {
6076
                Item.IMAGE_URL = Result;
6077
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
6078
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
6079
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
6080
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
6081
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
6082
            }
6083
        }
6084

    
6085
        public void Set_Capture()
6086
        {
6087
            double x = CanvasDrawingMouseDownPoint.X;
6088
            double y = CanvasDrawingMouseDownPoint.Y;
6089
            double width = dragCaptureBorder.Width;
6090
            double height = dragCaptureBorder.Height;
6091

    
6092
            if (width > 5 || height > 5)
6093
            {
6094
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
6095
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
6096
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
6097
            }
6098
        }
6099

    
6100
        #endregion 캡쳐 기능
6101

    
6102
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6103
        {
6104
            multi_Undo_Data = new Multi_Undo_data();
6105

    
6106
            multi_Undo_Data.Markup = control;
6107

    
6108
            if ((control as IShapeControl) != null)
6109
            {
6110
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6111
            }
6112
            if ((control as IDashControl) != null)
6113
            {
6114
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6115
            }
6116
            if ((control as IPath) != null)
6117
            {
6118
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6119
            }
6120
            if ((control as UIElement) != null)
6121
            {
6122
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6123
            }
6124

    
6125
            return multi_Undo_Data;
6126
        }
6127

    
6128
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6129
        {
6130
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6131
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6132
            {
6133
                if (items.MarkupInfoID == Select_ID)
6134
                {
6135
                    foreach (var item in items.MarkupList)
6136
                    {
6137
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6138
                        {
6139
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6140
                                 items.MarkupInfoID, Commons.shortGuid());
6141
                        }
6142
                    }
6143
                }
6144
            }
6145
        }
6146

    
6147
        /// <summary>
6148
        /// convert inkcontrol to polygoncontrol
6149
        /// </summary>
6150
        public void ConvertInkControlToPolygon()
6151
        {
6152
            if (inkBoard.Strokes.Count > 0)
6153
            {
6154
                inkBoard.Strokes.ToList().ForEach(stroke =>
6155
                {
6156
                    InkToPath ip = new InkToPath();
6157

    
6158
                    List<Point> inkPointSet = new List<Point>();
6159
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6160

    
6161
                    PolygonControl pc = new PolygonControl()
6162
                    {
6163
                        CommentAngle = 0,
6164
                        PointSet = inkPointSet,
6165
                        ControlType = ControlType.Ink
6166
                    };
6167
                    pc.StartPoint = inkPointSet[0];
6168
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6169
                    pc.LineSize = 3;
6170
                    pc.CommentID = Commons.shortGuid();
6171
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6172

    
6173
                    if (pc.PointSet.Count > 0)
6174
                    {
6175
                        CreateCommand.Instance.Execute(pc);
6176
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6177
                    }
6178
                });
6179
                inkBoard.Strokes.Clear();
6180
            }
6181
        }
6182

    
6183
        /// <summary>
6184
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6185
        /// </summary>
6186
        /// <author>ingu</author>
6187
        /// <date>2018.06.05</date>
6188
        /// <param name="getPoint"></param>
6189
        /// <returns></returns>
6190
        private bool IsGetoutpoint(Point getPoint)
6191
        {
6192
            if (getPoint == new Point())
6193
            {
6194
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6195
                currentControl = null;
6196
                return true;
6197
            }
6198

    
6199
            return false;
6200
        }
6201

    
6202
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6203
        {
6204
            e.Effects = DragDropEffects.Copy;
6205
        }
6206

    
6207
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6208
        {
6209
            e.Effects = DragDropEffects.Copy;
6210
        }
6211

    
6212
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6213
        {
6214
            e.Effects = DragDropEffects.None;
6215
        }
6216

    
6217
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6218
        {
6219
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6220
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6221

    
6222
            ScaleImage(pageWidth, pageHeight);
6223
        }
6224

    
6225
        /// <summary>
6226
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6227
        /// </summary>
6228
        /// <param name="pageWidth">원본 사이즈</param>
6229
        /// <param name="pageHeight">원본 사이즈</param>
6230
        /// <returns></returns>
6231
        private void ScaleImage(double pageWidth, double pageHeight)
6232
        {
6233
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6234
        }
6235

    
6236
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6237
        {
6238
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6239
        }
6240

    
6241
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6242
        {
6243
            var checkbox = (sender as CheckBox);
6244

    
6245
            if (checkbox != null)
6246
            {
6247
                if (checkbox.IsChecked.GetValueOrDefault())
6248
                {
6249
                    if (!App.ViewInfo.CreateFinalPDFPermission && App.ViewInfo.NewCommentPermission)
6250
                    {
6251
                        var currentItem = gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>().Where(x => x.UserID == App.ViewInfo.UserID);
6252

    
6253
                        if (currentItem.Count() > 0)
6254
                        {
6255
                            foreach (var item in gridViewMarkup.Items.OfType<IKCOM.MarkupInfoItem>())
6256
                            {
6257
                                if (item.Consolidate == 0 &&  item.Depatment == currentItem.First().Depatment)
6258
                                {
6259
                                    gridViewMarkup.SelectedItems.Add(item);
6260
                                }
6261
                            }
6262
                        }
6263
                    }
6264
                    else
6265
                    {
6266
                        gridViewMarkup.SelectAll();
6267
                    }
6268
                }
6269
                else
6270
                {
6271
                    gridViewMarkup.UnselectAll();
6272
                }
6273
            }
6274
        }
6275

    
6276
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6277
        {
6278
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6279

    
6280
            if (dataSet?.Count() == 1)
6281
            {
6282
                PopupWindow popup = new PopupWindow();
6283
                
6284
            }
6285
        }
6286
    
6287

    
6288
        /*
6289
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6290
        {
6291
            try
6292
            {
6293
                if (e.Data.GetDataPresent(typeof(string)))
6294
                {
6295
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6296
                    string dragData = e.Data.GetData(typeof(string)) as string;
6297
                    Move_Symbol(sender, dragData);
6298
                }
6299
            }
6300
            catch (Exception ex)
6301
            {
6302
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6303
            }
6304
        }
6305
        */
6306
    }
6307

    
6308
    public class testItem
6309
    {
6310
        public string Title { get; set; }
6311
    }
6312

    
6313

    
6314
}
클립보드 이미지 추가 (최대 크기: 500 MB)