프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 95c73392

이력 | 보기 | 이력해설 | 다운로드 (281 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 CommentUserInfo currentControl { get; set; }
122
        public ControlType controlType { get; set; }
123
        private Move move = new Move();
124
        private double[] rotateValue = { 0, 90, 180, 270 };
125
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
126
        private static readonly double DragThreshold = 5;
127
        private System.Windows.Input.Cursor cursor { get; set; }
128

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

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

    
149
        public string Filename_ { get; set; }
150
        public double L_Size = 0;
151
        public AdornerFinal adorner_;
152
        public Multi_Undo_data multi_Undo_Data;
153
        public string Symbol_ID = "";
154
        public event EventHandler<EventArgs> MarkupLoadComplated;
155
        /// <summary>
156
        /// Set to 'true' when the left mouse-button is down.
157
        /// </summary>
158
        public bool isLeftMouseButtonDownOnWindow = false;
159

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

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

    
168
        private Point Sync_Offset_Point;
169

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

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

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

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

    
214
        public bool IsSyncPDFMode { get; set; }
215

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

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

    
241
        #endregion 프로퍼티
242

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

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

    
257
            //lstSymbolPrivate.ItemsSource = testItems;
258

    
259
            this.Loaded += MainMenu_Loaded;
260
        }
261

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

    
272
        private List<TempDt> tempDtList = new List<TempDt>();
273

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

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

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

    
299
            return uri;
300
        }
301

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

    
320
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
321

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

    
340
            return uri;
341
        }
342

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

    
353
            return false;
354
        }
355

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

    
379
            return false;
380
        }
381

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

    
389
            ViewerDataModel.Instance._markupInfoList.Remove(item);
390

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

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

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

    
410
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
411

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

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

    
473
                        Button content = (sender as Button);
474
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
475

    
476
                        DeleteItem(item);
477
                    }
478
                }
479
            };
480
            RadWindow.Confirm(parameters);
481
        }
482

    
483
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
484

    
485
        private static Timer timer;
486
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
487

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

    
493
            if (App.ParameterMode)
494
            {
495
                App.splashString(ISplashMessage.MAINMENU_1);
496
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
497
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
498
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
499

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

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

    
517
            //timer = new Timer(timercallback, null, 0, InitInterval * 60000);
518
        }
519

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

    
528
            if (!string.IsNullOrWhiteSpace(directUri))
529
            {
530
                isRestDownload = true;
531
                filename = System.IO.Path.GetFileName(this._DocInfo.ORIGINAL_FILE);
532

    
533
                downloadurl = string.Format(directUri, filename);
534
             }
535
            else
536
            {
537
                downloadurl = GetOriginalPDFURL();
538
            }
539

    
540
            ViewerDataModel.Instance.OriginalTempFile = instnaceFile;
541
            
542
            string endpoint = Common.Commons.shortGuid() + "file";
543
            IIpc.WcfServer wcfServer = new IIpc.WcfServer(endpoint);
544
            wcfServer.IpcFileDownloadReceived += WcfServer_IpcFileDownloadReceived;
545
            wcfServer.Start();
546
            
547
            DownloadProcess.FileDownloader(endpoint, ViewerDataModel.Instance.IsAdmin, downloadurl, instnaceFile, isRestDownload);
548
            #endregion
549
        }
550

    
551
        string instnaceFile;
552
        string downloadurl;
553

    
554
        private void WcfServer_IpcFileDownloadReceived(object sender, IIpc.IpcDownloadStatusArgs e)
555
        {
556
            try
557
            {
558
                Dispatcher.BeginInvoke((Action)delegate () { ViewerDataModel.Instance.DownloadFileProgress = (int)e.Progress; });
559

    
560
                if (e.IsFinish)
561
                {
562
                    ViewerDataModel.Instance.SystemMain.dzMainMenu.searchPanel_Instance.SetSerachPDFFile(instnaceFile);
563
                    ViewerDataModel.Instance.IsDownloadOriginal = true;
564
                    (sender as IIpc.WcfServer).IpcFileDownloadReceived -= WcfServer_IpcFileDownloadReceived;
565
                    (sender as IIpc.WcfServer).Stop();
566
                }
567
            }
568
            catch (Exception ex)
569
            {
570
                throw;
571
            }
572
        }
573

    
574
        private void timercallback(Object o)
575
        {
576
            Stopwatch sw = new Stopwatch();
577
            sw.Start();
578
            TempFile.TempFileAdd();
579
            sw.Stop();
580

    
581
            Dispatcher.InvokeAsync(new Action(delegate
582
            {
583
                if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
584
                {
585
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
586
                }
587
            }));
588

    
589
            ////GC.Collect();
590
        }
591

    
592
        /// <summary>
593
        /// update my markuplist
594
        ///  - update existing markup data if already exist
595
        ///  - add new markup data if control is new
596
        /// </summary>
597
        public void UpdateMyMarkupList()
598
        {
599
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
600

    
601
            /// add or update markup list
602
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
603
            {
604
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
605

    
606
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
607
                if (exist != null) //신규 추가 된 코멘트
608
                {
609
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
610
                    {
611
                        exist.Data = root.ConvertData;
612
                        exist.IsUpdate = true;
613
                    }
614
                }
615
                else if (root.CommentID != null)
616
                {
617
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
618
                    {
619
                        ID = control.CommentID,
620
                        Data = root.ConvertData,
621
                        Data_Type = root.DATA_TYPE,
622
                        MarkupInfoID = App.Custom_ViewInfoId,
623
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
624
                        Symbol_ID = control.SymbolID,
625
                        //Group_ID = control.GroupID,
626
                    });
627
                }
628
            }
629

    
630
            //if (this.pageNavigator.CurrentPage != null)
631
            //{
632
            //    /// delete markup list
633
            //    int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
634

    
635
            //    var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
636
            //                   where (markup.PageNumber == iPageNo)
637
            //                   && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
638
            //                   select markup).ToList();
639

    
640
            //    foreach (var markup in deleted)
641
            //    {
642
            //        ViewerDataModel.Instance.MyMarkupList.Remove(markup);
643
            //    }
644
            //}
645
            //else
646
            //{
647
            //    System.Diagnostics.Debug.WriteLine("UpdateMyMarkupList : this.pageNavigator.CurrentPage null ");
648
            //}
649

    
650
            /// up to here
651

    
652
            //if (modified)
653
            //{
654
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
655
            //    {
656
            //        ComingNewBieEnd = true;
657
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
658
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
659
            //        gridViewMarkup.ItemsSource = null;
660
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
661
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
662

    
663
            //        GroupDescriptor descriptor = new GroupDescriptor();
664
            //        descriptor.Member = "Depatment";
665
            //        descriptor.DisplayContent = "DEPT";
666
            //        descriptor.SortDirection = ListSortDirection.Ascending;
667
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
668
            //    }
669
            //}
670
        }
671

    
672
        /// <summary>
673
        /// start page changing
674
        ///  - save controls if page is modified
675
        ///  - starting download page image
676
        /// </summary>
677
        /// <param name="sender"></param>
678
        /// <param name="e"></param>
679
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
680
        {
681
            System.Diagnostics.Debug.WriteLine("pageNavigator PageChanging");
682
            //    await PageLoadAsync(e.CurrentPage,e.PageNumber);
683
            //}
684

    
685
            //private async Task PageLoadAsync(DOCPAGE page, int PageNo)
686
            //{
687
            DOCPAGE page = e.CurrentPage;
688
            int PageNo = e.PageNumber;
689

    
690
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
691

    
692
            // 페이지 이미지 변경
693

    
694
            /// 컨트롤을 새로 생성한다.
695
            ViewerDataModel.Instance.ImageViewPath = tempPageImage;
696
            ViewerDataModel.Instance.ImageViewWidth = 1;
697
            ViewerDataModel.Instance.ImageViewHeight = 1;
698

    
699
            ViewerDataModel.Instance.SystemMain.dzMainMenu.SelectLayer.Children.Clear();
700
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
701
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
702

    
703
            await PageChangingAsync(page, PageNo, ViewerDataModel.Instance.NewPagImageCancelToken());
704
            
705
            await MarkupLoadAsync(PageNo, ViewerDataModel.Instance.PageAngle, ViewerDataModel.Instance.NewMarkupCancelToken());
706

    
707
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
708

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

    
711
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
712
        }
713

    
714
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
715
        {
716
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
717

    
718
            #region 페이지가 벗어난 경우
719

    
720
            if (BalancePoint < 1)
721
            {
722
                BalancePoint = 1;
723
                ViewerDataModel.Instance.PageBalanceNumber = 0;
724
            }
725

    
726
            if (pageNavigator.PageCount < BalancePoint)
727
            {
728
                BalancePoint = pageNavigator.PageCount;
729
                ViewerDataModel.Instance.PageBalanceNumber = 0;
730
            }
731

    
732
            #endregion 페이지가 벗어난 경우
733

    
734
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
735

    
736
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
737
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
738
            var contentScale = zoomAndPanControl.ContentScale;
739

    
740
            #region 페이지 이미지 로딩 수정
741
            
742

    
743
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
744

    
745
            if(token.IsCancellationRequested)
746
            {
747
                return;
748
            }
749

    
750
            ScaleImage(pageWidth, pageHeight);
751

    
752
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
753
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
754

    
755
            zoomAndPanCanvas.Width = pageWidth;
756
            zoomAndPanCanvas.Height = pageHeight;
757

    
758
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
759
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
760

    
761
            inkBoard.Width = pageWidth;
762
            inkBoard.Height = pageHeight;
763

    
764
            #endregion 페이지 이미지 로딩 수정
765

    
766
            if (!testPanel2.IsHidden)
767
            {
768
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
769
                //PDF모드일때 잠시 대기(강인구)
770
                if (IsSyncPDFMode)
771
                {
772
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
773
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
774

    
775
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
776
                    if (pdfpath.IsDownloading)
777
                    {
778
                        pdfpath.DownloadCompleted += (ex, arg) =>
779
                        {
780
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
781
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
782
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
783
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
784
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
785
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
786
                        };
787
                    }
788
                    else
789
                    {
790
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
791
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
792
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
793
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
794

    
795
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
796
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
797
                    }
798
                }
799
                else
800
                {
801
                    Logger.sendCheckLog("Compare Image Download", 1);
802
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
803
                    ComparePageLoad(compareImageUri,false);
804
                }
805

    
806
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
807
            }
808

    
809
            SearchFocusBorder.Visibility = Visibility.Collapsed;
810

    
811
            this.pageNavigator.ChangePage(changePageNumber);
812
        }
813

    
814
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
815
        {
816
            /// 현재 보고 있는 VP와 같은 크기로 로딩
817
            ViewerDataModel.Instance.ImageViewPath_C = null;
818

    
819
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
820
            {
821
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
822
            }
823
            else
824
            {
825
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
826
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
827
            }
828

    
829
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
830
            {
831
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
832
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
833
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
834
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
835

    
836
                zoomAndPanControl.ZoomTo(new Rect
837
                {
838
                    X = 0,
839
                    Y = 0,
840
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
841
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
842
                });
843

    
844
                if (Sync.IsChecked)
845
                {
846
                    Sync_Click(null, new RoutedEventArgs());
847
                }
848

    
849
                if (CompareMode.IsChecked)
850
                {
851
                    SyncCompare_Click(null, new RoutedEventArgs());
852
                }
853
            }
854
        }
855

    
856
        /// <summary>
857
        /// called after page is changed
858
        /// </summary>
859
        /// <param name="sender"></param>
860
        /// <param name="e"></param>
861
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
862
        {
863
            //if (zoomAndPanCanvas.Width.IsNaN())
864
            //{
865
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
866
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
867
            //    );
868
            //}
869

    
870
            var instanceMain = ViewerDataModel.Instance.SystemMain;
871

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

    
874
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
875
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
876

    
877
            instanceMain.dzTopMenu.rotateOffSet = 0;
878
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
879
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
880

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

    
885
            pageNavigator.LoadMakupList();
886

    
887
            //Point startPoint = new Point(15, 15);
888

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

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

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

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

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

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

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

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

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

    
911
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
912
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
913
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
914
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
915
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
916

    
917
            //symCtrl.ApplyTemplate();
918
            ////txtApproved.ApplyTemplate();
919
            ////txtCreator.ApplyTemplate();
920
            //txtOriginator.ApplyTemplate();
921
            //txtDate.ApplyTemplate();
922

    
923
            ////SetTextControl(txtApproved);
924
            ////SetTextControl(txtCreator);
925
            //SetTextControl(txtOriginator);
926
            //SetTextControl(txtDate);
927

    
928
            //multi_Undo_Data = new Multi_Undo_data();
929

    
930
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
931
            //{
932
            //    IsUndo = false,
933
            //    Event = Event_Type.Create,
934
            //    EventTime = DateTime.Now,
935
            //    Markup_List = new List<Multi_Undo_data>()
936
            //};
937

    
938
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
939
            //UndoData.Markup_List.Add(multi_Undo_Data);
940

    
941
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
942
            ////UndoData.Markup_List.Add(multi_Undo_Data);
943

    
944
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
945
            ////UndoData.Markup_List.Add(multi_Undo_Data);
946

    
947
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
948
            //UndoData.Markup_List.Add(multi_Undo_Data);
949

    
950
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
951
            //UndoData.Markup_List.Add(multi_Undo_Data);
952

    
953
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
954

    
955
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
956
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
957
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
958
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
959
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
960
        }
961

    
962
        private void SetTextControl(TextControl textControl)
963
        {
964
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
965
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
966
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
967
        }
968

    
969
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
970
        {
971
            SymControlN result = null;
972

    
973
            try
974
            {
975
                double height = 80;
976
                double itemWidth = 180;
977

    
978
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
979
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
980
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
981
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
982

    
983
                result = new SymControlN
984
                {
985
                    CommentID = Commons.shortGuid(),
986
                    MarkupInfoID = markupInfoId,
987
                    UserID = userId,
988
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
989
                    StartPoint = startPoint,
990
                    EndPoint = endPoint,
991
                    CommentAngle = 0,
992
                    LeftBottomPoint = leftBottomPoint,
993
                    TopRightPoint = topRightPoint,
994
                    Opacity = 1,
995
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
996
                    Memo = null
997
                };
998
            }
999
            catch (Exception ex)
1000
            {
1001
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1002
            }
1003

    
1004
            return result;
1005
        }
1006

    
1007
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
1008
        {
1009
            RectangleControl result = null;
1010

    
1011
            try
1012
            {
1013
                double height = 80;
1014
                double itemWidth = 180;
1015

    
1016
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1017
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
1018
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
1019
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
1020

    
1021
                result = new RectangleControl
1022
                {
1023
                    CommentID = Commons.shortGuid(),
1024
                    MarkupInfoID = markupInfoId,
1025
                    LineSize = 5,
1026
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
1027
                    StartPoint = startPoint,
1028
                    EndPoint = endPoint,
1029
                    CommentAngle = 0,
1030
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1031
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1032
                    FillColor = null,
1033
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1034
                    Opacity = 1,
1035
                    LeftBottomPoint = leftBottomPoint,
1036
                    TopRightPoint = topRightPoint,
1037
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1038
                    UserID = userId,
1039
                    Memo = null
1040
                };
1041
            }
1042
            catch (Exception ex)
1043
            {
1044
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1045
            }
1046

    
1047
            return result;
1048
        }
1049

    
1050
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1051
        {
1052
            TextControl result = null;
1053

    
1054
            try
1055
            {
1056
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1057

    
1058
                double startPositionX = parentRect.X;
1059

    
1060
                switch (textAlignment)
1061
                {
1062
                    case TextAlignment.Right:
1063
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1064
                        break;
1065

    
1066
                    case TextAlignment.Center:
1067
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1068
                        break;
1069
                }
1070

    
1071
                Point startPosition = new Point
1072
                {
1073
                    X = startPositionX,
1074
                    Y = positionY
1075
                };
1076

    
1077
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1078
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1079
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1080
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1081

    
1082
                result = new TextControl
1083
                {
1084
                    CommentID = Commons.shortGuid(),
1085
                    MarkupInfoID = markupInfoId,
1086
                    Text = Text,
1087
                    StartPoint = startPoint,
1088
                    EndPoint = endPoint,
1089
                    CanvasX = startPosition.X,
1090
                    CanvasY = startPosition.Y,
1091
                    BoxWidth = txtSize.Width,
1092
                    BoxHeight = txtSize.Height,
1093
                    ControlType_No = 0,
1094
                    LineSize = new Thickness(5),
1095
                    TextSize = fontSize,
1096
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1097
                    FontSize = 10,
1098
                    UserID = userId,
1099
                    IsHighLight = false,
1100
                    CommentAngle = 0,
1101
                    PointSet = new List<Point>(),
1102
                    Opacity = 1,
1103
                    IsSelected = false,
1104
                    TextFamily = new FontFamily("Tahoma"),
1105
                    TextStyle = FontStyles.Normal,
1106
                    TextWeight = FontWeights.Bold
1107
                };
1108
            }
1109
            catch (Exception ex)
1110
            {
1111
            }
1112

    
1113
            return result;
1114
        }
1115

    
1116
        public static Size ShapeMeasure(UIElement e)
1117
        {
1118
            // Measured Size is bounded to be less than maxSize
1119
            Size maxSize = new Size(
1120
                 double.PositiveInfinity,
1121
                 double.PositiveInfinity);
1122
            e.Measure(maxSize);
1123
            return e.DesiredSize;
1124
        }
1125

    
1126
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1127
        {
1128
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1129
            stopwatch.Start();
1130

    
1131
            /// 컨트롤을 새로 생성한다.
1132
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1133
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1134

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

    
1137
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1138
            {
1139
                if (cts.IsCancellationRequested)
1140
                {
1141
                    return;
1142
                }
1143

    
1144
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1145
                if (info != null)
1146
                {
1147
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1148
                    if (info.UserID == App.ViewInfo.UserID)
1149
                    {
1150
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1151
                                        markup.MarkupInfoID, markup.ID);
1152
                        control.Visibility = Visibility.Hidden;
1153
                    }
1154
                    else
1155
                    {
1156
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1157
                                                                markup.MarkupInfoID, markup.ID);
1158
                        control.Visibility = Visibility.Hidden;
1159
                    }
1160
                }
1161
            };
1162
            /// up to here
1163

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

    
1166
            /// fire selection event
1167
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1168
            this.gridViewMarkup.UnselectAll();
1169
            this.gridViewMarkup.Select(gridSelectionItem);
1170

    
1171
            if (!testPanel2.IsHidden)
1172
            {
1173
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1174
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1175
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1176

    
1177
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1178
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1179

    
1180
                foreach (var item in gridSelectionRevItem)
1181
                {
1182
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1183

    
1184
                    foreach (var markupitem in markupitems)
1185
                    {
1186
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1187

    
1188
                        if (cts.IsCancellationRequested)
1189
                        {
1190
                            return;
1191
                        }
1192
                    }
1193
                }
1194
            }
1195

    
1196
            SetCommentPages(cts);
1197

    
1198
            if (MarkupLoadComplated != null)
1199
            {
1200
                MarkupLoadComplated(this, new EventArgs());
1201
            }
1202
        }
1203

    
1204
        public void SetCommentPages(CancellationToken? cts)
1205
        {
1206
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1207
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1208
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1209
            {
1210
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1211
                if (item.MarkupList != null)
1212
                {
1213
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1214
                    instance.UserName = item.UserName;
1215
                    instance.Depart = item.Depatment;
1216
                    instance.MarkupInfoID = item.MarkupInfoID;
1217
                    instance.IsSelected = true;
1218
                    instance.isConSolidation = item.Consolidate;
1219
                    instance.SetColor = item.DisplayColor;
1220
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1221
                    {
1222
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1223
                    }
1224
                    else
1225
                    {
1226
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1227
                    }
1228
                    _pages.Add(instance);
1229
                }
1230

    
1231
                if (cts != null)
1232
                {
1233
                    if (cts.Value.IsCancellationRequested)
1234
                        return;
1235
                }
1236
            }
1237

    
1238
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1239
        }
1240

    
1241
        public void MarkupitemViewUpdate(string markupinfo_id)
1242
        {
1243
            //db에 업데이트 한 list 를 view 에 업데이트
1244
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1245
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1246
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1247
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1248
            if (dbinfo.MarkupList.Count > 0)
1249
            {
1250
                if (viewinfo.MarkupList != null)
1251
                {
1252
                    viewinfo.MarkupList.Clear();
1253
                    viewinfo.MarkupList = null;
1254
                }
1255

    
1256
                viewinfo.MarkupList = new List<MarkupItem>();
1257
                foreach (var item in dbinfo.MarkupList)
1258
                {
1259
                    System.Diagnostics.Debug.WriteLine(item.ID);
1260
                    viewinfo.MarkupList.Add(item);
1261
                }
1262
            }
1263
        }
1264

    
1265
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1266
        {
1267
            var instance = ViewerDataModel.Instance;
1268

    
1269
            if (instance.IsWheelPageChanage)
1270
            {
1271
                return;
1272
            }
1273

    
1274
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1275
            {
1276
                int changePage = 0;
1277

    
1278
                if (e.Delta > 0)
1279
                {
1280
                    if (0 < instance.ContentOffsetY)
1281
                    {
1282
                        Vector dragOffset = new Vector(0, e.Delta);
1283
                        MoveZoomAndPanControl(dragOffset);
1284
                    }
1285
                    //else
1286
                    //{
1287
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1288
                    //    {
1289
                    //        instance.IsWheelPageChanage = true;
1290
                    //        changePage -= 1;
1291
                    //    }
1292
                    //}
1293
                }
1294
                else if (e.Delta < 0)
1295
                {
1296
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1297
                    {
1298
                        Vector dragOffset = new Vector(0, e.Delta);
1299
                        MoveZoomAndPanControl(dragOffset);
1300
                    }
1301
                    //else
1302
                    //{
1303
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1304
                    //    {
1305
                    //        instance.IsWheelPageChanage = true;
1306
                    //        changePage += 1;
1307
                    //    }
1308
                    //}
1309
                }
1310

    
1311
                //if (changePage != 0)
1312
                //{
1313
                //    await Task.Factory.StartNew(() =>
1314
                //    {
1315
                //        double beforeScale = instance.ContentScale;
1316

    
1317
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1318

    
1319
                //        handler = (snd, evt) =>
1320
                //        {
1321
                //            /// 최상단으로 이전 zoomScale로 위치한다
1322
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1323
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1324
                //            instance.IsWheelPageChanage = false;
1325
                //            pageNavigator.PageChanged -= handler;
1326
                //        };
1327

    
1328
                //        pageNavigator.PageChanged += handler;
1329

    
1330
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1331
                //    });
1332

    
1333
                //}
1334
            }
1335
            else
1336
            {
1337
                e.Handled = true;
1338
                if (e.Delta > 0)
1339
                {
1340
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1341
                    ZoomIn(currentContentMousePoint);
1342
                }
1343
                else
1344
                {
1345
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1346
                    ZoomOut(currentContentMousePoint);
1347
                }
1348
            }
1349
        }
1350

    
1351
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1352
        {
1353
            e.Handled = true;
1354
            if (e.Delta > 0)
1355
            {
1356
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1357
                ZoomIn_Sync(currentContentMousePoint);
1358
            }
1359
            else
1360
            {
1361
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1362
                ZoomOut_Sync(currentContentMousePoint);
1363
            }
1364
        }
1365

    
1366
        #region ZoomIn & ZoomOut
1367

    
1368
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1369
        {
1370
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1371
                zoomAndPanControl.ContentZoomFocusY));
1372
        }
1373

    
1374
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1375
        {
1376
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1377
                zoomAndPanControl.ContentZoomFocusY));
1378
        }
1379

    
1380
        //강인구 추가 (줌 인아웃 수치 변경)
1381
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1382
        private void ZoomOut(Point contentZoomCenter)
1383
        {
1384
            if (zoomAndPanControl.ContentScale > 0.39)
1385
            {
1386
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1387
            }
1388
            else
1389
            {
1390
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1391
            }
1392

    
1393
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1394
            {
1395
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1396
            }
1397
        }
1398

    
1399
        private void ZoomIn(Point contentZoomCenter)
1400
        {
1401
            if (zoomAndPanControl.ContentScale > 0.19)
1402
            {
1403
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1404
            }
1405
            else
1406
            {
1407
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1408
            }
1409

    
1410
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1411
            {
1412
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1413
            }
1414
        }
1415

    
1416
        private void ZoomOut_Sync(Point contentZoomCenter)
1417
        {
1418
            if (zoomAndPanControl2.ContentScale > 0.39)
1419
            {
1420
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1421
            }
1422
            else
1423
            {
1424
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1425
            }
1426

    
1427
            if (Sync.IsChecked)
1428
            {
1429
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1430
            }
1431
        }
1432

    
1433
        private void ZoomIn_Sync(Point contentZoomCenter)
1434
        {
1435
            if (zoomAndPanControl2.ContentScale > 0.19)
1436
            {
1437
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1438
            }
1439
            else
1440
            {
1441
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1442
            }
1443

    
1444
            if (Sync.IsChecked)
1445
            {
1446
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1447
            }
1448
        }
1449

    
1450
        private void ZoomOut()
1451
        {
1452
            zoomAndPanControl.ContentScale -= 0.1;
1453
            //if (zoomAndPanControl2 != null)
1454
            //{
1455
            //    zoomAndPanControl2.ContentScale -= 0.1;
1456
            //}
1457
        }
1458

    
1459
        private void ZoomIn()
1460
        {
1461
            zoomAndPanControl.ContentScale += 0.1;
1462
            //if (zoomAndPanControl2 != null)
1463
            //{
1464
            //    zoomAndPanControl2.ContentScale += 0.1;
1465
            //}
1466
        }
1467

    
1468
        #endregion ZoomIn & ZoomOut
1469

    
1470
        private void init()
1471
        {
1472
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1473
            {
1474
                ControlList.Clear();
1475
                listBox.Items.Clear();
1476
                selected_item.Clear();
1477

    
1478
                (item as IMarkupCommonData).IsSelected = false;
1479
            }
1480
        }
1481

    
1482
        private HitTestResultBehavior MyCallback(HitTestResult result)
1483
        {
1484
            //this.cursor = Cursors.UpArrow;
1485
            var element = result.VisualHit;
1486
            while (element != null && !(element is CommentUserInfo))
1487
                element = VisualTreeHelper.GetParent(element);
1488

    
1489
            if (element == null)
1490
            {
1491
                return HitTestResultBehavior.Stop;
1492
            }
1493
            else
1494
            {
1495
                if (element is CommentUserInfo)
1496
                {
1497
                    if (!hitList.Contains(element))
1498
                    {
1499
                        hitList.Add((CommentUserInfo)element);
1500
                    }
1501
                    else
1502
                    {
1503
                        return HitTestResultBehavior.Stop;
1504
                    }
1505
                }
1506
            }
1507
            return HitTestResultBehavior.Continue;
1508
        }
1509

    
1510
        public void ReleaseSelectPath()
1511
        {
1512
            if (SelectionPath == null)
1513
            {
1514
                SelectionPath = new Path();
1515
                SelectionPath.Name = "";
1516
            }
1517
            if (SelectionPath.Name != "")
1518
            {
1519
                SelectionPath.Name = "None";
1520
            }
1521
            SelectionPath.Opacity = 0.01;
1522
            SelectionPath.RenderTransform = null;
1523
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1524
        }
1525

    
1526
        #region 컨트롤 초기화
1527

    
1528
        public void Control_Init(object control)
1529
        {
1530
            if (L_Size != 0 && (control as IPath) != null)
1531
            {
1532
                (control as IPath).LineSize = L_Size;
1533
                L_Size = 0;
1534
            }
1535

    
1536
            switch (control.GetType().Name)
1537
            {
1538
                case "RectangleControl":
1539
                    {
1540
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1541
                    }
1542
                    break;
1543

    
1544
                case "CircleControl":
1545
                    {
1546
                        (control as CircleControl).StrokeColor = Brushes.Red;
1547
                    }
1548
                    break;
1549

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

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

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

    
1568
                case "PolygonControl":
1569
                    {
1570
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1571
                    }
1572
                    break;
1573

    
1574
                case "ArcControl":
1575
                    {
1576
                        (control as ArcControl).StrokeColor = Brushes.Red;
1577
                    }
1578
                    break;
1579

    
1580
                case "ArrowArcControl":
1581
                    {
1582
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1583
                    }
1584
                    break;
1585

    
1586
                case "LineControl":
1587
                    {
1588
                        (control as LineControl).StrokeColor = Brushes.Red;
1589
                    }
1590
                    break;
1591

    
1592
                case "ArrowControl_Multi":
1593
                    {
1594
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1595
                    }
1596
                    break;
1597

    
1598
                case "TextControl":
1599
                    {
1600
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1601
                    }
1602
                    break;
1603

    
1604
                case "ArrowTextControl":
1605
                    {
1606
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1607
                    }
1608
                    break;
1609

    
1610
                case "InsideWhiteControl":
1611
                    {
1612
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1613
                    }
1614
                    break;
1615

    
1616
                case "OverlapWhiteControl":
1617
                    {
1618
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1619
                    }
1620
                    break;
1621

    
1622
                case "ClipWhiteControl":
1623
                    {
1624
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1625
                    }
1626
                    break;
1627

    
1628
                case "CoordinateControl":
1629
                    {
1630
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1631
                    }
1632
                    break;
1633
            }
1634
        }
1635

    
1636
        #endregion 컨트롤 초기화
1637

    
1638
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1639
        {
1640
            //Control_Init(e.Source);
1641
        }
1642

    
1643
        //private Window _dragdropWindow = null;
1644

    
1645
        [DllImport("user32.dll")]
1646
        [return: MarshalAs(UnmanagedType.Bool)]
1647
        internal static extern bool GetCursorPos(ref Win32Point pt);
1648

    
1649
        [StructLayout(LayoutKind.Sequential)]
1650
        internal struct Win32Point
1651
        {
1652
            public Int32 X;
1653
            public Int32 Y;
1654
        };
1655

    
1656
        /*
1657
       public string symbol_id = null;
1658
       public long symbol_group_id;
1659
       public int symbol_SelectedIndex;
1660
       public ImageSource symbol_img;
1661
       public string symbol_Data = null;
1662
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1663
       {
1664
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1665
               zoomAndPanCanvas.ActualHeight / 2));
1666

    
1667
               if (this._dragdropWindow != null)
1668
               {
1669
                   this._dragdropWindow.Close();
1670
                   this._dragdropWindow = null;
1671
               }
1672

    
1673
               symbol_id = id;
1674
               symbol_group_id = group_id;
1675
               symbol_SelectedIndex = SelectedIndex;
1676
               symbol_Data = Data_;
1677
               symbol_img = img;
1678

    
1679
               CreateDragDropWindow2(img);
1680
    }
1681

    
1682
    private void CreateDragDropWindow2(ImageSource image)
1683
        {
1684
            this._dragdropWindow = new Window();
1685
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1686
            _dragdropWindow.WindowStyle = WindowStyle.None;
1687
            _dragdropWindow.AllowsTransparency = true;
1688
            _dragdropWindow.AllowDrop = false;
1689
            _dragdropWindow.Background = null;
1690
            _dragdropWindow.IsHitTestVisible = false;
1691
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1692
            _dragdropWindow.Topmost = true;
1693
            _dragdropWindow.ShowInTaskbar = false;
1694

    
1695
            Rectangle r = new Rectangle();
1696
            r.Width = image.Width;
1697
            r.Height = image.Height;
1698
            r.Opacity = 0.5;
1699
            r.Fill = new ImageBrush(image);
1700
            this._dragdropWindow.Content = r;
1701

    
1702
            Win32Point w32Mouse = new Win32Point();
1703
            GetCursorPos(ref w32Mouse);
1704

    
1705
            //w32Mouse.X = getCurrentPoint.X;
1706
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1707
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1708
            this._dragdropWindow.Show();
1709
        }
1710

    
1711
         */
1712

    
1713
        public void MoveZoomAndPanControl(Vector dragOffset)
1714
        {
1715
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1716
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1717

    
1718
            if (Sync.IsChecked)
1719
            {
1720
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1721
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1722
            }
1723
        }
1724

    
1725
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1726
        {
1727
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1728
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1729
            //if(this.txtBatch.Visibility == Visibility.Visible)
1730
            {
1731
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1732

    
1733
                Point currentPos = e.GetPosition(rect);
1734

    
1735
                floatingTip.HorizontalOffset = currentPos.X + 20;
1736
                floatingTip.VerticalOffset = currentPos.Y;
1737
            }
1738

    
1739
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1740

    
1741
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1742
            {
1743
                SetCursor();
1744
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1745
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1746

    
1747
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1748

    
1749
                MoveZoomAndPanControl(dragOffset);
1750
            }
1751

    
1752
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1753
            {
1754
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1755
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1756
                SetCursor();
1757

    
1758
                if (currentControl != null)
1759
                {
1760
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1761
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1762
                    //강인구 추가
1763
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1764

    
1765
                    if ((currentControl as IPath) != null)
1766
                    {
1767
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1768
                    }
1769
                    if ((currentControl as LineControl) != null)
1770
                    {
1771
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1772
                    }
1773

    
1774
                    if ((currentControl as IShapeControl) != null)
1775
                    {
1776
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1777
                    }
1778
                    if ((currentControl as TextControl) != null)
1779
                    {
1780
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1781
                        {
1782
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1783
                        }
1784
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1785
                        {
1786
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1787
                        }
1788
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1789
                        {
1790
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1791
                        }
1792
                    }
1793
                    else if ((currentControl as ArrowTextControl) != null)
1794
                    {
1795
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1796
                        {
1797
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1798
                        }
1799
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1800
                        {
1801
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1802
                        }
1803
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1804
                        {
1805
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1806
                        }
1807
                    }
1808
                    else if ((currentControl as RectCloudControl) != null)
1809
                    {
1810
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1811
                    }
1812
                    else if ((currentControl as CloudControl) != null)
1813
                    {
1814
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1815
                    }
1816

    
1817
                    #region // 모든 컨트롤의 공통기능 제어
1818

    
1819
                    if (controlType != ControlType.PenControl)
1820
                    {
1821
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1822
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1823
                    }
1824

    
1825
                    #endregion // 모든 컨트롤의 공통기능 제어
1826

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

    
1829
                    switch (controlType)
1830
                    {
1831
                        case (ControlType.Coordinate):
1832
                            {
1833
                                var control = currentControl as CoordinateControl;
1834
                                if (control != null)
1835
                                {
1836
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1837
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1838
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1839
                                }
1840
                            }
1841
                            break;
1842

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

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

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

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

    
1894
                        case ControlType.SingleLine:
1895
                        case ControlType.CancelLine:
1896
                        case ControlType.ArrowLine:
1897
                        case ControlType.TwinLine:
1898
                        case ControlType.DimLine:
1899
                            {
1900
                                var control = currentControl as LineControl;
1901
                                if (control != null)
1902
                                {
1903
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1904
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1905
                                }
1906
                            }
1907
                            break;
1908

    
1909
                        case ControlType.ArcLine:
1910
                            {
1911
                                var control = currentControl as ArcControl;
1912
                                if (control != null)
1913
                                {
1914
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1915
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1916
                                }
1917
                            }
1918
                            break;
1919

    
1920
                        case ControlType.ArcArrow:
1921
                            {
1922
                                var control = currentControl as ArrowArcControl;
1923
                                if (control != null)
1924
                                {
1925
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1926
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1927
                                }
1928
                            }
1929
                            break;
1930

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

    
1942
                        case ControlType.Circle:
1943
                            {
1944
                                var control = currentControl as CircleControl;
1945

    
1946
                                if (control != null)
1947
                                {
1948
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1949
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1950
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1951
                                }
1952
                            }
1953
                            break;
1954

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

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

    
1979
                        case ControlType.ImgControl:
1980
                            {
1981
                                var control = currentControl as ImgControl;
1982
                                if (control != null)
1983
                                {
1984
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1985
                                }
1986
                            }
1987
                            break;
1988

    
1989
                        case ControlType.Date:
1990
                            {
1991
                                var control = currentControl as DateControl;
1992
                                if (control != null)
1993
                                {
1994
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1995
                                }
1996
                            }
1997
                            break;
1998

    
1999
                        case ControlType.ArrowTextControl:
2000
                        case ControlType.ArrowTransTextControl:
2001
                        case ControlType.ArrowTextBorderControl:
2002
                        case ControlType.ArrowTransTextBorderControl:
2003
                        case ControlType.ArrowTextCloudControl:
2004
                        case ControlType.ArrowTransTextCloudControl:
2005
                            {
2006
                                var control = currentControl as ArrowTextControl;
2007
                                if (control != null)
2008
                                {
2009
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2010
                                }
2011
                            }
2012
                            break;
2013

    
2014
                        case ControlType.PolygonControl:
2015
                        case ControlType.ChainLine:
2016
                            {
2017
                                var control = currentControl as PolygonControl;
2018
                                if (control != null)
2019
                                {
2020
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2021
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2022
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2023
                                }
2024
                            }
2025
                            break;
2026

    
2027
                        case ControlType.Sign:
2028
                            {
2029
                                var control = currentControl as SignControl;
2030
                                if (control != null)
2031
                                {
2032
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2033
                                }
2034
                            }
2035
                            break;
2036

    
2037
                        case ControlType.Symbol:
2038
                            {
2039
                                var control = currentControl as SymControl;
2040
                                if (control != null)
2041
                                {
2042
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2043
                                }
2044
                            }
2045
                            break;
2046

    
2047
                        case ControlType.Stamp:
2048
                            {
2049
                                var control = currentControl as SymControlN;
2050
                                if (control != null)
2051
                                {
2052
                                    if (control.STAMP != null)
2053
                                    {
2054
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2055
                                    }
2056
                                    else
2057
                                    {
2058
                                        currentControl = null;
2059
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2060
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2061
                                    }
2062
                                }
2063
                            }
2064
                            break;
2065

    
2066
                        case ControlType.Rectangle:
2067
                        case ControlType.Mark:
2068
                            {
2069
                                var control = currentControl as RectangleControl;
2070
                                if (control != null)
2071
                                {
2072
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2073
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2074
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2075
                                }
2076
                            }
2077
                            break;
2078

    
2079
                        case ControlType.PenControl:
2080
                            {
2081
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2082
                                //inkBoard.Strokes.Add(stroke);
2083
                            }
2084
                            break;
2085

    
2086
                        default:
2087
                            break;
2088
                    }
2089

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

    
2092
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2093
                    {
2094
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2095
                    }
2096
                }
2097
            }
2098
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2099
            {
2100
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2101
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2102
                SetCursor();
2103
                if (currentControl == null)
2104
                {
2105
                    switch (controlType)
2106
                    {
2107
                        case ControlType.PenControl:
2108
                            {
2109
                                if (inkBoard.Tag.ToString() == "Ink")
2110
                                {
2111
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2112
                                }
2113
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2114
                                {
2115
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2116
                                }
2117
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2118
                                {
2119
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2120
                                }
2121

    
2122
                                //inkBoard.Strokes.Add(stroke);
2123
                            }
2124
                            break;
2125
                    }
2126
                    return;
2127
                }
2128
            }
2129
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2130
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2131
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2132
            {
2133
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2134

    
2135
                if (isDraggingSelectionRect)
2136
                {
2137
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2138
                    e.Handled = true;
2139
                }
2140
                else if (isLeftMouseButtonDownOnWindow)
2141
                {
2142
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2143
                    double dragDistance = Math.Abs(dragDelta.Length);
2144

    
2145
                    if (dragDistance > DragThreshold)
2146
                    {
2147
                        isDraggingSelectionRect = true;
2148
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2149
                    }
2150

    
2151
                    e.Handled = true;
2152
                }
2153

    
2154
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2155
                {
2156
                }
2157
                else
2158
                {
2159
                    e.Handled = true;
2160
                }
2161
            }
2162
            /*
2163
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2164
            { //symbol
2165
                if(_dragdropWindow != null)
2166
                {
2167
                    Win32Point w32Mouse = new Win32Point();
2168
                    GetCursorPos(ref w32Mouse);
2169

    
2170
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2171
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2172
                }
2173
            }
2174
            */
2175
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2176
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2177
            {
2178
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2179
                if (control != null)
2180
                {
2181
                    this.cursor = Cursors.Hand;
2182
                    SetCursor();
2183
                }
2184
                else
2185
                {
2186
                    if (this.Cursor != Cursors.None)
2187
                    {
2188
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2189
                        SetCursor();
2190
                    }
2191
                }
2192
            }
2193
            else
2194
            {
2195
            }
2196
        }
2197

    
2198
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2199
        {
2200
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2201
            {
2202
                SetCursor();
2203
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2204
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2205

    
2206
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2207

    
2208
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2209
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2210

    
2211
                if (Sync.IsChecked)
2212
                {
2213
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2214
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2215
                }
2216
            }
2217
        }
2218

    
2219
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2220

    
2221
        private EllipseGeometry hitArea = new EllipseGeometry();
2222

    
2223
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2224
        {
2225
            IsDrawing = false;
2226

    
2227
            if (mouseHandlingMode != MouseHandlingMode.None)
2228
            {
2229
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2230
                {
2231
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2232

    
2233
                    SetCursor();
2234

    
2235
                    switch (controlType)
2236
                    {
2237
                        case ControlType.None:
2238
                            break;
2239

    
2240
                        case ControlType.Rectangle:
2241
                            {
2242
                            }
2243
                            break;
2244

    
2245
                        case ControlType.PenControl:
2246
                            {
2247
                            }
2248
                            break;
2249

    
2250
                        default:
2251
                            break;
2252
                    }
2253
                }
2254
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2255
                {
2256
                    if (isLeftMouseButtonDownOnWindow)
2257
                    {
2258
                        bool wasDragSelectionApplied = false;
2259

    
2260
                        if (isDraggingSelectionRect)
2261
                        {
2262
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2263
                            {
2264
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2265
                                mouseHandlingMode = MouseHandlingMode.None;
2266
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2267
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2268
                                Set_Symbol_Capture(endPoint);
2269
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2270
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2271
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2272
                            }
2273
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2274
                            {
2275
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2276
                                mouseHandlingMode = MouseHandlingMode.None;
2277
                                Set_Capture();
2278

    
2279
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2280
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2281
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2282
                            }
2283
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2284
                            {
2285
                                ApplyDragSelectionRect();
2286
                            }
2287
                            else
2288
                            {
2289
                                double x = Canvas.GetLeft(dragZoomBorder);
2290
                                double y = Canvas.GetTop(dragZoomBorder);
2291
                                double width = dragZoomBorder.Width;
2292
                                double height = dragZoomBorder.Height;
2293
                                Rect dragRect = new Rect(x, y, width, height);
2294

    
2295
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2296

    
2297
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2298
                            }
2299

    
2300
                            isDraggingSelectionRect = false;
2301
                            e.Handled = true;
2302
                            wasDragSelectionApplied = true;
2303
                        }
2304

    
2305
                        if (isLeftMouseButtonDownOnWindow)
2306
                        {
2307
                            isLeftMouseButtonDownOnWindow = false;
2308
                            this.ReleaseMouseCapture();
2309
                            e.Handled = true;
2310
                        }
2311

    
2312
                        if (!wasDragSelectionApplied)
2313
                        {
2314
                            init();
2315
                        }
2316
                    }
2317
                }
2318
                else if (e.RightButton == MouseButtonState.Pressed)
2319
                {
2320
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2321
                    SetCursor();
2322
                }
2323

    
2324
                zoomAndPanControl.ReleaseMouseCapture();
2325

    
2326
                e.Handled = true;
2327
            }
2328
            else
2329
            {
2330
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2331
                SetCursor();
2332
            }
2333

    
2334
            ///mouseButtonDown = MouseButton.Left;
2335
            //controlType = ControlType.SingleLine;
2336
        }
2337

    
2338
        public void Set_Symbol_Capture(Point endPoint)
2339
        {
2340
            double x = CanvasDrawingMouseDownPoint.X;
2341
            double y = CanvasDrawingMouseDownPoint.Y;
2342
            if (x > endPoint.X)
2343
            {
2344
                x = endPoint.X;
2345
                y = endPoint.Y;
2346
            }
2347

    
2348
            double width = dragCaptureBorder.Width;
2349
            double height = dragCaptureBorder.Height;
2350

    
2351
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2352

    
2353
            if (x < 0)
2354
            {
2355
                width += x;
2356
                x = 0;
2357
            }
2358
            if (y < 0)
2359
            {
2360
                height += y;
2361
                y = 0;
2362

    
2363
                width = (int)canvasImage.PixelWidth - x;
2364
            }
2365
            if (x + width > canvasImage.PixelWidth)
2366
            {
2367
                width = (int)canvasImage.PixelWidth - x;
2368
            }
2369
            if (y + height > canvasImage.PixelHeight)
2370
            {
2371
                height = (int)canvasImage.PixelHeight - y;
2372
            }
2373
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2374

    
2375
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2376
            var defaultBitmapImage = new BitmapImage();
2377
            defaultBitmapImage.BeginInit();
2378
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2379
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2380
            defaultBitmapImage.UriSource = new Uri(uri);
2381
            defaultBitmapImage.EndInit();
2382

    
2383
            //GC.Collect();
2384

    
2385
            if (defaultBitmapImage.IsDownloading)
2386
            {
2387
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2388
                {
2389
                    defaultBitmapImage.Freeze();
2390
                    //GC.Collect();
2391
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2392
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2393
                };
2394
            }
2395
        }
2396

    
2397
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2398
        {
2399
            ///mouseButtonDown = MouseButton.Left;
2400
        }
2401

    
2402
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2403
        {
2404
            ///mouseButtonDown = MouseButton.Left;
2405
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2406
        }
2407

    
2408
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2409
        {
2410
        }
2411

    
2412
        /// <summary>
2413
        /// select items by dragging
2414
        /// </summary>
2415
        private void ApplyDragSelectionRect()
2416
        {
2417
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2418

    
2419
            double x = Canvas.GetLeft(dragSelectionBorder);
2420
            double y = Canvas.GetTop(dragSelectionBorder);
2421
            double width = dragSelectionBorder.Width;
2422
            double height = dragSelectionBorder.Height;
2423
            Boolean Flag = false;
2424
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2425
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2426

    
2427
            Rect dragRect = new Rect(x, y, width, height);
2428
            ///dragRect.Inflate(width / 10, height / 10);
2429

    
2430
            foreach (var item in Items)
2431
            {
2432
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2433

    
2434
                if (Flag)
2435
                {
2436
                    adornerSet.Add(item);
2437
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2438
                    Control_Style(item);
2439
                }
2440
            }
2441
            if (adornerSet.Count > 0)
2442
            {
2443
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2444
                SelectLayer.Children.Add(final);
2445
            }
2446
        }
2447

    
2448
        private void InitDragSelectionRect(Point pt1, Point pt2)
2449
        {
2450
            //캡쳐 중
2451
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2452
            {
2453
                dragCaptureBorder.Visibility = Visibility.Visible;
2454
            }
2455
            //선택 중
2456
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2457
            {
2458
                dragSelectionBorder.Visibility = Visibility.Visible;
2459
            }
2460
            else
2461
            {
2462
                dragZoomBorder.Visibility = Visibility.Visible;
2463
            }
2464
            UpdateDragSelectionRect(pt1, pt2);
2465
        }
2466

    
2467
        /// <summary>
2468
        /// Update the position and size of the rectangle used for drag selection.
2469
        /// </summary>
2470
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2471
        {
2472
            double x, y, width, height;
2473

    
2474
            //
2475
            // Determine x,y,width and height of the rect inverting the points if necessary.
2476
            //
2477

    
2478
            if (pt2.X < pt1.X)
2479
            {
2480
                x = pt2.X;
2481
                width = pt1.X - pt2.X;
2482
            }
2483
            else
2484
            {
2485
                x = pt1.X;
2486
                width = pt2.X - pt1.X;
2487
            }
2488

    
2489
            if (pt2.Y < pt1.Y)
2490
            {
2491
                y = pt2.Y;
2492
                height = pt1.Y - pt2.Y;
2493
            }
2494
            else
2495
            {
2496
                y = pt1.Y;
2497
                height = pt2.Y - pt1.Y;
2498
            }
2499

    
2500
            //
2501
            // Update the coordinates of the rectangle used for drag selection.
2502
            //
2503
            //캡쳐 중
2504
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2505
            {
2506
                Canvas.SetLeft(dragCaptureBorder, x);
2507
                Canvas.SetTop(dragCaptureBorder, y);
2508
                dragCaptureBorder.Width = width;
2509
                dragCaptureBorder.Height = height;
2510
            }
2511
            //선택 중
2512
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2513
            {
2514
                Canvas.SetLeft(dragSelectionBorder, x);
2515
                Canvas.SetTop(dragSelectionBorder, y);
2516
                dragSelectionBorder.Width = width;
2517
                dragSelectionBorder.Height = height;
2518
            }
2519
            else
2520
            {
2521
                Canvas.SetLeft(dragZoomBorder, x);
2522
                Canvas.SetTop(dragZoomBorder, y);
2523
                dragZoomBorder.Width = width;
2524
                dragZoomBorder.Height = height;
2525
            }
2526
        }
2527

    
2528
        private void drawingPannelRotate(double angle)
2529
        {
2530
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2531
            rotate.Angle = angle;
2532
            var rotationNum = Math.Abs((rotate.Angle / 90));
2533

    
2534
            if (angle == 90 || angle == 270)
2535
            {
2536
                double emptySize = zoomAndPanCanvas.Width;
2537
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2538
                zoomAndPanCanvas.Height = emptySize;
2539
            }
2540
            if (angle == 0)
2541
            {
2542
                translate.X = 0;
2543
                translate.Y = 0;
2544
            }
2545
            else if (angle == 90)
2546
            {
2547
                translate.X = zoomAndPanCanvas.Width;
2548
                translate.Y = 0;
2549
            }
2550
            else if (angle == 180)
2551
            {
2552
                translate.X = zoomAndPanCanvas.Width;
2553
                translate.Y = zoomAndPanCanvas.Height;
2554
            }
2555
            else
2556
            {
2557
                translate.X = 0;
2558
                translate.Y = zoomAndPanCanvas.Height;
2559
            }
2560

    
2561
            zoomAndPanControl.RotationAngle = rotate.Angle;
2562

    
2563
            if (!testPanel2.IsHidden)
2564
            {
2565
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2566
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2567
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2568
            }
2569

    
2570
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2571
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2572
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2573
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2574
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2575
        }
2576

    
2577
        private void syncPannelRotate(double angle)
2578
        {
2579
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2580
            rotate.Angle = angle;
2581
            var rotationNum = Math.Abs((rotate.Angle / 90));
2582

    
2583
            if (angle == 90 || angle == 270)
2584
            {
2585
                double emptySize = zoomAndPanCanvas2.Width;
2586
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2587
                zoomAndPanCanvas2.Height = emptySize;
2588
            }
2589
            if (angle == 0)
2590
            {
2591
                translate2.X = 0;
2592
                translate2.Y = 0;
2593
            }
2594
            else if (angle == 90)
2595
            {
2596
                translate2.X = zoomAndPanCanvas2.Width;
2597
                translate2.Y = 0;
2598
            }
2599
            else if (angle == 180)
2600
            {
2601
                translate2.X = zoomAndPanCanvas2.Width;
2602
                translate2.Y = zoomAndPanCanvas2.Height;
2603
            }
2604
            else
2605
            {
2606
                translate2.X = 0;
2607
                translate2.Y = zoomAndPanCanvas2.Height;
2608
            }
2609

    
2610
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2611
        }
2612

    
2613
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2614
        {
2615
            string Data_ = "";
2616

    
2617
            try
2618
            {
2619
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2620
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2621
                if (Data_ != null || Data_ != "")
2622
                {
2623
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2624
                }
2625
                else
2626
                {
2627
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2628
                }
2629

    
2630
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2631
                //{
2632
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2633
                //    STATE = 0,
2634
                //};
2635
                if (Data_ != null)
2636
                {
2637
                    Image img = new Image();
2638
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2639
                    if (Data_.Contains(".svg"))
2640
                    {
2641
                        SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(Data_);
2642
                        img.Source = (DrawingImage)svgImage.ProvideValue(null);
2643
                    }
2644
                    else
2645
                    {
2646
                        img.Source = new BitmapImage(new Uri(Data_));
2647
                    }
2648

    
2649
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2650
                    {
2651
                        PointSet = new List<Point>(),
2652
                        FilePath = Data_,
2653
                        ImageData = img.Source,
2654
                        StartPoint = canvasZoomPanningMouseDownPoint,
2655
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2656
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2657
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2658
                        canvasZoomPanningMouseDownPoint.Y),
2659
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2660
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2661
                    };
2662

    
2663
                    currentControl.PointSet = new List<Point>
2664
                                        {
2665
                                            currentControl.StartPoint,
2666
                                            currentControl.LeftBottomPoint,
2667
                                            currentControl.EndPoint,
2668
                                            currentControl.TopRightPoint,
2669
                                        };
2670
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2671
                    UndoData = new Undo_data()
2672
                    {
2673
                        IsUndo = false,
2674
                        Event = Event_Type.Create,
2675
                        EventTime = DateTime.Now,
2676
                        Markup_List = new List<Multi_Undo_data>()
2677
                    };
2678
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2679
                    {
2680
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2681
                    });
2682

    
2683
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2684
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2685
                    UndoData.Markup_List.Add(multi_Undo_Data);
2686
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2687

    
2688
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2689
                    currentControl.CommentID = Commons.shortGuid();
2690
                    currentControl.SymbolID = id;
2691
                    currentControl.GroupID = group_id;
2692
                    currentControl.ApplyTemplate();
2693
                    currentControl.SetImage();
2694

    
2695
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2696
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2697
                    SelectLayer.Children.Add(final);
2698
                }
2699
            }
2700
            catch (Exception ex)
2701
            {
2702
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2703
            }
2704
        }
2705

    
2706
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2707
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2708
        {
2709
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2710
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2711
            {
2712
                set_option.Value = double.Parse(set_option.ContentText);
2713
                //set_option.Focusable = false;
2714
                zoomAndPanControl.Focus();
2715
            }
2716

    
2717
            ConvertInkControlToPolygon();
2718

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

    
2723
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2724
            {
2725
                DeleteCommand.Instance.Execute(new[] { text_item });
2726
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2727
            }
2728

    
2729
            /// up to here
2730

    
2731
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2732
            {
2733
                if (item as ArrowTextControl != null)
2734
                {
2735
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2736
                }
2737
                else if (item as TextControl != null)
2738
                {
2739
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2740
                }
2741
            }
2742

    
2743
            //if (currentControl != null)
2744
            {
2745
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2746
                if (text_item_ != null)
2747
                {
2748
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2749
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2750
                    (text_item_ as TextControl).IsEditingMode = false;
2751
                    currentControl = null;
2752
                }
2753

    
2754
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2755
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2756
                {
2757
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2758
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2759
                    currentControl = null;
2760
                }
2761
            }
2762

    
2763
            double Ang = 0;
2764
            if (rotate.Angle != 0)
2765
            {
2766
                Ang = 360 - rotate.Angle;
2767
            }
2768

    
2769
            if (e.OriginalSource is System.Windows.Controls.Image)
2770
            {
2771
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2772
            }
2773
            /*
2774
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2775
            {
2776
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2777
                if(symbol_id != null)
2778
                {
2779
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2780
                }
2781
            }
2782

    
2783
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2784
            {
2785
                if (this._dragdropWindow != null)
2786
                {
2787
                    this._dragdropWindow.Close();
2788
                    this._dragdropWindow = null;
2789
                    symbol_id = null;
2790
                }
2791
            }
2792
            */
2793

    
2794
            if (e.LeftButton == MouseButtonState.Pressed)
2795
            {
2796
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2797
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2798

    
2799
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2800
                SetCursor();
2801

    
2802
                if (!ViewerDataModel.Instance.IsPressCtrl)
2803
                {
2804
                    SelectionSet.Instance.UnSelect(this);
2805
                }
2806
            }
2807

    
2808
            if (e.MiddleButton == MouseButtonState.Pressed)
2809
            {
2810
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2811
                cursor = Cursors.SizeAll;
2812
                SetCursor();
2813
            }
2814
            if (e.RightButton == MouseButtonState.Pressed)
2815
            {
2816
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2817
                cursor = Cursors.SizeAll;
2818
                SetCursor();
2819
            }
2820
            else if (e.XButton1 == MouseButtonState.Pressed)
2821
            {
2822
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2823
                {
2824
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2825
                }
2826

    
2827
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2828
            }
2829
            else if (e.XButton2 == MouseButtonState.Pressed)
2830
            {
2831
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2832
                {
2833
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2834
                }
2835
            }
2836

    
2837
            bool isArrowTextEdit = false;
2838

    
2839
            if (currentControl is ArrowTextControl textControl)
2840
            {
2841
                if (textControl.IsEditingMode)
2842
                    isArrowTextEdit = true;
2843
            }
2844

    
2845
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2846
            {
2847
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2848
                {
2849
                    if (SelectLayer.Children.Count == 0)
2850
                    {
2851
                        isLeftMouseButtonDownOnWindow = true;
2852
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2853
                    }
2854

    
2855
                    if (controlType == ControlType.None)
2856
                    {
2857
                        isLeftMouseButtonDownOnWindow = true;
2858
                    }
2859
                }
2860

    
2861
                /// 캡쳐 모드 설정
2862
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2863
                {
2864
                    dragCaptureBorder.Visibility = Visibility.Visible;
2865
                    isLeftMouseButtonDownOnWindow = true;
2866
                }
2867

    
2868
                /// 줌 모드 설정
2869
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2870
                {
2871
                    isLeftMouseButtonDownOnWindow = true;
2872
                }
2873

    
2874
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2875

    
2876
                if (control == null)
2877
                {
2878
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2879
                }
2880
                else
2881
                {
2882
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2883
                    {
2884
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2885
                    }
2886

    
2887
                    AdornerFinal final = null;
2888

    
2889
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2890
                    {
2891
                        /// 기존 selection 해제
2892
                        SelectionSet.Instance.UnSelect(this);
2893

    
2894
                        final = new AdornerFinal(control);
2895

    
2896
                        this.Control_Style(control);
2897

    
2898
                        if ((control as IPath) != null)
2899
                        {
2900
                            if ((control as IPath).LineSize != 0)
2901
                            {
2902
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2903
                            }
2904
                        }
2905
                        if ((control as IShapeControl) != null)
2906
                        {
2907
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2908
                            {
2909
                                ViewerDataModel.Instance.checkHatchShape = true;
2910
                            }
2911
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2912
                            {
2913
                                ViewerDataModel.Instance.checkFillShape = true;
2914
                            }
2915
                            else
2916
                            {
2917
                                ViewerDataModel.Instance.checkHatchShape = false;
2918
                                ViewerDataModel.Instance.checkFillShape = false;
2919
                            }
2920
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2921
                        }
2922

    
2923
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2924

    
2925
                        if ((control as TextControl) != null)
2926
                        {
2927
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2928

    
2929
                            if (!((control as TextControl).EnableEditing))
2930
                            {
2931
                                (control as TextControl).EnableEditing = true;
2932
                            }
2933
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2934
                            {
2935
                                ViewerDataModel.Instance.checkTextStyle = true;
2936
                            }
2937
                            else
2938
                            {
2939
                                ViewerDataModel.Instance.checkTextStyle = false;
2940
                            }
2941
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2942
                            {
2943
                                ViewerDataModel.Instance.checkTextWeight = true;
2944
                            }
2945
                            else
2946
                            {
2947
                                ViewerDataModel.Instance.checkTextWeight = false;
2948
                            }
2949
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2950
                            {
2951
                                ViewerDataModel.Instance.checkUnderLine = true;
2952
                            }
2953
                            else
2954
                            {
2955
                                ViewerDataModel.Instance.checkUnderLine = false;
2956
                            }
2957
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2958
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2959
                        }
2960
                        else if ((control as ArrowTextControl) != null)
2961
                        {
2962
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2963

    
2964
                            if (!((control as ArrowTextControl).EnableEditing))
2965
                            {
2966
                                (control as ArrowTextControl).EnableEditing = true;
2967
                            }
2968
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2969
                            {
2970
                                ViewerDataModel.Instance.checkTextStyle = true;
2971
                            }
2972
                            else
2973
                            {
2974
                                ViewerDataModel.Instance.checkTextStyle = false;
2975
                            }
2976
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2977
                            {
2978
                                ViewerDataModel.Instance.checkTextWeight = true;
2979
                            }
2980
                            else
2981
                            {
2982
                                ViewerDataModel.Instance.checkTextWeight = false;
2983
                            }
2984
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2985
                            {
2986
                                ViewerDataModel.Instance.checkUnderLine = true;
2987
                            }
2988
                            else
2989
                            {
2990
                                ViewerDataModel.Instance.checkUnderLine = false;
2991
                            }
2992
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2993
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2994
                        }
2995
                        else if ((control as RectCloudControl) != null)
2996
                        {
2997
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2998
                        }
2999
                        else if ((control as CloudControl) != null)
3000
                        {
3001
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
3002
                        }
3003
                    }
3004
                    else
3005
                    {
3006
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
3007
                        SelectionSet.Instance.UnSelect(this);
3008
                        comment.Add(control);
3009

    
3010
                        Control_Style(control);
3011

    
3012
                        final = new AdornerFinal(comment);
3013
                    }
3014

    
3015
                    if (final != null)
3016
                    {
3017
                        this.SelectLayer.Children.Add(final);
3018
                    }
3019
                }
3020
            }
3021
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3022
            {
3023

    
3024

    
3025
                init();
3026
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3027
                if (cursor != Cursors.SizeAll)
3028
                {
3029
                    cursor = Cursors.Cross;
3030
                    SetCursor();
3031
                }
3032
                bool init_user = false;
3033
                foreach (var user in gridViewMarkup.Items)
3034
                {
3035
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3036
                    {
3037
                        init_user = true;
3038
                    }
3039
                }
3040
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3041
                {
3042
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3043
                    RadWindow.Alert(new DialogParameters
3044
                    {
3045
                        Owner = Application.Current.MainWindow,
3046
                        Theme = new VisualStudio2013Theme(),
3047
                        Header = "Info",
3048
                        Content = "Existing comments already existed. Select from the user list first",
3049
                    });
3050
                    return;
3051
                }
3052
                else
3053
                {
3054
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3055
                    if (item != null)
3056
                    {
3057
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3058
                    }
3059
                }
3060
                
3061
                switch (controlType)
3062
                {
3063
                    case ControlType.Coordinate:
3064
                        {
3065
                            if (e.LeftButton == MouseButtonState.Pressed)
3066
                            {
3067
                                if (currentControl is CoordinateControl)
3068
                                {
3069
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3070
                                    {
3071
                                        return;
3072
                                    }
3073

    
3074
                                    CreateCommand.Instance.Execute(currentControl);
3075

    
3076
                                    currentControl = null;
3077
                                    this.cursor = Cursors.Arrow;
3078
                                }
3079
                                else
3080
                                {
3081
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3082
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3083
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3084
                                    {
3085
                                        currentControl = null;
3086
                                        this.cursor = Cursors.Arrow;
3087
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3088
                                        return;
3089
                                    }
3090
                                    else
3091
                                    {
3092
                                        currentControl = new CoordinateControl
3093
                                        {
3094
                                            Background = new SolidColorBrush(Colors.Black),
3095
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3096
                                            ControlType = ControlType.Coordinate
3097
                                        };
3098

    
3099
                                        currentControl.CommentID = Commons.shortGuid();
3100
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3101
                                        currentControl.IsNew = true;
3102

    
3103
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3104

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

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

    
3123
                                    CreateCommand.Instance.Execute(currentControl);
3124

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

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

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

    
3148
                    case ControlType.OverlapWhite:
3149
                        {
3150
                            if (e.LeftButton == MouseButtonState.Pressed)
3151
                            {
3152
                                if (currentControl is OverlapWhiteControl)
3153
                                {
3154
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3155
                                    {
3156
                                        return;
3157
                                    }
3158

    
3159
                                    CreateCommand.Instance.Execute(currentControl);
3160

    
3161
                                    currentControl = null;
3162
                                    this.cursor = Cursors.Arrow;
3163
                                }
3164
                                else
3165
                                {
3166
                                    currentControl = new OverlapWhiteControl
3167
                                    {
3168
                                        Background = new SolidColorBrush(Colors.Black),
3169
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3170
                                        ControlType = ControlType.OverlapWhite
3171
                                    };
3172

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

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

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

    
3195
                                    CreateCommand.Instance.Execute(currentControl);
3196

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

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

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

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

    
3232
                                    CreateCommand.Instance.Execute(currentControl);
3233
                                    currentControl = null;
3234
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3235
                                }
3236
                                else
3237
                                {
3238
                                    currentControl = new RectangleControl
3239
                                    {
3240
                                        Background = new SolidColorBrush(Colors.Black),
3241
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3242
                                        ControlType = ControlType.Rectangle
3243
                                    };
3244

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

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

    
3256
                    case ControlType.RectCloud:
3257
                        {
3258
                            if (e.LeftButton == MouseButtonState.Pressed)
3259
                            {
3260
                                if (currentControl is RectCloudControl)
3261
                                {
3262
                                    //20180906 LJY TEST IsRotationDrawingEnable
3263
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3264
                                    {
3265
                                        return;
3266
                                    }
3267

    
3268
                                    CreateCommand.Instance.Execute(currentControl);
3269

    
3270
                                    currentControl = null;
3271

    
3272
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3273
                                }
3274
                                else
3275
                                {
3276
                                    currentControl = new RectCloudControl
3277
                                    {
3278
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3279
                                        ControlType = ControlType.RectCloud,
3280
                                        Background = new SolidColorBrush(Colors.Black)
3281
                                    };
3282

    
3283
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3284
                                    currentControl.CommentID = Commons.shortGuid();
3285
                                    currentControl.IsNew = true;
3286
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3287
                                }
3288
                            }
3289
                        }
3290
                        break;
3291

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

    
3304
                                    CreateCommand.Instance.Execute(currentControl);
3305

    
3306
                                    currentControl = null;
3307
                                }
3308
                                else
3309
                                {
3310
                                    currentControl = new CircleControl
3311
                                    {
3312
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3313
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3314
                                        Background = new SolidColorBrush(Colors.Black)
3315
                                    };
3316

    
3317
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3318
                                    currentControl.CommentID = Commons.shortGuid();
3319
                                    currentControl.IsNew = true;
3320
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3321
                                }
3322
                            }
3323
                        }
3324
                        break;
3325

    
3326
                    case ControlType.Triangle:
3327
                        {
3328
                            if (e.LeftButton == MouseButtonState.Pressed)
3329
                            {
3330
                                if (currentControl is TriControl)
3331
                                {
3332
                                    var content = currentControl as TriControl;
3333
                                    if (content.MidPoint == new Point(0, 0))
3334
                                    {
3335
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3336
                                    }
3337
                                    else
3338
                                    {
3339
                                        //20180906 LJY TEST IsRotationDrawingEnable
3340
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3341
                                        {
3342
                                            return;
3343
                                        }
3344

    
3345
                                        CreateCommand.Instance.Execute(currentControl);
3346

    
3347
                                        currentControl = null;
3348
                                    }
3349
                                }
3350
                                else
3351
                                {
3352
                                    currentControl = new TriControl
3353
                                    {
3354
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3355
                                        Background = new SolidColorBrush(Colors.Black),
3356
                                    };
3357

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

    
3367
                    case ControlType.CancelLine:
3368
                    case ControlType.SingleLine:
3369
                    case ControlType.ArrowLine:
3370
                    case ControlType.TwinLine:
3371
                    case ControlType.DimLine:
3372
                        {
3373
                            if (e.LeftButton == MouseButtonState.Pressed)
3374
                            {
3375
                                if (currentControl is LineControl)
3376
                                {
3377
                                    //20180906 LJY TEST IsRotationDrawingEnable
3378
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3379
                                    {
3380
                                        return;
3381
                                    }
3382

    
3383
                                    CreateCommand.Instance.Execute(currentControl);
3384
                                    currentControl = null;
3385
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3386
                                }
3387
                                else
3388
                                {
3389
                                    currentControl = new LineControl
3390
                                    {
3391
                                        ControlType = this.controlType,
3392
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3393
                                        Background = new SolidColorBrush(Colors.Black)
3394
                                    };
3395

    
3396
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3397
                                    currentControl.CommentID = Commons.shortGuid();
3398
                                    currentControl.IsNew = true;
3399
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3400
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3401
                                }
3402
                            }
3403
                        }
3404
                        break;
3405

    
3406
                    case ControlType.PolygonControl:
3407
                        {
3408
                            if (currentControl is PolygonControl)
3409
                            {
3410
                                var control = currentControl as PolygonControl;
3411

    
3412
                                if (e.RightButton == MouseButtonState.Pressed)
3413
                                {
3414
                                    control.IsCompleted = true;
3415
                                }
3416

    
3417
                                if (!control.IsCompleted)
3418
                                {
3419
                                    control.PointSet.Add(control.EndPoint);
3420
                                }
3421
                                else
3422
                                {
3423
                                    //20180906 LJY TEST IsRotationDrawingEnable
3424
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3425
                                    {
3426
                                        return;
3427
                                    }
3428

    
3429
                                    var firstPoint = control.PointSet.First();
3430
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3431
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3432
                                    control.PointSet.Add(firstPoint);
3433

    
3434
                                    control.ApplyOverViewData();
3435

    
3436
                                    CreateCommand.Instance.Execute(currentControl);
3437
                                    control.UpdateControl();
3438
                                    currentControl = null;
3439
                                }
3440
                            }
3441
                            else
3442
                            {
3443
                                if (e.LeftButton == MouseButtonState.Pressed)
3444
                                {
3445
                                    currentControl = new PolygonControl
3446
                                    {
3447
                                        PointSet = new List<Point>(),
3448
                                    };
3449

    
3450
                                    var polygonControl = (currentControl as PolygonControl);
3451
                                    currentControl.CommentID = Commons.shortGuid();
3452
                                    currentControl.IsNew = true;
3453
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3454
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3455
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3456
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3457
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3458
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3459
                                    polygonControl.ApplyTemplate();
3460
                                    polygonControl.Visibility = Visibility.Visible;
3461
                                }
3462
                            }
3463
                        }
3464
                        break;
3465

    
3466
                    case ControlType.ChainLine:
3467
                        {
3468
                            if (currentControl is PolygonControl)
3469
                            {
3470
                                var control = currentControl as PolygonControl;
3471

    
3472
                                if (e.RightButton == MouseButtonState.Pressed)
3473
                                {
3474
                                    //20180906 LJY TEST IsRotationDrawingEnable
3475
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3476
                                    {
3477
                                        return;
3478
                                    }
3479

    
3480
                                    CreateCommand.Instance.Execute(currentControl);
3481

    
3482
                                    currentControl = null;
3483
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3484
                                    return;
3485
                                }
3486

    
3487
                                if (!control.IsCompleted)
3488
                                {
3489
                                    control.PointSet.Add(control.EndPoint);
3490
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3491
                                }
3492
                            }
3493
                            else
3494
                            {
3495
                                if (e.LeftButton == MouseButtonState.Pressed)
3496
                                {
3497
                                    MainAngle.Visibility = Visibility.Visible;
3498
                                    currentControl = new PolygonControl
3499
                                    {
3500
                                        PointSet = new List<Point>(),
3501
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3502
                                        ControlType = ControlType.ChainLine,
3503
                                        DashSize = ViewerDataModel.Instance.DashSize,
3504
                                        LineSize = ViewerDataModel.Instance.LineSize,
3505
                                        //PointC = new StylusPointSet()
3506
                                    };
3507

    
3508
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3509
                                    //{
3510
                                    var polygonControl = (currentControl as PolygonControl);
3511
                                    currentControl.CommentID = Commons.shortGuid();
3512
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3513
                                    currentControl.IsNew = true;
3514
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3515
                                    //currentControl.OnApplyTemplate();
3516
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3517
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3518
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3519
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3520
                                    //}
3521
                                }
3522
                            }
3523
                        }
3524
                        break;
3525

    
3526
                    case ControlType.ArcLine:
3527
                        {
3528
                            if (e.LeftButton == MouseButtonState.Pressed)
3529
                            {
3530
                                if (currentControl is ArcControl)
3531
                                {
3532
                                    //20180906 LJY TEST IsRotationDrawingEnable
3533
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3534
                                    {
3535
                                        return;
3536
                                    }
3537

    
3538
                                    CreateCommand.Instance.Execute(currentControl);
3539

    
3540
                                    currentControl = null;
3541
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3542
                                }
3543
                                else
3544
                                {
3545
                                    currentControl = new ArcControl
3546
                                    {
3547
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3548
                                        Background = new SolidColorBrush(Colors.Black)
3549
                                    };
3550
                                    currentControl.CommentID = Commons.shortGuid();
3551
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3552
                                    currentControl.IsNew = true;
3553
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3554
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3555
                                }
3556
                            }
3557
                            else if (e.RightButton == MouseButtonState.Pressed)
3558
                            {
3559
                                if (currentControl != null)
3560
                                {
3561
                                    (currentControl as ArcControl).setClock();
3562
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3563
                                }
3564
                            }
3565
                        }
3566
                        break;
3567

    
3568
                    case ControlType.ArcArrow:
3569
                        {
3570
                            if (e.LeftButton == MouseButtonState.Pressed)
3571
                            {
3572
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3573
                                //{
3574
                                if (currentControl is ArrowArcControl)
3575
                                {
3576
                                    //20180906 LJY TEST IsRotationDrawingEnable
3577
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3578
                                    {
3579
                                        return;
3580
                                    }
3581

    
3582
                                    CreateCommand.Instance.Execute(currentControl);
3583

    
3584
                                    currentControl = null;
3585
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3586
                                }
3587
                                else
3588
                                {
3589
                                    currentControl = new ArrowArcControl
3590
                                    {
3591
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3592
                                        Background = new SolidColorBrush(Colors.Black)
3593
                                    };
3594
                                    currentControl.CommentID = Commons.shortGuid();
3595
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3596
                                    currentControl.IsNew = true;
3597
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3598
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3599
                                }
3600
                                //}
3601
                            }
3602
                            else if (e.RightButton == MouseButtonState.Pressed)
3603
                            {
3604
                                if (currentControl != null)
3605
                                {
3606
                                    (currentControl as ArrowArcControl).setClock();
3607
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3608
                                    //(currentControl as ArcControl).ApplyTemplate();
3609
                                }
3610
                            }
3611
                        }
3612
                        break;
3613

    
3614
                    case ControlType.ArrowMultiLine:
3615
                        {
3616
                            if (e.LeftButton == MouseButtonState.Pressed)
3617
                            {
3618
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3619
                                //{
3620
                                if (currentControl is ArrowControl_Multi)
3621
                                {
3622
                                    var content = currentControl as ArrowControl_Multi;
3623
                                    if (content.MiddlePoint == new Point(0, 0))
3624
                                    {
3625
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3626
                                        {
3627
                                            content.MiddlePoint = content.EndPoint;
3628
                                        }
3629
                                        else
3630
                                        {
3631
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3632
                                        }
3633
                                    }
3634
                                    else
3635
                                    {
3636
                                        //20180906 LJY TEST IsRotationDrawingEnable
3637
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3638
                                        {
3639
                                            return;
3640
                                        }
3641

    
3642
                                        CreateCommand.Instance.Execute(currentControl);
3643

    
3644
                                        currentControl = null;
3645
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3646
                                    }
3647
                                }
3648
                                else
3649
                                {
3650
                                    currentControl = new ArrowControl_Multi
3651
                                    {
3652
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3653
                                        Background = new SolidColorBrush(Colors.Black)
3654
                                    };
3655
                                    currentControl.CommentID = Commons.shortGuid();
3656
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3657
                                    currentControl.IsNew = true;
3658
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3659
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3660
                                }
3661
                                //}
3662
                            }
3663
                        }
3664
                        break;
3665

    
3666
                    case ControlType.PolygonCloud:
3667
                        {
3668
                            if (currentControl is CloudControl)
3669
                            {
3670
                                var control = currentControl as CloudControl;
3671
                                if (e.RightButton == MouseButtonState.Pressed)
3672
                                {
3673
                                    control.IsCompleted = true;
3674
                                }
3675

    
3676
                                if (!control.IsCompleted)
3677
                                {
3678
                                    control.PointSet.Add(control.EndPoint);
3679
                                }
3680
                                else
3681
                                {
3682
                                    //20180906 LJY TEST IsRotationDrawingEnable
3683
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3684
                                    {
3685
                                        return;
3686
                                    }
3687

    
3688
                                    CreateCommand.Instance.Execute(currentControl);
3689

    
3690
                                    control.isTransOn = true;
3691
                                    var firstPoint = control.PointSet.First();
3692

    
3693
                                    control.PointSet.Add(firstPoint);
3694
                                    control.DrawingCloud();
3695
                                    control.ApplyOverViewData();
3696

    
3697
                                    currentControl = null;
3698
                                }
3699
                            }
3700
                            else
3701
                            {
3702
                                if (e.LeftButton == MouseButtonState.Pressed)
3703
                                {
3704
                                    currentControl = new CloudControl
3705
                                    {
3706
                                        PointSet = new List<Point>(),
3707
                                        PointC = new StylusPointSet()
3708
                                    };
3709

    
3710
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3711
                                    //{
3712
                                    var polygonControl = (currentControl as CloudControl);
3713
                                    currentControl.CommentID = Commons.shortGuid();
3714
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3715
                                    currentControl.IsNew = true;
3716
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3717

    
3718
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3719
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3720

    
3721
                                    //}
3722
                                }
3723
                            }
3724
                        }
3725
                        break;
3726

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

    
3741
                                    CreateCommand.Instance.Execute(currentControl);
3742
                                    controlType = ControlType.ImgControl;
3743
                                    currentControl = null;
3744
                                }
3745
                                else
3746
                                {
3747
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3748
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3749
                                    {
3750
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3751
                                        UriBuilder uri = new UriBuilder(filename);
3752
                                        uri.Host = downloadUri.Host;
3753
                                        uri.Port = downloadUri.Port;
3754

    
3755
                                        Image img = new Image();
3756
                                        if (filename.Contains(".svg"))
3757
                                        {
3758
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3759
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3760
                                        }
3761
                                        else
3762
                                        {
3763
                                            img.Source = new BitmapImage(uri.Uri);
3764
                                        }
3765

    
3766
                                        currentControl = new ImgControl
3767
                                        {
3768
                                            Background = new SolidColorBrush(Colors.Black),
3769
                                            PointSet = new List<Point>(),
3770
                                            FilePath = uri.Uri.ToString(),
3771
                                            ImageData = img.Source,
3772
                                            StartPoint = CanvasDrawingMouseDownPoint,
3773
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3774
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3775
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3776
                                            ControlType = ControlType.ImgControl
3777
                                        };
3778

    
3779
                                        currentControl.CommentID = Commons.shortGuid();
3780
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3781
                                        currentControl.IsNew = true;
3782
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3783

    
3784
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3785
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3786
                                    }
3787
                                }
3788
                                //}
3789
                            }
3790
                        }
3791
                        break;
3792

    
3793
                    case ControlType.Date:
3794
                        {
3795
                            if (e.LeftButton == MouseButtonState.Pressed)
3796
                            {
3797
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3798
                                //{
3799
                                if (currentControl is DateControl)
3800
                                {
3801
                                    //20180906 LJY TEST IsRotationDrawingEnable
3802
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3803
                                    {
3804
                                        return;
3805
                                    }
3806

    
3807
                                    CreateCommand.Instance.Execute(currentControl);
3808
                                    currentControl = null;
3809

    
3810
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3811
                                    { 
3812
                                        controlType = ControlType.None;
3813
                                        IsSwingMode = false;
3814
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3815
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3816
                                        mouseHandlingMode = MouseHandlingMode.None;
3817
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3818
                                        txtBatch.Visibility = Visibility.Collapsed;
3819
                                    }
3820
                                }
3821
                                else
3822
                                {
3823
                                    currentControl = new DateControl
3824
                                    {
3825
                                        StartPoint = CanvasDrawingMouseDownPoint,
3826
                                        Background = new SolidColorBrush(Colors.Black)
3827
                                    };
3828
                                    currentControl.CommentID = Commons.shortGuid();
3829
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3830
                                    currentControl.IsNew = true;
3831
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3832

    
3833
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3834
                                    if (currentControl is ImgControl)
3835
                                    {
3836
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3837
                                    }
3838
                                }
3839
                                //}
3840
                            }
3841
                        }
3842
                        break;
3843

    
3844
                    case ControlType.TextControl:
3845
                        {
3846
                            if (e.LeftButton == MouseButtonState.Pressed)
3847
                            {
3848
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3849
                                {
3850
                                    currentControl = new TextControl
3851
                                    {
3852
                                        ControlType = controlType
3853
                                    };
3854
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3855
                                    currentControl.CommentID = Commons.shortGuid();
3856
                                    currentControl.IsNew = true;
3857
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3858
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3859
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3860

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

    
3864
                                    (currentControl as TextControl).ControlType_No = 0;
3865
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3866
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3867
                                    (currentControl as TextControl).ApplyTemplate();
3868
                                    (currentControl as TextControl).Base_TextBox.Focus();
3869
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3870
                                    CreateCommand.Instance.Execute(currentControl);
3871
                                }
3872
                            }
3873
                        }
3874
                        break;
3875

    
3876
                    case ControlType.TextBorder:
3877
                        {
3878
                            if (e.LeftButton == MouseButtonState.Pressed)
3879
                            {
3880
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3881
                                {
3882
                                    currentControl = new TextControl
3883
                                    {
3884
                                        ControlType = controlType
3885
                                    };
3886

    
3887
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3888
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3889
                                    currentControl.CommentID = Commons.shortGuid();
3890
                                    currentControl.IsNew = true;
3891
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3892
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3893
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3894
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3895

    
3896
                                    (currentControl as TextControl).ControlType_No = 1;
3897
                                    (currentControl as TextControl).CommentAngle = Ang;
3898
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3899
                                    (currentControl as TextControl).ApplyTemplate();
3900
                                    (currentControl as TextControl).Base_TextBox.Focus();
3901
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3902
                                    CreateCommand.Instance.Execute(currentControl);
3903
                                }
3904
                            }
3905
                        }
3906
                        break;
3907

    
3908
                    case ControlType.TextCloud:
3909
                        {
3910
                            if (e.LeftButton == MouseButtonState.Pressed)
3911
                            {
3912
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3913
                                {
3914
                                    currentControl = new TextControl
3915
                                    {
3916
                                        ControlType = controlType
3917
                                    };
3918

    
3919
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3920
                                    currentControl.CommentID = Commons.shortGuid();
3921
                                    currentControl.IsNew = true;
3922
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3923
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3924

    
3925
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3926
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3927
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3928

    
3929
                                    (currentControl as TextControl).CommentAngle = Ang;
3930
                                    (currentControl as TextControl).ControlType_No = 2;
3931
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3932
                                    (currentControl as TextControl).ApplyTemplate();
3933

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

    
3936
                                    (currentControl as TextControl).Base_TextBox.Focus();
3937
                                    CreateCommand.Instance.Execute(currentControl);
3938
                                    
3939
                                    //currentControl = null;
3940
                                }
3941
                            }
3942
                        }
3943
                        break;
3944

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

    
3957
                                    CreateCommand.Instance.Execute(currentControl);
3958

    
3959
                                    try
3960
                                    {
3961
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3962
                                        {
3963
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3964
                                        }
3965
                                    }
3966
                                    catch (Exception ex)
3967
                                    {
3968
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3969
                                    }
3970

    
3971
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3972
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3973
                                    (currentControl as ArrowTextControl).IsNew = false;
3974
                                    currentControl = null;
3975
                                }
3976
                                else
3977
                                {
3978
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3979
                                    //{
3980
                                    currentControl = new ArrowTextControl()
3981
                                    {
3982
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3983
                                    };
3984

    
3985
                                    currentControl.CommentID = Commons.shortGuid();
3986
                                    currentControl.IsNew = true;
3987
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3988

    
3989
                                    try
3990
                                    {
3991
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3992
                                    }
3993
                                    catch (Exception ex)
3994
                                    {
3995
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3996
                                    }
3997

    
3998
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3999
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4000
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4001
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4002
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4003

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

    
4007
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4008
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4009
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4010
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4011

    
4012
                                    //}
4013
                                }
4014
                            }
4015
                        }
4016
                        break;
4017

    
4018
                    case ControlType.ArrowTransTextControl:
4019
                        {
4020
                            if (e.LeftButton == MouseButtonState.Pressed)
4021
                            {
4022
                                if (currentControl is ArrowTextControl)
4023
                                {
4024
                                    //20180906 LJY TEST IsRotationDrawingEnable
4025
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4026
                                    {
4027
                                        return;
4028
                                    }
4029

    
4030
                                    CreateCommand.Instance.Execute(currentControl);
4031

    
4032
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4033

    
4034
                                    currentControl.IsNew = false;
4035
                                    currentControl = null;
4036
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4037
                                }
4038
                                else
4039
                                {
4040
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4041
                                    //{
4042
                                    currentControl = new ArrowTextControl()
4043
                                    {
4044
                                        ControlType = ControlType.ArrowTransTextControl,
4045
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4046
                                    };
4047
                                    currentControl.CommentID = Commons.shortGuid();
4048
                                    currentControl.IsNew = true;
4049
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4050
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4051
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4052
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4053
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4054
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4055
                                    (currentControl as ArrowTextControl).isFixed = true;
4056
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4057

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

    
4061
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4062
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4063
                                    (currentControl as ArrowTextControl).isTrans = true;
4064
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4065
                                }
4066
                            }
4067
                        }
4068
                        break;
4069

    
4070
                    case ControlType.ArrowTextBorderControl:
4071
                        {
4072
                            if (e.LeftButton == MouseButtonState.Pressed)
4073
                            {
4074
                                if (currentControl is ArrowTextControl)
4075
                                {
4076
                                    //20180906 LJY TEST IsRotationDrawingEnable
4077
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4078
                                    {
4079
                                        return;
4080
                                    }
4081

    
4082
                                    CreateCommand.Instance.Execute(currentControl);
4083
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4084
                                    currentControl.IsNew = false;
4085
                                    currentControl = null;
4086
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4087
                                }
4088
                                else
4089
                                {
4090
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4091
                                    //{
4092
                                    currentControl = new ArrowTextControl()
4093
                                    {
4094
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4095
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4096
                                    };
4097
                                    currentControl.CommentID = Commons.shortGuid();
4098
                                    currentControl.IsNew = true;
4099
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4100
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4101

    
4102
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4103

    
4104
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4105

    
4106
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4107
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4108
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4109
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4110
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4111
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4112
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4113
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4114
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4115
                                    //}
4116
                                }
4117
                            }
4118
                        }
4119
                        break;
4120

    
4121
                    case ControlType.ArrowTransTextBorderControl:
4122
                        {
4123
                            if (e.LeftButton == MouseButtonState.Pressed)
4124
                            {
4125
                                if (currentControl is ArrowTextControl)
4126
                                {
4127
                                    //20180906 LJY TEST IsRotationDrawingEnable
4128
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4129
                                    {
4130
                                        return;
4131
                                    }
4132
                                    CreateCommand.Instance.Execute(currentControl);
4133
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4134
                                    currentControl.IsNew = false;
4135
                                    currentControl = null;
4136

    
4137
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4138
                                }
4139
                                else
4140
                                {
4141
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4142
                                    //{
4143
                                    currentControl = new ArrowTextControl()
4144
                                    {
4145
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4146
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4147
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4148
                                    };
4149
                                    
4150
                                    currentControl.CommentID = Commons.shortGuid();
4151
                                    currentControl.IsNew = true;
4152
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4153
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4154

    
4155
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4156

    
4157
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4158
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4159
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4160
                                    (currentControl as ArrowTextControl).isFixed = true;
4161
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4162

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

    
4170
                                    //20180911 LJY
4171
                                    (currentControl as ArrowTextControl).isTrans = true;
4172

    
4173
                                    //}
4174
                                }
4175
                            }
4176
                        }
4177
                        break;
4178

    
4179
                    case ControlType.ArrowTextCloudControl:
4180
                        {
4181
                            if (e.LeftButton == MouseButtonState.Pressed)
4182
                            {
4183
                                if (currentControl is ArrowTextControl)
4184
                                {
4185
                                    //20180906 LJY TEST IsRotationDrawingEnable
4186
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4187
                                    {
4188
                                        return;
4189
                                    }
4190
                                    CreateCommand.Instance.Execute(currentControl);
4191
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4192
                                    currentControl.IsNew = false;
4193
                                    currentControl = null;
4194
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4195
                                }
4196
                                else
4197
                                {
4198
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4199
                                    //{
4200
                                    currentControl = new ArrowTextControl()
4201
                                    {
4202
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4203
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4204
                                        ControlType = ControlType.ArrowTextCloudControl
4205
                                    };
4206
                                    currentControl.CommentID = Commons.shortGuid();
4207
                                    currentControl.IsNew = true;
4208
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4209
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4210

    
4211
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4212
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4213
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4214
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4215
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4216
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4217
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4218
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4219

    
4220
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4221
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4222
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4223
                                    //}
4224
                                }
4225
                            }
4226
                        }
4227
                        break;
4228

    
4229
                    case ControlType.ArrowTransTextCloudControl:
4230
                        {
4231
                            if (e.LeftButton == MouseButtonState.Pressed)
4232
                            {
4233
                                if (currentControl is ArrowTextControl)
4234
                                {
4235
                                    //20180906 LJY TEST IsRotationDrawingEnable
4236
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4237
                                    {
4238
                                        return;
4239
                                    }
4240
                                    CreateCommand.Instance.Execute(currentControl);
4241
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4242
                                    currentControl.IsNew = false;
4243
                                    currentControl = null;
4244
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4245
                                }
4246
                                else
4247
                                {
4248
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4249
                                    //{
4250
                                    currentControl = new ArrowTextControl()
4251
                                    {
4252
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4253
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4254
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4255
                                    };
4256
                                    currentControl.CommentID = Commons.shortGuid();
4257
                                    currentControl.IsNew = true;
4258
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4259
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4260
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4261

    
4262
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4263
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4264
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4265
                                    (currentControl as ArrowTextControl).isFixed = true;
4266
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4267

    
4268
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4269
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4270
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4271
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4272
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4273
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4274

    
4275
                                    //20180911 LJY
4276
                                    (currentControl as ArrowTextControl).isTrans = true;
4277
                                    //}
4278
                                }
4279
                            }
4280
                        }
4281
                        break;
4282
                    //강인구 추가
4283
                    case ControlType.Sign:
4284
                        {
4285
                            if (e.LeftButton == MouseButtonState.Pressed)
4286
                            {
4287
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4288
                                //{
4289
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4290

    
4291
                                if (_sign == null)
4292
                                {
4293
                                    txtBatch.Visibility = Visibility.Collapsed;
4294
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4295
                                    controlType = ControlType.None;
4296

    
4297
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4298
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4299
                                    return;
4300
                                }
4301
                                else
4302
                                {
4303
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4304
                                    {
4305
                                        Application.Current.Resources.Add("UserSign", _sign);
4306
                                    }
4307
                                    else
4308
                                    {
4309
                                        Application.Current.Resources["UserSign"] = _sign;
4310
                                    }
4311
                                }
4312

    
4313
                                if (currentControl is SignControl)
4314
                                {
4315
                                    //20180906 LJY TEST IsRotationDrawingEnable
4316
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4317
                                    {
4318
                                        return;
4319
                                    }
4320

    
4321
                                    CreateCommand.Instance.Execute(currentControl);
4322
                                    currentControl = null;
4323
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4324
                                    {
4325
                                        txtBatch.Text = "Place Date";
4326
                                        controlType = ControlType.Date;
4327
                                    }
4328
                                }
4329
                                else
4330
                                {
4331
                                    currentControl = new SignControl
4332
                                    {
4333
                                        Background = new SolidColorBrush(Colors.Black),
4334
                                        UserNumber = App.ViewInfo.UserID,
4335
                                        ProjectNO = App.ViewInfo.ProjectNO,
4336
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4337
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4338
                                        ControlType = ControlType.Sign
4339
                                    };
4340

    
4341
                                    currentControl.CommentID = Commons.shortGuid();
4342
                                    currentControl.IsNew = true;
4343
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4344
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4345

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

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

    
4368
                                    CreateCommand.Instance.Execute(currentControl);
4369
                                    (currentControl as RectangleControl).ApplyOverViewData();
4370
                                    currentControl = null;
4371

    
4372
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4373

    
4374
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4375
                                    {
4376
                                        txtBatch.Text = "Place Signature";
4377
                                        controlType = ControlType.Sign;
4378
                                    }
4379
                                }
4380
                                else
4381
                                {
4382
                                    currentControl = new RectangleControl
4383
                                    {
4384
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4385
                                        Background = new SolidColorBrush(Colors.Black),
4386
                                        ControlType = ControlType.Mark,
4387
                                        Paint = PaintSet.Fill
4388
                                    };
4389

    
4390
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4391
                                    currentControl.CommentID = Commons.shortGuid();
4392
                                    currentControl.IsNew = true;
4393
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4394
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4395
                                }
4396
                                //}
4397
                            }
4398
                        }
4399
                        break;
4400

    
4401
                    case ControlType.Symbol:
4402
                        {
4403
                            if (e.LeftButton == MouseButtonState.Pressed)
4404
                            {
4405
                                if (currentControl is SymControl)
4406
                                {
4407
                                    //20180906 LJY TEST IsRotationDrawingEnable
4408
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4409
                                    {
4410
                                        return;
4411
                                    }
4412
                                    CreateCommand.Instance.Execute(currentControl);
4413
                                    currentControl = null;
4414

    
4415
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4416
                                }
4417
                                else
4418
                                {
4419
                                    currentControl = new SymControl
4420
                                    {
4421
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4422
                                        Background = new SolidColorBrush(Colors.Black),
4423
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4424
                                        ControlType = ControlType.Symbol
4425
                                    };
4426

    
4427
                                    currentControl.IsNew = true;
4428
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4429
                                    currentControl.CommentID = Commons.shortGuid();
4430
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4431

    
4432
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4433
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4434
                                }
4435
                                //}
4436
                            }
4437
                        }
4438
                        break;
4439

    
4440
                    case ControlType.Stamp:
4441
                        {
4442
                            if (e.LeftButton == MouseButtonState.Pressed)
4443
                            {
4444
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4445
                                //{
4446
                                if (currentControl is SymControlN)
4447
                                {
4448
                                    //20180906 LJY TEST IsRotationDrawingEnable
4449
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4450
                                    {
4451
                                        return;
4452
                                    }
4453

    
4454
                                    CreateCommand.Instance.Execute(currentControl);
4455
                                    currentControl = null;
4456

    
4457
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4458
                                }
4459
                                else
4460
                                {
4461
                                    currentControl = new SymControlN
4462
                                    {
4463
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4464
                                        Background = new SolidColorBrush(Colors.Black),
4465
                                        STAMP = App.SystemInfo.STAMP,
4466
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4467
                                        ControlType = ControlType.Stamp
4468
                                    };
4469

    
4470
                                    currentControl.IsNew = true;
4471
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4472
                                    currentControl.CommentID = Commons.shortGuid();
4473
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4474
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4475
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4476
                                }
4477
                                //}
4478
                            }
4479
                        }
4480
                        break;
4481

    
4482
                    case ControlType.PenControl:
4483
                        {
4484
                            if (inkBoard.Tag.ToString() == "Ink")
4485
                            {
4486
                                inkBoard.IsEnabled = true;
4487
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4488
                            }
4489
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4490
                            {
4491
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4492
                            }
4493
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4494
                            {
4495
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4496
                            }
4497
                            IsDrawing = true;
4498
                            return;
4499
                        }
4500
                    default:
4501
                        if (currentControl != null)
4502
                        {
4503
                            currentControl.CommentID = null;
4504
                            currentControl.IsNew = false;
4505
                        }
4506
                        break;
4507
                }
4508

    
4509
                try
4510
                {
4511
                    if (currentControl is ITextControl)
4512
                    {
4513
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4514

    
4515
                        if(textBox.Count() > 0)
4516
                        {
4517
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4518
                            specialcharRemove.Attach(textBox.First());
4519
                        }
4520
                        else
4521
                        {
4522

    
4523
                        }
4524

    
4525
                    }
4526
                }
4527
                catch (Exception ex)
4528
                {
4529
                    System.Diagnostics.Debug.WriteLine(ex);
4530

    
4531
                }
4532

    
4533
                if (currentControl is ArrowTextControl)
4534
                {
4535
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4536
                    {
4537
                        var control = snd as ArrowTextControl;
4538

    
4539
                        if (string.IsNullOrEmpty(control.ArrowText))
4540
                        {
4541
                            DeleteCommand.Instance.Execute(new [] { control });
4542
                        }
4543
                    };
4544

    
4545
                }
4546

    
4547
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4548
                {
4549
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4550
                    {
4551
                        MacroHelper.MacroAction();
4552
                    }
4553
                    //if (currentControl.ControlType)
4554
                    //txtBatch.Text = "Draw a TextBox";
4555
                    //controlType = ControlType.ArrowTextBorderControl;
4556
                }
4557

    
4558
                //if (currentControl != null)
4559
                //{
4560
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4561
                //}
4562
            }
4563
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4564
            {
4565
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4566
             
4567

    
4568
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4569
                {
4570
                    bool mouseOff = false;
4571
                    foreach (var item in SelectLayer.Children)
4572
                    {
4573
                        if (item is AdornerFinal)
4574
                        {
4575
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4576
                            if (over != null)
4577
                            {
4578
                                mouseOff = true;
4579
                            }
4580
                        }
4581
                    }
4582

    
4583
                    if (!mouseOff)
4584
                    {
4585
                        SelectionSet.Instance.UnSelect(this);
4586
                    }
4587
                }
4588
                zoomAndPanControl.CaptureMouse();
4589
                e.Handled = true;
4590
            }
4591
        }
4592

    
4593
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4594
        {
4595
            ///mouseButtonDown = e.ChangedButton;
4596
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4597
        }
4598

    
4599
        private void RemoveLineStroke(Point P)
4600
        {
4601
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4602
            if (control != null)
4603
            {
4604
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4605
            }
4606
        }
4607

    
4608
        private void RemovePointStroke(Point P)
4609
        {
4610
            foreach (Stroke hits in inkBoard.Strokes)
4611
            {
4612
                foreach (StylusPoint sty in hits.StylusPoints)
4613
                {
4614
                }
4615
                if (hits.HitTest(P))
4616
                {
4617
                    inkBoard.Strokes.Remove(hits);
4618
                    return;
4619
                }
4620
            }
4621
        }
4622

    
4623
        private void StartNewStroke(Point P)
4624
        {
4625
            strokePoints = new StylusPointCollection();
4626
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4627
            strokePoints.Add(segment1Start);
4628
            stroke = new Stroke(strokePoints);
4629

    
4630
            stroke.DrawingAttributes.Color = Colors.Red;
4631
            stroke.DrawingAttributes.Width = 4;
4632
            stroke.DrawingAttributes.Height = 4;
4633

    
4634
            inkBoard.Strokes.Add(stroke);
4635
        }
4636

    
4637
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4638
        {
4639
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4640
            //// update mylist and gridview
4641
            //this.UpdateMyMarkupList();
4642

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

    
4645
            //if (result)
4646
            //{
4647
            btnFinalPDF.IsEnabled = false;
4648
            btnConsolidate.IsEnabled = false;
4649
            await  ConsolidationMethod();
4650
            //}
4651
            //else
4652
            //{
4653
            //    MessageBox.Show("오류");
4654
            //}
4655
        }
4656

    
4657
        /// <summary>
4658
        /// execute TeamConsolidationCommand
4659
        /// </summary>
4660
        public void TeamConsolidationMethod2()
4661
        {
4662
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4663
            {
4664
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4665
            }
4666
            else
4667
            {
4668

    
4669
                ViewerDataModel.Instance.IsConsolidate = true;
4670
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4671
                // update mylist and gridview
4672
        
4673
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4674
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4675
                ViewerDataModel.Instance.IsConsolidate = false;
4676
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4677
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4678
                {
4679
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4680
                    {
4681
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4682
                        return;
4683
                    }
4684
                }
4685
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4686
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4687
                {
4688
                    MarkupInfoList.Add(item);
4689
                }
4690

    
4691
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4692
            }
4693
        }
4694
        public async void TeamConsolidationMethod()
4695
        {
4696
            bool result = false;
4697

    
4698
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4699
            {
4700
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4701
            }
4702
            else
4703
            {
4704
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4705
                {
4706
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4707
                    {
4708
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4709
                    }
4710
                }
4711

    
4712
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4713

    
4714
                if (isSave)
4715
                {
4716
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4717

    
4718
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4719
                     
4720
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4721
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4722
                    {
4723
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4724
                    }
4725

    
4726
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4727
                    result = true;
4728
                }
4729
            }
4730
        }
4731

    
4732
        public async Task<bool> ConsolidationMethod()
4733
        {
4734
            bool result = false;
4735

    
4736
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4737
            {
4738
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4739
            }
4740
            else
4741
            {
4742
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4743

    
4744
                if (isSave)
4745
                {
4746
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4747
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4748

    
4749
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4750
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4751
                    {
4752
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4753
                    }
4754
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4755

    
4756
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4757
                }
4758
            }
4759

    
4760
            return result;
4761
        }
4762

    
4763
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4764
        {
4765
            if (App.ViewInfo != null)
4766
            {
4767
                btnConsolidate = (sender as RadRibbonButton);
4768
                if (!App.ViewInfo.NewCommentPermission)
4769
                {
4770
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4771
                }
4772
            }
4773
        }
4774

    
4775
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4776
        {
4777
            TeamConsolidationMethod();
4778
        }
4779

    
4780
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4781
        {
4782
            btnTeamConsolidate = sender as RadRibbonButton;
4783
            if (App.ViewInfo != null)
4784
            {
4785
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4786
                {
4787
                    if (btnConsolidate != null)
4788
                    {
4789
                        btnConsolidate.Visibility = Visibility.Collapsed;
4790
                    }
4791

    
4792
                    if (!App.ViewInfo.NewCommentPermission)
4793
                    {
4794
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4795
                    }
4796
                }
4797
                else
4798
                {
4799
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4800
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4801
                }
4802
            }
4803
        }
4804

    
4805
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4806
        {
4807
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4808
            // update mylist and gridview
4809
            this.UpdateMyMarkupList();
4810

    
4811
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4812

    
4813
            if(!result)
4814
            {
4815

    
4816
            }
4817
            else
4818
            {
4819
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4820

    
4821
                if (item != null)
4822
                {
4823
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4824
                    {
4825
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4826

    
4827
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4828

    
4829
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4830
                    }
4831
                    else
4832
                    {
4833
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4834
                    }
4835
                }
4836
                else
4837
                {
4838
                    //Consolidate 가 없는 경우
4839
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4840
                }
4841
            }
4842

    
4843
        }
4844

    
4845
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4846
        {
4847
            btnFinalPDF = sender as RadRibbonButton;
4848
            if (App.ViewInfo != null)
4849
            {
4850
                //btnFinalPDF.IsEnabled = false;
4851

    
4852
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4853
                {
4854
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4855
                    if (btnConsolidate != null)
4856
                    {
4857
                        btnConsolidate.Visibility = Visibility.Collapsed;
4858
                    }
4859
                }
4860
            }
4861
        }
4862

    
4863
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4864
        {
4865
            //UpdateMyMarkupList();
4866

    
4867
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4868
            {
4869
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4870
            }
4871
            else
4872
            {
4873
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4874
                //{
4875
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4876
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4877
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4878

    
4879
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4880
                //// update mylist and gridview
4881
                //this.UpdateMyMarkupList();
4882

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

    
4885
                Mouse.SetCursor(Cursors.Wait);
4886

    
4887
                bool result = await ConsolidationMethod();
4888

    
4889
                //System.Threading.Thread.Sleep(500);
4890

    
4891
                if (result)
4892
                {
4893
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4894

    
4895
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4896
                    if (item2 != null)
4897
                    {
4898
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4899
                        {
4900
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4901

    
4902
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4903
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4904

    
4905
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4906

    
4907
                            Mouse.SetCursor(Cursors.Arrow);
4908
                        }
4909
                        else
4910
                        {
4911
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4912
                        }
4913
                    }
4914
                    else
4915
                    {
4916
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4917
                    }
4918
                }
4919
                else
4920
                {
4921
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4922
                }
4923

    
4924
                Mouse.SetCursor(Cursors.Arrow);
4925
            }
4926
        }
4927

    
4928
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4929
        {
4930
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4931
#if Hyosung
4932
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4933
#else
4934

    
4935
            //btnConsolidateFinalPDF.IsEnabled = false;
4936

    
4937
            if (App.ViewInfo != null)
4938
            {
4939
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4940
                {
4941
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4942
                }
4943
            }
4944
#endif
4945
        }
4946

    
4947
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4948
        {
4949
            SetCompareRect();
4950
        }
4951

    
4952
        private void Sync_Click(object sender, RoutedEventArgs e)
4953
        {
4954
            if (Sync.IsChecked)
4955
            {
4956
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4957
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4958
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4959
            }
4960
        }
4961

    
4962
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4963
        {
4964
            if (UserList.IsChecked)
4965
            {
4966
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4967
            }
4968
            else
4969
            {
4970
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4971
            }
4972
        }
4973

    
4974
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4975
        {
4976
            if (BalanceMode.IsChecked)
4977
            {
4978
                ViewerDataModel.Instance.PageBalanceMode = true;
4979
            }
4980
            else
4981
            {
4982
                ViewerDataModel.Instance.PageBalanceMode = false;
4983
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4984
            }
4985
        }
4986

    
4987
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4988
        {
4989
            //초기화
4990
            testPanel2.IsHidden = true;
4991
            ViewerDataModel.Instance.PageBalanceMode = false;
4992
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4993
            ViewerDataModel.Instance.SyncPageNumber = 0;
4994
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4995
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4996
            UserList.IsChecked = false;
4997
            BalanceMode.IsChecked = false;
4998
        }
4999

    
5000
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5001
        {
5002
            if ((sender as System.Windows.Controls.Control).Tag != null)
5003
            {
5004
                //Compare 초기화
5005
                CompareMode.IsChecked = false;
5006
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5007
                
5008
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5009
                {
5010
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5011
                }
5012

    
5013
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5014
                {
5015
                }
5016
                else
5017
                {
5018
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5019
                }
5020

    
5021
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5022
                {
5023
                }
5024
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5025
                {
5026
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5027
                }
5028

    
5029
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5030

    
5031
                if (!testPanel2.IsHidden)
5032
                {
5033
                    if (IsSyncPDFMode)
5034
                    {
5035
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5036
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5037

    
5038
                        if (pdfpath.IsDownloading)
5039
                        {
5040
                            pdfpath.DownloadCompleted += (ex, arg) =>
5041
                            {
5042
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5043
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5044
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5045
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5046
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5047
                            };
5048
                        }
5049
                        else
5050
                        {
5051
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5052
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5053
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5054

    
5055
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5056
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5057
                        }
5058
                    }
5059
                    else
5060
                    {
5061
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5062

    
5063
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5064
                        ComparePageLoad(uri, isOriginalSize);
5065
                    }
5066
                   
5067
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5068
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5069
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5070

    
5071
                    foreach (var item in gridSelectionRevItem)
5072
                    {
5073
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5074
                        foreach (var markupitem in markupitems)
5075
                        {
5076
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5077
                        }
5078
                    }
5079

    
5080
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5081
                }
5082
            }
5083
        }
5084

    
5085
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5086
        {
5087
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5088

    
5089
            double translateX = 0;
5090
            double translateY = 0;
5091
            double angle = rotate2.Angle;
5092

    
5093
            if (direction == 1)
5094
            {
5095
                if (angle < 270)
5096
                {
5097
                    angle += 90;
5098
                }
5099
                else
5100
                {
5101
                    angle = 0;
5102
                }
5103
            }
5104
            else
5105
            {
5106
                if (angle > 0)
5107
                {
5108
                    angle -= 90;
5109
                }
5110
                else
5111
                {
5112
                    angle = 270;
5113
                }
5114
            }
5115
            zoomAndPanControl2.RotationAngle = angle;
5116
            zoomAndPanControl2.ScaleToFit();
5117

    
5118
            //if (angle == 90 || angle == 270)
5119
            //{
5120
                double emptySize = zoomAndPanCanvas2.Width;
5121
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5122
                zoomAndPanCanvas2.Height = emptySize;
5123
            //}
5124

    
5125
            if (angle == 90)
5126
            {
5127
                translateX = zoomAndPanCanvas2.Width;
5128
                translateY = 0;
5129
            }
5130
            else if (angle == 180)
5131
            {
5132
                translateX = zoomAndPanCanvas2.Width;
5133
                translateY = zoomAndPanCanvas2.Height;
5134
            }
5135
            else if (angle == 270)
5136
            {
5137
                translateX = 0;
5138
                translateY = zoomAndPanCanvas2.Height;
5139
            }
5140
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5141
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5142
            translate2.X = translateX;
5143
            translate2.Y = translateY;
5144
            rotate2.Angle = angle;
5145
            //translate2CompareBorder.X = translateX;
5146
            //translate2CompareBorder.Y = translateY;
5147
            //rotate2CompareBorder.Angle = angle;
5148

    
5149
        }
5150

    
5151
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5152
        {
5153
            if (MarkupMode.IsChecked)
5154
            {
5155
                IsSyncPDFMode = true;
5156

    
5157
                var uri = CurrentRev.TO_VENDOR;
5158

    
5159
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5160
                {
5161
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5162
                }
5163

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

    
5168
                if (pdfpath.IsDownloading)
5169
                {
5170
                    pdfpath.DownloadCompleted += (ex, arg) =>
5171
                    {
5172
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5173
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5174
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5175
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5176
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5177
                    };
5178
                }
5179
                else
5180
                {
5181
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5182
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5183
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5184

    
5185
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5186
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5187
                }
5188
            }
5189
            else
5190
            {
5191
                IsSyncPDFMode = false;
5192
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5193

    
5194
                ComparePageLoad(uri,false);
5195

    
5196
                zoomAndPanControl2.ApplyTemplate();
5197
                zoomAndPanControl2.UpdateLayout();
5198
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5199
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5200
            }
5201
        }
5202

    
5203
        /// <summary>
5204
        /// Compare된 영역을 초기화
5205
        /// </summary>
5206
        private void ClearCompareRect()
5207
        {
5208
            da.From = 1;
5209
            da.To = 1;
5210
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5211
            da.AutoReverse = false;
5212
            canvas_compareBorder.Children.Clear();
5213
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5214
        }
5215

    
5216
        /// <summary>
5217
        /// 문서 Comprare
5218
        /// </summary>
5219
        private void SetCompareRect()
5220
        {
5221
            canvas_compareBorder.Children.Clear();
5222

    
5223
            if (CompareMode.IsChecked)
5224
            {
5225
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5226
                {
5227
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5228
                }
5229
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5230
                {
5231
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5232
                }
5233

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

    
5236
                /// 비교대상원본, 비교할 대상
5237
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5238
            }
5239
            else
5240
            {
5241
                canvas_compareBorder.Visibility = Visibility.Hidden;
5242
                ClearCompareRect();
5243
            }
5244
        }
5245

    
5246
        private void btnSync_Click(object sender, RoutedEventArgs e)
5247
        {
5248
            gridViewHistory_Busy.IsBusy = true;
5249

    
5250
            RadButton instance = sender as RadButton;
5251
            if (instance.CommandParameter != null)
5252
            {
5253
                CurrentRev = instance.CommandParameter as VPRevision;
5254
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5255

    
5256
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5257
                {
5258
                    if (ea.Error == null && ea.Result != null)
5259
                    {
5260
                        testPanel2.IsHidden = false;
5261

    
5262
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5263
                        foreach (var info in ea.Result)
5264
                        {
5265
                            if (info.UserID == App.ViewInfo.UserID)
5266
                            {
5267
                                info.userDelete = true;
5268
                                info.DisplayColor = "#FFFF0000";
5269
                            }
5270
                            else
5271
                            {
5272
                                info.userDelete = false;
5273
                            }
5274
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5275
                        }
5276
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5277

    
5278
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5279
                        ComparePageLoad(uri,false);
5280

    
5281
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5282

    
5283
                        zoomAndPanControl2.ApplyTemplate();
5284
                        zoomAndPanControl2.UpdateLayout();
5285

    
5286
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5287
                        {
5288
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5289
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5290
                        }
5291

    
5292
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5293
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5294
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5295

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

    
5299
                        zoomAndPanControl.ScaleToFit();
5300
                        zoomAndPanControl2.ScaleToFit();
5301

    
5302
                        gridViewHistory_Busy.IsBusy = false;
5303
                    }
5304

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

    
5307
                    if (GetSyncMarkupInfoItemshandler != null)
5308
                    {
5309
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5310
                    }
5311

    
5312
                    //ClearCompareRect();
5313
                    SetCompareRect();
5314
                };
5315

    
5316
                /// 중복 실행이 발생하여 수정함.
5317
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5318
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5319

    
5320
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5321
            }
5322
        }
5323

    
5324
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5325
        {
5326
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5327
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5328

    
5329
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5330
        }
5331

    
5332
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5333
        {
5334
            try
5335
            {
5336
                if (sender is RadButton)
5337
                {
5338
                    if ((sender as RadButton).Tag != null)
5339
                    {
5340
                        var url = (sender as RadButton).Tag.ToString();
5341
                        System.Diagnostics.Process.Start(url);
5342
                    }
5343
                    else
5344
                    {
5345
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5346
                    }
5347
                }
5348
            }
5349
            catch (Exception ex)
5350
            {
5351
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5352
            }
5353
        }
5354

    
5355
        public void Sync_Event(VPRevision Currnet_Rev)
5356
        {
5357
            CurrentRev = Currnet_Rev;
5358

    
5359
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5360
            {
5361
                if (ea.Error == null && ea.Result != null)
5362
                {
5363
                    testPanel2.IsHidden = false;
5364

    
5365
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5366
                    foreach (var info in ea.Result)
5367
                    {
5368
                        if (info.UserID == App.ViewInfo.UserID)
5369
                        {
5370
                            info.userDelete = true;
5371
                            info.DisplayColor = "#FFFF0000";
5372
                        }
5373
                        else
5374
                        {
5375
                            info.userDelete = false;
5376
                        }
5377
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5378
                    }
5379
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5380

    
5381
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5382

    
5383
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5384

    
5385
                    ComparePageLoad(uri,false);
5386

    
5387
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5388
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5389
                    zoomAndPanControl2.ApplyTemplate();
5390
                    zoomAndPanControl2.UpdateLayout();
5391

    
5392
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5393
                    {
5394
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5395
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5396
                    }
5397
                    //}
5398
                    
5399
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5400
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5401
                    gridViewHistory_Busy.IsBusy = false;
5402
                }
5403
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5404
            };
5405
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5406
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5407
        }
5408

    
5409
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5410
        {
5411
            if (sender is Image)
5412
            {
5413
                if ((sender as Image).Tag != null)
5414
                {
5415
                    var pdfUrl = (sender as Image).Tag.ToString();
5416
                    System.Diagnostics.Process.Start(pdfUrl);
5417
                }
5418
                else
5419
                {
5420
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5421
                }
5422
            }
5423
        }
5424

    
5425
        private void Create_Symbol(object sender, RoutedEventArgs e)
5426
        {
5427
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5428

    
5429
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5430
            {
5431
                DialogMessage_Alert("Please Select Controls", "Alert");
5432
            }
5433
            else //선택된 것이 있으면
5434
            {
5435
                string MarkupData = "";
5436
                adorner_ = new AdornerFinal();
5437

    
5438
                foreach (var item in SelectLayer.Children)
5439
                {
5440
                    if (item.GetType().Name == "AdornerFinal")
5441
                    {
5442
                        adorner_ = (item as Controls.AdornerFinal);
5443
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5444
                        {
5445
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5446
                            {
5447
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5448
                                MarkupData += markupReturn.ConvertData;
5449
                            }
5450
                        }
5451
                    }
5452
                }
5453
                DialogParameters parameters = new DialogParameters()
5454
                {
5455
                    Owner = Application.Current.MainWindow,
5456
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5457
                    DefaultPromptResultValue = "Custom State",
5458
                    Content = "Name :",
5459
                    Header = "Insert Custom Symbol Name",
5460
                    Theme = new VisualStudio2013Theme(),
5461
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5462
                };
5463
                RadWindow.Prompt(parameters);
5464
            }
5465
        }
5466

    
5467
        public int symbolselectindex = 0;
5468

    
5469
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5470
        {
5471
            //Save save = new Save();
5472
            try
5473
            {
5474
                string svgfilename = null;
5475
                if (symbolname != null)
5476
                {
5477
                    if (symbolpng == true || symbolsvg == true)
5478
                    {
5479
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5480
                        string guid = Commons.shortGuid();
5481

    
5482
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5483
                        //Check_Uri.UriCheck();
5484
                        fileUploader.RunCompleted += (ex, arg) =>
5485
                        {
5486
                            filename = arg.Result;
5487
                            if (symbolpng == true)
5488
                            {
5489
                                if (filename != null)
5490
                                {
5491
                                    if (symbolselectindex == 0)
5492
                                    {
5493
                                        SymbolSave(symbolname, filename, data);
5494
                                    }
5495
                                    else
5496
                                    {
5497
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5498
                                    }
5499
                                    DataBind();
5500
                                }
5501
                            }
5502

    
5503
                            if (symbolsvg == true)
5504
                            {
5505
                                try
5506
                                {
5507
                                    var defaultBitmapImage = new BitmapImage();
5508
                                    defaultBitmapImage.BeginInit();
5509
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5510
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5511
                                    Check_Uri.UriCheck(filename);
5512
                                    defaultBitmapImage.UriSource = new Uri(filename);
5513
                                    defaultBitmapImage.EndInit();
5514

    
5515
                                    System.Drawing.Bitmap image;
5516

    
5517
                                    if (defaultBitmapImage.IsDownloading)
5518
                                    {
5519
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5520
                                        {
5521
                                            defaultBitmapImage.Freeze();
5522
                                            image = GetBitmap(defaultBitmapImage);
5523
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5524
                                            Process potrace = new Process
5525
                                            {
5526
                                                StartInfo = new ProcessStartInfo
5527
                                                {
5528
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5529
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5530
                                                    RedirectStandardInput = true,
5531
                                                    RedirectStandardOutput = true,
5532
                                                    RedirectStandardError = true,
5533
                                                    UseShellExecute = false,
5534
                                                    CreateNoWindow = true,
5535
                                                    WindowStyle = ProcessWindowStyle.Hidden
5536
                                                },
5537
                                            };
5538

    
5539
                                            StringBuilder svgBuilder = new StringBuilder();
5540
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5541
                                            {
5542
                                                svgBuilder.AppendLine(e2.Data);
5543
                                            };
5544

    
5545
                                            potrace.EnableRaisingEvents = true;
5546
                                            potrace.Start();
5547
                                            potrace.Exited += (sender, e) =>
5548
                                            {
5549
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5550
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5551
                                                Check_Uri.UriCheck(svgfilename);
5552
                                                if (symbolselectindex == 0)
5553
                                                {
5554
                                                    SymbolSave(symbolname, svgfilename, data);
5555
                                                }
5556
                                                else
5557
                                                {
5558
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5559
                                                }
5560

    
5561
                                                DataBind();
5562
                                            };
5563
                                            potrace.WaitForExit();
5564
                                        };
5565
                                    }
5566
                                    else
5567
                                    {
5568
                                        //GC.Collect();
5569
                                    }
5570
                                }
5571
                                catch (Exception ee)
5572
                                {
5573
                                    DialogMessage_Alert("" + ee, "Alert");
5574
                                }
5575
                            }
5576
                        };
5577
                    }
5578
                }
5579
            }
5580
            catch (Exception e)
5581
            {
5582
                //DialogMessage_Alert(e + "", "Alert");
5583
            }
5584
        }
5585

    
5586
        public void SymbolSave(string Name, string Url, string Data)
5587
        {
5588
            try
5589
            {
5590
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5591
                {
5592
                    ID = Commons.shortGuid(),
5593
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5594
                    NAME = Name,
5595
                    IMAGE_URL = Url,
5596
                    DATA = Data
5597
                };
5598

    
5599
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5600
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5601
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5602
            }
5603
            catch (Exception)
5604
            {
5605
                throw;
5606
            }
5607
        }
5608

    
5609
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5610
        {
5611
            try
5612
            {
5613
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5614
                {
5615
                    ID = Commons.shortGuid(),
5616
                    DEPARTMENT = Department,
5617
                    NAME = Name,
5618
                    IMAGE_URL = Url,
5619
                    DATA = Data
5620
                };
5621
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5622
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5623
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5624
            }
5625
            catch (Exception)
5626
            {
5627
                throw;
5628
            }
5629
        }
5630

    
5631
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5632
        {
5633
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5634
            DataBind();
5635
        }
5636

    
5637
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5638
        {
5639
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5640
            DataBind();
5641
        }
5642

    
5643
        private void DataBind()
5644
        {
5645
            try
5646
            {
5647
                Symbol_Custom Custom = new Symbol_Custom();
5648
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5649

    
5650
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5651
                foreach (var item in symbol_Private)
5652
                {
5653
                    Custom.Name = item.NAME;
5654
                    Custom.ImageUri = item.IMAGE_URL;
5655
                    Custom.ID = item.ID;
5656
                    Custom_List.Add(Custom);
5657
                    Custom = new Symbol_Custom();
5658
                }
5659
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5660

    
5661
                Custom = new Symbol_Custom();
5662
                Custom_List = new List<Symbol_Custom>();
5663

    
5664
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5665

    
5666
                List<SYMBOL_PUBLIC> symbol_Public;
5667

    
5668
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5669
                {
5670
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5671
                }
5672
                else
5673
                {
5674
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5675
                }
5676
                foreach (var item in symbol_Public)
5677
                {
5678
                    Custom.Name = item.NAME;
5679
                    Custom.ImageUri = item.IMAGE_URL;
5680
                    Custom.ID = item.ID;
5681
                    Custom_List.Add(Custom);
5682
                    Custom = new Symbol_Custom();
5683
                }
5684
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5685
                BaseClient.Close();
5686
            }
5687
            catch (Exception e)
5688
            {
5689
                //DialogMessage_Alert("DataBind", "Alert");
5690
            }
5691
        }
5692

    
5693
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5694
        {
5695
            try
5696
            {
5697
                if (args.PromptResult != null)
5698
                {
5699
                    if (args.DialogResult.Value)
5700
                    {
5701
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5702

    
5703
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5704
                        _Encoder.Save(fs);
5705
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5706

    
5707
                        byte[] Img_byte = fs.ToArray();
5708

    
5709
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5710
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5711
                        Check_Uri.UriCheck(filename);
5712
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5713
                        {
5714
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5715
                        }
5716
                        else
5717
                        {
5718
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5719
                        }
5720
                        DataBind();
5721
                    }
5722
                }
5723
            }
5724
            catch (Exception ex)
5725
            {
5726
                DialogMessage_Alert("" + ex, "Alert");
5727
            }
5728
        }
5729

    
5730
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5731
        {
5732
            Canvas _canvas = new Canvas();
5733
            _canvas.Background = Brushes.White;
5734
            _canvas.Width = adorner_.BorderSize.Width;
5735
            _canvas.Height = adorner_.BorderSize.Height;
5736
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5737

    
5738
            BitmapEncoder encoder = new PngBitmapEncoder();
5739

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

    
5742
            DrawingVisual dv = new DrawingVisual();
5743

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

    
5747
            using (DrawingContext ctx = dv.RenderOpen())
5748
            {
5749
                VisualBrush vb = new VisualBrush(_canvas);
5750
                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)));
5751
            }
5752

    
5753
            try
5754
            {
5755
                renderBitmap.Render(dv);
5756

    
5757
                GC.Collect(2);
5758
                GC.WaitForPendingFinalizers();
5759
                //GC.Collect();
5760
                // encode png data
5761
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5762
                // puch rendered bitmap into it
5763
                pngEncoder.Interlace = PngInterlaceOption.Off;
5764
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5765
                return pngEncoder;
5766
            }
5767
            catch //(Exception ex)
5768
            {
5769
                return null;
5770
            }
5771
        }
5772

    
5773
        public void DialogMessage_Alert(string content, string header)
5774
        {
5775
            App.splashScreen.Close();
5776
            App.FileLogger.Error(content + " " + header);
5777

    
5778
            DialogParameters parameters = new DialogParameters()
5779
            {
5780
                Owner = this.ParentOfType<MainWindow>(),
5781
                Content = new TextBlock()
5782
                {
5783
                    MinWidth = 400,
5784
                    FontSize = 11,
5785
                    Text = content,
5786
                    TextWrapping = System.Windows.TextWrapping.Wrap
5787
                },
5788
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5789
                Header = header,
5790
                Theme = new VisualStudio2013Theme(),
5791
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5792
            };
5793
            RadWindow.Alert(parameters);
5794
        }
5795

    
5796
        #region 캡쳐 기능
5797

    
5798
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5799
        {
5800
            if (x < 0)
5801
            {
5802
                width += x;
5803
                x = 0;
5804
            }
5805
            if (y < 0)
5806
            {
5807
                height += y;
5808
                y = 0;
5809

    
5810
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5811
            }
5812
            if (x + width > zoomAndPanCanvas.ActualWidth)
5813
            {
5814
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5815
            }
5816
            if (y + height > zoomAndPanCanvas.ActualHeight)
5817
            {
5818
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5819
            }
5820

    
5821
            byte[] pixels = CopyPixels(x, y, width, height);
5822

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

    
5825
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5826
        }
5827

    
5828
        public byte[] CopyPixels(int x, int y, int width, int height)
5829
        {
5830
            byte[] pixels = new byte[width * height * 4];
5831
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5832

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

    
5836
            return pixels;
5837
        }
5838

    
5839
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5840
        {
5841
            DrawingVisual drawingVisual = new DrawingVisual();
5842
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5843

    
5844
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5845
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5846
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5847
            drawingContext.Close();
5848

    
5849
            // 비트맵으로 변환합니다.
5850
            RenderTargetBitmap target =
5851
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5852
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5853

    
5854
            target.Render(drawingVisual);
5855
            return target;
5856
        }
5857

    
5858
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5859
        {
5860
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5861
            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);
5862
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5863
            bmp.UnlockBits(data);
5864
            return bmp;
5865
        }
5866

    
5867
        public string symbolname = null;
5868
        public bool symbolsvg = true;
5869
        public bool symbolpng = true;
5870

    
5871
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5872
        {
5873
            System.Drawing.Bitmap image = GetBitmap(source);
5874
            //흰색 제거
5875
            //image.MakeTransparent(System.Drawing.Color.White);
5876

    
5877
            var imageStream = new System.IO.MemoryStream();
5878
            byte[] imageBytes = null;
5879
            using (imageStream)
5880
            {
5881
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5882
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5883
                imageStream.Position = 0;
5884
                imageBytes = imageStream.ToArray();
5885
            }
5886

    
5887
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5888

    
5889
            RadWindow CheckPop = new RadWindow();
5890
            //Alert check = new Alert(Msg);
5891

    
5892
            CheckPop = new RadWindow
5893
            {
5894
                MinWidth = 400,
5895
                MinHeight = 100,
5896
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5897
                Header = "Alert",
5898
                Content = symbolPrompt,
5899
                //DialogResult =
5900
                ResizeMode = System.Windows.ResizeMode.NoResize,
5901
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5902
                IsTopmost = true,
5903
            };
5904
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5905
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5906
            CheckPop.ShowDialog();
5907

    
5908
            /*
5909
            DialogParameters parameters = new DialogParameters()
5910
            {
5911
                Owner = Application.Current.MainWindow,
5912
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5913
                DefaultPromptResultValue = "Custom State",
5914
                Content = "Name :",
5915
                Header = "Insert Custom Symbol Name",
5916
                Theme = new VisualStudio2013Theme(),
5917
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5918
            };
5919
            RadWindow.Prompt(parameters);
5920
            */
5921
        }
5922

    
5923
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5924
        {
5925
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5926
            KCOMDataModel.DataModel.CHECK_LIST check_;
5927
            string Result = streamToBase64.ImageToBase64(source);
5928
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5929
            string projectno = App.ViewInfo.ProjectNO;
5930
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5931

    
5932
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5933
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5934
            if (Item != null)
5935
            {
5936
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5937
            }
5938
            else
5939
            {
5940
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5941
            }
5942

    
5943
            if (Item == null)
5944
            {
5945
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5946
                {
5947
                    ID = Commons.shortGuid(),
5948
                    USER_ID = App.ViewInfo.UserID,
5949
                    IMAGE_URL = Result,
5950
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5951
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5952
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5953
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5954
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5955
                    STATUS = "False",
5956
                    CREATE_TIME = DateTime.Now,
5957
                    UPDATE_TIME = DateTime.Now,
5958
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5959
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5960
                };
5961
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5962
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5963
                this.BaseClient.AddCheckList(projectno, check_);
5964
            }
5965
            else
5966
            {
5967
                Item.IMAGE_URL = Result;
5968
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5969
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5970
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5971
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5972
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5973
            }
5974
        }
5975

    
5976
        public void Set_Capture()
5977
        {
5978
            double x = CanvasDrawingMouseDownPoint.X;
5979
            double y = CanvasDrawingMouseDownPoint.Y;
5980
            double width = dragCaptureBorder.Width;
5981
            double height = dragCaptureBorder.Height;
5982

    
5983
            if (width > 5 || height > 5)
5984
            {
5985
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5986
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5987
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5988
            }
5989
        }
5990

    
5991
        #endregion 캡쳐 기능
5992

    
5993
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5994
        {
5995
            multi_Undo_Data = new Multi_Undo_data();
5996

    
5997
            multi_Undo_Data.Markup = control;
5998

    
5999
            if ((control as IShapeControl) != null)
6000
            {
6001
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6002
            }
6003
            if ((control as IDashControl) != null)
6004
            {
6005
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6006
            }
6007
            if ((control as IPath) != null)
6008
            {
6009
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6010
            }
6011
            if ((control as UIElement) != null)
6012
            {
6013
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6014
            }
6015

    
6016
            return multi_Undo_Data;
6017
        }
6018

    
6019
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6020
        {
6021
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6022
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6023
            {
6024
                if (items.MarkupInfoID == Select_ID)
6025
                {
6026
                    foreach (var item in items.MarkupList)
6027
                    {
6028
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6029
                        {
6030
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6031
                                 items.MarkupInfoID, Commons.shortGuid());
6032
                        }
6033
                    }
6034
                }
6035
            }
6036
        }
6037

    
6038
        /// <summary>
6039
        /// convert inkcontrol to polygoncontrol
6040
        /// </summary>
6041
        public void ConvertInkControlToPolygon()
6042
        {
6043
            if (inkBoard.Strokes.Count > 0)
6044
            {
6045
                inkBoard.Strokes.ToList().ForEach(stroke =>
6046
                {
6047
                    InkToPath ip = new InkToPath();
6048

    
6049
                    List<Point> inkPointSet = new List<Point>();
6050
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6051

    
6052
                    PolygonControl pc = new PolygonControl()
6053
                    {
6054
                        CommentAngle = 0,
6055
                        PointSet = inkPointSet,
6056
                        ControlType = ControlType.Ink
6057
                    };
6058
                    pc.StartPoint = inkPointSet[0];
6059
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6060
                    pc.LineSize = 3;
6061
                    pc.CommentID = Commons.shortGuid();
6062
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6063

    
6064
                    if (pc.PointSet.Count > 0)
6065
                    {
6066
                        CreateCommand.Instance.Execute(pc);
6067
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6068
                    }
6069
                });
6070
                inkBoard.Strokes.Clear();
6071
            }
6072
        }
6073

    
6074
        /// <summary>
6075
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6076
        /// </summary>
6077
        /// <author>ingu</author>
6078
        /// <date>2018.06.05</date>
6079
        /// <param name="getPoint"></param>
6080
        /// <returns></returns>
6081
        private bool IsGetoutpoint(Point getPoint)
6082
        {
6083
            if (getPoint == new Point())
6084
            {
6085
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6086
                currentControl = null;
6087
                return true;
6088
            }
6089

    
6090
            return false;
6091
        }
6092

    
6093
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6094
        {
6095
            e.Effects = DragDropEffects.Copy;
6096
        }
6097

    
6098
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6099
        {
6100
            e.Effects = DragDropEffects.Copy;
6101
        }
6102

    
6103
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6104
        {
6105
            e.Effects = DragDropEffects.None;
6106
        }
6107

    
6108
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6109
        {
6110
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6111
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6112

    
6113
            ScaleImage(pageWidth, pageHeight);
6114
        }
6115

    
6116
        /// <summary>
6117
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6118
        /// </summary>
6119
        /// <param name="pageWidth">원본 사이즈</param>
6120
        /// <param name="pageHeight">원본 사이즈</param>
6121
        /// <returns></returns>
6122
        private void ScaleImage(double pageWidth, double pageHeight)
6123
        {
6124
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6125
        }
6126

    
6127
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6128
        {
6129
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6130
        }
6131

    
6132
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6133
        {
6134
            var checkbox = (sender as CheckBox);
6135

    
6136
            if (checkbox != null)
6137
            {
6138
                if (checkbox.IsChecked.GetValueOrDefault())
6139
                {
6140
                    gridViewMarkup.SelectAll();
6141
                }
6142
                else
6143
                {
6144
                    gridViewMarkup.UnselectAll();
6145
                }
6146
            }
6147
        }
6148
        
6149
        /*
6150
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6151
        {
6152
            try
6153
            {
6154
                if (e.Data.GetDataPresent(typeof(string)))
6155
                {
6156
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6157
                    string dragData = e.Data.GetData(typeof(string)) as string;
6158
                    Move_Symbol(sender, dragData);
6159
                }
6160
            }
6161
            catch (Exception ex)
6162
            {
6163
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6164
            }
6165
        }
6166
        */
6167
    }
6168

    
6169
    public class testItem
6170
    {
6171
        public string Title { get; set; }
6172
    }
6173
}
클립보드 이미지 추가 (최대 크기: 500 MB)