프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (282 KB)

1
using IKCOM;
2
using KCOM.Common;
3
using KCOM.Controls;
4
using KCOM.Events;
5
using KCOMDataModel.DataModel;
6
using MarkupToPDF.Common;
7
using MarkupToPDF.Controls.Cad;
8
using MarkupToPDF.Controls.Common;
9
using MarkupToPDF.Controls.Etc;
10
using MarkupToPDF.Controls.Line;
11
using MarkupToPDF.Controls.Parsing;
12
using MarkupToPDF.Controls.Polygon;
13
using MarkupToPDF.Controls.Shape;
14
using MarkupToPDF.Controls.Text;
15
using Svg2Xaml;
16
using System;
17
using System.Collections.Generic;
18
using System.Diagnostics;
19
using System.Linq;
20
using System.Reflection;
21
using System.Runtime.InteropServices;
22
using System.Text;
23
using System.Threading;
24
using System.Threading.Tasks;
25
using System.Web;
26
using System.Windows;
27
using System.Windows.Controls;
28
using System.Windows.Ink;
29
using System.Windows.Input;
30
using System.Windows.Media;
31
using System.Windows.Media.Imaging;
32
using System.Windows.Shapes;
33
using System.Windows.Threading;
34
using Telerik.Windows.Controls;
35
using Telerik.Windows.Data;
36
using static KCOM.TempFile;
37

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

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

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

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

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

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

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

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

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

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

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

    
120
        private BitmapFrame tempPageImage =null;  
121

    
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
                App.splashString(ISplashMessage.MAINMENU_1);
497
                this.pageNavigator.ThumbInitialized += pageNavigator_ThumbInitialized;
498
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
499
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
500

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

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

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

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

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

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

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

    
552
        string instnaceFile;
553
        string downloadurl;
554

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

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

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

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

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

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

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

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

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

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

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

    
651
            /// up to here
652

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
735
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
736

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

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

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

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

    
751
            ScaleImage(pageWidth, pageHeight);
752

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

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

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

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

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

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

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

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

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

    
810
            SearchFocusBorder.Visibility = Visibility.Collapsed;
811

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

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

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

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

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

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

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

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

    
871
            var instanceMain = ViewerDataModel.Instance.SystemMain;
872

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

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

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

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

    
886
            pageNavigator.LoadMakupList();
887

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

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

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

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

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

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

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

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

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

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

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

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

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

    
929
            //multi_Undo_Data = new Multi_Undo_data();
930

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1005
            return result;
1006
        }
1007

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

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

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

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

    
1048
            return result;
1049
        }
1050

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

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

    
1059
                double startPositionX = parentRect.X;
1060

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

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

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

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

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

    
1114
            return result;
1115
        }
1116

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1197
            SetCommentPages(cts);
1198
        }
1199

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

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

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

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

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

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

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

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

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

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

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

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

    
1324
                //        pageNavigator.PageChanged += handler;
1325

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

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

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

    
1362
        #region ZoomIn & ZoomOut
1363

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

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

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

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

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

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

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

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

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

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

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

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

    
1464
        #endregion ZoomIn & ZoomOut
1465

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

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

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

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

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

    
1522
        #region 컨트롤 초기화
1523

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1632
        #endregion 컨트롤 초기화
1633

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

    
1639
        //private Window _dragdropWindow = null;
1640

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

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

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

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

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

    
1675
               CreateDragDropWindow2(img);
1676
    }
1677

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

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

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

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

    
1707
         */
1708

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

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

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

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

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

    
1735
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1736

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

    
1743
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1744

    
1745
                MoveZoomAndPanControl(dragOffset);
1746
            }
1747

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2082
                        default:
2083
                            break;
2084
                    }
2085

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

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

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

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

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

    
2147
                    e.Handled = true;
2148
                }
2149

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

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

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

    
2202
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2203

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

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

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

    
2217
        private EllipseGeometry hitArea = new EllipseGeometry();
2218

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

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

    
2229
                    SetCursor();
2230

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

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

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

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

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

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

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

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

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

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

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

    
2320
                zoomAndPanControl.ReleaseMouseCapture();
2321

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

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

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

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

    
2347
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2348

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

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

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

    
2379
            //GC.Collect();
2380

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2557
            zoomAndPanControl.RotationAngle = rotate.Angle;
2558

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

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

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

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

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

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

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

    
2626
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2627
                //{
2628
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2629
                //    STATE = 0,
2630
                //};
2631
                if (Data_ != null)
2632
                {
2633
                    Image img = new Image();
2634
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2635
                    if (Data_.Contains(".svg"))
2636
                    {
2637
                        byte[] imageData = null;
2638
                        DrawingImage image = null;
2639
                        using (System.Net.WebClient web = new System.Net.WebClient())
2640
                        {
2641
                            imageData = web.DownloadData(new Uri(Data_));
2642
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2643
                            image = SvgReader.Load(stream);
2644
                        }
2645
                        img.Source = image;
2646
                    }
2647
                    else
2648
                    {
2649
                        img.Source = new BitmapImage(new Uri(Data_));
2650
                    }
2651

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

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

    
2686
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2687
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2688
                    UndoData.Markup_List.Add(multi_Undo_Data);
2689
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2690

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

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

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

    
2720
            ConvertInkControlToPolygon();
2721

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

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

    
2732
            /// up to here
2733

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

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

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

    
2766
            double Ang = 0;
2767
            if (rotate.Angle != 0)
2768
            {
2769
                Ang = 360 - rotate.Angle;
2770
            }
2771

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

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

    
2797
            if (e.LeftButton == MouseButtonState.Pressed)
2798
            {
2799
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2800
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2801

    
2802
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2803
                SetCursor();
2804

    
2805
                if (!ViewerDataModel.Instance.IsPressCtrl)
2806
                {
2807
                    SelectionSet.Instance.UnSelect(this);
2808
                }
2809
            }
2810

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

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

    
2840
            bool isArrowTextEdit = false;
2841

    
2842
            if (currentControl is ArrowTextControl textControl)
2843
            {
2844
                if (textControl.IsEditingMode)
2845
                    isArrowTextEdit = true;
2846
            }
2847

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

    
2858
                    if (controlType == ControlType.None)
2859
                    {
2860
                        isLeftMouseButtonDownOnWindow = true;
2861
                    }
2862
                }
2863

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

    
2871
                /// 줌 모드 설정
2872
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2873
                {
2874
                    isLeftMouseButtonDownOnWindow = true;
2875
                }
2876

    
2877
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2878

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

    
2890
                    AdornerFinal final = null;
2891

    
2892
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2893
                    {
2894
                        /// 기존 selection 해제
2895
                        SelectionSet.Instance.UnSelect(this);
2896

    
2897
                        final = new AdornerFinal(control);
2898

    
2899
                        this.Control_Style(control);
2900

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

    
2926
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2927

    
2928
                        if ((control as TextControl) != null)
2929
                        {
2930
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2931

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

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

    
3013
                        Control_Style(control);
3014

    
3015
                        final = new AdornerFinal(comment);
3016
                    }
3017

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

    
3027

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

    
3077
                                    CreateCommand.Instance.Execute(currentControl);
3078

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

    
3102
                                        currentControl.CommentID = Commons.shortGuid();
3103
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3104
                                        currentControl.IsNew = true;
3105

    
3106
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3107

    
3108
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3109
                                    }
3110
                                }
3111
                            }
3112
                        }
3113
                        break;
3114

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

    
3126
                                    CreateCommand.Instance.Execute(currentControl);
3127

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

    
3140
                                    currentControl.CommentID = Commons.shortGuid();
3141
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3142
                                    currentControl.IsNew = true;
3143
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3144

    
3145
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3146
                                }
3147
                            }
3148
                        }
3149
                        break;
3150

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

    
3162
                                    CreateCommand.Instance.Execute(currentControl);
3163

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

    
3176
                                    currentControl.CommentID = Commons.shortGuid();
3177
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3178
                                    currentControl.IsNew = true;
3179
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3180

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

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

    
3198
                                    CreateCommand.Instance.Execute(currentControl);
3199

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

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

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

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

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

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

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

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

    
3271
                                    CreateCommand.Instance.Execute(currentControl);
3272

    
3273
                                    currentControl = null;
3274

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

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

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

    
3307
                                    CreateCommand.Instance.Execute(currentControl);
3308

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

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

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

    
3348
                                        CreateCommand.Instance.Execute(currentControl);
3349

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

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

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

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

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

    
3409
                    case ControlType.PolygonControl:
3410
                        {
3411
                            if (currentControl is PolygonControl)
3412
                            {
3413
                                var control = currentControl as PolygonControl;
3414

    
3415
                                if (e.RightButton == MouseButtonState.Pressed)
3416
                                {
3417
                                    control.IsCompleted = true;
3418
                                }
3419

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

    
3432
                                    var firstPoint = control.PointSet.First();
3433
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3434
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3435
                                    control.PointSet.Add(firstPoint);
3436

    
3437
                                    control.ApplyOverViewData();
3438

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

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

    
3469
                    case ControlType.ChainLine:
3470
                        {
3471
                            if (currentControl is PolygonControl)
3472
                            {
3473
                                var control = currentControl as PolygonControl;
3474

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

    
3483
                                    CreateCommand.Instance.Execute(currentControl);
3484

    
3485
                                    currentControl = null;
3486
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3487
                                    return;
3488
                                }
3489

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

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

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

    
3541
                                    CreateCommand.Instance.Execute(currentControl);
3542

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

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

    
3585
                                    CreateCommand.Instance.Execute(currentControl);
3586

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

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

    
3645
                                        CreateCommand.Instance.Execute(currentControl);
3646

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

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

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

    
3691
                                    CreateCommand.Instance.Execute(currentControl);
3692

    
3693
                                    control.isTransOn = true;
3694
                                    var firstPoint = control.PointSet.First();
3695

    
3696
                                    control.PointSet.Add(firstPoint);
3697
                                    control.DrawingCloud();
3698
                                    control.ApplyOverViewData();
3699

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

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

    
3721
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3722
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3723

    
3724
                                    //}
3725
                                }
3726
                            }
3727
                        }
3728
                        break;
3729

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

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

    
3758
                                        Image img = new Image();
3759
                                        if (filename.Contains(".svg"))
3760
                                        {
3761
                                            byte[] imageData = null;
3762
                                            DrawingImage image = null;
3763
                                            using (System.Net.WebClient web = new System.Net.WebClient())
3764
                                            {
3765
                                                imageData = web.DownloadData(uri.Uri);
3766
                                                System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3767
                                                image = SvgReader.Load(stream);
3768
                                            }
3769
                                            img.Source = image;
3770
                                        }
3771
                                        else
3772
                                        {
3773
                                            img.Source = new BitmapImage(uri.Uri);
3774
                                        }
3775

    
3776
                                        currentControl = new ImgControl
3777
                                        {
3778
                                            Background = new SolidColorBrush(Colors.Black),
3779
                                            PointSet = new List<Point>(),
3780
                                            FilePath = uri.Uri.ToString(),
3781
                                            ImageData = img.Source,
3782
                                            StartPoint = CanvasDrawingMouseDownPoint,
3783
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3784
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3785
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3786
                                            ControlType = ControlType.ImgControl
3787
                                        };
3788

    
3789
                                        currentControl.CommentID = Commons.shortGuid();
3790
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3791
                                        currentControl.IsNew = true;
3792
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3793

    
3794
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3795
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3796
                                    }
3797
                                }
3798
                                //}
3799
                            }
3800
                        }
3801
                        break;
3802

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

    
3817
                                    CreateCommand.Instance.Execute(currentControl);
3818
                                    currentControl = null;
3819

    
3820
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3821
                                    { 
3822
                                        controlType = ControlType.None;
3823
                                        IsSwingMode = false;
3824
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3825
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3826
                                        mouseHandlingMode = MouseHandlingMode.None;
3827
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3828
                                        txtBatch.Visibility = Visibility.Collapsed;
3829
                                    }
3830
                                }
3831
                                else
3832
                                {
3833
                                    currentControl = new DateControl
3834
                                    {
3835
                                        StartPoint = CanvasDrawingMouseDownPoint,
3836
                                        Background = new SolidColorBrush(Colors.Black)
3837
                                    };
3838
                                    currentControl.CommentID = Commons.shortGuid();
3839
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3840
                                    currentControl.IsNew = true;
3841
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3842

    
3843
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3844
                                    if (currentControl is ImgControl)
3845
                                    {
3846
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3847
                                    }
3848
                                }
3849
                                //}
3850
                            }
3851
                        }
3852
                        break;
3853

    
3854
                    case ControlType.TextControl:
3855
                        {
3856
                            if (e.LeftButton == MouseButtonState.Pressed)
3857
                            {
3858
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3859
                                {
3860
                                    currentControl = new TextControl
3861
                                    {
3862
                                        ControlType = controlType
3863
                                    };
3864
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3865
                                    currentControl.CommentID = Commons.shortGuid();
3866
                                    currentControl.IsNew = true;
3867
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3868
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3869
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3870

    
3871
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3872
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3873

    
3874
                                    (currentControl as TextControl).ControlType_No = 0;
3875
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3876
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3877
                                    (currentControl as TextControl).ApplyTemplate();
3878
                                    (currentControl as TextControl).Base_TextBox.Focus();
3879
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3880
                                    CreateCommand.Instance.Execute(currentControl);
3881
                                }
3882
                            }
3883
                        }
3884
                        break;
3885

    
3886
                    case ControlType.TextBorder:
3887
                        {
3888
                            if (e.LeftButton == MouseButtonState.Pressed)
3889
                            {
3890
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3891
                                {
3892
                                    currentControl = new TextControl
3893
                                    {
3894
                                        ControlType = controlType
3895
                                    };
3896

    
3897
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3898
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3899
                                    currentControl.CommentID = Commons.shortGuid();
3900
                                    currentControl.IsNew = true;
3901
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3902
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3903
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3904
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3905

    
3906
                                    (currentControl as TextControl).ControlType_No = 1;
3907
                                    (currentControl as TextControl).CommentAngle = Ang;
3908
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3909
                                    (currentControl as TextControl).ApplyTemplate();
3910
                                    (currentControl as TextControl).Base_TextBox.Focus();
3911
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3912
                                    CreateCommand.Instance.Execute(currentControl);
3913
                                }
3914
                            }
3915
                        }
3916
                        break;
3917

    
3918
                    case ControlType.TextCloud:
3919
                        {
3920
                            if (e.LeftButton == MouseButtonState.Pressed)
3921
                            {
3922
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3923
                                {
3924
                                    currentControl = new TextControl
3925
                                    {
3926
                                        ControlType = controlType
3927
                                    };
3928

    
3929
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3930
                                    currentControl.CommentID = Commons.shortGuid();
3931
                                    currentControl.IsNew = true;
3932
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3933
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3934

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

    
3939
                                    (currentControl as TextControl).CommentAngle = Ang;
3940
                                    (currentControl as TextControl).ControlType_No = 2;
3941
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3942
                                    (currentControl as TextControl).ApplyTemplate();
3943

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

    
3946
                                    (currentControl as TextControl).Base_TextBox.Focus();
3947
                                    CreateCommand.Instance.Execute(currentControl);
3948
                                    
3949
                                    //currentControl = null;
3950
                                }
3951
                            }
3952
                        }
3953
                        break;
3954

    
3955
                    case ControlType.ArrowTextControl:
3956
                        {
3957
                            if (e.LeftButton == MouseButtonState.Pressed)
3958
                            {
3959
                                if (currentControl is ArrowTextControl)
3960
                                {
3961
                                    //20180906 LJY TEST IsRotationDrawingEnable
3962
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3963
                                    {
3964
                                        return;
3965
                                    }
3966

    
3967
                                    CreateCommand.Instance.Execute(currentControl);
3968

    
3969
                                    try
3970
                                    {
3971
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3972
                                        {
3973
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3974
                                        }
3975
                                    }
3976
                                    catch (Exception ex)
3977
                                    {
3978
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3979
                                    }
3980

    
3981
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3982
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3983
                                    (currentControl as ArrowTextControl).IsNew = false;
3984
                                    currentControl = null;
3985
                                }
3986
                                else
3987
                                {
3988
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3989
                                    //{
3990
                                    currentControl = new ArrowTextControl()
3991
                                    {
3992
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3993
                                    };
3994

    
3995
                                    currentControl.CommentID = Commons.shortGuid();
3996
                                    currentControl.IsNew = true;
3997
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3998

    
3999
                                    try
4000
                                    {
4001
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4002
                                    }
4003
                                    catch (Exception ex)
4004
                                    {
4005
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
4006
                                    }
4007

    
4008
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4009
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4010
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4011
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4012
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4013

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

    
4017
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4018
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4019
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4020
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4021

    
4022
                                    //}
4023
                                }
4024
                            }
4025
                        }
4026
                        break;
4027

    
4028
                    case ControlType.ArrowTransTextControl:
4029
                        {
4030
                            if (e.LeftButton == MouseButtonState.Pressed)
4031
                            {
4032
                                if (currentControl is ArrowTextControl)
4033
                                {
4034
                                    //20180906 LJY TEST IsRotationDrawingEnable
4035
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4036
                                    {
4037
                                        return;
4038
                                    }
4039

    
4040
                                    CreateCommand.Instance.Execute(currentControl);
4041

    
4042
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4043

    
4044
                                    currentControl.IsNew = false;
4045
                                    currentControl = null;
4046
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4047
                                }
4048
                                else
4049
                                {
4050
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4051
                                    //{
4052
                                    currentControl = new ArrowTextControl()
4053
                                    {
4054
                                        ControlType = ControlType.ArrowTransTextControl,
4055
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4056
                                    };
4057
                                    currentControl.CommentID = Commons.shortGuid();
4058
                                    currentControl.IsNew = true;
4059
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4060
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4061
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4062
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4063
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4064
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4065
                                    (currentControl as ArrowTextControl).isFixed = true;
4066
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4067

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

    
4071
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4072
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4073
                                    (currentControl as ArrowTextControl).isTrans = true;
4074
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4075
                                }
4076
                            }
4077
                        }
4078
                        break;
4079

    
4080
                    case ControlType.ArrowTextBorderControl:
4081
                        {
4082
                            if (e.LeftButton == MouseButtonState.Pressed)
4083
                            {
4084
                                if (currentControl is ArrowTextControl)
4085
                                {
4086
                                    //20180906 LJY TEST IsRotationDrawingEnable
4087
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4088
                                    {
4089
                                        return;
4090
                                    }
4091

    
4092
                                    CreateCommand.Instance.Execute(currentControl);
4093
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4094
                                    currentControl.IsNew = false;
4095
                                    currentControl = null;
4096
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4097
                                }
4098
                                else
4099
                                {
4100
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4101
                                    //{
4102
                                    currentControl = new ArrowTextControl()
4103
                                    {
4104
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4105
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4106
                                    };
4107
                                    currentControl.CommentID = Commons.shortGuid();
4108
                                    currentControl.IsNew = true;
4109
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4110
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4111

    
4112
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4113

    
4114
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4115

    
4116
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4117
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4118
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4119
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4120
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4121
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4122
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4123
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4124
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4125
                                    //}
4126
                                }
4127
                            }
4128
                        }
4129
                        break;
4130

    
4131
                    case ControlType.ArrowTransTextBorderControl:
4132
                        {
4133
                            if (e.LeftButton == MouseButtonState.Pressed)
4134
                            {
4135
                                if (currentControl is ArrowTextControl)
4136
                                {
4137
                                    //20180906 LJY TEST IsRotationDrawingEnable
4138
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4139
                                    {
4140
                                        return;
4141
                                    }
4142
                                    CreateCommand.Instance.Execute(currentControl);
4143
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4144
                                    currentControl.IsNew = false;
4145
                                    currentControl = null;
4146

    
4147
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4148
                                }
4149
                                else
4150
                                {
4151
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4152
                                    //{
4153
                                    currentControl = new ArrowTextControl()
4154
                                    {
4155
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4156
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4157
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4158
                                    };
4159
                                    
4160
                                    currentControl.CommentID = Commons.shortGuid();
4161
                                    currentControl.IsNew = true;
4162
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4163
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4164

    
4165
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4166

    
4167
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4168
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4169
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4170
                                    (currentControl as ArrowTextControl).isFixed = true;
4171
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4172

    
4173
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4174
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4175
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4176
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4177
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4178
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4179

    
4180
                                    //20180911 LJY
4181
                                    (currentControl as ArrowTextControl).isTrans = true;
4182

    
4183
                                    //}
4184
                                }
4185
                            }
4186
                        }
4187
                        break;
4188

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

    
4221
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4222
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4223
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4224
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4225
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4226
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4227
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4228
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4229

    
4230
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4231
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4232
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4233
                                    //}
4234
                                }
4235
                            }
4236
                        }
4237
                        break;
4238

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

    
4272
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4273
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4274
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4275
                                    (currentControl as ArrowTextControl).isFixed = true;
4276
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4277

    
4278
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4279
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4280
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4281
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4282
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4283
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4284

    
4285
                                    //20180911 LJY
4286
                                    (currentControl as ArrowTextControl).isTrans = true;
4287
                                    //}
4288
                                }
4289
                            }
4290
                        }
4291
                        break;
4292
                    //강인구 추가
4293
                    case ControlType.Sign:
4294
                        {
4295
                            if (e.LeftButton == MouseButtonState.Pressed)
4296
                            {
4297
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4298
                                //{
4299
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4300

    
4301
                                if (_sign == null)
4302
                                {
4303
                                    txtBatch.Visibility = Visibility.Collapsed;
4304
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4305
                                    controlType = ControlType.None;
4306

    
4307
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4308
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4309
                                    return;
4310
                                }
4311
                                else
4312
                                {
4313
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4314
                                    {
4315
                                        Application.Current.Resources.Add("UserSign", _sign);
4316
                                    }
4317
                                    else
4318
                                    {
4319
                                        Application.Current.Resources["UserSign"] = _sign;
4320
                                    }
4321
                                }
4322

    
4323
                                if (currentControl is SignControl)
4324
                                {
4325
                                    //20180906 LJY TEST IsRotationDrawingEnable
4326
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4327
                                    {
4328
                                        return;
4329
                                    }
4330

    
4331
                                    CreateCommand.Instance.Execute(currentControl);
4332
                                    currentControl = null;
4333
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4334
                                    {
4335
                                        txtBatch.Text = "Place Date";
4336
                                        controlType = ControlType.Date;
4337
                                    }
4338
                                }
4339
                                else
4340
                                {
4341
                                    currentControl = new SignControl
4342
                                    {
4343
                                        Background = new SolidColorBrush(Colors.Black),
4344
                                        UserNumber = App.ViewInfo.UserID,
4345
                                        ProjectNO = App.ViewInfo.ProjectNO,
4346
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4347
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4348
                                        ControlType = ControlType.Sign
4349
                                    };
4350

    
4351
                                    currentControl.CommentID = Commons.shortGuid();
4352
                                    currentControl.IsNew = true;
4353
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4354
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4355

    
4356
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4357
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4358
                                }
4359
                                //}
4360
                            }
4361
                        }
4362
                        break;
4363

    
4364
                    case ControlType.Mark:
4365
                        {
4366
                            if (e.LeftButton == MouseButtonState.Pressed)
4367
                            {
4368
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4369
                                //{
4370
                                if (currentControl is RectangleControl)
4371
                                {
4372
                                    //20180906 LJY TEST IsRotationDrawingEnable
4373
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4374
                                    {
4375
                                        return;
4376
                                    }
4377

    
4378
                                    CreateCommand.Instance.Execute(currentControl);
4379
                                    (currentControl as RectangleControl).ApplyOverViewData();
4380
                                    currentControl = null;
4381

    
4382
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4383

    
4384
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4385
                                    {
4386
                                        txtBatch.Text = "Place Signature";
4387
                                        controlType = ControlType.Sign;
4388
                                    }
4389
                                }
4390
                                else
4391
                                {
4392
                                    currentControl = new RectangleControl
4393
                                    {
4394
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4395
                                        Background = new SolidColorBrush(Colors.Black),
4396
                                        ControlType = ControlType.Mark,
4397
                                        Paint = PaintSet.Fill
4398
                                    };
4399

    
4400
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4401
                                    currentControl.CommentID = Commons.shortGuid();
4402
                                    currentControl.IsNew = true;
4403
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4404
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4405
                                }
4406
                                //}
4407
                            }
4408
                        }
4409
                        break;
4410

    
4411
                    case ControlType.Symbol:
4412
                        {
4413
                            if (e.LeftButton == MouseButtonState.Pressed)
4414
                            {
4415
                                if (currentControl is SymControl)
4416
                                {
4417
                                    //20180906 LJY TEST IsRotationDrawingEnable
4418
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4419
                                    {
4420
                                        return;
4421
                                    }
4422
                                    CreateCommand.Instance.Execute(currentControl);
4423
                                    currentControl = null;
4424

    
4425
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4426
                                }
4427
                                else
4428
                                {
4429
                                    currentControl = new SymControl
4430
                                    {
4431
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4432
                                        Background = new SolidColorBrush(Colors.Black),
4433
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4434
                                        ControlType = ControlType.Symbol
4435
                                    };
4436

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

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

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

    
4464
                                    CreateCommand.Instance.Execute(currentControl);
4465
                                    currentControl = null;
4466

    
4467
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4468
                                }
4469
                                else
4470
                                {
4471
                                    currentControl = new SymControlN
4472
                                    {
4473
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4474
                                        Background = new SolidColorBrush(Colors.Black),
4475
                                        STAMP = App.SystemInfo.STAMP,
4476
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4477
                                        ControlType = ControlType.Stamp
4478
                                    };
4479

    
4480
                                    currentControl.IsNew = true;
4481
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4482
                                    currentControl.CommentID = Commons.shortGuid();
4483
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4484
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4485
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4486
                                }
4487
                                //}
4488
                            }
4489
                        }
4490
                        break;
4491

    
4492
                    case ControlType.PenControl:
4493
                        {
4494
                            if (inkBoard.Tag.ToString() == "Ink")
4495
                            {
4496
                                inkBoard.IsEnabled = true;
4497
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4498
                            }
4499
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4500
                            {
4501
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4502
                            }
4503
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4504
                            {
4505
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4506
                            }
4507
                            IsDrawing = true;
4508
                            return;
4509
                        }
4510
                    default:
4511
                        if (currentControl != null)
4512
                        {
4513
                            currentControl.CommentID = null;
4514
                            currentControl.IsNew = false;
4515
                        }
4516
                        break;
4517
                }
4518

    
4519
                try
4520
                {
4521
                    if (currentControl is ITextControl)
4522
                    {
4523
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4524

    
4525
                        if(textBox.Count() > 0)
4526
                        {
4527
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4528
                            specialcharRemove.Attach(textBox.First());
4529
                        }
4530
                        else
4531
                        {
4532

    
4533
                        }
4534

    
4535
                    }
4536
                }
4537
                catch (Exception ex)
4538
                {
4539
                    System.Diagnostics.Debug.WriteLine(ex);
4540

    
4541
                }
4542

    
4543
                if (currentControl is ArrowTextControl)
4544
                {
4545
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4546
                    {
4547
                        var control = snd as ArrowTextControl;
4548

    
4549
                        if (string.IsNullOrEmpty(control.ArrowText))
4550
                        {
4551
                            DeleteCommand.Instance.Execute(new [] { control });
4552
                        }
4553
                    };
4554

    
4555
                }
4556

    
4557
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4558
                {
4559
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4560
                    {
4561
                        MacroHelper.MacroAction();
4562
                    }
4563
                    //if (currentControl.ControlType)
4564
                    //txtBatch.Text = "Draw a TextBox";
4565
                    //controlType = ControlType.ArrowTextBorderControl;
4566
                }
4567

    
4568
                //if (currentControl != null)
4569
                //{
4570
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4571
                //}
4572
            }
4573
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4574
            {
4575
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4576
             
4577

    
4578
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4579
                {
4580
                    bool mouseOff = false;
4581
                    foreach (var item in SelectLayer.Children)
4582
                    {
4583
                        if (item is AdornerFinal)
4584
                        {
4585
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4586
                            if (over != null)
4587
                            {
4588
                                mouseOff = true;
4589
                            }
4590
                        }
4591
                    }
4592

    
4593
                    if (!mouseOff)
4594
                    {
4595
                        SelectionSet.Instance.UnSelect(this);
4596
                    }
4597
                }
4598
                zoomAndPanControl.CaptureMouse();
4599
                e.Handled = true;
4600
            }
4601
        }
4602

    
4603
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4604
        {
4605
            ///mouseButtonDown = e.ChangedButton;
4606
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4607
        }
4608

    
4609
        private void RemoveLineStroke(Point P)
4610
        {
4611
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4612
            if (control != null)
4613
            {
4614
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4615
            }
4616
        }
4617

    
4618
        private void RemovePointStroke(Point P)
4619
        {
4620
            foreach (Stroke hits in inkBoard.Strokes)
4621
            {
4622
                foreach (StylusPoint sty in hits.StylusPoints)
4623
                {
4624
                }
4625
                if (hits.HitTest(P))
4626
                {
4627
                    inkBoard.Strokes.Remove(hits);
4628
                    return;
4629
                }
4630
            }
4631
        }
4632

    
4633
        private void StartNewStroke(Point P)
4634
        {
4635
            strokePoints = new StylusPointCollection();
4636
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4637
            strokePoints.Add(segment1Start);
4638
            stroke = new Stroke(strokePoints);
4639

    
4640
            stroke.DrawingAttributes.Color = Colors.Red;
4641
            stroke.DrawingAttributes.Width = 4;
4642
            stroke.DrawingAttributes.Height = 4;
4643

    
4644
            inkBoard.Strokes.Add(stroke);
4645
        }
4646

    
4647
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4648
        {
4649
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4650
            //// update mylist and gridview
4651
            //this.UpdateMyMarkupList();
4652

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

    
4655
            //if (result)
4656
            //{
4657
            btnFinalPDF.IsEnabled = false;
4658
            btnConsolidate.IsEnabled = false;
4659
            await  ConsolidationMethod();
4660
            //}
4661
            //else
4662
            //{
4663
            //    MessageBox.Show("오류");
4664
            //}
4665
        }
4666

    
4667
        /// <summary>
4668
        /// execute TeamConsolidationCommand
4669
        /// </summary>
4670
        public void TeamConsolidationMethod2()
4671
        {
4672
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4673
            {
4674
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4675
            }
4676
            else
4677
            {
4678

    
4679
                ViewerDataModel.Instance.IsConsolidate = true;
4680
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4681
                // update mylist and gridview
4682
        
4683
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4684
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4685
                ViewerDataModel.Instance.IsConsolidate = false;
4686
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4687
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4688
                {
4689
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4690
                    {
4691
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4692
                        return;
4693
                    }
4694
                }
4695
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4696
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4697
                {
4698
                    MarkupInfoList.Add(item);
4699
                }
4700

    
4701
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4702
            }
4703
        }
4704
        public async void TeamConsolidationMethod()
4705
        {
4706
            bool result = false;
4707

    
4708
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4709
            {
4710
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4711
            }
4712
            else
4713
            {
4714
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4715
                {
4716
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4717
                    {
4718
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4719
                    }
4720
                }
4721

    
4722
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4723

    
4724
                if (isSave)
4725
                {
4726
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4727

    
4728
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4729
                     
4730
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4731
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4732
                    {
4733
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4734
                    }
4735

    
4736
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4737
                    result = true;
4738
                }
4739
            }
4740
        }
4741

    
4742
        public async Task<bool> ConsolidationMethod()
4743
        {
4744
            bool result = false;
4745

    
4746
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4747
            {
4748
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4749
            }
4750
            else
4751
            {
4752
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4753

    
4754
                if (isSave)
4755
                {
4756
                    var token = ViewerDataModel.Instance.NewMarkupCancelToken();
4757
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4758

    
4759
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4760
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4761
                    {
4762
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4763
                    }
4764
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4765

    
4766
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4767
                }
4768
            }
4769

    
4770
            return result;
4771
        }
4772

    
4773
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4774
        {
4775
            if (App.ViewInfo != null)
4776
            {
4777
                btnConsolidate = (sender as RadRibbonButton);
4778
                if (!App.ViewInfo.NewCommentPermission)
4779
                {
4780
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4781
                }
4782
            }
4783
        }
4784

    
4785
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4786
        {
4787
            TeamConsolidationMethod();
4788
        }
4789

    
4790
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4791
        {
4792
            btnTeamConsolidate = sender as RadRibbonButton;
4793
            if (App.ViewInfo != null)
4794
            {
4795
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4796
                {
4797
                    if (btnConsolidate != null)
4798
                    {
4799
                        btnConsolidate.Visibility = Visibility.Collapsed;
4800
                    }
4801

    
4802
                    if (!App.ViewInfo.NewCommentPermission)
4803
                    {
4804
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4805
                    }
4806
                }
4807
                else
4808
                {
4809
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4810
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4811
                }
4812
            }
4813
        }
4814

    
4815
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4816
        {
4817
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4818
            // update mylist and gridview
4819
            this.UpdateMyMarkupList();
4820

    
4821
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4822

    
4823
            if(!result)
4824
            {
4825

    
4826
            }
4827
            else
4828
            {
4829
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4830

    
4831
                if (item != null)
4832
                {
4833
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4834
                    {
4835
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4836

    
4837
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4838

    
4839
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4840
                    }
4841
                    else
4842
                    {
4843
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4844
                    }
4845
                }
4846
                else
4847
                {
4848
                    //Consolidate 가 없는 경우
4849
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4850
                }
4851
            }
4852

    
4853
        }
4854

    
4855
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4856
        {
4857
            btnFinalPDF = sender as RadRibbonButton;
4858
            if (App.ViewInfo != null)
4859
            {
4860
                //btnFinalPDF.IsEnabled = false;
4861

    
4862
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4863
                {
4864
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4865
                    if (btnConsolidate != null)
4866
                    {
4867
                        btnConsolidate.Visibility = Visibility.Collapsed;
4868
                    }
4869
                }
4870
            }
4871
        }
4872

    
4873
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4874
        {
4875
            //UpdateMyMarkupList();
4876

    
4877
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4878
            {
4879
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4880
            }
4881
            else
4882
            {
4883
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4884
                //{
4885
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4886
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4887
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4888

    
4889
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4890
                //// update mylist and gridview
4891
                //this.UpdateMyMarkupList();
4892

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

    
4895
                Mouse.SetCursor(Cursors.Wait);
4896

    
4897
                bool result = await ConsolidationMethod();
4898

    
4899
                //System.Threading.Thread.Sleep(500);
4900

    
4901
                if (result)
4902
                {
4903
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4904

    
4905
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4906
                    if (item2 != null)
4907
                    {
4908
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4909
                        {
4910
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4911

    
4912
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4913
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4914

    
4915
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4916

    
4917
                            Mouse.SetCursor(Cursors.Arrow);
4918
                        }
4919
                        else
4920
                        {
4921
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4922
                        }
4923
                    }
4924
                    else
4925
                    {
4926
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4927
                    }
4928
                }
4929
                else
4930
                {
4931
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4932
                }
4933

    
4934
                Mouse.SetCursor(Cursors.Arrow);
4935
            }
4936
        }
4937

    
4938
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4939
        {
4940
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4941
#if Hyosung
4942
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4943
#else
4944

    
4945
            //btnConsolidateFinalPDF.IsEnabled = false;
4946

    
4947
            if (App.ViewInfo != null)
4948
            {
4949
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4950
                {
4951
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4952
                }
4953
            }
4954
#endif
4955
        }
4956

    
4957
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4958
        {
4959
            SetCompareRect();
4960
        }
4961

    
4962
        private void Sync_Click(object sender, RoutedEventArgs e)
4963
        {
4964
            if (Sync.IsChecked)
4965
            {
4966
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4967
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4968
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4969
            }
4970
        }
4971

    
4972
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4973
        {
4974
            if (UserList.IsChecked)
4975
            {
4976
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4977
            }
4978
            else
4979
            {
4980
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4981
            }
4982
        }
4983

    
4984
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4985
        {
4986
            if (BalanceMode.IsChecked)
4987
            {
4988
                ViewerDataModel.Instance.PageBalanceMode = true;
4989
            }
4990
            else
4991
            {
4992
                ViewerDataModel.Instance.PageBalanceMode = false;
4993
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4994
            }
4995
        }
4996

    
4997
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4998
        {
4999
            //초기화
5000
            testPanel2.IsHidden = true;
5001
            ViewerDataModel.Instance.PageBalanceMode = false;
5002
            ViewerDataModel.Instance.PageBalanceNumber = 0;
5003
            ViewerDataModel.Instance.SyncPageNumber = 0;
5004
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5005
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
5006
            UserList.IsChecked = false;
5007
            BalanceMode.IsChecked = false;
5008
        }
5009

    
5010
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
5011
        {
5012
            if ((sender as System.Windows.Controls.Control).Tag != null)
5013
            {
5014
                //Compare 초기화
5015
                CompareMode.IsChecked = false;
5016
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
5017
                
5018
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5019
                {
5020
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5021
                }
5022

    
5023
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
5024
                {
5025
                }
5026
                else
5027
                {
5028
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5029
                }
5030

    
5031
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5032
                {
5033
                }
5034
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5035
                {
5036
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5037
                }
5038

    
5039
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5040

    
5041
                if (!testPanel2.IsHidden)
5042
                {
5043
                    if (IsSyncPDFMode)
5044
                    {
5045
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5046
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5047

    
5048
                        if (pdfpath.IsDownloading)
5049
                        {
5050
                            pdfpath.DownloadCompleted += (ex, arg) =>
5051
                            {
5052
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5053
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5054
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5055
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5056
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5057
                            };
5058
                        }
5059
                        else
5060
                        {
5061
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5062
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5063
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5064

    
5065
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5066
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5067
                        }
5068
                    }
5069
                    else
5070
                    {
5071
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5072

    
5073
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5074
                        ComparePageLoad(uri, isOriginalSize);
5075
                    }
5076
                   
5077
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5078
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5079
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5080

    
5081
                    foreach (var item in gridSelectionRevItem)
5082
                    {
5083
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5084
                        foreach (var markupitem in markupitems)
5085
                        {
5086
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5087
                        }
5088
                    }
5089

    
5090
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5091
                }
5092
            }
5093
        }
5094

    
5095
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5096
        {
5097
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5098

    
5099
            double translateX = 0;
5100
            double translateY = 0;
5101
            double angle = rotate2.Angle;
5102

    
5103
            if (direction == 1)
5104
            {
5105
                if (angle < 270)
5106
                {
5107
                    angle += 90;
5108
                }
5109
                else
5110
                {
5111
                    angle = 0;
5112
                }
5113
            }
5114
            else
5115
            {
5116
                if (angle > 0)
5117
                {
5118
                    angle -= 90;
5119
                }
5120
                else
5121
                {
5122
                    angle = 270;
5123
                }
5124
            }
5125
            zoomAndPanControl2.RotationAngle = angle;
5126
            zoomAndPanControl2.ScaleToFit();
5127

    
5128
            //if (angle == 90 || angle == 270)
5129
            //{
5130
                double emptySize = zoomAndPanCanvas2.Width;
5131
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5132
                zoomAndPanCanvas2.Height = emptySize;
5133
            //}
5134

    
5135
            if (angle == 90)
5136
            {
5137
                translateX = zoomAndPanCanvas2.Width;
5138
                translateY = 0;
5139
            }
5140
            else if (angle == 180)
5141
            {
5142
                translateX = zoomAndPanCanvas2.Width;
5143
                translateY = zoomAndPanCanvas2.Height;
5144
            }
5145
            else if (angle == 270)
5146
            {
5147
                translateX = 0;
5148
                translateY = zoomAndPanCanvas2.Height;
5149
            }
5150
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5151
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5152
            translate2.X = translateX;
5153
            translate2.Y = translateY;
5154
            rotate2.Angle = angle;
5155
            //translate2CompareBorder.X = translateX;
5156
            //translate2CompareBorder.Y = translateY;
5157
            //rotate2CompareBorder.Angle = angle;
5158

    
5159
        }
5160

    
5161
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5162
        {
5163
            if (MarkupMode.IsChecked)
5164
            {
5165
                IsSyncPDFMode = true;
5166

    
5167
                var uri = CurrentRev.TO_VENDOR;
5168

    
5169
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5170
                {
5171
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5172
                }
5173

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

    
5178
                if (pdfpath.IsDownloading)
5179
                {
5180
                    pdfpath.DownloadCompleted += (ex, arg) =>
5181
                    {
5182
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5183
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5184
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5185
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5186
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5187
                    };
5188
                }
5189
                else
5190
                {
5191
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5192
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5193
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5194

    
5195
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5196
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5197
                }
5198
            }
5199
            else
5200
            {
5201
                IsSyncPDFMode = false;
5202
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5203

    
5204
                ComparePageLoad(uri,false);
5205

    
5206
                zoomAndPanControl2.ApplyTemplate();
5207
                zoomAndPanControl2.UpdateLayout();
5208
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5209
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5210
            }
5211
        }
5212

    
5213
        /// <summary>
5214
        /// Compare된 영역을 초기화
5215
        /// </summary>
5216
        private void ClearCompareRect()
5217
        {
5218
            da.From = 1;
5219
            da.To = 1;
5220
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5221
            da.AutoReverse = false;
5222
            canvas_compareBorder.Children.Clear();
5223
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5224
        }
5225

    
5226
        /// <summary>
5227
        /// 문서 Comprare
5228
        /// </summary>
5229
        private void SetCompareRect()
5230
        {
5231
            canvas_compareBorder.Children.Clear();
5232

    
5233
            if (CompareMode.IsChecked)
5234
            {
5235
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5236
                {
5237
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5238
                }
5239
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5240
                {
5241
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5242
                }
5243

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

    
5246
                /// 비교대상원본, 비교할 대상
5247
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5248
            }
5249
            else
5250
            {
5251
                canvas_compareBorder.Visibility = Visibility.Hidden;
5252
                ClearCompareRect();
5253
            }
5254
        }
5255

    
5256
        private void btnSync_Click(object sender, RoutedEventArgs e)
5257
        {
5258
            gridViewHistory_Busy.IsBusy = true;
5259

    
5260
            RadButton instance = sender as RadButton;
5261
            if (instance.CommandParameter != null)
5262
            {
5263
                CurrentRev = instance.CommandParameter as VPRevision;
5264
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5265

    
5266
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5267
                {
5268
                    if (ea.Error == null && ea.Result != null)
5269
                    {
5270
                        testPanel2.IsHidden = false;
5271

    
5272
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5273
                        foreach (var info in ea.Result)
5274
                        {
5275
                            if (info.UserID == App.ViewInfo.UserID)
5276
                            {
5277
                                info.userDelete = true;
5278
                                info.DisplayColor = "#FFFF0000";
5279
                            }
5280
                            else
5281
                            {
5282
                                info.userDelete = false;
5283
                            }
5284
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5285
                        }
5286
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5287

    
5288
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5289
                        ComparePageLoad(uri,false);
5290

    
5291
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5292

    
5293
                        zoomAndPanControl2.ApplyTemplate();
5294
                        zoomAndPanControl2.UpdateLayout();
5295

    
5296
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5297
                        {
5298
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5299
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5300
                        }
5301

    
5302
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5303
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5304
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5305

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

    
5309
                        zoomAndPanControl.ScaleToFit();
5310
                        zoomAndPanControl2.ScaleToFit();
5311

    
5312
                        gridViewHistory_Busy.IsBusy = false;
5313
                    }
5314

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

    
5317
                    if (GetSyncMarkupInfoItemshandler != null)
5318
                    {
5319
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5320
                    }
5321

    
5322
                    //ClearCompareRect();
5323
                    SetCompareRect();
5324
                };
5325

    
5326
                /// 중복 실행이 발생하여 수정함.
5327
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5328
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5329

    
5330
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5331
            }
5332
        }
5333

    
5334
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5335
        {
5336
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5337
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5338

    
5339
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5340
        }
5341

    
5342
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5343
        {
5344
            try
5345
            {
5346
                if (sender is RadButton)
5347
                {
5348
                    if ((sender as RadButton).Tag != null)
5349
                    {
5350
                        var url = (sender as RadButton).Tag.ToString();
5351
                        System.Diagnostics.Process.Start(url);
5352
                    }
5353
                    else
5354
                    {
5355
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5356
                    }
5357
                }
5358
            }
5359
            catch (Exception ex)
5360
            {
5361
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5362
            }
5363
        }
5364

    
5365
        public void Sync_Event(VPRevision Currnet_Rev)
5366
        {
5367
            CurrentRev = Currnet_Rev;
5368

    
5369
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5370
            {
5371
                if (ea.Error == null && ea.Result != null)
5372
                {
5373
                    testPanel2.IsHidden = false;
5374

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

    
5391
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5392

    
5393
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5394

    
5395
                    ComparePageLoad(uri,false);
5396

    
5397
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5398
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5399
                    zoomAndPanControl2.ApplyTemplate();
5400
                    zoomAndPanControl2.UpdateLayout();
5401

    
5402
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5403
                    {
5404
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5405
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5406
                    }
5407
                    //}
5408
                    
5409
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5410
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5411
                    gridViewHistory_Busy.IsBusy = false;
5412
                }
5413
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5414
            };
5415
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5416
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5417
        }
5418

    
5419
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5420
        {
5421
            if (sender is Image)
5422
            {
5423
                if ((sender as Image).Tag != null)
5424
                {
5425
                    var pdfUrl = (sender as Image).Tag.ToString();
5426
                    System.Diagnostics.Process.Start(pdfUrl);
5427
                }
5428
                else
5429
                {
5430
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5431
                }
5432
            }
5433
        }
5434

    
5435
        private void Create_Symbol(object sender, RoutedEventArgs e)
5436
        {
5437
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5438

    
5439
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5440
            {
5441
                DialogMessage_Alert("Please Select Controls", "Alert");
5442
            }
5443
            else //선택된 것이 있으면
5444
            {
5445
                string MarkupData = "";
5446
                adorner_ = new AdornerFinal();
5447

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

    
5477
        public int symbolselectindex = 0;
5478

    
5479
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5480
        {
5481
            //Save save = new Save();
5482
            try
5483
            {
5484
                string svgfilename = null;
5485
                if (symbolname != null)
5486
                {
5487
                    if (symbolpng == true || symbolsvg == true)
5488
                    {
5489
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5490
                        string guid = Commons.shortGuid();
5491

    
5492
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5493
                        //Check_Uri.UriCheck();
5494
                        fileUploader.RunCompleted += (ex, arg) =>
5495
                        {
5496
                            filename = arg.Result;
5497
                            if (symbolpng == true)
5498
                            {
5499
                                if (filename != null)
5500
                                {
5501
                                    if (symbolselectindex == 0)
5502
                                    {
5503
                                        SymbolSave(symbolname, filename, data);
5504
                                    }
5505
                                    else
5506
                                    {
5507
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5508
                                    }
5509
                                    DataBind();
5510
                                }
5511
                            }
5512

    
5513
                            if (symbolsvg == true)
5514
                            {
5515
                                try
5516
                                {
5517
                                    var defaultBitmapImage = new BitmapImage();
5518
                                    defaultBitmapImage.BeginInit();
5519
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5520
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5521
                                    Check_Uri.UriCheck(filename);
5522
                                    defaultBitmapImage.UriSource = new Uri(filename);
5523
                                    defaultBitmapImage.EndInit();
5524

    
5525
                                    System.Drawing.Bitmap image;
5526

    
5527
                                    if (defaultBitmapImage.IsDownloading)
5528
                                    {
5529
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5530
                                        {
5531
                                            defaultBitmapImage.Freeze();
5532
                                            image = GetBitmap(defaultBitmapImage);
5533
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5534
                                            Process potrace = new Process
5535
                                            {
5536
                                                StartInfo = new ProcessStartInfo
5537
                                                {
5538
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5539
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5540
                                                    RedirectStandardInput = true,
5541
                                                    RedirectStandardOutput = true,
5542
                                                    RedirectStandardError = true,
5543
                                                    UseShellExecute = false,
5544
                                                    CreateNoWindow = true,
5545
                                                    WindowStyle = ProcessWindowStyle.Hidden
5546
                                                },
5547
                                            };
5548

    
5549
                                            StringBuilder svgBuilder = new StringBuilder();
5550
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5551
                                            {
5552
                                                svgBuilder.AppendLine(e2.Data);
5553
                                            };
5554

    
5555
                                            potrace.EnableRaisingEvents = true;
5556
                                            potrace.Start();
5557
                                            potrace.Exited += (sender, e) =>
5558
                                            {
5559
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5560
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5561
                                                Check_Uri.UriCheck(svgfilename);
5562
                                                if (symbolselectindex == 0)
5563
                                                {
5564
                                                    SymbolSave(symbolname, svgfilename, data);
5565
                                                }
5566
                                                else
5567
                                                {
5568
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5569
                                                }
5570

    
5571
                                                DataBind();
5572
                                            };
5573
                                            potrace.WaitForExit();
5574
                                        };
5575
                                    }
5576
                                    else
5577
                                    {
5578
                                        //GC.Collect();
5579
                                    }
5580
                                }
5581
                                catch (Exception ee)
5582
                                {
5583
                                    DialogMessage_Alert("" + ee, "Alert");
5584
                                }
5585
                            }
5586
                        };
5587
                    }
5588
                }
5589
            }
5590
            catch (Exception e)
5591
            {
5592
                //DialogMessage_Alert(e + "", "Alert");
5593
            }
5594
        }
5595

    
5596
        public void SymbolSave(string Name, string Url, string Data)
5597
        {
5598
            try
5599
            {
5600
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5601
                {
5602
                    ID = Commons.shortGuid(),
5603
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5604
                    NAME = Name,
5605
                    IMAGE_URL = Url,
5606
                    DATA = Data
5607
                };
5608

    
5609
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5610
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5611
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5612
            }
5613
            catch (Exception)
5614
            {
5615
                throw;
5616
            }
5617
        }
5618

    
5619
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5620
        {
5621
            try
5622
            {
5623
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5624
                {
5625
                    ID = Commons.shortGuid(),
5626
                    DEPARTMENT = Department,
5627
                    NAME = Name,
5628
                    IMAGE_URL = Url,
5629
                    DATA = Data
5630
                };
5631
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5632
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5633
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5634
            }
5635
            catch (Exception)
5636
            {
5637
                throw;
5638
            }
5639
        }
5640

    
5641
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5642
        {
5643
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5644
            DataBind();
5645
        }
5646

    
5647
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5648
        {
5649
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5650
            DataBind();
5651
        }
5652

    
5653
        private void DataBind()
5654
        {
5655
            try
5656
            {
5657
                Symbol_Custom Custom = new Symbol_Custom();
5658
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5659

    
5660
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5661
                foreach (var item in symbol_Private)
5662
                {
5663
                    Custom.Name = item.NAME;
5664
                    Custom.ImageUri = item.IMAGE_URL;
5665
                    Custom.ID = item.ID;
5666
                    Custom_List.Add(Custom);
5667
                    Custom = new Symbol_Custom();
5668
                }
5669
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5670

    
5671
                Custom = new Symbol_Custom();
5672
                Custom_List = new List<Symbol_Custom>();
5673

    
5674
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5675

    
5676
                List<SYMBOL_PUBLIC> symbol_Public;
5677

    
5678
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5679
                {
5680
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5681
                }
5682
                else
5683
                {
5684
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5685
                }
5686
                foreach (var item in symbol_Public)
5687
                {
5688
                    Custom.Name = item.NAME;
5689
                    Custom.ImageUri = item.IMAGE_URL;
5690
                    Custom.ID = item.ID;
5691
                    Custom_List.Add(Custom);
5692
                    Custom = new Symbol_Custom();
5693
                }
5694
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5695
                BaseClient.Close();
5696
            }
5697
            catch (Exception e)
5698
            {
5699
                //DialogMessage_Alert("DataBind", "Alert");
5700
            }
5701
        }
5702

    
5703
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5704
        {
5705
            try
5706
            {
5707
                if (args.PromptResult != null)
5708
                {
5709
                    if (args.DialogResult.Value)
5710
                    {
5711
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5712

    
5713
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5714
                        _Encoder.Save(fs);
5715
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5716

    
5717
                        byte[] Img_byte = fs.ToArray();
5718

    
5719
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5720
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5721
                        Check_Uri.UriCheck(filename);
5722
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5723
                        {
5724
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5725
                        }
5726
                        else
5727
                        {
5728
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5729
                        }
5730
                        DataBind();
5731
                    }
5732
                }
5733
            }
5734
            catch (Exception ex)
5735
            {
5736
                DialogMessage_Alert("" + ex, "Alert");
5737
            }
5738
        }
5739

    
5740
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5741
        {
5742
            Canvas _canvas = new Canvas();
5743
            _canvas.Background = Brushes.White;
5744
            _canvas.Width = adorner_.BorderSize.Width;
5745
            _canvas.Height = adorner_.BorderSize.Height;
5746
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.NewMarkupCancelToken());
5747

    
5748
            BitmapEncoder encoder = new PngBitmapEncoder();
5749

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

    
5752
            DrawingVisual dv = new DrawingVisual();
5753

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

    
5757
            using (DrawingContext ctx = dv.RenderOpen())
5758
            {
5759
                VisualBrush vb = new VisualBrush(_canvas);
5760
                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)));
5761
            }
5762

    
5763
            try
5764
            {
5765
                renderBitmap.Render(dv);
5766

    
5767
                GC.Collect(2);
5768
                GC.WaitForPendingFinalizers();
5769
                //GC.Collect();
5770
                // encode png data
5771
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5772
                // puch rendered bitmap into it
5773
                pngEncoder.Interlace = PngInterlaceOption.Off;
5774
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5775
                return pngEncoder;
5776
            }
5777
            catch //(Exception ex)
5778
            {
5779
                return null;
5780
            }
5781
        }
5782

    
5783
        public void DialogMessage_Alert(string content, string header)
5784
        {
5785
            App.splashScreen.Close();
5786
            App.FileLogger.Error(content + " " + header);
5787

    
5788
            DialogParameters parameters = new DialogParameters()
5789
            {
5790
                Owner = this.ParentOfType<MainWindow>(),
5791
                Content = new TextBlock()
5792
                {
5793
                    MinWidth = 400,
5794
                    FontSize = 11,
5795
                    Text = content,
5796
                    TextWrapping = System.Windows.TextWrapping.Wrap
5797
                },
5798
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5799
                Header = header,
5800
                Theme = new VisualStudio2013Theme(),
5801
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5802
            };
5803
            RadWindow.Alert(parameters);
5804
        }
5805

    
5806
        #region 캡쳐 기능
5807

    
5808
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5809
        {
5810
            if (x < 0)
5811
            {
5812
                width += x;
5813
                x = 0;
5814
            }
5815
            if (y < 0)
5816
            {
5817
                height += y;
5818
                y = 0;
5819

    
5820
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5821
            }
5822
            if (x + width > zoomAndPanCanvas.ActualWidth)
5823
            {
5824
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5825
            }
5826
            if (y + height > zoomAndPanCanvas.ActualHeight)
5827
            {
5828
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5829
            }
5830

    
5831
            byte[] pixels = CopyPixels(x, y, width, height);
5832

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

    
5835
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5836
        }
5837

    
5838
        public byte[] CopyPixels(int x, int y, int width, int height)
5839
        {
5840
            byte[] pixels = new byte[width * height * 4];
5841
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5842

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

    
5846
            return pixels;
5847
        }
5848

    
5849
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5850
        {
5851
            DrawingVisual drawingVisual = new DrawingVisual();
5852
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5853

    
5854
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5855
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5856
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5857
            drawingContext.Close();
5858

    
5859
            // 비트맵으로 변환합니다.
5860
            RenderTargetBitmap target =
5861
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5862
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5863

    
5864
            target.Render(drawingVisual);
5865
            return target;
5866
        }
5867

    
5868
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5869
        {
5870
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5871
            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);
5872
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5873
            bmp.UnlockBits(data);
5874
            return bmp;
5875
        }
5876

    
5877
        public string symbolname = null;
5878
        public bool symbolsvg = true;
5879
        public bool symbolpng = true;
5880

    
5881
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5882
        {
5883
            System.Drawing.Bitmap image = GetBitmap(source);
5884
            //흰색 제거
5885
            //image.MakeTransparent(System.Drawing.Color.White);
5886

    
5887
            var imageStream = new System.IO.MemoryStream();
5888
            byte[] imageBytes = null;
5889
            using (imageStream)
5890
            {
5891
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5892
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5893
                imageStream.Position = 0;
5894
                imageBytes = imageStream.ToArray();
5895
            }
5896

    
5897
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5898

    
5899
            RadWindow CheckPop = new RadWindow();
5900
            //Alert check = new Alert(Msg);
5901

    
5902
            CheckPop = new RadWindow
5903
            {
5904
                MinWidth = 400,
5905
                MinHeight = 100,
5906
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5907
                Header = "Alert",
5908
                Content = symbolPrompt,
5909
                //DialogResult =
5910
                ResizeMode = System.Windows.ResizeMode.NoResize,
5911
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5912
                IsTopmost = true,
5913
            };
5914
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5915
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5916
            CheckPop.ShowDialog();
5917

    
5918
            /*
5919
            DialogParameters parameters = new DialogParameters()
5920
            {
5921
                Owner = Application.Current.MainWindow,
5922
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5923
                DefaultPromptResultValue = "Custom State",
5924
                Content = "Name :",
5925
                Header = "Insert Custom Symbol Name",
5926
                Theme = new VisualStudio2013Theme(),
5927
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5928
            };
5929
            RadWindow.Prompt(parameters);
5930
            */
5931
        }
5932

    
5933
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5934
        {
5935
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5936
            KCOMDataModel.DataModel.CHECK_LIST check_;
5937
            string Result = streamToBase64.ImageToBase64(source);
5938
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5939
            string projectno = App.ViewInfo.ProjectNO;
5940
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5941

    
5942
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5943
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5944
            if (Item != null)
5945
            {
5946
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5947
            }
5948
            else
5949
            {
5950
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5951
            }
5952

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

    
5986
        public void Set_Capture()
5987
        {
5988
            double x = CanvasDrawingMouseDownPoint.X;
5989
            double y = CanvasDrawingMouseDownPoint.Y;
5990
            double width = dragCaptureBorder.Width;
5991
            double height = dragCaptureBorder.Height;
5992

    
5993
            if (width > 5 || height > 5)
5994
            {
5995
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5996
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5997
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5998
            }
5999
        }
6000

    
6001
        #endregion 캡쳐 기능
6002

    
6003
        public Multi_Undo_data Control_Style(CommentUserInfo control)
6004
        {
6005
            multi_Undo_Data = new Multi_Undo_data();
6006

    
6007
            multi_Undo_Data.Markup = control;
6008

    
6009
            if ((control as IShapeControl) != null)
6010
            {
6011
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
6012
            }
6013
            if ((control as IDashControl) != null)
6014
            {
6015
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
6016
            }
6017
            if ((control as IPath) != null)
6018
            {
6019
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
6020
            }
6021
            if ((control as UIElement) != null)
6022
            {
6023
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
6024
            }
6025

    
6026
            return multi_Undo_Data;
6027
        }
6028

    
6029
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6030
        {
6031
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6032
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6033
            {
6034
                if (items.MarkupInfoID == Select_ID)
6035
                {
6036
                    foreach (var item in items.MarkupList)
6037
                    {
6038
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6039
                        {
6040
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.NewMarkupCancelToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6041
                                 items.MarkupInfoID, Commons.shortGuid());
6042
                        }
6043
                    }
6044
                }
6045
            }
6046
        }
6047

    
6048
        /// <summary>
6049
        /// convert inkcontrol to polygoncontrol
6050
        /// </summary>
6051
        public void ConvertInkControlToPolygon()
6052
        {
6053
            if (inkBoard.Strokes.Count > 0)
6054
            {
6055
                inkBoard.Strokes.ToList().ForEach(stroke =>
6056
                {
6057
                    InkToPath ip = new InkToPath();
6058

    
6059
                    List<Point> inkPointSet = new List<Point>();
6060
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6061

    
6062
                    PolygonControl pc = new PolygonControl()
6063
                    {
6064
                        CommentAngle = 0,
6065
                        PointSet = inkPointSet,
6066
                        ControlType = ControlType.Ink
6067
                    };
6068
                    pc.StartPoint = inkPointSet[0];
6069
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6070
                    pc.LineSize = 3;
6071
                    pc.CommentID = Commons.shortGuid();
6072
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6073

    
6074
                    if (pc.PointSet.Count > 0)
6075
                    {
6076
                        CreateCommand.Instance.Execute(pc);
6077
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6078
                    }
6079
                });
6080
                inkBoard.Strokes.Clear();
6081
            }
6082
        }
6083

    
6084
        /// <summary>
6085
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6086
        /// </summary>
6087
        /// <author>ingu</author>
6088
        /// <date>2018.06.05</date>
6089
        /// <param name="getPoint"></param>
6090
        /// <returns></returns>
6091
        private bool IsGetoutpoint(Point getPoint)
6092
        {
6093
            if (getPoint == new Point())
6094
            {
6095
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6096
                currentControl = null;
6097
                return true;
6098
            }
6099

    
6100
            return false;
6101
        }
6102

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

    
6108
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6109
        {
6110
            e.Effects = DragDropEffects.Copy;
6111
        }
6112

    
6113
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6114
        {
6115
            e.Effects = DragDropEffects.None;
6116
        }
6117

    
6118
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6119
        {
6120
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6121
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6122

    
6123
            ScaleImage(pageWidth, pageHeight);
6124
        }
6125

    
6126
        /// <summary>
6127
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6128
        /// </summary>
6129
        /// <param name="pageWidth">원본 사이즈</param>
6130
        /// <param name="pageHeight">원본 사이즈</param>
6131
        /// <returns></returns>
6132
        private void ScaleImage(double pageWidth, double pageHeight)
6133
        {
6134
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6135
        }
6136

    
6137
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6138
        {
6139
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6140
        }
6141

    
6142
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6143
        {
6144
            var checkbox = (sender as CheckBox);
6145

    
6146
            if (checkbox != null)
6147
            {
6148
                if (checkbox.IsChecked.GetValueOrDefault())
6149
                {
6150
                    gridViewMarkup.SelectAll();
6151
                }
6152
                else
6153
                {
6154
                    gridViewMarkup.UnselectAll();
6155
                }
6156
            }
6157
        }
6158
        
6159
        /*
6160
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6161
        {
6162
            try
6163
            {
6164
                if (e.Data.GetDataPresent(typeof(string)))
6165
                {
6166
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6167
                    string dragData = e.Data.GetData(typeof(string)) as string;
6168
                    Move_Symbol(sender, dragData);
6169
                }
6170
            }
6171
            catch (Exception ex)
6172
            {
6173
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6174
            }
6175
        }
6176
        */
6177
    }
6178

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