프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 3abe8d4e

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

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

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

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

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

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

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

    
169
        private Point Sync_Offset_Point;
170

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

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

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

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

    
215
        public bool IsSyncPDFMode { get; set; }
216

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

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

    
242
        #endregion 프로퍼티
243

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

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

    
258
            //lstSymbolPrivate.ItemsSource = testItems;
259

    
260
            this.Loaded += MainMenu_Loaded;
261
        }
262

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

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

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

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

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

    
300
            return uri;
301
        }
302

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

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

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

    
341
            return uri;
342
        }
343

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

    
354
            return false;
355
        }
356

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

    
380
            return false;
381
        }
382

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

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

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

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

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

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

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

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

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

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

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

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

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

    
494
            if (App.ParameterMode)
495
            {
496

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

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

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

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

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

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

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

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

    
553
        string instnaceFile;
554
        string downloadurl;
555

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

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

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

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

    
591
        //    ////GC.Collect();
592
        //}
593

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

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

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

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

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

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

    
652
            /// up to here
653

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

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

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

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

    
692
            ViewerDataModel.Instance.PageAngle = page.PAGE_ANGLE;
693

    
694
            // 페이지 이미지 변경
695

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

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

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

    
709
            //var pagechangeTask = PageChangingAsync(page, page.PAGE_NUMBER, ViewerDataModel.Instance.NewPagImageCancelToken());
710

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

    
713
            //await Task.WhenAll(pagechangeTask, markupLoadTask);
714
        }
715

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

    
720
            #region 페이지가 벗어난 경우
721

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

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

    
734
            #endregion 페이지가 벗어난 경우
735

    
736
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
737

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

    
742
            #region 페이지 이미지 로딩 수정
743
            
744

    
745
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
746

    
747
            if(token.IsCancellationRequested)
748
            {
749
                return;
750
            }
751

    
752
            ScaleImage(pageWidth, pageHeight);
753

    
754
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
755
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
756

    
757
            zoomAndPanCanvas.Width = pageWidth;
758
            zoomAndPanCanvas.Height = pageHeight;
759

    
760
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
761
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
762

    
763
            inkBoard.Width = pageWidth;
764
            inkBoard.Height = pageHeight;
765

    
766
            #endregion 페이지 이미지 로딩 수정
767

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

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

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

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

    
811
            SearchFocusBorder.Visibility = Visibility.Collapsed;
812

    
813
            this.pageNavigator.ChangePage(changePageNumber);
814
        }
815

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

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

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

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

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

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

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

    
872
            var instanceMain = ViewerDataModel.Instance.SystemMain;
873

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

    
876
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
877
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
878

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

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

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

    
1226
                if (cts != null)
1227
                {
1228
                    if (cts.Value.IsCancellationRequested)
1229
                        return;
1230
                }
1231
            }
1232

    
1233
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1234
        }
1235

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

    
1251
                viewinfo.MarkupList = new List<MarkupItem>();
1252
                foreach (var item in dbinfo.MarkupList)
1253
                {
1254
                    System.Diagnostics.Debug.WriteLine(item.ID);
1255
                    viewinfo.MarkupList.Add(item);
1256
                }
1257
            }
1258
        }
1259

    
1260
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1261
        {
1262
            var instance = ViewerDataModel.Instance;
1263

    
1264
            if (instance.IsWheelPageChanage)
1265
            {
1266
                return;
1267
            }
1268

    
1269
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1270
            {
1271
                int changePage = 0;
1272

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

    
1306
                //if (changePage != 0)
1307
                //{
1308
                //    await Task.Factory.StartNew(() =>
1309
                //    {
1310
                //        double beforeScale = instance.ContentScale;
1311

    
1312
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1313

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

    
1323
                //        pageNavigator.PageChanged += handler;
1324

    
1325
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1326
                //    });
1327

    
1328
                //}
1329
            }
1330
            else
1331
            {
1332
                e.Handled = true;
1333
                if (e.Delta > 0)
1334
                {
1335
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1336
                    ZoomIn(currentContentMousePoint);
1337
                }
1338
                else
1339
                {
1340
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1341
                    ZoomOut(currentContentMousePoint);
1342
                }
1343
            }
1344
        }
1345

    
1346
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1347
        {
1348
            e.Handled = true;
1349
            if (e.Delta > 0)
1350
            {
1351
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1352
                ZoomIn_Sync(currentContentMousePoint);
1353
            }
1354
            else
1355
            {
1356
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1357
                ZoomOut_Sync(currentContentMousePoint);
1358
            }
1359
        }
1360

    
1361
        #region ZoomIn & ZoomOut
1362

    
1363
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1364
        {
1365
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1366
                zoomAndPanControl.ContentZoomFocusY));
1367
        }
1368

    
1369
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1370
        {
1371
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1372
                zoomAndPanControl.ContentZoomFocusY));
1373
        }
1374

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

    
1388
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1389
            {
1390
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1391
            }
1392
        }
1393

    
1394
        private void ZoomIn(Point contentZoomCenter)
1395
        {
1396
            if (zoomAndPanControl.ContentScale > 0.19)
1397
            {
1398
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1399
            }
1400
            else
1401
            {
1402
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1403
            }
1404

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

    
1411
        private void ZoomOut_Sync(Point contentZoomCenter)
1412
        {
1413
            if (zoomAndPanControl2.ContentScale > 0.39)
1414
            {
1415
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1416
            }
1417
            else
1418
            {
1419
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1420
            }
1421

    
1422
            if (Sync.IsChecked)
1423
            {
1424
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1425
            }
1426
        }
1427

    
1428
        private void ZoomIn_Sync(Point contentZoomCenter)
1429
        {
1430
            if (zoomAndPanControl2.ContentScale > 0.19)
1431
            {
1432
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1433
            }
1434
            else
1435
            {
1436
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1437
            }
1438

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

    
1445
        private void ZoomOut()
1446
        {
1447
            zoomAndPanControl.ContentScale -= 0.1;
1448
            //if (zoomAndPanControl2 != null)
1449
            //{
1450
            //    zoomAndPanControl2.ContentScale -= 0.1;
1451
            //}
1452
        }
1453

    
1454
        private void ZoomIn()
1455
        {
1456
            zoomAndPanControl.ContentScale += 0.1;
1457
            //if (zoomAndPanControl2 != null)
1458
            //{
1459
            //    zoomAndPanControl2.ContentScale += 0.1;
1460
            //}
1461
        }
1462

    
1463
        #endregion ZoomIn & ZoomOut
1464

    
1465
        private void init()
1466
        {
1467
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1468
            {
1469
                ControlList.Clear();
1470
                listBox.Items.Clear();
1471
                selected_item.Clear();
1472

    
1473
                (item as IMarkupCommonData).IsSelected = false;
1474
            }
1475
        }
1476

    
1477
        private HitTestResultBehavior MyCallback(HitTestResult result)
1478
        {
1479
            //this.cursor = Cursors.UpArrow;
1480
            var element = result.VisualHit;
1481
            while (element != null && !(element is CommentUserInfo))
1482
                element = VisualTreeHelper.GetParent(element);
1483

    
1484
            if (element == null)
1485
            {
1486
                return HitTestResultBehavior.Stop;
1487
            }
1488
            else
1489
            {
1490
                if (element is CommentUserInfo)
1491
                {
1492
                    if (!hitList.Contains(element))
1493
                    {
1494
                        hitList.Add((CommentUserInfo)element);
1495
                    }
1496
                    else
1497
                    {
1498
                        return HitTestResultBehavior.Stop;
1499
                    }
1500
                }
1501
            }
1502
            return HitTestResultBehavior.Continue;
1503
        }
1504

    
1505
        public void ReleaseSelectPath()
1506
        {
1507
            if (SelectionPath == null)
1508
            {
1509
                SelectionPath = new Path();
1510
                SelectionPath.Name = "";
1511
            }
1512
            if (SelectionPath.Name != "")
1513
            {
1514
                SelectionPath.Name = "None";
1515
            }
1516
            SelectionPath.Opacity = 0.01;
1517
            SelectionPath.RenderTransform = null;
1518
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1519
        }
1520

    
1521
        #region 컨트롤 초기화
1522

    
1523
        public void Control_Init(object control)
1524
        {
1525
            if (L_Size != 0 && (control as IPath) != null)
1526
            {
1527
                (control as IPath).LineSize = L_Size;
1528
                L_Size = 0;
1529
            }
1530

    
1531
            switch (control.GetType().Name)
1532
            {
1533
                case "RectangleControl":
1534
                    {
1535
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1536
                    }
1537
                    break;
1538

    
1539
                case "CircleControl":
1540
                    {
1541
                        (control as CircleControl).StrokeColor = Brushes.Red;
1542
                    }
1543
                    break;
1544

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

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

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

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

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

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

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

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

    
1593
                case "TextControl":
1594
                    {
1595
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1596
                    }
1597
                    break;
1598

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

    
1605
                case "InsideWhiteControl":
1606
                    {
1607
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1608
                    }
1609
                    break;
1610

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

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

    
1623
                case "CoordinateControl":
1624
                    {
1625
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1626
                    }
1627
                    break;
1628
            }
1629
        }
1630

    
1631
        #endregion 컨트롤 초기화
1632

    
1633
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1634
        {
1635
            //Control_Init(e.Source);
1636
        }
1637

    
1638
        //private Window _dragdropWindow = null;
1639

    
1640
        [DllImport("user32.dll")]
1641
        [return: MarshalAs(UnmanagedType.Bool)]
1642
        internal static extern bool GetCursorPos(ref Win32Point pt);
1643

    
1644
        [StructLayout(LayoutKind.Sequential)]
1645
        internal struct Win32Point
1646
        {
1647
            public Int32 X;
1648
            public Int32 Y;
1649
        };
1650

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

    
1662
               if (this._dragdropWindow != null)
1663
               {
1664
                   this._dragdropWindow.Close();
1665
                   this._dragdropWindow = null;
1666
               }
1667

    
1668
               symbol_id = id;
1669
               symbol_group_id = group_id;
1670
               symbol_SelectedIndex = SelectedIndex;
1671
               symbol_Data = Data_;
1672
               symbol_img = img;
1673

    
1674
               CreateDragDropWindow2(img);
1675
    }
1676

    
1677
    private void CreateDragDropWindow2(ImageSource image)
1678
        {
1679
            this._dragdropWindow = new Window();
1680
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1681
            _dragdropWindow.WindowStyle = WindowStyle.None;
1682
            _dragdropWindow.AllowsTransparency = true;
1683
            _dragdropWindow.AllowDrop = false;
1684
            _dragdropWindow.Background = null;
1685
            _dragdropWindow.IsHitTestVisible = false;
1686
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1687
            _dragdropWindow.Topmost = true;
1688
            _dragdropWindow.ShowInTaskbar = false;
1689

    
1690
            Rectangle r = new Rectangle();
1691
            r.Width = image.Width;
1692
            r.Height = image.Height;
1693
            r.Opacity = 0.5;
1694
            r.Fill = new ImageBrush(image);
1695
            this._dragdropWindow.Content = r;
1696

    
1697
            Win32Point w32Mouse = new Win32Point();
1698
            GetCursorPos(ref w32Mouse);
1699

    
1700
            //w32Mouse.X = getCurrentPoint.X;
1701
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1702
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1703
            this._dragdropWindow.Show();
1704
        }
1705

    
1706
         */
1707

    
1708
        public void MoveZoomAndPanControl(Vector dragOffset)
1709
        {
1710
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1711
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1712

    
1713
            if (Sync.IsChecked)
1714
            {
1715
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1716
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1717
            }
1718
        }
1719

    
1720
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1721
        {
1722
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1723
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1724
            //if(this.txtBatch.Visibility == Visibility.Visible)
1725
            {
1726
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1727

    
1728
                Point currentPos = e.GetPosition(rect);
1729

    
1730
                floatingTip.HorizontalOffset = currentPos.X + 20;
1731
                floatingTip.VerticalOffset = currentPos.Y;
1732
            }
1733

    
1734
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1735

    
1736
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1737
            {
1738
                SetCursor();
1739
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1740
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1741

    
1742
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1743

    
1744
                MoveZoomAndPanControl(dragOffset);
1745
            }
1746

    
1747
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1748
            {
1749
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1750
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1751
                SetCursor();
1752

    
1753
                if (currentControl != null)
1754
                {
1755
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1756
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1757
                    //강인구 추가
1758
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1759

    
1760
                    if ((currentControl as IPath) != null)
1761
                    {
1762
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1763
                    }
1764
                    if ((currentControl as LineControl) != null)
1765
                    {
1766
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1767
                    }
1768

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

    
1812
                    #region // 모든 컨트롤의 공통기능 제어
1813

    
1814
                    if (controlType != ControlType.PenControl)
1815
                    {
1816
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1817
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1818
                    }
1819

    
1820
                    #endregion // 모든 컨트롤의 공통기능 제어
1821

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

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

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

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

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

    
1877
                        case ControlType.RectCloud:
1878
                            {
1879
                                var control = currentControl as RectCloudControl;
1880
                                if (control != null)
1881
                                {
1882
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1883
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1884
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1885
                                }
1886
                            }
1887
                            break;
1888

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

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

    
1915
                        case ControlType.ArcArrow:
1916
                            {
1917
                                var control = currentControl as ArrowArcControl;
1918
                                if (control != null)
1919
                                {
1920
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1921
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1922
                                }
1923
                            }
1924
                            break;
1925

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

    
1937
                        case ControlType.Circle:
1938
                            {
1939
                                var control = currentControl as CircleControl;
1940

    
1941
                                if (control != null)
1942
                                {
1943
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1944
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1945
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1946
                                }
1947
                            }
1948
                            break;
1949

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

    
1962
                        case ControlType.Triangle:
1963
                            {
1964
                                var control = currentControl as TriControl;
1965
                                if (control != null)
1966
                                {
1967
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1968
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1969
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1970
                                }
1971
                            }
1972
                            break;
1973

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

    
1984
                        case ControlType.Date:
1985
                            {
1986
                                var control = currentControl as DateControl;
1987
                                if (control != null)
1988
                                {
1989
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1990
                                }
1991
                            }
1992
                            break;
1993

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

    
2009
                        case ControlType.PolygonControl:
2010
                        case ControlType.ChainLine:
2011
                            {
2012
                                var control = currentControl as PolygonControl;
2013
                                if (control != null)
2014
                                {
2015
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2016
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2017
                                    control.Paint = ViewerDataModel.Instance.paintSet;
2018
                                }
2019
                            }
2020
                            break;
2021

    
2022
                        case ControlType.Sign:
2023
                            {
2024
                                var control = currentControl as SignControl;
2025
                                if (control != null)
2026
                                {
2027
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2028
                                }
2029
                            }
2030
                            break;
2031

    
2032
                        case ControlType.Symbol:
2033
                            {
2034
                                var control = currentControl as SymControl;
2035
                                if (control != null)
2036
                                {
2037
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2038
                                }
2039
                            }
2040
                            break;
2041

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

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

    
2074
                        case ControlType.PenControl:
2075
                            {
2076
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2077
                                //inkBoard.Strokes.Add(stroke);
2078
                            }
2079
                            break;
2080

    
2081
                        default:
2082
                            break;
2083
                    }
2084

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

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

    
2117
                                //inkBoard.Strokes.Add(stroke);
2118
                            }
2119
                            break;
2120
                    }
2121
                    return;
2122
                }
2123
            }
2124
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2125
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2126
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2127
            {
2128
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2129

    
2130
                if (isDraggingSelectionRect)
2131
                {
2132
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2133
                    e.Handled = true;
2134
                }
2135
                else if (isLeftMouseButtonDownOnWindow)
2136
                {
2137
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2138
                    double dragDistance = Math.Abs(dragDelta.Length);
2139

    
2140
                    if (dragDistance > DragThreshold)
2141
                    {
2142
                        isDraggingSelectionRect = true;
2143
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2144
                    }
2145

    
2146
                    e.Handled = true;
2147
                }
2148

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

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

    
2193
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2194
        {
2195
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2196
            {
2197
                SetCursor();
2198
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2199
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2200

    
2201
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2202

    
2203
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2204
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2205

    
2206
                if (Sync.IsChecked)
2207
                {
2208
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2209
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2210
                }
2211
            }
2212
        }
2213

    
2214
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2215

    
2216
        private EllipseGeometry hitArea = new EllipseGeometry();
2217

    
2218
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2219
        {
2220
            IsDrawing = false;
2221

    
2222
            if (mouseHandlingMode != MouseHandlingMode.None)
2223
            {
2224
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2225
                {
2226
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2227

    
2228
                    SetCursor();
2229

    
2230
                    switch (controlType)
2231
                    {
2232
                        case ControlType.None:
2233
                            break;
2234

    
2235
                        case ControlType.Rectangle:
2236
                            {
2237
                            }
2238
                            break;
2239

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

    
2245
                        default:
2246
                            break;
2247
                    }
2248
                }
2249
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2250
                {
2251
                    if (isLeftMouseButtonDownOnWindow)
2252
                    {
2253
                        bool wasDragSelectionApplied = false;
2254

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

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

    
2290
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2291

    
2292
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2293
                            }
2294

    
2295
                            isDraggingSelectionRect = false;
2296
                            e.Handled = true;
2297
                            wasDragSelectionApplied = true;
2298
                        }
2299

    
2300
                        if (isLeftMouseButtonDownOnWindow)
2301
                        {
2302
                            isLeftMouseButtonDownOnWindow = false;
2303
                            this.ReleaseMouseCapture();
2304
                            e.Handled = true;
2305
                        }
2306

    
2307
                        if (!wasDragSelectionApplied)
2308
                        {
2309
                            init();
2310
                        }
2311
                    }
2312
                }
2313
                else if (e.RightButton == MouseButtonState.Pressed)
2314
                {
2315
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2316
                    SetCursor();
2317
                }
2318

    
2319
                zoomAndPanControl.ReleaseMouseCapture();
2320

    
2321
                e.Handled = true;
2322
            }
2323
            else
2324
            {
2325
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2326
                SetCursor();
2327
            }
2328

    
2329
            ///mouseButtonDown = MouseButton.Left;
2330
            //controlType = ControlType.SingleLine;
2331
        }
2332

    
2333
        public void Set_Symbol_Capture(Point endPoint)
2334
        {
2335
            double x = CanvasDrawingMouseDownPoint.X;
2336
            double y = CanvasDrawingMouseDownPoint.Y;
2337
            if (x > endPoint.X)
2338
            {
2339
                x = endPoint.X;
2340
                y = endPoint.Y;
2341
            }
2342

    
2343
            double width = dragCaptureBorder.Width;
2344
            double height = dragCaptureBorder.Height;
2345

    
2346
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2347

    
2348
            if (x < 0)
2349
            {
2350
                width += x;
2351
                x = 0;
2352
            }
2353
            if (y < 0)
2354
            {
2355
                height += y;
2356
                y = 0;
2357

    
2358
                width = (int)canvasImage.PixelWidth - x;
2359
            }
2360
            if (x + width > canvasImage.PixelWidth)
2361
            {
2362
                width = (int)canvasImage.PixelWidth - x;
2363
            }
2364
            if (y + height > canvasImage.PixelHeight)
2365
            {
2366
                height = (int)canvasImage.PixelHeight - y;
2367
            }
2368
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2369

    
2370
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2371
            var defaultBitmapImage = new BitmapImage();
2372
            defaultBitmapImage.BeginInit();
2373
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2374
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2375
            defaultBitmapImage.UriSource = new Uri(uri);
2376
            defaultBitmapImage.EndInit();
2377

    
2378
            //GC.Collect();
2379

    
2380
            if (defaultBitmapImage.IsDownloading)
2381
            {
2382
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2383
                {
2384
                    defaultBitmapImage.Freeze();
2385
                    //GC.Collect();
2386
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2387
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2388
                };
2389
            }
2390
        }
2391

    
2392
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2393
        {
2394
            ///mouseButtonDown = MouseButton.Left;
2395
        }
2396

    
2397
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2398
        {
2399
            ///mouseButtonDown = MouseButton.Left;
2400
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2401
        }
2402

    
2403
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2404
        {
2405
        }
2406

    
2407
        /// <summary>
2408
        /// select items by dragging
2409
        /// </summary>
2410
        private void ApplyDragSelectionRect()
2411
        {
2412
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2413

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

    
2422
            Rect dragRect = new Rect(x, y, width, height);
2423
            ///dragRect.Inflate(width / 10, height / 10);
2424

    
2425
            foreach (var item in Items)
2426
            {
2427
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2428

    
2429
                if (Flag)
2430
                {
2431
                    adornerSet.Add(item);
2432
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2433
                    Control_Style(item);
2434
                }
2435
            }
2436
            if (adornerSet.Count > 0)
2437
            {
2438
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2439
                SelectLayer.Children.Add(final);
2440
            }
2441
        }
2442

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

    
2462
        /// <summary>
2463
        /// Update the position and size of the rectangle used for drag selection.
2464
        /// </summary>
2465
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2466
        {
2467
            double x, y, width, height;
2468

    
2469
            //
2470
            // Determine x,y,width and height of the rect inverting the points if necessary.
2471
            //
2472

    
2473
            if (pt2.X < pt1.X)
2474
            {
2475
                x = pt2.X;
2476
                width = pt1.X - pt2.X;
2477
            }
2478
            else
2479
            {
2480
                x = pt1.X;
2481
                width = pt2.X - pt1.X;
2482
            }
2483

    
2484
            if (pt2.Y < pt1.Y)
2485
            {
2486
                y = pt2.Y;
2487
                height = pt1.Y - pt2.Y;
2488
            }
2489
            else
2490
            {
2491
                y = pt1.Y;
2492
                height = pt2.Y - pt1.Y;
2493
            }
2494

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

    
2523
        private void drawingPannelRotate(double angle)
2524
        {
2525
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2526
            rotate.Angle = angle;
2527
            var rotationNum = Math.Abs((rotate.Angle / 90));
2528

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

    
2556
            zoomAndPanControl.RotationAngle = rotate.Angle;
2557

    
2558
            if (!testPanel2.IsHidden)
2559
            {
2560
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2561
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2562
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2563
            }
2564

    
2565
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2566
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2567
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2568
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2569
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2570
        }
2571

    
2572
        private void syncPannelRotate(double angle)
2573
        {
2574
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2575
            rotate.Angle = angle;
2576
            var rotationNum = Math.Abs((rotate.Angle / 90));
2577

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

    
2605
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2606
        }
2607

    
2608
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2609
        {
2610
            string Data_ = "";
2611

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

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

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

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

    
2678
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2679
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2680
                    UndoData.Markup_List.Add(multi_Undo_Data);
2681
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2682

    
2683
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2684
                    currentControl.CommentID = Commons.shortGuid();
2685
                    currentControl.SymbolID = id;
2686
                    currentControl.GroupID = group_id;
2687
                    currentControl.ApplyTemplate();
2688
                    currentControl.SetImage();
2689

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

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

    
2712
            ConvertInkControlToPolygon();
2713

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

    
2718
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2719
            {
2720
                DeleteCommand.Instance.Execute(new[] { text_item });
2721
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2722
            }
2723

    
2724
            /// up to here
2725

    
2726
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2727
            {
2728
                if (item as ArrowTextControl != null)
2729
                {
2730
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2731
                }
2732
                else if (item as TextControl != null)
2733
                {
2734
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2735
                }
2736
            }
2737

    
2738
            //if (currentControl != null)
2739
            {
2740
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2741
                if (text_item_ != null)
2742
                {
2743
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2744
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2745
                    (text_item_ as TextControl).IsEditingMode = false;
2746
                    currentControl = null;
2747
                }
2748

    
2749
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2750
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2751
                {
2752
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2753
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2754
                    currentControl = null;
2755
                }
2756
            }
2757

    
2758
            double Ang = 0;
2759
            if (rotate.Angle != 0)
2760
            {
2761
                Ang = 360 - rotate.Angle;
2762
            }
2763

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

    
2778
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2779
            {
2780
                if (this._dragdropWindow != null)
2781
                {
2782
                    this._dragdropWindow.Close();
2783
                    this._dragdropWindow = null;
2784
                    symbol_id = null;
2785
                }
2786
            }
2787
            */
2788

    
2789
            if (e.LeftButton == MouseButtonState.Pressed)
2790
            {
2791
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2792
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2793

    
2794
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2795
                SetCursor();
2796

    
2797
                if (!ViewerDataModel.Instance.IsPressCtrl)
2798
                {
2799
                    SelectionSet.Instance.UnSelect(this);
2800
                }
2801
            }
2802

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

    
2822
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2823
            }
2824
            else if (e.XButton2 == MouseButtonState.Pressed)
2825
            {
2826
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2827
                {
2828
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2829
                }
2830
            }
2831

    
2832
            bool isArrowTextEdit = false;
2833

    
2834
            if (currentControl is ArrowTextControl textControl)
2835
            {
2836
                if (textControl.IsEditingMode)
2837
                    isArrowTextEdit = true;
2838
            }
2839

    
2840
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2841
            {
2842
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2843
                {
2844
                    if (SelectLayer.Children.Count == 0)
2845
                    {
2846
                        isLeftMouseButtonDownOnWindow = true;
2847
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2848
                    }
2849

    
2850
                    if (controlType == ControlType.None)
2851
                    {
2852
                        isLeftMouseButtonDownOnWindow = true;
2853
                    }
2854
                }
2855

    
2856
                /// 캡쳐 모드 설정
2857
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2858
                {
2859
                    dragCaptureBorder.Visibility = Visibility.Visible;
2860
                    isLeftMouseButtonDownOnWindow = true;
2861
                }
2862

    
2863
                /// 줌 모드 설정
2864
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2865
                {
2866
                    isLeftMouseButtonDownOnWindow = true;
2867
                }
2868

    
2869
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2870

    
2871
                if (control == null)
2872
                {
2873
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2874
                }
2875
                else
2876
                {
2877
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2878
                    {
2879
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2880
                    }
2881

    
2882
                    AdornerFinal final = null;
2883

    
2884
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2885
                    {
2886
                        /// 기존 selection 해제
2887
                        SelectionSet.Instance.UnSelect(this);
2888

    
2889
                        final = new AdornerFinal(control);
2890

    
2891
                        this.Control_Style(control);
2892

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

    
2918
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2919

    
2920
                        if ((control as TextControl) != null)
2921
                        {
2922
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2923

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

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

    
3005
                        Control_Style(control);
3006

    
3007
                        final = new AdornerFinal(comment);
3008
                    }
3009

    
3010
                    if (final != null)
3011
                    {
3012
                        this.SelectLayer.Children.Add(final);
3013
                    }
3014
                }
3015
            }
3016
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
3017
            {
3018

    
3019

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

    
3069
                                    CreateCommand.Instance.Execute(currentControl);
3070

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

    
3094
                                        currentControl.CommentID = Commons.shortGuid();
3095
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3096
                                        currentControl.IsNew = true;
3097

    
3098
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3099

    
3100
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3101
                                    }
3102
                                }
3103
                            }
3104
                        }
3105
                        break;
3106

    
3107
                    case ControlType.InsideWhite:
3108
                        {
3109
                            if (e.LeftButton == MouseButtonState.Pressed)
3110
                            {
3111
                                if (currentControl is InsideWhiteControl)
3112
                                {
3113
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3114
                                    {
3115
                                        return;
3116
                                    }
3117

    
3118
                                    CreateCommand.Instance.Execute(currentControl);
3119

    
3120
                                    currentControl = null;
3121
                                    this.cursor = Cursors.Arrow;
3122
                                }
3123
                                else
3124
                                {
3125
                                    currentControl = new InsideWhiteControl
3126
                                    {
3127
                                        Background = new SolidColorBrush(Colors.Black),
3128
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3129
                                        ControlType = ControlType.InsideWhite
3130
                                    };
3131

    
3132
                                    currentControl.CommentID = Commons.shortGuid();
3133
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3134
                                    currentControl.IsNew = true;
3135
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3136

    
3137
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3138
                                }
3139
                            }
3140
                        }
3141
                        break;
3142

    
3143
                    case ControlType.OverlapWhite:
3144
                        {
3145
                            if (e.LeftButton == MouseButtonState.Pressed)
3146
                            {
3147
                                if (currentControl is OverlapWhiteControl)
3148
                                {
3149
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3150
                                    {
3151
                                        return;
3152
                                    }
3153

    
3154
                                    CreateCommand.Instance.Execute(currentControl);
3155

    
3156
                                    currentControl = null;
3157
                                    this.cursor = Cursors.Arrow;
3158
                                }
3159
                                else
3160
                                {
3161
                                    currentControl = new OverlapWhiteControl
3162
                                    {
3163
                                        Background = new SolidColorBrush(Colors.Black),
3164
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3165
                                        ControlType = ControlType.OverlapWhite
3166
                                    };
3167

    
3168
                                    currentControl.CommentID = Commons.shortGuid();
3169
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3170
                                    currentControl.IsNew = true;
3171
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3172

    
3173
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3174
                                }
3175
                            }
3176
                        }
3177
                        break;
3178

    
3179
                    case ControlType.ClipWhite:
3180
                        {
3181
                            if (e.LeftButton == MouseButtonState.Pressed)
3182
                            {
3183
                                if (currentControl is ClipWhiteControl)
3184
                                {
3185
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3186
                                    {
3187
                                        return;
3188
                                    }
3189

    
3190
                                    CreateCommand.Instance.Execute(currentControl);
3191

    
3192
                                    currentControl = null;
3193
                                    this.cursor = Cursors.Arrow;
3194
                                }
3195
                                else
3196
                                {
3197
                                    currentControl = new ClipWhiteControl
3198
                                    {
3199
                                        Background = new SolidColorBrush(Colors.Black),
3200
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3201
                                        ControlType = ControlType.ClipWhite
3202
                                    };
3203

    
3204
                                    currentControl.CommentID = Commons.shortGuid();
3205
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3206
                                    currentControl.IsNew = true;
3207
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3208

    
3209
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3210
                                }
3211
                            }
3212
                        }
3213
                        break;
3214

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

    
3227
                                    CreateCommand.Instance.Execute(currentControl);
3228
                                    currentControl = null;
3229
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3230
                                }
3231
                                else
3232
                                {
3233
                                    currentControl = new RectangleControl
3234
                                    {
3235
                                        Background = new SolidColorBrush(Colors.Black),
3236
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3237
                                        ControlType = ControlType.Rectangle
3238
                                    };
3239

    
3240
                                    currentControl.CommentID = Commons.shortGuid();
3241
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3242
                                    currentControl.IsNew = true;
3243
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3244

    
3245
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3246
                                }
3247
                            }
3248
                        }
3249
                        break;
3250

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

    
3263
                                    CreateCommand.Instance.Execute(currentControl);
3264

    
3265
                                    currentControl = null;
3266

    
3267
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3268
                                }
3269
                                else
3270
                                {
3271
                                    currentControl = new RectCloudControl
3272
                                    {
3273
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3274
                                        ControlType = ControlType.RectCloud,
3275
                                        Background = new SolidColorBrush(Colors.Black)
3276
                                    };
3277

    
3278
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3279
                                    currentControl.CommentID = Commons.shortGuid();
3280
                                    currentControl.IsNew = true;
3281
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3282
                                }
3283
                            }
3284
                        }
3285
                        break;
3286

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

    
3299
                                    CreateCommand.Instance.Execute(currentControl);
3300

    
3301
                                    currentControl = null;
3302
                                }
3303
                                else
3304
                                {
3305
                                    currentControl = new CircleControl
3306
                                    {
3307
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3308
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3309
                                        Background = new SolidColorBrush(Colors.Black)
3310
                                    };
3311

    
3312
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3313
                                    currentControl.CommentID = Commons.shortGuid();
3314
                                    currentControl.IsNew = true;
3315
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3316
                                }
3317
                            }
3318
                        }
3319
                        break;
3320

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

    
3340
                                        CreateCommand.Instance.Execute(currentControl);
3341

    
3342
                                        currentControl = null;
3343
                                    }
3344
                                }
3345
                                else
3346
                                {
3347
                                    currentControl = new TriControl
3348
                                    {
3349
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3350
                                        Background = new SolidColorBrush(Colors.Black),
3351
                                    };
3352

    
3353
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3354
                                    currentControl.CommentID = Commons.shortGuid();
3355
                                    currentControl.IsNew = true;
3356
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3357
                                }
3358
                            }
3359
                        }
3360
                        break;
3361

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

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

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

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

    
3407
                                if (e.RightButton == MouseButtonState.Pressed)
3408
                                {
3409
                                    control.IsCompleted = true;
3410
                                }
3411

    
3412
                                if (!control.IsCompleted)
3413
                                {
3414
                                    control.PointSet.Add(control.EndPoint);
3415
                                }
3416
                                else
3417
                                {
3418
                                    //20180906 LJY TEST IsRotationDrawingEnable
3419
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3420
                                    {
3421
                                        return;
3422
                                    }
3423

    
3424
                                    var firstPoint = control.PointSet.First();
3425
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3426
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3427
                                    control.PointSet.Add(firstPoint);
3428

    
3429
                                    control.ApplyOverViewData();
3430

    
3431
                                    CreateCommand.Instance.Execute(currentControl);
3432
                                    control.UpdateControl();
3433
                                    currentControl = null;
3434
                                }
3435
                            }
3436
                            else
3437
                            {
3438
                                if (e.LeftButton == MouseButtonState.Pressed)
3439
                                {
3440
                                    currentControl = new PolygonControl
3441
                                    {
3442
                                        PointSet = new List<Point>(),
3443
                                    };
3444

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

    
3461
                    case ControlType.ChainLine:
3462
                        {
3463
                            if (currentControl is PolygonControl)
3464
                            {
3465
                                var control = currentControl as PolygonControl;
3466

    
3467
                                if (e.RightButton == MouseButtonState.Pressed)
3468
                                {
3469
                                    //20180906 LJY TEST IsRotationDrawingEnable
3470
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3471
                                    {
3472
                                        return;
3473
                                    }
3474

    
3475
                                    CreateCommand.Instance.Execute(currentControl);
3476

    
3477
                                    currentControl = null;
3478
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3479
                                    return;
3480
                                }
3481

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

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

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

    
3533
                                    CreateCommand.Instance.Execute(currentControl);
3534

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

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

    
3577
                                    CreateCommand.Instance.Execute(currentControl);
3578

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

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

    
3637
                                        CreateCommand.Instance.Execute(currentControl);
3638

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

    
3661
                    case ControlType.PolygonCloud:
3662
                        {
3663
                            if (currentControl is CloudControl)
3664
                            {
3665
                                var control = currentControl as CloudControl;
3666
                                if (e.RightButton == MouseButtonState.Pressed)
3667
                                {
3668
                                    control.IsCompleted = true;
3669
                                }
3670

    
3671
                                if (!control.IsCompleted)
3672
                                {
3673
                                    control.PointSet.Add(control.EndPoint);
3674
                                }
3675
                                else
3676
                                {
3677
                                    //20180906 LJY TEST IsRotationDrawingEnable
3678
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3679
                                    {
3680
                                        return;
3681
                                    }
3682

    
3683
                                    CreateCommand.Instance.Execute(currentControl);
3684

    
3685
                                    control.isTransOn = true;
3686
                                    var firstPoint = control.PointSet.First();
3687

    
3688
                                    control.PointSet.Add(firstPoint);
3689
                                    control.DrawingCloud();
3690
                                    control.ApplyOverViewData();
3691

    
3692
                                    currentControl = null;
3693
                                }
3694
                            }
3695
                            else
3696
                            {
3697
                                if (e.LeftButton == MouseButtonState.Pressed)
3698
                                {
3699
                                    currentControl = new CloudControl
3700
                                    {
3701
                                        PointSet = new List<Point>(),
3702
                                        PointC = new StylusPointSet()
3703
                                    };
3704

    
3705
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3706
                                    //{
3707
                                    var polygonControl = (currentControl as CloudControl);
3708
                                    currentControl.CommentID = Commons.shortGuid();
3709
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3710
                                    currentControl.IsNew = true;
3711
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3712

    
3713
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3714
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3715

    
3716
                                    //}
3717
                                }
3718
                            }
3719
                        }
3720
                        break;
3721

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

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

    
3750
                                        Image img = new Image();
3751
                                        if (filename.Contains(".svg"))
3752
                                        {
3753
                                            SharpVectors.Converters.SvgImageExtension svgImage = new SharpVectors.Converters.SvgImageExtension(uri.Uri.ToString());
3754
                                            img.Source = (DrawingImage)svgImage.ProvideValue(null);
3755
                                        }
3756
                                        else
3757
                                        {
3758
                                            img.Source = new BitmapImage(uri.Uri);
3759
                                        }
3760

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

    
3774
                                        currentControl.CommentID = Commons.shortGuid();
3775
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3776
                                        currentControl.IsNew = true;
3777
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3778

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

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

    
3802
                                    CreateCommand.Instance.Execute(currentControl);
3803
                                    currentControl = null;
3804

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

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

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

    
3856
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3857
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3858

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

    
3871
                    case ControlType.TextBorder:
3872
                        {
3873
                            if (e.LeftButton == MouseButtonState.Pressed)
3874
                            {
3875
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3876
                                {
3877
                                    currentControl = new TextControl
3878
                                    {
3879
                                        ControlType = controlType
3880
                                    };
3881

    
3882
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3883
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3884
                                    currentControl.CommentID = Commons.shortGuid();
3885
                                    currentControl.IsNew = true;
3886
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3887
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3888
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3889
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3890

    
3891
                                    (currentControl as TextControl).ControlType_No = 1;
3892
                                    (currentControl as TextControl).CommentAngle = Ang;
3893
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3894
                                    (currentControl as TextControl).ApplyTemplate();
3895
                                    (currentControl as TextControl).Base_TextBox.Focus();
3896
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3897
                                    CreateCommand.Instance.Execute(currentControl);
3898
                                }
3899
                            }
3900
                        }
3901
                        break;
3902

    
3903
                    case ControlType.TextCloud:
3904
                        {
3905
                            if (e.LeftButton == MouseButtonState.Pressed)
3906
                            {
3907
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3908
                                {
3909
                                    currentControl = new TextControl
3910
                                    {
3911
                                        ControlType = controlType
3912
                                    };
3913

    
3914
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3915
                                    currentControl.CommentID = Commons.shortGuid();
3916
                                    currentControl.IsNew = true;
3917
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3918
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3919

    
3920
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3921
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3922
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3923

    
3924
                                    (currentControl as TextControl).CommentAngle = Ang;
3925
                                    (currentControl as TextControl).ControlType_No = 2;
3926
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3927
                                    (currentControl as TextControl).ApplyTemplate();
3928

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

    
3931
                                    (currentControl as TextControl).Base_TextBox.Focus();
3932
                                    CreateCommand.Instance.Execute(currentControl);
3933
                                    
3934
                                    //currentControl = null;
3935
                                }
3936
                            }
3937
                        }
3938
                        break;
3939

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

    
3952
                                    CreateCommand.Instance.Execute(currentControl);
3953

    
3954
                                    try
3955
                                    {
3956
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3957
                                        {
3958
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3959
                                        }
3960
                                    }
3961
                                    catch (Exception ex)
3962
                                    {
3963
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3964
                                    }
3965

    
3966
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3967
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3968
                                    (currentControl as ArrowTextControl).IsNew = false;
3969
                                    currentControl = null;
3970
                                }
3971
                                else
3972
                                {
3973
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3974
                                    //{
3975
                                    currentControl = new ArrowTextControl()
3976
                                    {
3977
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3978
                                    };
3979

    
3980
                                    currentControl.CommentID = Commons.shortGuid();
3981
                                    currentControl.IsNew = true;
3982
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3983

    
3984
                                    try
3985
                                    {
3986
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3987
                                    }
3988
                                    catch (Exception ex)
3989
                                    {
3990
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3991
                                    }
3992

    
3993
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3994
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3995
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3996
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3997
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3998

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

    
4002
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4003
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4004
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4005
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4006

    
4007
                                    //}
4008
                                }
4009
                            }
4010
                        }
4011
                        break;
4012

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

    
4025
                                    CreateCommand.Instance.Execute(currentControl);
4026

    
4027
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4028

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

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

    
4056
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4057
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4058
                                    (currentControl as ArrowTextControl).isTrans = true;
4059
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4060
                                }
4061
                            }
4062
                        }
4063
                        break;
4064

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

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

    
4097
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4098

    
4099
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4100

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

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

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

    
4150
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4151

    
4152
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4153
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4154
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4155
                                    (currentControl as ArrowTextControl).isFixed = true;
4156
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4157

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

    
4165
                                    //20180911 LJY
4166
                                    (currentControl as ArrowTextControl).isTrans = true;
4167

    
4168
                                    //}
4169
                                }
4170
                            }
4171
                        }
4172
                        break;
4173

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

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

    
4215
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4216
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4217
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4218
                                    //}
4219
                                }
4220
                            }
4221
                        }
4222
                        break;
4223

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

    
4257
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4258
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4259
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4260
                                    (currentControl as ArrowTextControl).isFixed = true;
4261
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4262

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

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

    
4286
                                if (_sign == null)
4287
                                {
4288
                                    txtBatch.Visibility = Visibility.Collapsed;
4289
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4290
                                    controlType = ControlType.None;
4291

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

    
4308
                                if (currentControl is SignControl)
4309
                                {
4310
                                    //20180906 LJY TEST IsRotationDrawingEnable
4311
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4312
                                    {
4313
                                        return;
4314
                                    }
4315

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

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

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

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

    
4363
                                    CreateCommand.Instance.Execute(currentControl);
4364
                                    (currentControl as RectangleControl).ApplyOverViewData();
4365
                                    currentControl = null;
4366

    
4367
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4368

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

    
4385
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4386
                                    currentControl.CommentID = Commons.shortGuid();
4387
                                    currentControl.IsNew = true;
4388
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4389
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4390
                                }
4391
                                //}
4392
                            }
4393
                        }
4394
                        break;
4395

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

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

    
4422
                                    currentControl.IsNew = true;
4423
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4424
                                    currentControl.CommentID = Commons.shortGuid();
4425
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4426

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

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

    
4449
                                    CreateCommand.Instance.Execute(currentControl);
4450
                                    currentControl = null;
4451

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

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

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

    
4504
                try
4505
                {
4506
                    if (currentControl is ITextControl)
4507
                    {
4508
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4509

    
4510
                        if(textBox.Count() > 0)
4511
                        {
4512
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4513
                            specialcharRemove.Attach(textBox.First());
4514
                        }
4515
                        else
4516
                        {
4517

    
4518
                        }
4519

    
4520
                    }
4521
                }
4522
                catch (Exception ex)
4523
                {
4524
                    System.Diagnostics.Debug.WriteLine(ex);
4525

    
4526
                }
4527

    
4528
                if (currentControl is ArrowTextControl)
4529
                {
4530
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4531
                    {
4532
                        var control = snd as ArrowTextControl;
4533

    
4534
                        if (string.IsNullOrEmpty(control.ArrowText))
4535
                        {
4536
                            DeleteCommand.Instance.Execute(new [] { control });
4537
                        }
4538
                    };
4539

    
4540
                }
4541

    
4542
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4543
                {
4544
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4545
                    {
4546
                        MacroHelper.MacroAction();
4547
                    }
4548
                    //if (currentControl.ControlType)
4549
                    //txtBatch.Text = "Draw a TextBox";
4550
                    //controlType = ControlType.ArrowTextBorderControl;
4551
                }
4552

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

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

    
4578
                    if (!mouseOff)
4579
                    {
4580
                        SelectionSet.Instance.UnSelect(this);
4581
                    }
4582
                }
4583
                zoomAndPanControl.CaptureMouse();
4584
                e.Handled = true;
4585
            }
4586
        }
4587

    
4588
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4589
        {
4590
            ///mouseButtonDown = e.ChangedButton;
4591
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4592
        }
4593

    
4594
        private void RemoveLineStroke(Point P)
4595
        {
4596
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4597
            if (control != null)
4598
            {
4599
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4600
            }
4601
        }
4602

    
4603
        private void RemovePointStroke(Point P)
4604
        {
4605
            foreach (Stroke hits in inkBoard.Strokes)
4606
            {
4607
                foreach (StylusPoint sty in hits.StylusPoints)
4608
                {
4609
                }
4610
                if (hits.HitTest(P))
4611
                {
4612
                    inkBoard.Strokes.Remove(hits);
4613
                    return;
4614
                }
4615
            }
4616
        }
4617

    
4618
        private void StartNewStroke(Point P)
4619
        {
4620
            strokePoints = new StylusPointCollection();
4621
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4622
            strokePoints.Add(segment1Start);
4623
            stroke = new Stroke(strokePoints);
4624

    
4625
            stroke.DrawingAttributes.Color = Colors.Red;
4626
            stroke.DrawingAttributes.Width = 4;
4627
            stroke.DrawingAttributes.Height = 4;
4628

    
4629
            inkBoard.Strokes.Add(stroke);
4630
        }
4631

    
4632
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4633
        {
4634
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4635
            //// update mylist and gridview
4636
            //this.UpdateMyMarkupList();
4637

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

    
4640
            //if (result)
4641
            //{
4642
            btnFinalPDF.IsEnabled = false;
4643
            btnConsolidate.IsEnabled = false;
4644
            await  ConsolidationMethod();
4645
            //}
4646
            //else
4647
            //{
4648
            //    MessageBox.Show("오류");
4649
            //}
4650
        }
4651

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

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

    
4686
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4687
            }
4688
        }
4689
        public async void TeamConsolidationMethod()
4690
        {
4691
            bool result = false;
4692

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

    
4707
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4708

    
4709
                if (isSave)
4710
                {
4711
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4712

    
4713
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4714
                     
4715
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4716
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4717
                    {
4718
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4719
                    }
4720

    
4721
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4722
                    result = true;
4723
                }
4724
            }
4725
        }
4726

    
4727
        public async Task<bool> ConsolidationMethod()
4728
        {
4729
            bool result = false;
4730

    
4731
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4732
            {
4733
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4734
            }
4735
            else
4736
            {
4737
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4738

    
4739
                if (isSave)
4740
                {
4741
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4742
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4743

    
4744
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4745
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4746
                    {
4747
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4748
                    }
4749
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4750

    
4751
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4752
                }
4753
            }
4754

    
4755
            return result;
4756
        }
4757

    
4758
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4759
        {
4760
            if (App.ViewInfo != null)
4761
            {
4762
                btnConsolidate = (sender as RadRibbonButton);
4763
                if (!App.ViewInfo.NewCommentPermission)
4764
                {
4765
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4766
                }
4767
            }
4768
        }
4769

    
4770
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4771
        {
4772
            TeamConsolidationMethod();
4773
        }
4774

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

    
4787
                    if (!App.ViewInfo.NewCommentPermission)
4788
                    {
4789
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4790
                    }
4791
                }
4792
                else
4793
                {
4794
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4795
                }
4796
            }
4797
        }
4798

    
4799
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4800
        {
4801
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4802
            // update mylist and gridview
4803
            this.UpdateMyMarkupList();
4804

    
4805
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4806

    
4807
            if(!result)
4808
            {
4809

    
4810
            }
4811
            else
4812
            {
4813
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4814

    
4815
                if (item != null)
4816
                {
4817
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4818
                    {
4819
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4820

    
4821
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4822

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

    
4837
        }
4838

    
4839
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4840
        {
4841
            btnFinalPDF = sender as RadRibbonButton;
4842
            if (App.ViewInfo != null)
4843
            {
4844
                //btnFinalPDF.IsEnabled = false;
4845

    
4846
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4847
                {
4848
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4849
                    if (btnConsolidate != null)
4850
                    {
4851
                        btnConsolidate.Visibility = Visibility.Collapsed;
4852
                    }
4853
                }
4854
            }
4855
        }
4856

    
4857
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4858
        {
4859
            //UpdateMyMarkupList();
4860

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

    
4873
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4874
                //// update mylist and gridview
4875
                //this.UpdateMyMarkupList();
4876

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

    
4879
                Mouse.SetCursor(Cursors.Wait);
4880

    
4881
                bool result = await ConsolidationMethod();
4882

    
4883
                //System.Threading.Thread.Sleep(500);
4884

    
4885
                if (result)
4886
                {
4887
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4888

    
4889
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4890
                    if (item2 != null)
4891
                    {
4892
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4893
                        {
4894
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4895

    
4896
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4897
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4898

    
4899
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4900

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

    
4918
                Mouse.SetCursor(Cursors.Arrow);
4919
            }
4920
        }
4921

    
4922
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4923
        {
4924
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4925
#if Hyosung
4926
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4927
#else
4928

    
4929
            //btnConsolidateFinalPDF.IsEnabled = false;
4930

    
4931
            if (App.ViewInfo != null)
4932
            {
4933
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4934
                {
4935
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4936
                }
4937
            }
4938
#endif
4939
        }
4940

    
4941
        private void btnColorList_Click(object sender, RoutedEventArgs e)
4942
        {
4943

    
4944
        }
4945

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5148
        }
5149

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

    
5156
                var uri = CurrentRev.TO_VENDOR;
5157

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

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

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

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

    
5193
                ComparePageLoad(uri,false);
5194

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5301
                        gridViewHistory_Busy.IsBusy = false;
5302
                    }
5303

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5384
                    ComparePageLoad(uri,false);
5385

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

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

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

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

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

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

    
5466
        public int symbolselectindex = 0;
5467

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

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

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

    
5514
                                    System.Drawing.Bitmap image;
5515

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

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

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

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

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

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

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

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

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

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

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

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

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

    
5665
                List<SYMBOL_PUBLIC> symbol_Public;
5666

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

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

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

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

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

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

    
5737
            BitmapEncoder encoder = new PngBitmapEncoder();
5738

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

    
5741
            DrawingVisual dv = new DrawingVisual();
5742

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

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

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

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

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

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

    
5795
        #region 캡쳐 기능
5796

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

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

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

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

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

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

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

    
5835
            return pixels;
5836
        }
5837

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

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

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

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

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

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

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

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

    
5886
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5887

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

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

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

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

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

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

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

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

    
5990
        #endregion 캡쳐 기능
5991

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

    
5996
            multi_Undo_Data.Markup = control;
5997

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

    
6015
            return multi_Undo_Data;
6016
        }
6017

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

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

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

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

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

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

    
6089
            return false;
6090
        }
6091

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

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

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

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

    
6112
            ScaleImage(pageWidth, pageHeight);
6113
        }
6114

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

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

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

    
6135
            if (checkbox != null)
6136
            {
6137
                if (checkbox.IsChecked.GetValueOrDefault())
6138
                {
6139
                    gridViewMarkup.SelectAll();
6140
                }
6141
                else
6142
                {
6143
                    gridViewMarkup.UnselectAll();
6144
                }
6145
            }
6146
        }
6147

    
6148
        private void gridViewMarkup_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
6149
        {
6150
            var dataSet = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>();
6151

    
6152
            if (dataSet?.Count() == 1)
6153
            {
6154
                PopupWindow popup = new PopupWindow();
6155
                
6156
            }
6157
        }
6158

    
6159

    
6160
        /*
6161
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6162
        {
6163
            try
6164
            {
6165
                if (e.Data.GetDataPresent(typeof(string)))
6166
                {
6167
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6168
                    string dragData = e.Data.GetData(typeof(string)) as string;
6169
                    Move_Symbol(sender, dragData);
6170
                }
6171
            }
6172
            catch (Exception ex)
6173
            {
6174
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6175
            }
6176
        }
6177
        */
6178
    }
6179

    
6180
    public class testItem
6181
    {
6182
        public string Title { get; set; }
6183
    }
6184
}
클립보드 이미지 추가 (최대 크기: 500 MB)