프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 6a19b48d

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
167
        private Point Sync_Offset_Point;
168

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

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

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

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

    
213
        public bool IsSyncPDFMode { get; set; }
214

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

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

    
240
        #endregion 프로퍼티
241

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

    
247
            //List<testItem> testItems = new List<testItem>
248
            //{
249
            //    new testItem{Title = "test1"},
250
            //    new testItem{Title = "test2"},
251
            //    new testItem{Title = "test3"},
252
            //    new testItem{Title = "test4"},
253
            //};
254

    
255
            //lstSymbolPrivate.ItemsSource = testItems;
256

    
257
            this.Loaded += MainMenu_Loaded;
258
        }
259

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

    
270
        private List<TempDt> tempDtList = new List<TempDt>();
271

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

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

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

    
297
            return uri;
298
        }
299

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

    
318
            var directUri = CommonLib.Common.GetConfigString("DocumentDownloadPath", "url", "");
319

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

    
338
            return uri;
339
        }
340

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

    
351
            return false;
352
        }
353

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

    
377
            return false;
378
        }
379

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

    
387
            ViewerDataModel.Instance._markupInfoList.Remove(item);
388

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

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

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

    
408
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
409

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

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

    
471
                        Button content = (sender as Button);
472
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
473

    
474
                        DeleteItem(item);
475
                    }
476
                }
477
            };
478
            RadWindow.Confirm(parameters);
479
        }
480

    
481
        private System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
482

    
483
        private static Timer timer;
484
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
485

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

    
491
            if (App.ParameterMode)
492
            {
493

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

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

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

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

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

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

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

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

    
550
        string instnaceFile;
551
        string downloadurl;
552

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

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

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

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

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

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

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

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

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

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

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

    
649
            /// up to here
650

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

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

    
671
        /// <summary>
672
        /// start page changing
673
        ///  - save controls if page is modified
674
        ///  - starting download page image
675
        /// </summary>
676
        /// <param name="sender"></param>
677
        /// <param name="e"></param>
678
        private async void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
679
        {
680
            //await Task.Delay(10);
681

    
682
            // 마크업 로드
683
            //await this.Dispatcher.InvokeAsync(()=>MarkupLoad(e.PageNumber));
684

    
685
            ViewerDataModel.Instance.PageAngle = e.CurrentPage.PAGE_ANGLE;
686

    
687
            var token = ViewerDataModel.Instance.NewCancellationToken();
688
            
689
            await MarkupLoadAsync(e.PageNumber, ViewerDataModel.Instance.PageAngle, token);
690

    
691
            // 페이지 이미지 변경
692
            await PageChangingAsync(e.CurrentPage, e.PageNumber, token);
693
        }
694

    
695
        private async Task PageChangingAsync(DOCPAGE currentPage, int changePageNumber,CancellationToken token)
696
        {
697
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? changePageNumber + ViewerDataModel.Instance.PageBalanceNumber : changePageNumber;
698

    
699
            #region 페이지가 벗어난 경우
700

    
701
            if (BalancePoint < 1)
702
            {
703
                BalancePoint = 1;
704
                ViewerDataModel.Instance.PageBalanceNumber = 0;
705
            }
706

    
707
            if (pageNavigator.PageCount < BalancePoint)
708
            {
709
                BalancePoint = pageNavigator.PageCount;
710
                ViewerDataModel.Instance.PageBalanceNumber = 0;
711
            }
712

    
713
            #endregion 페이지가 벗어난 경우
714

    
715
            ViewerDataModel.Instance.SyncPageNumber = BalancePoint;
716

    
717
            var pageWidth = Convert.ToDouble(currentPage.PAGE_WIDTH);
718
            var pageHeight = Convert.ToDouble(currentPage.PAGE_HEIGHT);
719
            var contentScale = zoomAndPanControl.ContentScale;
720

    
721
            #region 페이지 이미지 로딩 수정
722

    
723
            ViewerDataModel.Instance.ImageViewPath = await App.PageStorage.GetPageImageAsync(token,changePageNumber);
724

    
725
            ScaleImage(pageWidth, pageHeight);
726

    
727
            ViewerDataModel.Instance.ImageViewWidth = pageWidth;
728
            ViewerDataModel.Instance.ImageViewHeight = pageHeight;
729

    
730
            zoomAndPanCanvas.Width = pageWidth;
731
            zoomAndPanCanvas.Height = pageHeight;
732

    
733
            Common.ViewerDataModel.Instance.ContentWidth = pageWidth;
734
            Common.ViewerDataModel.Instance.ContentHeight = pageHeight;
735

    
736
            inkBoard.Width = pageWidth;
737
            inkBoard.Height = pageHeight;
738

    
739
            #endregion 페이지 이미지 로딩 수정
740

    
741
            if (!testPanel2.IsHidden)
742
            {
743
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
744
                //PDF모드일때 잠시 대기(강인구)
745
                if (IsSyncPDFMode)
746
                {
747
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
748
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
749

    
750
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
751
                    if (pdfpath.IsDownloading)
752
                    {
753
                        pdfpath.DownloadCompleted += (ex, arg) =>
754
                        {
755
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
756
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
757
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
758
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
759
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
760
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
761
                        };
762
                    }
763
                    else
764
                    {
765
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
766
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
767
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
768
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
769

    
770
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
771
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
772
                    }
773
                }
774
                else
775
                {
776
                    Logger.sendCheckLog("Compare Image Download", 1);
777
                    string compareImageUri = this.GetImageURL(CurrentRev.DOCUMENT_ID, BalancePoint);
778
                    ComparePageLoad(compareImageUri,false);
779
                }
780

    
781
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
782
            }
783

    
784
            SearchFocusBorder.Visibility = Visibility.Collapsed;
785

    
786
            this.pageNavigator.ChangePage(changePageNumber);
787
        }
788

    
789
        private void ComparePageLoad(string pageUri, bool IsOriginalSize)
790
        {
791
            /// 현재 보고 있는 VP와 같은 크기로 로딩
792
            ViewerDataModel.Instance.ImageViewPath_C = null;
793

    
794
            if (IsOriginalSize && OriginalSizeMode.IsChecked)
795
            {
796
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri);
797
            }
798
            else
799
            {
800
                var imageSize = new Size(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight);
801
                ViewerDataModel.Instance.ImageViewPath_C = ImageSourceHelper.GetDownloadImage(pageUri, imageSize);
802
            }
803

    
804
            if (ViewerDataModel.Instance.ImageViewPath_C != null)
805
            {
806
                ViewerDataModel.Instance.ImageViewWidth_C = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
807
                ViewerDataModel.Instance.ImageViewHeight_C = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
808
                zoomAndPanCanvas2.Width = ViewerDataModel.Instance.ImageViewPath_C.PixelWidth;
809
                zoomAndPanCanvas2.Height = ViewerDataModel.Instance.ImageViewPath_C.PixelHeight;
810

    
811
                zoomAndPanControl.ZoomTo(new Rect
812
                {
813
                    X = 0,
814
                    Y = 0,
815
                    Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
816
                    Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
817
                });
818

    
819
                if (Sync.IsChecked)
820
                {
821
                    Sync_Click(null, new RoutedEventArgs());
822
                }
823

    
824
                if (CompareMode.IsChecked)
825
                {
826
                    SyncCompare_Click(null, new RoutedEventArgs());
827
                }
828
            }
829
        }
830

    
831
        /// <summary>
832
        /// called after page is changed
833
        /// </summary>
834
        /// <param name="sender"></param>
835
        /// <param name="e"></param>
836
        private async void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
837
        {
838
            //if (zoomAndPanCanvas.Width.IsNaN())
839
            //{
840
            //await zoomAndPanControl.Dispatcher.InvokeAsync(() =>
841
            //    zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height })
842
            //    );
843
            //}
844

    
845
            var instanceMain = ViewerDataModel.Instance.SystemMain;
846

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

    
849
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
850
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
851

    
852
            instanceMain.dzTopMenu.rotateOffSet = 0;
853
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
854
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
855

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

    
860
            //Point startPoint = new Point(15, 15);
861

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

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

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

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

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

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

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

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

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

    
884
            //ViewerDataModel.Instance.MarkupControls_USER.Add(symCtrl);
885
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtApproved);
886
            ////ViewerDataModel.Instance.MarkupControls_USER.Add(txtCreator);
887
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtOriginator);
888
            //ViewerDataModel.Instance.MarkupControls_USER.Add(txtDate);
889

    
890
            //symCtrl.ApplyTemplate();
891
            ////txtApproved.ApplyTemplate();
892
            ////txtCreator.ApplyTemplate();
893
            //txtOriginator.ApplyTemplate();
894
            //txtDate.ApplyTemplate();
895

    
896
            ////SetTextControl(txtApproved);
897
            ////SetTextControl(txtCreator);
898
            //SetTextControl(txtOriginator);
899
            //SetTextControl(txtDate);
900

    
901
            //multi_Undo_Data = new Multi_Undo_data();
902

    
903
            //MarkupToPDF.Common.Undo_data UndoData = new Undo_data()
904
            //{
905
            //    IsUndo = false,
906
            //    Event = Event_Type.Create,
907
            //    EventTime = DateTime.Now,
908
            //    Markup_List = new List<Multi_Undo_data>()
909
            //};
910

    
911
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(symCtrl as MarkupToPDF.Common.CommentUserInfo);
912
            //UndoData.Markup_List.Add(multi_Undo_Data);
913

    
914
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtApproved as MarkupToPDF.Common.CommentUserInfo);
915
            ////UndoData.Markup_List.Add(multi_Undo_Data);
916

    
917
            ////multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtCreator as MarkupToPDF.Common.CommentUserInfo);
918
            ////UndoData.Markup_List.Add(multi_Undo_Data);
919

    
920
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtOriginator as MarkupToPDF.Common.CommentUserInfo);
921
            //UndoData.Markup_List.Add(multi_Undo_Data);
922

    
923
            //multi_Undo_Data = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.Control_Style(txtDate as MarkupToPDF.Common.CommentUserInfo);
924
            //UndoData.Markup_List.Add(multi_Undo_Data);
925

    
926
            //ViewerDataModel.Instance.UndoDataList.Add(UndoData);
927

    
928
            //System.Diagnostics.Debug.WriteLine(symCtrl.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
929
            ////System.Diagnostics.Debug.WriteLine(txtApproved.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
930
            ////System.Diagnostics.Debug.WriteLine(txtCreator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
931
            //System.Diagnostics.Debug.WriteLine(txtOriginator.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
932
            //System.Diagnostics.Debug.WriteLine(txtDate.GetMarkupData(App.ViewInfo.UserID, 1, markupinfo.MarkupVersionID).DATA);
933
        }
934

    
935
        private void SetTextControl(TextControl textControl)
936
        {
937
            textControl.Base_TextBlock.Margin = new Thickness(0, 0, 10, 0);
938
            textControl.Base_TextBox.Visibility = Visibility.Collapsed;
939
            textControl.Base_TextBlock.Visibility = Visibility.Visible;
940
        }
941

    
942
        private SymControlN GetSymNControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
943
        {
944
            SymControlN result = null;
945

    
946
            try
947
            {
948
                double height = 80;
949
                double itemWidth = 180;
950

    
951
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
952
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
953
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
954
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
955

    
956
                result = new SymControlN
957
                {
958
                    CommentID = Commons.shortGuid(),
959
                    MarkupInfoID = markupInfoId,
960
                    UserID = userId,
961
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
962
                    StartPoint = startPoint,
963
                    EndPoint = endPoint,
964
                    CommentAngle = 0,
965
                    LeftBottomPoint = leftBottomPoint,
966
                    TopRightPoint = topRightPoint,
967
                    Opacity = 1,
968
                    PathXathData = "eJy1Ul1PwjAU/SvN9c3EdY5g1FAShyIxRgygxsemu7AbupZ0Vae/3g42/Azxxfuw9Z7Tnpx72t6lo4zdyAIFyHUBqwptSgG596tTzkuVYyHLqCDlbGnnPlK24C9k5hVP4viIV7LQfOWwROOlJ2ug36tVo1Sq5cLZJ5P1e1OrKRtYbV3qnsqcrZcC9oZNARuvpCL/KiCODoHxfo//EJmg8tIsNLKpd+hVLmBIWkPd2iU2cnGoFprlpJYGyzBOt8WuyeCVJSNgUstCM/1WHNgDZT5oJ3E4M0Ja5F7A8QmwgTTPIYlrnAfgIIm6W2hmVy3CN9M3GUzsyznOyVAdTBlG+NxvxffXx37nOlF3Fx3vppNd5P6nnL8bnWHlU23VktUrAWe3t5Px/cU5sKE1/qFRuKi8k6nV2Qae0ltIshPXncPNtX25lZF19BY2Sn2maWGK8GQEDMIXHbB7dJ7Ur1RrUcDmbXx3l76y0eN4endz+Qd/yX/663xk2v7eAQ==",
969
                    Memo = null
970
                };
971
            }
972
            catch (Exception ex)
973
            {
974
                System.Diagnostics.Debug.WriteLine(ex.ToString());
975
            }
976

    
977
            return result;
978
        }
979

    
980
        private RectangleControl GetRectControl(double PageWidth, double PageHeight, string userId, string markupInfoId, Point startPosition)
981
        {
982
            RectangleControl result = null;
983

    
984
            try
985
            {
986
                double height = 80;
987
                double itemWidth = 180;
988

    
989
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
990
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y + height);
991
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + height);
992
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + itemWidth, startPosition.Y);
993

    
994
                result = new RectangleControl
995
                {
996
                    CommentID = Commons.shortGuid(),
997
                    MarkupInfoID = markupInfoId,
998
                    LineSize = 5,
999
                    Paint = MarkupToPDF.Controls.Common.PaintSet.None,
1000
                    StartPoint = startPoint,
1001
                    EndPoint = endPoint,
1002
                    CommentAngle = 0,
1003
                    StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0x0, 0x0)),
1004
                    //StrokeColor = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 224, 208)),
1005
                    FillColor = null,
1006
                    DashSize = new System.Windows.Media.DoubleCollection(new[] { 999999.0 }),
1007
                    Opacity = 1,
1008
                    LeftBottomPoint = leftBottomPoint,
1009
                    TopRightPoint = topRightPoint,
1010
                    PointSet = new List<Point> { startPoint, leftBottomPoint, endPoint, topRightPoint },
1011
                    UserID = userId,
1012
                    Memo = null
1013
                };
1014
            }
1015
            catch (Exception ex)
1016
            {
1017
                System.Diagnostics.Debug.WriteLine(ex.ToString());
1018
            }
1019

    
1020
            return result;
1021
        }
1022

    
1023
        private TextControl GetTextControl(double PageWidth, double PageHeight, string userId, string markupInfoId, string Text, double fontSize, FontWeight fontWeight, TextAlignment textAlignment, Rect parentRect, double positionY)
1024
        {
1025
            TextControl result = null;
1026

    
1027
            try
1028
            {
1029
                var txtSize = ShapeMeasure(new TextBlock { Text = Text, FontSize = fontSize, FontWeight = fontWeight, FontFamily = new FontFamily("Tahoma") });
1030

    
1031
                double startPositionX = parentRect.X;
1032

    
1033
                switch (textAlignment)
1034
                {
1035
                    case TextAlignment.Right:
1036
                        startPositionX = parentRect.X + parentRect.Width - txtSize.Width;
1037
                        break;
1038

    
1039
                    case TextAlignment.Center:
1040
                        startPositionX = parentRect.X + parentRect.Width / 2 - txtSize.Width / 2 - 3;
1041
                        break;
1042
                }
1043

    
1044
                Point startPosition = new Point
1045
                {
1046
                    X = startPositionX,
1047
                    Y = positionY
1048
                };
1049

    
1050
                System.Windows.Point startPoint = new System.Windows.Point(startPosition.X, startPosition.Y);
1051
                System.Windows.Point endPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y + txtSize.Height);
1052
                System.Windows.Point leftBottomPoint = new System.Windows.Point(startPosition.X, startPosition.Y + txtSize.Height);
1053
                System.Windows.Point topRightPoint = new System.Windows.Point(startPosition.X + txtSize.Width, startPosition.Y);
1054

    
1055
                result = new TextControl
1056
                {
1057
                    CommentID = Commons.shortGuid(),
1058
                    MarkupInfoID = markupInfoId,
1059
                    Text = Text,
1060
                    StartPoint = startPoint,
1061
                    EndPoint = endPoint,
1062
                    CanvasX = startPosition.X,
1063
                    CanvasY = startPosition.Y,
1064
                    BoxWidth = txtSize.Width,
1065
                    BoxHeight = txtSize.Height,
1066
                    ControlType_No = 0,
1067
                    LineSize = new Thickness(5),
1068
                    TextSize = fontSize,
1069
                    Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0)),
1070
                    FontSize = 10,
1071
                    UserID = userId,
1072
                    IsHighLight = false,
1073
                    CommentAngle = 0,
1074
                    PointSet = new List<Point>(),
1075
                    Opacity = 1,
1076
                    IsSelected = false,
1077
                    TextFamily = new FontFamily("Tahoma"),
1078
                    TextStyle = FontStyles.Normal,
1079
                    TextWeight = FontWeights.Bold
1080
                };
1081
            }
1082
            catch (Exception ex)
1083
            {
1084
            }
1085

    
1086
            return result;
1087
        }
1088

    
1089
        public static Size ShapeMeasure(UIElement e)
1090
        {
1091
            // Measured Size is bounded to be less than maxSize
1092
            Size maxSize = new Size(
1093
                 double.PositiveInfinity,
1094
                 double.PositiveInfinity);
1095
            e.Measure(maxSize);
1096
            return e.DesiredSize;
1097
        }
1098

    
1099
        private async Task MarkupLoadAsync(int pageNumber,Double PageAngle, CancellationToken cts)
1100
        {
1101
            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
1102
            stopwatch.Start();
1103

    
1104
            /// 컨트롤을 새로 생성한다.
1105
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
1106
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
1107

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

    
1110
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == pageNumber))
1111
            {
1112
                if (cts.IsCancellationRequested)
1113
                {
1114
                    return;
1115
                }
1116

    
1117
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).FirstOrDefault();
1118
                if (info != null)
1119
                {
1120
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
1121
                    if (info.UserID == App.ViewInfo.UserID)
1122
                    {
1123
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, PageAngle, sColor, "",
1124
                                        markup.MarkupInfoID, markup.ID);
1125
                        control.Visibility = Visibility.Hidden;
1126
                    }
1127
                    else
1128
                    {
1129
                        var control = await MarkupParser.ParseExAsync(App.BaseAddress, cts, App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, PageAngle, sColor, "",
1130
                                                                markup.MarkupInfoID, markup.ID);
1131
                        control.Visibility = Visibility.Hidden;
1132
                    }
1133
                }
1134
            };
1135
            /// up to here
1136

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

    
1139
            /// fire selection event
1140
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
1141
            this.gridViewMarkup.UnselectAll();
1142
            this.gridViewMarkup.Select(gridSelectionItem);
1143

    
1144
            if (!testPanel2.IsHidden)
1145
            {
1146
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1147
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1148
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
1149

    
1150
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
1151
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
1152

    
1153
                foreach (var item in gridSelectionRevItem)
1154
                {
1155
                    var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == pageNumber).ToList();
1156

    
1157
                    foreach (var markupitem in markupitems)
1158
                    {
1159
                        await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,PageAngle, item.DisplayColor, "", item.MarkupInfoID);
1160

    
1161
                        if (cts.IsCancellationRequested)
1162
                        {
1163
                            return;
1164
                        }
1165
                    }
1166
                }
1167
            }
1168

    
1169
            SetCommentPages(cts);
1170
        }
1171

    
1172
        public void SetCommentPages(CancellationToken? cts)
1173
        {
1174
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
1175
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
1176
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
1177
            {
1178
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
1179
                if (item.MarkupList != null)
1180
                {
1181
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
1182
                    instance.UserName = item.UserName;
1183
                    instance.Depart = item.Depatment;
1184
                    instance.MarkupInfoID = item.MarkupInfoID;
1185
                    instance.IsSelected = true;
1186
                    instance.isConSolidation = item.Consolidate;
1187
                    instance.SetColor = item.DisplayColor;
1188
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
1189
                    {
1190
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
1191
                    }
1192
                    else
1193
                    {
1194
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
1195
                    }
1196
                    _pages.Add(instance);
1197
                }
1198

    
1199
                if (cts != null)
1200
                {
1201
                    if (cts.Value.IsCancellationRequested)
1202
                        return;
1203
                }
1204
            }
1205

    
1206
            this.pageNavigator.SetCommentList(_pages.ToList(),cts);
1207
        }
1208

    
1209
        public void MarkupitemViewUpdate(string markupinfo_id)
1210
        {
1211
            //db에 업데이트 한 list 를 view 에 업데이트
1212
            string sDocID = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu._DocInfo.ID;
1213
            List<MarkupInfoItem> results = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, sDocID);
1214
            MarkupInfoItem dbinfo = results.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1215
            MarkupInfoItem viewinfo = Common.ViewerDataModel.Instance._markupInfoList.Where(x => x.MarkupInfoID == markupinfo_id).FirstOrDefault();
1216
            if (dbinfo.MarkupList.Count > 0)
1217
            {
1218
                if (viewinfo.MarkupList != null)
1219
                {
1220
                    viewinfo.MarkupList.Clear();
1221
                    viewinfo.MarkupList = null;
1222
                }
1223

    
1224
                viewinfo.MarkupList = new List<MarkupItem>();
1225
                foreach (var item in dbinfo.MarkupList)
1226
                {
1227
                    System.Diagnostics.Debug.WriteLine(item.ID);
1228
                    viewinfo.MarkupList.Add(item);
1229
                }
1230
            }
1231
        }
1232

    
1233
        private async void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
1234
        {
1235
            var instance = ViewerDataModel.Instance;
1236

    
1237
            if (instance.IsWheelPageChanage)
1238
            {
1239
                return;
1240
            }
1241

    
1242
            if (instance.IsPressCtrl) // && !instance.IsWheelPageChanage)
1243
            {
1244
                int changePage = 0;
1245

    
1246
                if (e.Delta > 0)
1247
                {
1248
                    if (0 < instance.ContentOffsetY)
1249
                    {
1250
                        Vector dragOffset = new Vector(0, e.Delta);
1251
                        MoveZoomAndPanControl(dragOffset);
1252
                    }
1253
                    //else
1254
                    //{
1255
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber > 1)
1256
                    //    {
1257
                    //        instance.IsWheelPageChanage = true;
1258
                    //        changePage -= 1;
1259
                    //    }
1260
                    //}
1261
                }
1262
                else if (e.Delta < 0)
1263
                {
1264
                    if (instance.ContentHeight > instance.ContentOffsetY + instance.ContentViewportHeight)
1265
                    {
1266
                        Vector dragOffset = new Vector(0, e.Delta);
1267
                        MoveZoomAndPanControl(dragOffset);
1268
                    }
1269
                    //else
1270
                    //{
1271
                    //    if (instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber < instance.SystemMain.dzMainMenu.pageNavigator.PageCount)
1272
                    //    {
1273
                    //        instance.IsWheelPageChanage = true;
1274
                    //        changePage += 1;
1275
                    //    }
1276
                    //}
1277
                }
1278

    
1279
                //if (changePage != 0)
1280
                //{
1281
                //    await Task.Factory.StartNew(() =>
1282
                //    {
1283
                //        double beforeScale = instance.ContentScale;
1284

    
1285
                //        EventHandler<Sample.PageChangeEventArgs> handler = null;
1286

    
1287
                //        handler = (snd, evt) =>
1288
                //        {
1289
                //            /// 최상단으로 이전 zoomScale로 위치한다
1290
                //            //Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1291
                //            //zoomAndPanControl.ZoomAboutPoint(beforeScale, new Point(currentContentMousePoint.X, 0));
1292
                //            instance.IsWheelPageChanage = false;
1293
                //            pageNavigator.PageChanged -= handler;
1294
                //        };
1295

    
1296
                //        pageNavigator.PageChanged += handler;
1297

    
1298
                //        pageNavigator.GotoPage(Convert.ToInt32(instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber) + changePage);
1299
                //    });
1300

    
1301
                //}
1302
            }
1303
            else
1304
            {
1305
                e.Handled = true;
1306
                if (e.Delta > 0)
1307
                {
1308
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1309
                    ZoomIn(currentContentMousePoint);
1310
                }
1311
                else
1312
                {
1313
                    Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
1314
                    ZoomOut(currentContentMousePoint);
1315
                }
1316
            }
1317
        }
1318

    
1319
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
1320
        {
1321
            e.Handled = true;
1322
            if (e.Delta > 0)
1323
            {
1324
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1325
                ZoomIn_Sync(currentContentMousePoint);
1326
            }
1327
            else
1328
            {
1329
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
1330
                ZoomOut_Sync(currentContentMousePoint);
1331
            }
1332
        }
1333

    
1334
        #region ZoomIn & ZoomOut
1335

    
1336
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
1337
        {
1338
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
1339
                zoomAndPanControl.ContentZoomFocusY));
1340
        }
1341

    
1342
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
1343
        {
1344
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
1345
                zoomAndPanControl.ContentZoomFocusY));
1346
        }
1347

    
1348
        //강인구 추가 (줌 인아웃 수치 변경)
1349
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
1350
        private void ZoomOut(Point contentZoomCenter)
1351
        {
1352
            if (zoomAndPanControl.ContentScale > 0.39)
1353
            {
1354
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
1355
            }
1356
            else
1357
            {
1358
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
1359
            }
1360

    
1361
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1362
            {
1363
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1364
            }
1365
        }
1366

    
1367
        private void ZoomIn(Point contentZoomCenter)
1368
        {
1369
            if (zoomAndPanControl.ContentScale > 0.19)
1370
            {
1371
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
1372
            }
1373
            else
1374
            {
1375
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
1376
            }
1377

    
1378
            if (zoomAndPanControl2 != null && Sync.IsChecked)
1379
            {
1380
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
1381
            }
1382
        }
1383

    
1384
        private void ZoomOut_Sync(Point contentZoomCenter)
1385
        {
1386
            if (zoomAndPanControl2.ContentScale > 0.39)
1387
            {
1388
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
1389
            }
1390
            else
1391
            {
1392
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
1393
            }
1394

    
1395
            if (Sync.IsChecked)
1396
            {
1397
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1398
            }
1399
        }
1400

    
1401
        private void ZoomIn_Sync(Point contentZoomCenter)
1402
        {
1403
            if (zoomAndPanControl2.ContentScale > 0.19)
1404
            {
1405
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
1406
            }
1407
            else
1408
            {
1409
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
1410
            }
1411

    
1412
            if (Sync.IsChecked)
1413
            {
1414
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
1415
            }
1416
        }
1417

    
1418
        private void ZoomOut()
1419
        {
1420
            zoomAndPanControl.ContentScale -= 0.1;
1421
            //if (zoomAndPanControl2 != null)
1422
            //{
1423
            //    zoomAndPanControl2.ContentScale -= 0.1;
1424
            //}
1425
        }
1426

    
1427
        private void ZoomIn()
1428
        {
1429
            zoomAndPanControl.ContentScale += 0.1;
1430
            //if (zoomAndPanControl2 != null)
1431
            //{
1432
            //    zoomAndPanControl2.ContentScale += 0.1;
1433
            //}
1434
        }
1435

    
1436
        #endregion ZoomIn & ZoomOut
1437

    
1438
        private void init()
1439
        {
1440
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
1441
            {
1442
                ControlList.Clear();
1443
                listBox.Items.Clear();
1444
                selected_item.Clear();
1445

    
1446
                (item as IMarkupCommonData).IsSelected = false;
1447
            }
1448
        }
1449

    
1450
        private HitTestResultBehavior MyCallback(HitTestResult result)
1451
        {
1452
            //this.cursor = Cursors.UpArrow;
1453
            var element = result.VisualHit;
1454
            while (element != null && !(element is CommentUserInfo))
1455
                element = VisualTreeHelper.GetParent(element);
1456

    
1457
            if (element == null)
1458
            {
1459
                return HitTestResultBehavior.Stop;
1460
            }
1461
            else
1462
            {
1463
                if (element is CommentUserInfo)
1464
                {
1465
                    if (!hitList.Contains(element))
1466
                    {
1467
                        hitList.Add((CommentUserInfo)element);
1468
                    }
1469
                    else
1470
                    {
1471
                        return HitTestResultBehavior.Stop;
1472
                    }
1473
                }
1474
            }
1475
            return HitTestResultBehavior.Continue;
1476
        }
1477

    
1478
        public void ReleaseSelectPath()
1479
        {
1480
            if (SelectionPath == null)
1481
            {
1482
                SelectionPath = new Path();
1483
                SelectionPath.Name = "";
1484
            }
1485
            if (SelectionPath.Name != "")
1486
            {
1487
                SelectionPath.Name = "None";
1488
            }
1489
            SelectionPath.Opacity = 0.01;
1490
            SelectionPath.RenderTransform = null;
1491
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
1492
        }
1493

    
1494
        #region 컨트롤 초기화
1495

    
1496
        public void Control_Init(object control)
1497
        {
1498
            if (L_Size != 0 && (control as IPath) != null)
1499
            {
1500
                (control as IPath).LineSize = L_Size;
1501
                L_Size = 0;
1502
            }
1503

    
1504
            switch (control.GetType().Name)
1505
            {
1506
                case "RectangleControl":
1507
                    {
1508
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1509
                    }
1510
                    break;
1511

    
1512
                case "CircleControl":
1513
                    {
1514
                        (control as CircleControl).StrokeColor = Brushes.Red;
1515
                    }
1516
                    break;
1517

    
1518
                case "TriControl":
1519
                    {
1520
                        (control as TriControl).StrokeColor = Brushes.Red;
1521
                    }
1522
                    break;
1523

    
1524
                case "RectCloudControl":
1525
                    {
1526
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1527
                    }
1528
                    break;
1529

    
1530
                case "CloudControl":
1531
                    {
1532
                        (control as CloudControl).StrokeColor = Brushes.Red;
1533
                    }
1534
                    break;
1535

    
1536
                case "PolygonControl":
1537
                    {
1538
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1539
                    }
1540
                    break;
1541

    
1542
                case "ArcControl":
1543
                    {
1544
                        (control as ArcControl).StrokeColor = Brushes.Red;
1545
                    }
1546
                    break;
1547

    
1548
                case "ArrowArcControl":
1549
                    {
1550
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1551
                    }
1552
                    break;
1553

    
1554
                case "LineControl":
1555
                    {
1556
                        (control as LineControl).StrokeColor = Brushes.Red;
1557
                    }
1558
                    break;
1559

    
1560
                case "ArrowControl_Multi":
1561
                    {
1562
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1563
                    }
1564
                    break;
1565

    
1566
                case "TextControl":
1567
                    {
1568
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1569
                    }
1570
                    break;
1571

    
1572
                case "ArrowTextControl":
1573
                    {
1574
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1575
                    }
1576
                    break;
1577

    
1578
                case "InsideWhiteControl":
1579
                    {
1580
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1581
                    }
1582
                    break;
1583

    
1584
                case "OverlapWhiteControl":
1585
                    {
1586
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1587
                    }
1588
                    break;
1589

    
1590
                case "ClipWhiteControl":
1591
                    {
1592
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1593
                    }
1594
                    break;
1595

    
1596
                case "CoordinateControl":
1597
                    {
1598
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1599
                    }
1600
                    break;
1601
            }
1602
        }
1603

    
1604
        #endregion 컨트롤 초기화
1605

    
1606
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1607
        {
1608
            //Control_Init(e.Source);
1609
        }
1610

    
1611
        //private Window _dragdropWindow = null;
1612

    
1613
        [DllImport("user32.dll")]
1614
        [return: MarshalAs(UnmanagedType.Bool)]
1615
        internal static extern bool GetCursorPos(ref Win32Point pt);
1616

    
1617
        [StructLayout(LayoutKind.Sequential)]
1618
        internal struct Win32Point
1619
        {
1620
            public Int32 X;
1621
            public Int32 Y;
1622
        };
1623

    
1624
        /*
1625
       public string symbol_id = null;
1626
       public long symbol_group_id;
1627
       public int symbol_SelectedIndex;
1628
       public ImageSource symbol_img;
1629
       public string symbol_Data = null;
1630
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1631
       {
1632
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1633
               zoomAndPanCanvas.ActualHeight / 2));
1634

    
1635
               if (this._dragdropWindow != null)
1636
               {
1637
                   this._dragdropWindow.Close();
1638
                   this._dragdropWindow = null;
1639
               }
1640

    
1641
               symbol_id = id;
1642
               symbol_group_id = group_id;
1643
               symbol_SelectedIndex = SelectedIndex;
1644
               symbol_Data = Data_;
1645
               symbol_img = img;
1646

    
1647
               CreateDragDropWindow2(img);
1648
    }
1649

    
1650
    private void CreateDragDropWindow2(ImageSource image)
1651
        {
1652
            this._dragdropWindow = new Window();
1653
            _dragdropWindow.Cursor = new Cursor(App.DefaultArrowCursorStream);
1654
            _dragdropWindow.WindowStyle = WindowStyle.None;
1655
            _dragdropWindow.AllowsTransparency = true;
1656
            _dragdropWindow.AllowDrop = false;
1657
            _dragdropWindow.Background = null;
1658
            _dragdropWindow.IsHitTestVisible = false;
1659
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1660
            _dragdropWindow.Topmost = true;
1661
            _dragdropWindow.ShowInTaskbar = false;
1662

    
1663
            Rectangle r = new Rectangle();
1664
            r.Width = image.Width;
1665
            r.Height = image.Height;
1666
            r.Opacity = 0.5;
1667
            r.Fill = new ImageBrush(image);
1668
            this._dragdropWindow.Content = r;
1669

    
1670
            Win32Point w32Mouse = new Win32Point();
1671
            GetCursorPos(ref w32Mouse);
1672

    
1673
            //w32Mouse.X = getCurrentPoint.X;
1674
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1675
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2);
1676
            this._dragdropWindow.Show();
1677
        }
1678

    
1679
         */
1680

    
1681
        public void MoveZoomAndPanControl(Vector dragOffset)
1682
        {
1683
            zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1684
            zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1685

    
1686
            if (Sync.IsChecked)
1687
            {
1688
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1689
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1690
            }
1691
        }
1692

    
1693
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1694
        {
1695
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch"
1696
                || Common.ViewerDataModel.Instance.SelectedControl == "MACRO")
1697
            //if(this.txtBatch.Visibility == Visibility.Visible)
1698
            {
1699
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1700

    
1701
                Point currentPos = e.GetPosition(rect);
1702

    
1703
                floatingTip.HorizontalOffset = currentPos.X + 20;
1704
                floatingTip.VerticalOffset = currentPos.Y;
1705
            }
1706

    
1707
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1708

    
1709
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1710
            {
1711
                SetCursor();
1712
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1713
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1714

    
1715
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1716

    
1717
                MoveZoomAndPanControl(dragOffset);
1718
            }
1719

    
1720
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1721
            {
1722
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1723
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1724
                SetCursor();
1725

    
1726
                if (currentControl != null)
1727
                {
1728
                    double moveX = currentCanvasDrawingMouseMovePoint.X - CanvasDrawingMouseDownPoint.X;
1729
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - CanvasDrawingMouseDownPoint.Y;
1730
                    //강인구 추가
1731
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1732

    
1733
                    if ((currentControl as IPath) != null)
1734
                    {
1735
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1736
                    }
1737
                    if ((currentControl as LineControl) != null)
1738
                    {
1739
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1740
                    }
1741

    
1742
                    if ((currentControl as IShapeControl) != null)
1743
                    {
1744
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1745
                    }
1746
                    if ((currentControl as TextControl) != null)
1747
                    {
1748
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1749
                        {
1750
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1751
                        }
1752
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1753
                        {
1754
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1755
                        }
1756
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1757
                        {
1758
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1759
                        }
1760
                    }
1761
                    else if ((currentControl as ArrowTextControl) != null)
1762
                    {
1763
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1764
                        {
1765
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1766
                        }
1767
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1768
                        {
1769
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1770
                        }
1771
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1772
                        {
1773
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1774
                        }
1775
                    }
1776
                    else if ((currentControl as RectCloudControl) != null)
1777
                    {
1778
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1779
                    }
1780
                    else if ((currentControl as CloudControl) != null)
1781
                    {
1782
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1783
                    }
1784

    
1785
                    #region // 모든 컨트롤의 공통기능 제어
1786

    
1787
                    if (controlType != ControlType.PenControl)
1788
                    {
1789
                        currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1790
                        ViewerDataModel.Instance.IsMarkupUpdate = true;
1791
                    }
1792

    
1793
                    #endregion // 모든 컨트롤의 공통기능 제어
1794

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

    
1797
                    switch (controlType)
1798
                    {
1799
                        case (ControlType.Coordinate):
1800
                            {
1801
                                var control = currentControl as CoordinateControl;
1802
                                if (control != null)
1803
                                {
1804
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1805
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1806
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1807
                                }
1808
                            }
1809
                            break;
1810

    
1811
                        case (ControlType.InsideWhite):
1812
                            {
1813
                                var control = currentControl as InsideWhiteControl;
1814
                                if (control != null)
1815
                                {
1816
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1817
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1818
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1819
                                    control.Paint = PaintSet.Fill;
1820
                                }
1821
                            }
1822
                            break;
1823

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

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

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

    
1862
                        case ControlType.SingleLine:
1863
                        case ControlType.CancelLine:
1864
                        case ControlType.ArrowLine:
1865
                        case ControlType.TwinLine:
1866
                        case ControlType.DimLine:
1867
                            {
1868
                                var control = currentControl as LineControl;
1869
                                if (control != null)
1870
                                {
1871
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1872
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1873
                                }
1874
                            }
1875
                            break;
1876

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

    
1888
                        case ControlType.ArcArrow:
1889
                            {
1890
                                var control = currentControl as ArrowArcControl;
1891
                                if (control != null)
1892
                                {
1893
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1894
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1895
                                }
1896
                            }
1897
                            break;
1898

    
1899
                        case ControlType.ArrowMultiLine:
1900
                            {
1901
                                var control = currentControl as ArrowControl_Multi;
1902
                                if (control != null)
1903
                                {
1904
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1905
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1906
                                }
1907
                            }
1908
                            break;
1909

    
1910
                        case ControlType.Circle:
1911
                            {
1912
                                var control = currentControl as CircleControl;
1913

    
1914
                                if (control != null)
1915
                                {
1916
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1917
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1918
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1919
                                }
1920
                            }
1921
                            break;
1922

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

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

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

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

    
1967
                        case ControlType.ArrowTextControl:
1968
                        case ControlType.ArrowTransTextControl:
1969
                        case ControlType.ArrowTextBorderControl:
1970
                        case ControlType.ArrowTransTextBorderControl:
1971
                        case ControlType.ArrowTextCloudControl:
1972
                        case ControlType.ArrowTransTextCloudControl:
1973
                            {
1974
                                var control = currentControl as ArrowTextControl;
1975
                                if (control != null)
1976
                                {
1977
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1978
                                }
1979
                            }
1980
                            break;
1981

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

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

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

    
2015
                        case ControlType.Stamp:
2016
                            {
2017
                                var control = currentControl as SymControlN;
2018
                                if (control != null)
2019
                                {
2020
                                    if (control.STAMP != null)
2021
                                    {
2022
                                        //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2023
                                    }
2024
                                    else
2025
                                    {
2026
                                        currentControl = null;
2027
                                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2028
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
2029
                                    }
2030
                                }
2031
                            }
2032
                            break;
2033

    
2034
                        case ControlType.Rectangle:
2035
                        case ControlType.Mark:
2036
                            {
2037
                                var control = currentControl as RectangleControl;
2038
                                if (control != null)
2039
                                {
2040
                                    //control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
2041
                                    if (control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
2042
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2043
                                }
2044
                            }
2045
                            break;
2046

    
2047
                        case ControlType.PenControl:
2048
                            {
2049
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2050
                                //inkBoard.Strokes.Add(stroke);
2051
                            }
2052
                            break;
2053

    
2054
                        default:
2055
                            break;
2056
                    }
2057

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

    
2060
                    if (ViewerDataModel.Instance.MarkupAngleVisibility == Visibility.Visible)
2061
                    {
2062
                        ViewerDataModel.Instance.MarkupAngle = currentControl.CommentAngle;
2063
                    }
2064
                }
2065
            }
2066
            else if (mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
2067
            {
2068
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
2069
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
2070
                SetCursor();
2071
                if (currentControl == null)
2072
                {
2073
                    switch (controlType)
2074
                    {
2075
                        case ControlType.PenControl:
2076
                            {
2077
                                if (inkBoard.Tag.ToString() == "Ink")
2078
                                {
2079
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
2080
                                }
2081
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
2082
                                {
2083
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
2084
                                }
2085
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
2086
                                {
2087
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
2088
                                }
2089

    
2090
                                //inkBoard.Strokes.Add(stroke);
2091
                            }
2092
                            break;
2093
                    }
2094
                    return;
2095
                }
2096
            }
2097
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) ||
2098
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) ||
2099
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
2100
            {
2101
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2102

    
2103
                if (isDraggingSelectionRect)
2104
                {
2105
                    UpdateDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2106
                    e.Handled = true;
2107
                }
2108
                else if (isLeftMouseButtonDownOnWindow)
2109
                {
2110
                    var dragDelta = curMouseDownPoint - CanvasDrawingMouseDownPoint;
2111
                    double dragDistance = Math.Abs(dragDelta.Length);
2112

    
2113
                    if (dragDistance > DragThreshold)
2114
                    {
2115
                        isDraggingSelectionRect = true;
2116
                        InitDragSelectionRect(CanvasDrawingMouseDownPoint, curMouseDownPoint);
2117
                    }
2118

    
2119
                    e.Handled = true;
2120
                }
2121

    
2122
                if (CanvasDrawingMouseDownPoint == curMouseDownPoint)
2123
                {
2124
                }
2125
                else
2126
                {
2127
                    e.Handled = true;
2128
                }
2129
            }
2130
            /*
2131
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
2132
            { //symbol
2133
                if(_dragdropWindow != null)
2134
                {
2135
                    Win32Point w32Mouse = new Win32Point();
2136
                    GetCursorPos(ref w32Mouse);
2137

    
2138
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
2139
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
2140
                }
2141
            }
2142
            */
2143
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) &&
2144
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
2145
            {
2146
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2147
                if (control != null)
2148
                {
2149
                    this.cursor = Cursors.Hand;
2150
                    SetCursor();
2151
                }
2152
                else
2153
                {
2154
                    if (this.Cursor != Cursors.None)
2155
                    {
2156
                        this.cursor = new Cursor(App.DefaultArrowCursorStream);
2157
                        SetCursor();
2158
                    }
2159
                }
2160
            }
2161
            else
2162
            {
2163
            }
2164
        }
2165

    
2166
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
2167
        {
2168
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
2169
            {
2170
                SetCursor();
2171
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
2172
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
2173

    
2174
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
2175

    
2176
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
2177
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
2178

    
2179
                if (Sync.IsChecked)
2180
                {
2181
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
2182
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
2183
                }
2184
            }
2185
        }
2186

    
2187
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
2188

    
2189
        private EllipseGeometry hitArea = new EllipseGeometry();
2190

    
2191
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
2192
        {
2193
            IsDrawing = false;
2194

    
2195
            if (mouseHandlingMode != MouseHandlingMode.None)
2196
            {
2197
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
2198
                {
2199
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2200

    
2201
                    SetCursor();
2202

    
2203
                    switch (controlType)
2204
                    {
2205
                        case ControlType.None:
2206
                            break;
2207

    
2208
                        case ControlType.Rectangle:
2209
                            {
2210
                            }
2211
                            break;
2212

    
2213
                        case ControlType.PenControl:
2214
                            {
2215
                            }
2216
                            break;
2217

    
2218
                        default:
2219
                            break;
2220
                    }
2221
                }
2222
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
2223
                {
2224
                    if (isLeftMouseButtonDownOnWindow)
2225
                    {
2226
                        bool wasDragSelectionApplied = false;
2227

    
2228
                        if (isDraggingSelectionRect)
2229
                        {
2230
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
2231
                            {
2232
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2233
                                mouseHandlingMode = MouseHandlingMode.None;
2234
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
2235
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
2236
                                Set_Symbol_Capture(endPoint);
2237
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2238
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2239
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2240
                            }
2241
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
2242
                            {
2243
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
2244
                                mouseHandlingMode = MouseHandlingMode.None;
2245
                                Set_Capture();
2246

    
2247
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
2248
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
2249
                                ViewerDataModel.Instance.Capture_Opacity = 0;
2250
                            }
2251
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2252
                            {
2253
                                ApplyDragSelectionRect();
2254
                            }
2255
                            else
2256
                            {
2257
                                double x = Canvas.GetLeft(dragZoomBorder);
2258
                                double y = Canvas.GetTop(dragZoomBorder);
2259
                                double width = dragZoomBorder.Width;
2260
                                double height = dragZoomBorder.Height;
2261
                                Rect dragRect = new Rect(x, y, width, height);
2262

    
2263
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
2264

    
2265
                                dragZoomBorder.Visibility = Visibility.Collapsed;
2266
                            }
2267

    
2268
                            isDraggingSelectionRect = false;
2269
                            e.Handled = true;
2270
                            wasDragSelectionApplied = true;
2271
                        }
2272

    
2273
                        if (isLeftMouseButtonDownOnWindow)
2274
                        {
2275
                            isLeftMouseButtonDownOnWindow = false;
2276
                            this.ReleaseMouseCapture();
2277
                            e.Handled = true;
2278
                        }
2279

    
2280
                        if (!wasDragSelectionApplied)
2281
                        {
2282
                            init();
2283
                        }
2284
                    }
2285
                }
2286
                else if (e.RightButton == MouseButtonState.Pressed)
2287
                {
2288
                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
2289
                    SetCursor();
2290
                }
2291

    
2292
                zoomAndPanControl.ReleaseMouseCapture();
2293

    
2294
                e.Handled = true;
2295
            }
2296
            else
2297
            {
2298
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2299
                SetCursor();
2300
            }
2301

    
2302
            ///mouseButtonDown = MouseButton.Left;
2303
            //controlType = ControlType.SingleLine;
2304
        }
2305

    
2306
        public void Set_Symbol_Capture(Point endPoint)
2307
        {
2308
            double x = CanvasDrawingMouseDownPoint.X;
2309
            double y = CanvasDrawingMouseDownPoint.Y;
2310
            if (x > endPoint.X)
2311
            {
2312
                x = endPoint.X;
2313
                y = endPoint.Y;
2314
            }
2315

    
2316
            double width = dragCaptureBorder.Width;
2317
            double height = dragCaptureBorder.Height;
2318

    
2319
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
2320

    
2321
            if (x < 0)
2322
            {
2323
                width += x;
2324
                x = 0;
2325
            }
2326
            if (y < 0)
2327
            {
2328
                height += y;
2329
                y = 0;
2330

    
2331
                width = (int)canvasImage.PixelWidth - x;
2332
            }
2333
            if (x + width > canvasImage.PixelWidth)
2334
            {
2335
                width = (int)canvasImage.PixelWidth - x;
2336
            }
2337
            if (y + height > canvasImage.PixelHeight)
2338
            {
2339
                height = (int)canvasImage.PixelHeight - y;
2340
            }
2341
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
2342

    
2343
            string uri = this.GetImageURL(_ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
2344
            var defaultBitmapImage = new BitmapImage();
2345
            defaultBitmapImage.BeginInit();
2346
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
2347
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
2348
            defaultBitmapImage.UriSource = new Uri(uri);
2349
            defaultBitmapImage.EndInit();
2350

    
2351
            //GC.Collect();
2352

    
2353
            if (defaultBitmapImage.IsDownloading)
2354
            {
2355
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
2356
                {
2357
                    defaultBitmapImage.Freeze();
2358
                    //GC.Collect();
2359
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
2360
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
2361
                };
2362
            }
2363
        }
2364

    
2365
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
2366
        {
2367
            ///mouseButtonDown = MouseButton.Left;
2368
        }
2369

    
2370
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
2371
        {
2372
            ///mouseButtonDown = MouseButton.Left;
2373
            //this.cursor = new Cursor(App.DefaultArrowCursorStream);
2374
        }
2375

    
2376
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2377
        {
2378
        }
2379

    
2380
        /// <summary>
2381
        /// select items by dragging
2382
        /// </summary>
2383
        private void ApplyDragSelectionRect()
2384
        {
2385
            dragSelectionBorder.Visibility = Visibility.Collapsed;
2386

    
2387
            double x = Canvas.GetLeft(dragSelectionBorder);
2388
            double y = Canvas.GetTop(dragSelectionBorder);
2389
            double width = dragSelectionBorder.Width;
2390
            double height = dragSelectionBorder.Height;
2391
            Boolean Flag = false;
2392
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
2393
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
2394

    
2395
            Rect dragRect = new Rect(x, y, width, height);
2396
            ///dragRect.Inflate(width / 10, height / 10);
2397

    
2398
            foreach (var item in Items)
2399
            {
2400
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
2401

    
2402
                if (Flag)
2403
                {
2404
                    adornerSet.Add(item);
2405
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
2406
                    Control_Style(item);
2407
                }
2408
            }
2409
            if (adornerSet.Count > 0)
2410
            {
2411
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
2412
                SelectLayer.Children.Add(final);
2413
            }
2414
        }
2415

    
2416
        private void InitDragSelectionRect(Point pt1, Point pt2)
2417
        {
2418
            //캡쳐 중
2419
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2420
            {
2421
                dragCaptureBorder.Visibility = Visibility.Visible;
2422
            }
2423
            //선택 중
2424
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2425
            {
2426
                dragSelectionBorder.Visibility = Visibility.Visible;
2427
            }
2428
            else
2429
            {
2430
                dragZoomBorder.Visibility = Visibility.Visible;
2431
            }
2432
            UpdateDragSelectionRect(pt1, pt2);
2433
        }
2434

    
2435
        /// <summary>
2436
        /// Update the position and size of the rectangle used for drag selection.
2437
        /// </summary>
2438
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
2439
        {
2440
            double x, y, width, height;
2441

    
2442
            //
2443
            // Determine x,y,width and height of the rect inverting the points if necessary.
2444
            //
2445

    
2446
            if (pt2.X < pt1.X)
2447
            {
2448
                x = pt2.X;
2449
                width = pt1.X - pt2.X;
2450
            }
2451
            else
2452
            {
2453
                x = pt1.X;
2454
                width = pt2.X - pt1.X;
2455
            }
2456

    
2457
            if (pt2.Y < pt1.Y)
2458
            {
2459
                y = pt2.Y;
2460
                height = pt1.Y - pt2.Y;
2461
            }
2462
            else
2463
            {
2464
                y = pt1.Y;
2465
                height = pt2.Y - pt1.Y;
2466
            }
2467

    
2468
            //
2469
            // Update the coordinates of the rectangle used for drag selection.
2470
            //
2471
            //캡쳐 중
2472
            if (mouseHandlingMode == MouseHandlingMode.Capture)
2473
            {
2474
                Canvas.SetLeft(dragCaptureBorder, x);
2475
                Canvas.SetTop(dragCaptureBorder, y);
2476
                dragCaptureBorder.Width = width;
2477
                dragCaptureBorder.Height = height;
2478
            }
2479
            //선택 중
2480
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
2481
            {
2482
                Canvas.SetLeft(dragSelectionBorder, x);
2483
                Canvas.SetTop(dragSelectionBorder, y);
2484
                dragSelectionBorder.Width = width;
2485
                dragSelectionBorder.Height = height;
2486
            }
2487
            else
2488
            {
2489
                Canvas.SetLeft(dragZoomBorder, x);
2490
                Canvas.SetTop(dragZoomBorder, y);
2491
                dragZoomBorder.Width = width;
2492
                dragZoomBorder.Height = height;
2493
            }
2494
        }
2495

    
2496
        private void drawingPannelRotate(double angle)
2497
        {
2498
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2499
            rotate.Angle = angle;
2500
            var rotationNum = Math.Abs((rotate.Angle / 90));
2501

    
2502
            if (angle == 90 || angle == 270)
2503
            {
2504
                double emptySize = zoomAndPanCanvas.Width;
2505
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
2506
                zoomAndPanCanvas.Height = emptySize;
2507
            }
2508
            if (angle == 0)
2509
            {
2510
                translate.X = 0;
2511
                translate.Y = 0;
2512
            }
2513
            else if (angle == 90)
2514
            {
2515
                translate.X = zoomAndPanCanvas.Width;
2516
                translate.Y = 0;
2517
            }
2518
            else if (angle == 180)
2519
            {
2520
                translate.X = zoomAndPanCanvas.Width;
2521
                translate.Y = zoomAndPanCanvas.Height;
2522
            }
2523
            else
2524
            {
2525
                translate.X = 0;
2526
                translate.Y = zoomAndPanCanvas.Height;
2527
            }
2528

    
2529
            zoomAndPanControl.RotationAngle = rotate.Angle;
2530

    
2531
            if (!testPanel2.IsHidden)
2532
            {
2533
                zoomAndPanControl2.RotationAngle = rotate.Angle;
2534
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
2535
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
2536
            }
2537

    
2538
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
2539
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
2540
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2541
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2542
            ViewerDataModel.Instance.MarkupAngle = rotate.Angle;
2543
        }
2544

    
2545
        private void syncPannelRotate(double angle)
2546
        {
2547
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2548
            rotate.Angle = angle;
2549
            var rotationNum = Math.Abs((rotate.Angle / 90));
2550

    
2551
            if (angle == 90 || angle == 270)
2552
            {
2553
                double emptySize = zoomAndPanCanvas2.Width;
2554
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2555
                zoomAndPanCanvas2.Height = emptySize;
2556
            }
2557
            if (angle == 0)
2558
            {
2559
                translate2.X = 0;
2560
                translate2.Y = 0;
2561
            }
2562
            else if (angle == 90)
2563
            {
2564
                translate2.X = zoomAndPanCanvas2.Width;
2565
                translate2.Y = 0;
2566
            }
2567
            else if (angle == 180)
2568
            {
2569
                translate2.X = zoomAndPanCanvas2.Width;
2570
                translate2.Y = zoomAndPanCanvas2.Height;
2571
            }
2572
            else
2573
            {
2574
                translate2.X = 0;
2575
                translate2.Y = zoomAndPanCanvas2.Height;
2576
            }
2577

    
2578
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2579
        }
2580

    
2581
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2582
        {
2583
            string Data_ = "";
2584

    
2585
            try
2586
            {
2587
                //Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2588
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2589
                if (Data_ != null || Data_ != "")
2590
                {
2591
                    //Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2592
                }
2593
                else
2594
                {
2595
                    //Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2596
                }
2597

    
2598
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2599
                //{
2600
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2601
                //    STATE = 0,
2602
                //};
2603
                if (Data_ != null)
2604
                {
2605
                    Image img = new Image();
2606
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2607
                    if (Data_.Contains(".svg"))
2608
                    {
2609
                        byte[] imageData = null;
2610
                        DrawingImage image = null;
2611
                        using (System.Net.WebClient web = new System.Net.WebClient())
2612
                        {
2613
                            imageData = web.DownloadData(new Uri(Data_));
2614
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2615
                            image = SvgReader.Load(stream);
2616
                        }
2617
                        img.Source = image;
2618
                    }
2619
                    else
2620
                    {
2621
                        img.Source = new BitmapImage(new Uri(Data_));
2622
                    }
2623

    
2624
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2625
                    {
2626
                        PointSet = new List<Point>(),
2627
                        FilePath = Data_,
2628
                        ImageData = img.Source,
2629
                        StartPoint = canvasZoomPanningMouseDownPoint,
2630
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2631
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2632
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width,
2633
                        canvasZoomPanningMouseDownPoint.Y),
2634
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2635
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2636
                    };
2637

    
2638
                    currentControl.PointSet = new List<Point>
2639
                                        {
2640
                                            currentControl.StartPoint,
2641
                                            currentControl.LeftBottomPoint,
2642
                                            currentControl.EndPoint,
2643
                                            currentControl.TopRightPoint,
2644
                                        };
2645
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2646
                    UndoData = new Undo_data()
2647
                    {
2648
                        IsUndo = false,
2649
                        Event = Event_Type.Create,
2650
                        EventTime = DateTime.Now,
2651
                        Markup_List = new List<Multi_Undo_data>()
2652
                    };
2653
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2654
                    {
2655
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2656
                    });
2657

    
2658
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2659
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2660
                    UndoData.Markup_List.Add(multi_Undo_Data);
2661
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2662

    
2663
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2664
                    currentControl.CommentID = Commons.shortGuid();
2665
                    currentControl.SymbolID = id;
2666
                    currentControl.GroupID = group_id;
2667
                    currentControl.ApplyTemplate();
2668
                    currentControl.SetImage();
2669

    
2670
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2671
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2672
                    SelectLayer.Children.Add(final);
2673
                }
2674
            }
2675
            catch (Exception ex)
2676
            {
2677
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2678
            }
2679
        }
2680

    
2681
        // 저장전 textbox 입력 완료 때문에 public로 하여 savecommand에서 호출하도록 임시로 함.
2682
        public async void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2683
        {
2684
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2685
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2686
            {
2687
                set_option.Value = double.Parse(set_option.ContentText);
2688
                //set_option.Focusable = false;
2689
                zoomAndPanControl.Focus();
2690
            }
2691

    
2692
            ConvertInkControlToPolygon();
2693

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

    
2698
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2699
            {
2700
                DeleteCommand.Instance.Execute(new[] { text_item });
2701
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2702
            }
2703

    
2704
            /// up to here
2705

    
2706
            foreach (var item in ViewerDataModel.Instance.MarkupControls_USER)
2707
            {
2708
                if (item as ArrowTextControl != null)
2709
                {
2710
                    (item as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2711
                }
2712
                else if (item as TextControl != null)
2713
                {
2714
                    (item as TextControl).Base_TextBox.IsHitTestVisible = false;
2715
                }
2716
            }
2717

    
2718
            //if (currentControl != null)
2719
            {
2720
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).IsEditingMode == true).FirstOrDefault();
2721
                if (text_item_ != null)
2722
                {
2723
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2724
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2725
                    (text_item_ as TextControl).IsEditingMode = false;
2726
                    currentControl = null;
2727
                }
2728

    
2729
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2730
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2731
                {
2732
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2733
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2734
                    currentControl = null;
2735
                }
2736
            }
2737

    
2738
            double Ang = 0;
2739
            if (rotate.Angle != 0)
2740
            {
2741
                Ang = 360 - rotate.Angle;
2742
            }
2743

    
2744
            if (e.OriginalSource is System.Windows.Controls.Image)
2745
            {
2746
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2747
            }
2748
            /*
2749
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2750
            {
2751
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2752
                if(symbol_id != null)
2753
                {
2754
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2755
                }
2756
            }
2757

    
2758
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2759
            {
2760
                if (this._dragdropWindow != null)
2761
                {
2762
                    this._dragdropWindow.Close();
2763
                    this._dragdropWindow = null;
2764
                    symbol_id = null;
2765
                }
2766
            }
2767
            */
2768

    
2769
            if (e.LeftButton == MouseButtonState.Pressed)
2770
            {
2771
                CanvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2772
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2773

    
2774
                this.cursor = new Cursor(App.DefaultArrowCursorStream);
2775
                SetCursor();
2776

    
2777
                if (!ViewerDataModel.Instance.IsPressCtrl)
2778
                {
2779
                    SelectionSet.Instance.UnSelect(this);
2780
                }
2781
            }
2782

    
2783
            if (e.MiddleButton == MouseButtonState.Pressed)
2784
            {
2785
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2786
                cursor = Cursors.SizeAll;
2787
                SetCursor();
2788
            }
2789
            if (e.RightButton == MouseButtonState.Pressed)
2790
            {
2791
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2792
                cursor = Cursors.SizeAll;
2793
                SetCursor();
2794
            }
2795
            else if (e.XButton1 == MouseButtonState.Pressed)
2796
            {
2797
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2798
                {
2799
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2800
                }
2801

    
2802
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2803
            }
2804
            else if (e.XButton2 == MouseButtonState.Pressed)
2805
            {
2806
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2807
                {
2808
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2809
                }
2810
            }
2811

    
2812
            bool isArrowTextEdit = false;
2813

    
2814
            if (currentControl is ArrowTextControl textControl)
2815
            {
2816
                if (textControl.IsEditingMode)
2817
                    isArrowTextEdit = true;
2818
            }
2819

    
2820
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2821
            {
2822
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2823
                {
2824
                    if (SelectLayer.Children.Count == 0)
2825
                    {
2826
                        isLeftMouseButtonDownOnWindow = true;
2827
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2828
                    }
2829

    
2830
                    if (controlType == ControlType.None)
2831
                    {
2832
                        isLeftMouseButtonDownOnWindow = true;
2833
                    }
2834
                }
2835

    
2836
                /// 캡쳐 모드 설정
2837
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2838
                {
2839
                    dragCaptureBorder.Visibility = Visibility.Visible;
2840
                    isLeftMouseButtonDownOnWindow = true;
2841
                }
2842

    
2843
                /// 줌 모드 설정
2844
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2845
                {
2846
                    isLeftMouseButtonDownOnWindow = true;
2847
                }
2848

    
2849
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
2850

    
2851
                if (control == null)
2852
                {
2853
                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
2854
                }
2855
                else
2856
                {
2857
                    if (ControlTypeExtansions.LineTypes.Contains(control.ControlType))
2858
                    {
2859
                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
2860
                    }
2861

    
2862
                    AdornerFinal final = null;
2863

    
2864
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2865
                    {
2866
                        /// 기존 selection 해제
2867
                        SelectionSet.Instance.UnSelect(this);
2868

    
2869
                        final = new AdornerFinal(control);
2870

    
2871
                        this.Control_Style(control);
2872

    
2873
                        if ((control as IPath) != null)
2874
                        {
2875
                            if ((control as IPath).LineSize != 0)
2876
                            {
2877
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2878
                            }
2879
                        }
2880
                        if ((control as IShapeControl) != null)
2881
                        {
2882
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2883
                            {
2884
                                ViewerDataModel.Instance.checkHatchShape = true;
2885
                            }
2886
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2887
                            {
2888
                                ViewerDataModel.Instance.checkFillShape = true;
2889
                            }
2890
                            else
2891
                            {
2892
                                ViewerDataModel.Instance.checkHatchShape = false;
2893
                                ViewerDataModel.Instance.checkFillShape = false;
2894
                            }
2895
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2896
                        }
2897

    
2898
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2899

    
2900
                        if ((control as TextControl) != null)
2901
                        {
2902
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as TextControl).TextFamily);
2903

    
2904
                            if (!((control as TextControl).EnableEditing))
2905
                            {
2906
                                (control as TextControl).EnableEditing = true;
2907
                            }
2908
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2909
                            {
2910
                                ViewerDataModel.Instance.checkTextStyle = true;
2911
                            }
2912
                            else
2913
                            {
2914
                                ViewerDataModel.Instance.checkTextStyle = false;
2915
                            }
2916
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2917
                            {
2918
                                ViewerDataModel.Instance.checkTextWeight = true;
2919
                            }
2920
                            else
2921
                            {
2922
                                ViewerDataModel.Instance.checkTextWeight = false;
2923
                            }
2924
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2925
                            {
2926
                                ViewerDataModel.Instance.checkUnderLine = true;
2927
                            }
2928
                            else
2929
                            {
2930
                                ViewerDataModel.Instance.checkUnderLine = false;
2931
                            }
2932
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2933
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2934
                        }
2935
                        else if ((control as ArrowTextControl) != null)
2936
                        {
2937
                            ViewerDataModel.Instance.SystemMain.dzTopMenu.SetFont((control as ArrowTextControl).TextFamily);
2938

    
2939
                            if (!((control as ArrowTextControl).EnableEditing))
2940
                            {
2941
                                (control as ArrowTextControl).EnableEditing = true;
2942
                            }
2943
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2944
                            {
2945
                                ViewerDataModel.Instance.checkTextStyle = true;
2946
                            }
2947
                            else
2948
                            {
2949
                                ViewerDataModel.Instance.checkTextStyle = false;
2950
                            }
2951
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2952
                            {
2953
                                ViewerDataModel.Instance.checkTextWeight = true;
2954
                            }
2955
                            else
2956
                            {
2957
                                ViewerDataModel.Instance.checkTextWeight = false;
2958
                            }
2959
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2960
                            {
2961
                                ViewerDataModel.Instance.checkUnderLine = true;
2962
                            }
2963
                            else
2964
                            {
2965
                                ViewerDataModel.Instance.checkUnderLine = false;
2966
                            }
2967
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2968
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2969
                        }
2970
                        else if ((control as RectCloudControl) != null)
2971
                        {
2972
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2973
                        }
2974
                        else if ((control as CloudControl) != null)
2975
                        {
2976
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2977
                        }
2978
                    }
2979
                    else
2980
                    {
2981
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2982
                        SelectionSet.Instance.UnSelect(this);
2983
                        comment.Add(control);
2984

    
2985
                        Control_Style(control);
2986

    
2987
                        final = new AdornerFinal(comment);
2988
                    }
2989

    
2990
                    if (final != null)
2991
                    {
2992
                        this.SelectLayer.Children.Add(final);
2993
                    }
2994
                }
2995
            }
2996
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2997
            {
2998

    
2999

    
3000
                init();
3001
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
3002
                if (cursor != Cursors.SizeAll)
3003
                {
3004
                    cursor = Cursors.Cross;
3005
                    SetCursor();
3006
                }
3007
                bool init_user = false;
3008
                foreach (var user in gridViewMarkup.Items)
3009
                {
3010
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
3011
                    {
3012
                        init_user = true;
3013
                    }
3014
                }
3015
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
3016
                {
3017
                    // 기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요
3018
                    RadWindow.Alert(new DialogParameters
3019
                    {
3020
                        Owner = Application.Current.MainWindow,
3021
                        Theme = new VisualStudio2013Theme(),
3022
                        Header = "Info",
3023
                        Content = "Existing comments already existed. Select from the user list first",
3024
                    });
3025
                    return;
3026
                }
3027
                else
3028
                {
3029
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
3030
                    if (item != null)
3031
                    {
3032
                        App.Custom_ViewInfoId = item.MarkupInfoID;
3033
                    }
3034
                }
3035
                
3036
                switch (controlType)
3037
                {
3038
                    case ControlType.Coordinate:
3039
                        {
3040
                            if (e.LeftButton == MouseButtonState.Pressed)
3041
                            {
3042
                                if (currentControl is CoordinateControl)
3043
                                {
3044
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3045
                                    {
3046
                                        return;
3047
                                    }
3048

    
3049
                                    CreateCommand.Instance.Execute(currentControl);
3050

    
3051
                                    currentControl = null;
3052
                                    this.cursor = Cursors.Arrow;
3053
                                }
3054
                                else
3055
                                {
3056
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3057
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
3058
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
3059
                                    {
3060
                                        currentControl = null;
3061
                                        this.cursor = Cursors.Arrow;
3062
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
3063
                                        return;
3064
                                    }
3065
                                    else
3066
                                    {
3067
                                        currentControl = new CoordinateControl
3068
                                        {
3069
                                            Background = new SolidColorBrush(Colors.Black),
3070
                                            StartPoint = this.CanvasDrawingMouseDownPoint,
3071
                                            ControlType = ControlType.Coordinate
3072
                                        };
3073

    
3074
                                        currentControl.CommentID = Commons.shortGuid();
3075
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3076
                                        currentControl.IsNew = true;
3077

    
3078
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3079

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

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

    
3098
                                    CreateCommand.Instance.Execute(currentControl);
3099

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

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

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

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

    
3134
                                    CreateCommand.Instance.Execute(currentControl);
3135

    
3136
                                    currentControl = null;
3137
                                    this.cursor = Cursors.Arrow;
3138
                                }
3139
                                else
3140
                                {
3141
                                    currentControl = new OverlapWhiteControl
3142
                                    {
3143
                                        Background = new SolidColorBrush(Colors.Black),
3144
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3145
                                        ControlType = ControlType.OverlapWhite
3146
                                    };
3147

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

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

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

    
3170
                                    CreateCommand.Instance.Execute(currentControl);
3171

    
3172
                                    currentControl = null;
3173
                                    this.cursor = Cursors.Arrow;
3174
                                }
3175
                                else
3176
                                {
3177
                                    currentControl = new ClipWhiteControl
3178
                                    {
3179
                                        Background = new SolidColorBrush(Colors.Black),
3180
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3181
                                        ControlType = ControlType.ClipWhite
3182
                                    };
3183

    
3184
                                    currentControl.CommentID = Commons.shortGuid();
3185
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3186
                                    currentControl.IsNew = true;
3187
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3188

    
3189
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3190
                                }
3191
                            }
3192
                        }
3193
                        break;
3194

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

    
3207
                                    CreateCommand.Instance.Execute(currentControl);
3208
                                    currentControl = null;
3209
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3210
                                }
3211
                                else
3212
                                {
3213
                                    currentControl = new RectangleControl
3214
                                    {
3215
                                        Background = new SolidColorBrush(Colors.Black),
3216
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3217
                                        ControlType = ControlType.Rectangle
3218
                                    };
3219

    
3220
                                    currentControl.CommentID = Commons.shortGuid();
3221
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3222
                                    currentControl.IsNew = true;
3223
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3224

    
3225
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3226
                                }
3227
                            }
3228
                        }
3229
                        break;
3230

    
3231
                    case ControlType.RectCloud:
3232
                        {
3233
                            if (e.LeftButton == MouseButtonState.Pressed)
3234
                            {
3235
                                if (currentControl is RectCloudControl)
3236
                                {
3237
                                    //20180906 LJY TEST IsRotationDrawingEnable
3238
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3239
                                    {
3240
                                        return;
3241
                                    }
3242

    
3243
                                    CreateCommand.Instance.Execute(currentControl);
3244

    
3245
                                    currentControl = null;
3246

    
3247
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
3248
                                }
3249
                                else
3250
                                {
3251
                                    currentControl = new RectCloudControl
3252
                                    {
3253
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3254
                                        ControlType = ControlType.RectCloud,
3255
                                        Background = new SolidColorBrush(Colors.Black)
3256
                                    };
3257

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

    
3267
                    case ControlType.Circle:
3268
                        {
3269
                            if (e.LeftButton == MouseButtonState.Pressed)
3270
                            {
3271
                                if (currentControl is CircleControl)
3272
                                {
3273
                                    //20180906 LJY TEST IsRotationDrawingEnable
3274
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3275
                                    {
3276
                                        return;
3277
                                    }
3278

    
3279
                                    CreateCommand.Instance.Execute(currentControl);
3280

    
3281
                                    currentControl = null;
3282
                                }
3283
                                else
3284
                                {
3285
                                    currentControl = new CircleControl
3286
                                    {
3287
                                        StartPoint = this.CanvasDrawingMouseDownPoint,
3288
                                        LeftBottomPoint = this.CanvasDrawingMouseDownPoint,
3289
                                        Background = new SolidColorBrush(Colors.Black)
3290
                                    };
3291

    
3292
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3293
                                    currentControl.CommentID = Commons.shortGuid();
3294
                                    currentControl.IsNew = true;
3295
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3296
                                }
3297
                            }
3298
                        }
3299
                        break;
3300

    
3301
                    case ControlType.Triangle:
3302
                        {
3303
                            if (e.LeftButton == MouseButtonState.Pressed)
3304
                            {
3305
                                if (currentControl is TriControl)
3306
                                {
3307
                                    var content = currentControl as TriControl;
3308
                                    if (content.MidPoint == new Point(0, 0))
3309
                                    {
3310
                                        content.MidPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3311
                                    }
3312
                                    else
3313
                                    {
3314
                                        //20180906 LJY TEST IsRotationDrawingEnable
3315
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3316
                                        {
3317
                                            return;
3318
                                        }
3319

    
3320
                                        CreateCommand.Instance.Execute(currentControl);
3321

    
3322
                                        currentControl = null;
3323
                                    }
3324
                                }
3325
                                else
3326
                                {
3327
                                    currentControl = new TriControl
3328
                                    {
3329
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3330
                                        Background = new SolidColorBrush(Colors.Black),
3331
                                    };
3332

    
3333
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3334
                                    currentControl.CommentID = Commons.shortGuid();
3335
                                    currentControl.IsNew = true;
3336
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3337
                                }
3338
                            }
3339
                        }
3340
                        break;
3341

    
3342
                    case ControlType.CancelLine:
3343
                    case ControlType.SingleLine:
3344
                    case ControlType.ArrowLine:
3345
                    case ControlType.TwinLine:
3346
                    case ControlType.DimLine:
3347
                        {
3348
                            if (e.LeftButton == MouseButtonState.Pressed)
3349
                            {
3350
                                if (currentControl is LineControl)
3351
                                {
3352
                                    //20180906 LJY TEST IsRotationDrawingEnable
3353
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3354
                                    {
3355
                                        return;
3356
                                    }
3357

    
3358
                                    CreateCommand.Instance.Execute(currentControl);
3359
                                    currentControl = null;
3360
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3361
                                }
3362
                                else
3363
                                {
3364
                                    currentControl = new LineControl
3365
                                    {
3366
                                        ControlType = this.controlType,
3367
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3368
                                        Background = new SolidColorBrush(Colors.Black)
3369
                                    };
3370

    
3371
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3372
                                    currentControl.CommentID = Commons.shortGuid();
3373
                                    currentControl.IsNew = true;
3374
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3375
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3376
                                }
3377
                            }
3378
                        }
3379
                        break;
3380

    
3381
                    case ControlType.PolygonControl:
3382
                        {
3383
                            if (currentControl is PolygonControl)
3384
                            {
3385
                                var control = currentControl as PolygonControl;
3386

    
3387
                                if (e.RightButton == MouseButtonState.Pressed)
3388
                                {
3389
                                    control.IsCompleted = true;
3390
                                }
3391

    
3392
                                if (!control.IsCompleted)
3393
                                {
3394
                                    control.PointSet.Add(control.EndPoint);
3395
                                }
3396
                                else
3397
                                {
3398
                                    //20180906 LJY TEST IsRotationDrawingEnable
3399
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3400
                                    {
3401
                                        return;
3402
                                    }
3403

    
3404
                                    var firstPoint = control.PointSet.First();
3405
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
3406
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
3407
                                    control.PointSet.Add(firstPoint);
3408

    
3409
                                    control.ApplyOverViewData();
3410

    
3411
                                    CreateCommand.Instance.Execute(currentControl);
3412
                                    control.UpdateControl();
3413
                                    currentControl = null;
3414
                                }
3415
                            }
3416
                            else
3417
                            {
3418
                                if (e.LeftButton == MouseButtonState.Pressed)
3419
                                {
3420
                                    currentControl = new PolygonControl
3421
                                    {
3422
                                        PointSet = new List<Point>(),
3423
                                    };
3424

    
3425
                                    var polygonControl = (currentControl as PolygonControl);
3426
                                    currentControl.CommentID = Commons.shortGuid();
3427
                                    currentControl.IsNew = true;
3428
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3429
                                    polygonControl.StartPoint = CanvasDrawingMouseDownPoint;
3430
                                    polygonControl.EndPoint = CanvasDrawingMouseDownPoint;
3431
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3432
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3433
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3434
                                    polygonControl.ApplyTemplate();
3435
                                    polygonControl.Visibility = Visibility.Visible;
3436
                                }
3437
                            }
3438
                        }
3439
                        break;
3440

    
3441
                    case ControlType.ChainLine:
3442
                        {
3443
                            if (currentControl is PolygonControl)
3444
                            {
3445
                                var control = currentControl as PolygonControl;
3446

    
3447
                                if (e.RightButton == MouseButtonState.Pressed)
3448
                                {
3449
                                    //20180906 LJY TEST IsRotationDrawingEnable
3450
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3451
                                    {
3452
                                        return;
3453
                                    }
3454

    
3455
                                    CreateCommand.Instance.Execute(currentControl);
3456

    
3457
                                    currentControl = null;
3458
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3459
                                    return;
3460
                                }
3461

    
3462
                                if (!control.IsCompleted)
3463
                                {
3464
                                    control.PointSet.Add(control.EndPoint);
3465
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3466
                                }
3467
                            }
3468
                            else
3469
                            {
3470
                                if (e.LeftButton == MouseButtonState.Pressed)
3471
                                {
3472
                                    MainAngle.Visibility = Visibility.Visible;
3473
                                    currentControl = new PolygonControl
3474
                                    {
3475
                                        PointSet = new List<Point>(),
3476
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
3477
                                        ControlType = ControlType.ChainLine,
3478
                                        DashSize = ViewerDataModel.Instance.DashSize,
3479
                                        LineSize = ViewerDataModel.Instance.LineSize,
3480
                                        //PointC = new StylusPointSet()
3481
                                    };
3482

    
3483
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3484
                                    //{
3485
                                    var polygonControl = (currentControl as PolygonControl);
3486
                                    currentControl.CommentID = Commons.shortGuid();
3487
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3488
                                    currentControl.IsNew = true;
3489
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3490
                                    //currentControl.OnApplyTemplate();
3491
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3492
                                    //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
3493
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3494
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3495
                                    //}
3496
                                }
3497
                            }
3498
                        }
3499
                        break;
3500

    
3501
                    case ControlType.ArcLine:
3502
                        {
3503
                            if (e.LeftButton == MouseButtonState.Pressed)
3504
                            {
3505
                                if (currentControl is ArcControl)
3506
                                {
3507
                                    //20180906 LJY TEST IsRotationDrawingEnable
3508
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3509
                                    {
3510
                                        return;
3511
                                    }
3512

    
3513
                                    CreateCommand.Instance.Execute(currentControl);
3514

    
3515
                                    currentControl = null;
3516
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3517
                                }
3518
                                else
3519
                                {
3520
                                    currentControl = new ArcControl
3521
                                    {
3522
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3523
                                        Background = new SolidColorBrush(Colors.Black)
3524
                                    };
3525
                                    currentControl.CommentID = Commons.shortGuid();
3526
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3527
                                    currentControl.IsNew = true;
3528
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3530
                                }
3531
                            }
3532
                            else if (e.RightButton == MouseButtonState.Pressed)
3533
                            {
3534
                                if (currentControl != null)
3535
                                {
3536
                                    (currentControl as ArcControl).setClock();
3537
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
3538
                                }
3539
                            }
3540
                        }
3541
                        break;
3542

    
3543
                    case ControlType.ArcArrow:
3544
                        {
3545
                            if (e.LeftButton == MouseButtonState.Pressed)
3546
                            {
3547
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3548
                                //{
3549
                                if (currentControl is ArrowArcControl)
3550
                                {
3551
                                    //20180906 LJY TEST IsRotationDrawingEnable
3552
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3553
                                    {
3554
                                        return;
3555
                                    }
3556

    
3557
                                    CreateCommand.Instance.Execute(currentControl);
3558

    
3559
                                    currentControl = null;
3560
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3561
                                }
3562
                                else
3563
                                {
3564
                                    currentControl = new ArrowArcControl
3565
                                    {
3566
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3567
                                        Background = new SolidColorBrush(Colors.Black)
3568
                                    };
3569
                                    currentControl.CommentID = Commons.shortGuid();
3570
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3571
                                    currentControl.IsNew = true;
3572
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3573
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3574
                                }
3575
                                //}
3576
                            }
3577
                            else if (e.RightButton == MouseButtonState.Pressed)
3578
                            {
3579
                                if (currentControl != null)
3580
                                {
3581
                                    (currentControl as ArrowArcControl).setClock();
3582
                                    (currentControl as ArrowArcControl).MiddlePoint = new Point(0, 0);
3583
                                    //(currentControl as ArcControl).ApplyTemplate();
3584
                                }
3585
                            }
3586
                        }
3587
                        break;
3588

    
3589
                    case ControlType.ArrowMultiLine:
3590
                        {
3591
                            if (e.LeftButton == MouseButtonState.Pressed)
3592
                            {
3593
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3594
                                //{
3595
                                if (currentControl is ArrowControl_Multi)
3596
                                {
3597
                                    var content = currentControl as ArrowControl_Multi;
3598
                                    if (content.MiddlePoint == new Point(0, 0))
3599
                                    {
3600
                                        if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
3601
                                        {
3602
                                            content.MiddlePoint = content.EndPoint;
3603
                                        }
3604
                                        else
3605
                                        {
3606
                                            content.MiddlePoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y);
3607
                                        }
3608
                                    }
3609
                                    else
3610
                                    {
3611
                                        //20180906 LJY TEST IsRotationDrawingEnable
3612
                                        if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3613
                                        {
3614
                                            return;
3615
                                        }
3616

    
3617
                                        CreateCommand.Instance.Execute(currentControl);
3618

    
3619
                                        currentControl = null;
3620
                                        ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
3621
                                    }
3622
                                }
3623
                                else
3624
                                {
3625
                                    currentControl = new ArrowControl_Multi
3626
                                    {
3627
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
3628
                                        Background = new SolidColorBrush(Colors.Black)
3629
                                    };
3630
                                    currentControl.CommentID = Commons.shortGuid();
3631
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3632
                                    currentControl.IsNew = true;
3633
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3634
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3635
                                }
3636
                                //}
3637
                            }
3638
                        }
3639
                        break;
3640

    
3641
                    case ControlType.PolygonCloud:
3642
                        {
3643
                            if (currentControl is CloudControl)
3644
                            {
3645
                                var control = currentControl as CloudControl;
3646
                                if (e.RightButton == MouseButtonState.Pressed)
3647
                                {
3648
                                    control.IsCompleted = true;
3649
                                }
3650

    
3651
                                if (!control.IsCompleted)
3652
                                {
3653
                                    control.PointSet.Add(control.EndPoint);
3654
                                }
3655
                                else
3656
                                {
3657
                                    //20180906 LJY TEST IsRotationDrawingEnable
3658
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3659
                                    {
3660
                                        return;
3661
                                    }
3662

    
3663
                                    CreateCommand.Instance.Execute(currentControl);
3664

    
3665
                                    control.isTransOn = true;
3666
                                    var firstPoint = control.PointSet.First();
3667

    
3668
                                    control.PointSet.Add(firstPoint);
3669
                                    control.DrawingCloud();
3670
                                    control.ApplyOverViewData();
3671

    
3672
                                    currentControl = null;
3673
                                }
3674
                            }
3675
                            else
3676
                            {
3677
                                if (e.LeftButton == MouseButtonState.Pressed)
3678
                                {
3679
                                    currentControl = new CloudControl
3680
                                    {
3681
                                        PointSet = new List<Point>(),
3682
                                        PointC = new StylusPointSet()
3683
                                    };
3684

    
3685
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3686
                                    //{
3687
                                    var polygonControl = (currentControl as CloudControl);
3688
                                    currentControl.CommentID = Commons.shortGuid();
3689
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3690
                                    currentControl.IsNew = true;
3691
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3692

    
3693
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3694
                                    polygonControl.PointSet.Add(CanvasDrawingMouseDownPoint);
3695

    
3696
                                    //}
3697
                                }
3698
                            }
3699
                        }
3700
                        break;
3701

    
3702
                    case ControlType.ImgControl:
3703
                        {
3704
                            if (e.LeftButton == MouseButtonState.Pressed)
3705
                            {
3706
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3707
                                //{
3708
                                if (currentControl is ImgControl)
3709
                                {
3710
                                    //20180906 LJY TEST IsRotationDrawingEnable
3711
                                    if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3712
                                    {
3713
                                        return;
3714
                                    }
3715

    
3716
                                    CreateCommand.Instance.Execute(currentControl);
3717
                                    controlType = ControlType.ImgControl;
3718
                                    currentControl = null;
3719
                                }
3720
                                else
3721
                                {
3722
                                    string extension = System.IO.Path.GetExtension(filename).ToUpper();
3723
                                    if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3724
                                    {
3725
                                        UriBuilder downloadUri = new UriBuilder(App.BaseAddress);
3726
                                        UriBuilder uri = new UriBuilder(filename);
3727
                                        uri.Host = downloadUri.Host;
3728
                                        uri.Port = downloadUri.Port;
3729

    
3730
                                        Image img = new Image();
3731
                                        if (filename.Contains(".svg"))
3732
                                        {
3733
                                            byte[] imageData = null;
3734
                                            DrawingImage image = null;
3735
                                            using (System.Net.WebClient web = new System.Net.WebClient())
3736
                                            {
3737
                                                imageData = web.DownloadData(uri.Uri);
3738
                                                System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3739
                                                image = SvgReader.Load(stream);
3740
                                            }
3741
                                            img.Source = image;
3742
                                        }
3743
                                        else
3744
                                        {
3745
                                            img.Source = new BitmapImage(uri.Uri);
3746
                                        }
3747

    
3748
                                        currentControl = new ImgControl
3749
                                        {
3750
                                            Background = new SolidColorBrush(Colors.Black),
3751
                                            PointSet = new List<Point>(),
3752
                                            FilePath = uri.Uri.ToString(),
3753
                                            ImageData = img.Source,
3754
                                            StartPoint = CanvasDrawingMouseDownPoint,
3755
                                            EndPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y + 100),
3756
                                            TopRightPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y + 100),
3757
                                            LeftBottomPoint = new Point(CanvasDrawingMouseDownPoint.X + 100, CanvasDrawingMouseDownPoint.Y),
3758
                                            ControlType = ControlType.ImgControl
3759
                                        };
3760

    
3761
                                        currentControl.CommentID = Commons.shortGuid();
3762
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3763
                                        currentControl.IsNew = true;
3764
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3765

    
3766
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3767
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3768
                                    }
3769
                                }
3770
                                //}
3771
                            }
3772
                        }
3773
                        break;
3774

    
3775
                    case ControlType.Date:
3776
                        {
3777
                            if (e.LeftButton == MouseButtonState.Pressed)
3778
                            {
3779
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3780
                                //{
3781
                                if (currentControl is DateControl)
3782
                                {
3783
                                    //20180906 LJY TEST IsRotationDrawingEnable
3784
                                    if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3785
                                    {
3786
                                        return;
3787
                                    }
3788

    
3789
                                    CreateCommand.Instance.Execute(currentControl);
3790
                                    currentControl = null;
3791

    
3792
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3793
                                    { 
3794
                                        controlType = ControlType.None;
3795
                                        IsSwingMode = false;
3796
                                        Common.ViewerDataModel.Instance.SelectedControl = "";
3797
                                        Common.ViewerDataModel.Instance.ControlTag = null;
3798
                                        mouseHandlingMode = MouseHandlingMode.None;
3799
                                        this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3800
                                        txtBatch.Visibility = Visibility.Collapsed;
3801
                                    }
3802
                                }
3803
                                else
3804
                                {
3805
                                    currentControl = new DateControl
3806
                                    {
3807
                                        StartPoint = CanvasDrawingMouseDownPoint,
3808
                                        Background = new SolidColorBrush(Colors.Black)
3809
                                    };
3810
                                    currentControl.CommentID = Commons.shortGuid();
3811
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3812
                                    currentControl.IsNew = true;
3813
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3814

    
3815
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
3816
                                    if (currentControl is ImgControl)
3817
                                    {
3818
                                        (currentControl as ImgControl).CommentAngle -= rotate.Angle;
3819
                                    }
3820
                                }
3821
                                //}
3822
                            }
3823
                        }
3824
                        break;
3825

    
3826
                    case ControlType.TextControl:
3827
                        {
3828
                            if (e.LeftButton == MouseButtonState.Pressed)
3829
                            {
3830
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3831
                                {
3832
                                    currentControl = new TextControl
3833
                                    {
3834
                                        ControlType = controlType
3835
                                    };
3836
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3837
                                    currentControl.CommentID = Commons.shortGuid();
3838
                                    currentControl.IsNew = true;
3839
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3840
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3841
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3842

    
3843
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3844
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3845

    
3846
                                    (currentControl as TextControl).ControlType_No = 0;
3847
                                    (currentControl as TextControl).CommentAngle -= rotate.Angle;
3848
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3849
                                    (currentControl as TextControl).ApplyTemplate();
3850
                                    (currentControl as TextControl).Base_TextBox.Focus();
3851
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3852
                                    CreateCommand.Instance.Execute(currentControl);
3853
                                }
3854
                            }
3855
                        }
3856
                        break;
3857

    
3858
                    case ControlType.TextBorder:
3859
                        {
3860
                            if (e.LeftButton == MouseButtonState.Pressed)
3861
                            {
3862
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3863
                                {
3864
                                    currentControl = new TextControl
3865
                                    {
3866
                                        ControlType = controlType
3867
                                    };
3868

    
3869
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3870
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3871
                                    currentControl.CommentID = Commons.shortGuid();
3872
                                    currentControl.IsNew = true;
3873
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3874
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3875
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3876
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3877

    
3878
                                    (currentControl as TextControl).ControlType_No = 1;
3879
                                    (currentControl as TextControl).CommentAngle = Ang;
3880
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3881
                                    (currentControl as TextControl).ApplyTemplate();
3882
                                    (currentControl as TextControl).Base_TextBox.Focus();
3883
                                    (currentControl as TextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3884
                                    CreateCommand.Instance.Execute(currentControl);
3885
                                }
3886
                            }
3887
                        }
3888
                        break;
3889

    
3890
                    case ControlType.TextCloud:
3891
                        {
3892
                            if (e.LeftButton == MouseButtonState.Pressed)
3893
                            {
3894
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3895
                                {
3896
                                    currentControl = new TextControl
3897
                                    {
3898
                                        ControlType = controlType
3899
                                    };
3900

    
3901
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3902
                                    currentControl.CommentID = Commons.shortGuid();
3903
                                    currentControl.IsNew = true;
3904
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3905
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3906

    
3907
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3908
                                    currentControl.SetValue(TextControl.CanvasXProperty, CanvasDrawingMouseDownPoint.X);
3909
                                    currentControl.SetValue(TextControl.CanvasYProperty, CanvasDrawingMouseDownPoint.Y);
3910

    
3911
                                    (currentControl as TextControl).CommentAngle = Ang;
3912
                                    (currentControl as TextControl).ControlType_No = 2;
3913
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3914
                                    (currentControl as TextControl).ApplyTemplate();
3915

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

    
3918
                                    (currentControl as TextControl).Base_TextBox.Focus();
3919
                                    CreateCommand.Instance.Execute(currentControl);
3920
                                    
3921
                                    //currentControl = null;
3922
                                }
3923
                            }
3924
                        }
3925
                        break;
3926

    
3927
                    case ControlType.ArrowTextControl:
3928
                        {
3929
                            if (e.LeftButton == MouseButtonState.Pressed)
3930
                            {
3931
                                if (currentControl is ArrowTextControl)
3932
                                {
3933
                                    //20180906 LJY TEST IsRotationDrawingEnable
3934
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3935
                                    {
3936
                                        return;
3937
                                    }
3938

    
3939
                                    CreateCommand.Instance.Execute(currentControl);
3940

    
3941
                                    try
3942
                                    {
3943
                                        if(!(currentControl as ArrowTextControl).IsEditingMode)
3944
                                        {
3945
                                            ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3946
                                        }
3947
                                    }
3948
                                    catch (Exception ex)
3949
                                    {
3950
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3951
                                    }
3952

    
3953
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3954
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3955
                                    (currentControl as ArrowTextControl).IsNew = false;
3956
                                    currentControl = null;
3957
                                }
3958
                                else
3959
                                {
3960
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3961
                                    //{
3962
                                    currentControl = new ArrowTextControl()
3963
                                    {
3964
                                        PageAngle = ViewerDataModel.Instance.PageAngle
3965
                                    };
3966

    
3967
                                    currentControl.CommentID = Commons.shortGuid();
3968
                                    currentControl.IsNew = true;
3969
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3970

    
3971
                                    try
3972
                                    {
3973
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3974
                                    }
3975
                                    catch (Exception ex)
3976
                                    {
3977
                                        System.Diagnostics.Debug.WriteLine(ex.ToString());
3978
                                    }
3979

    
3980
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3981
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
3982
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
3983
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3984
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3985

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

    
3989
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3990
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3991
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
3992
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
3993

    
3994
                                    //}
3995
                                }
3996
                            }
3997
                        }
3998
                        break;
3999

    
4000
                    case ControlType.ArrowTransTextControl:
4001
                        {
4002
                            if (e.LeftButton == MouseButtonState.Pressed)
4003
                            {
4004
                                if (currentControl is ArrowTextControl)
4005
                                {
4006
                                    //20180906 LJY TEST IsRotationDrawingEnable
4007
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4008
                                    {
4009
                                        return;
4010
                                    }
4011

    
4012
                                    CreateCommand.Instance.Execute(currentControl);
4013

    
4014
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4015

    
4016
                                    currentControl.IsNew = false;
4017
                                    currentControl = null;
4018
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4019
                                }
4020
                                else
4021
                                {
4022
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4023
                                    //{
4024
                                    currentControl = new ArrowTextControl()
4025
                                    {
4026
                                        ControlType = ControlType.ArrowTransTextControl,
4027
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4028
                                    };
4029
                                    currentControl.CommentID = Commons.shortGuid();
4030
                                    currentControl.IsNew = true;
4031
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4032
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4033
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4034
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4035
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4036
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4037
                                    (currentControl as ArrowTextControl).isFixed = true;
4038
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4039

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

    
4043
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4044
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4045
                                    (currentControl as ArrowTextControl).isTrans = true;
4046
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4047
                                }
4048
                            }
4049
                        }
4050
                        break;
4051

    
4052
                    case ControlType.ArrowTextBorderControl:
4053
                        {
4054
                            if (e.LeftButton == MouseButtonState.Pressed)
4055
                            {
4056
                                if (currentControl is ArrowTextControl)
4057
                                {
4058
                                    //20180906 LJY TEST IsRotationDrawingEnable
4059
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4060
                                    {
4061
                                        return;
4062
                                    }
4063

    
4064
                                    CreateCommand.Instance.Execute(currentControl);
4065
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4066
                                    currentControl.IsNew = false;
4067
                                    currentControl = null;
4068
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4069
                                }
4070
                                else
4071
                                {
4072
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4073
                                    //{
4074
                                    currentControl = new ArrowTextControl()
4075
                                    {
4076
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4077
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4078
                                    };
4079
                                    currentControl.CommentID = Commons.shortGuid();
4080
                                    currentControl.IsNew = true;
4081
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4082
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4083

    
4084
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4085

    
4086
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4087

    
4088
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4089
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4090
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4091
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4092
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4093
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4094
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4095
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4096
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4097
                                    //}
4098
                                }
4099
                            }
4100
                        }
4101
                        break;
4102

    
4103
                    case ControlType.ArrowTransTextBorderControl:
4104
                        {
4105
                            if (e.LeftButton == MouseButtonState.Pressed)
4106
                            {
4107
                                if (currentControl is ArrowTextControl)
4108
                                {
4109
                                    //20180906 LJY TEST IsRotationDrawingEnable
4110
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4111
                                    {
4112
                                        return;
4113
                                    }
4114
                                    CreateCommand.Instance.Execute(currentControl);
4115
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4116
                                    currentControl.IsNew = false;
4117
                                    currentControl = null;
4118

    
4119
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4120
                                }
4121
                                else
4122
                                {
4123
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4124
                                    //{
4125
                                    currentControl = new ArrowTextControl()
4126
                                    {
4127
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
4128
                                        ControlType = ControlType.ArrowTransTextBorderControl,
4129
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4130
                                    };
4131
                                    
4132
                                    currentControl.CommentID = Commons.shortGuid();
4133
                                    currentControl.IsNew = true;
4134
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4135
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4136

    
4137
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4138

    
4139
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4140
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4141
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4142
                                    (currentControl as ArrowTextControl).isFixed = true;
4143
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4144

    
4145
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4146
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4147
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4148
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4149
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4150
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4151

    
4152
                                    //20180911 LJY
4153
                                    (currentControl as ArrowTextControl).isTrans = true;
4154

    
4155
                                    //}
4156
                                }
4157
                            }
4158
                        }
4159
                        break;
4160

    
4161
                    case ControlType.ArrowTextCloudControl:
4162
                        {
4163
                            if (e.LeftButton == MouseButtonState.Pressed)
4164
                            {
4165
                                if (currentControl is ArrowTextControl)
4166
                                {
4167
                                    //20180906 LJY TEST IsRotationDrawingEnable
4168
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4169
                                    {
4170
                                        return;
4171
                                    }
4172
                                    CreateCommand.Instance.Execute(currentControl);
4173
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4174
                                    currentControl.IsNew = false;
4175
                                    currentControl = null;
4176
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4177
                                }
4178
                                else
4179
                                {
4180
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4181
                                    //{
4182
                                    currentControl = new ArrowTextControl()
4183
                                    {
4184
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4185
                                        PageAngle = ViewerDataModel.Instance.PageAngle,
4186
                                        ControlType = ControlType.ArrowTextCloudControl
4187
                                    };
4188
                                    currentControl.CommentID = Commons.shortGuid();
4189
                                    currentControl.IsNew = true;
4190
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4191
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4192

    
4193
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4194
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4195
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4196
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4197
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4198
                                    (currentControl as ArrowTextControl).SetFontFamily((this.ParentOfType<MainWindow>().dzTopMenu.comboFontFamily.SelectedValue as Markus.Fonts.MarkusFont).FontFamily);
4199
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4200
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4201

    
4202
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4203
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4204
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4205
                                    //}
4206
                                }
4207
                            }
4208
                        }
4209
                        break;
4210

    
4211
                    case ControlType.ArrowTransTextCloudControl:
4212
                        {
4213
                            if (e.LeftButton == MouseButtonState.Pressed)
4214
                            {
4215
                                if (currentControl is ArrowTextControl)
4216
                                {
4217
                                    //20180906 LJY TEST IsRotationDrawingEnable
4218
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4219
                                    {
4220
                                        return;
4221
                                    }
4222
                                    CreateCommand.Instance.Execute(currentControl);
4223
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
4224
                                    currentControl.IsNew = false;
4225
                                    currentControl = null;
4226
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Collapsed);
4227
                                }
4228
                                else
4229
                                {
4230
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4231
                                    //{
4232
                                    currentControl = new ArrowTextControl()
4233
                                    {
4234
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
4235
                                        ControlType = ControlType.ArrowTransTextCloudControl,
4236
                                        PageAngle = ViewerDataModel.Instance.PageAngle
4237
                                    };
4238
                                    currentControl.CommentID = Commons.shortGuid();
4239
                                    currentControl.IsNew = true;
4240
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4241
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4242
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
4243

    
4244
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, CanvasDrawingMouseDownPoint);
4245
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, CanvasDrawingMouseDownPoint);
4246
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
4247
                                    (currentControl as ArrowTextControl).isFixed = true;
4248
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
4249

    
4250
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4251
                                    (currentControl as ArrowTextControl).CommentAngle -= rotate.Angle;
4252
                                    (currentControl as ArrowTextControl).SetFontFamily(this.ParentOfType<MainWindow>().dzTopMenu.GetFontFamily().FontFamily);
4253
                                    (currentControl as ArrowTextControl).ApplyTemplate();
4254
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
4255
                                    ViewerDataModel.Instance.SetAngleVisible(Visibility.Visible);
4256

    
4257
                                    //20180911 LJY
4258
                                    (currentControl as ArrowTextControl).isTrans = true;
4259
                                    //}
4260
                                }
4261
                            }
4262
                        }
4263
                        break;
4264
                    //강인구 추가
4265
                    case ControlType.Sign:
4266
                        {
4267
                            if (e.LeftButton == MouseButtonState.Pressed)
4268
                            {
4269
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4270
                                //{
4271
                                var _sign = await BaseTaskClient.GetSignDataAsync(App.ViewInfo.ProjectNO, App.ViewInfo.UserID);
4272

    
4273
                                if (_sign == null)
4274
                                {
4275
                                    txtBatch.Visibility = Visibility.Collapsed;
4276
                                    mouseHandlingMode = IKCOM.MouseHandlingMode.None;
4277
                                    controlType = ControlType.None;
4278

    
4279
                                    this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
4280
                                    this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
4281
                                    return;
4282
                                }
4283
                                else
4284
                                {
4285
                                    if ( Application.Current.Resources.Keys.OfType<string>().Count(x => x == "UserSign") == 0)
4286
                                    {
4287
                                        Application.Current.Resources.Add("UserSign", _sign);
4288
                                    }
4289
                                    else
4290
                                    {
4291
                                        Application.Current.Resources["UserSign"] = _sign;
4292
                                    }
4293
                                }
4294

    
4295
                                if (currentControl is SignControl)
4296
                                {
4297
                                    //20180906 LJY TEST IsRotationDrawingEnable
4298
                                    if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4299
                                    {
4300
                                        return;
4301
                                    }
4302

    
4303
                                    CreateCommand.Instance.Execute(currentControl);
4304
                                    currentControl = null;
4305
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4306
                                    {
4307
                                        txtBatch.Text = "Place Date";
4308
                                        controlType = ControlType.Date;
4309
                                    }
4310
                                }
4311
                                else
4312
                                {
4313
                                    currentControl = new SignControl
4314
                                    {
4315
                                        Background = new SolidColorBrush(Colors.Black),
4316
                                        UserNumber = App.ViewInfo.UserID,
4317
                                        ProjectNO = App.ViewInfo.ProjectNO,
4318
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4319
                                        EndPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4320
                                        ControlType = ControlType.Sign
4321
                                    };
4322

    
4323
                                    currentControl.CommentID = Commons.shortGuid();
4324
                                    currentControl.IsNew = true;
4325
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4326
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4327

    
4328
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4329
                                    (currentControl as SignControl).CommentAngle -= rotate.Angle;
4330
                                }
4331
                                //}
4332
                            }
4333
                        }
4334
                        break;
4335

    
4336
                    case ControlType.Mark:
4337
                        {
4338
                            if (e.LeftButton == MouseButtonState.Pressed)
4339
                            {
4340
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4341
                                //{
4342
                                if (currentControl is RectangleControl)
4343
                                {
4344
                                    //20180906 LJY TEST IsRotationDrawingEnable
4345
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4346
                                    {
4347
                                        return;
4348
                                    }
4349

    
4350
                                    CreateCommand.Instance.Execute(currentControl);
4351
                                    (currentControl as RectangleControl).ApplyOverViewData();
4352
                                    currentControl = null;
4353

    
4354
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4355

    
4356
                                    if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
4357
                                    {
4358
                                        txtBatch.Text = "Place Signature";
4359
                                        controlType = ControlType.Sign;
4360
                                    }
4361
                                }
4362
                                else
4363
                                {
4364
                                    currentControl = new RectangleControl
4365
                                    {
4366
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4367
                                        Background = new SolidColorBrush(Colors.Black),
4368
                                        ControlType = ControlType.Mark,
4369
                                        Paint = PaintSet.Fill
4370
                                    };
4371

    
4372
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4373
                                    currentControl.CommentID = Commons.shortGuid();
4374
                                    currentControl.IsNew = true;
4375
                                    (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
4376
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4377
                                }
4378
                                //}
4379
                            }
4380
                        }
4381
                        break;
4382

    
4383
                    case ControlType.Symbol:
4384
                        {
4385
                            if (e.LeftButton == MouseButtonState.Pressed)
4386
                            {
4387
                                if (currentControl is SymControl)
4388
                                {
4389
                                    //20180906 LJY TEST IsRotationDrawingEnable
4390
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4391
                                    {
4392
                                        return;
4393
                                    }
4394
                                    CreateCommand.Instance.Execute(currentControl);
4395
                                    currentControl = null;
4396

    
4397
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4398
                                }
4399
                                else
4400
                                {
4401
                                    currentControl = new SymControl
4402
                                    {
4403
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4404
                                        Background = new SolidColorBrush(Colors.Black),
4405
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
4406
                                        ControlType = ControlType.Symbol
4407
                                    };
4408

    
4409
                                    currentControl.IsNew = true;
4410
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4411
                                    currentControl.CommentID = Commons.shortGuid();
4412
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4413

    
4414
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4415
                                    (currentControl as SymControl).CommentAngle -= rotate.Angle;
4416
                                }
4417
                                //}
4418
                            }
4419
                        }
4420
                        break;
4421

    
4422
                    case ControlType.Stamp:
4423
                        {
4424
                            if (e.LeftButton == MouseButtonState.Pressed)
4425
                            {
4426
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
4427
                                //{
4428
                                if (currentControl is SymControlN)
4429
                                {
4430
                                    //20180906 LJY TEST IsRotationDrawingEnable
4431
                                    if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
4432
                                    {
4433
                                        return;
4434
                                    }
4435

    
4436
                                    CreateCommand.Instance.Execute(currentControl);
4437
                                    currentControl = null;
4438

    
4439
                                    this.cursor = new Cursor(App.DefaultArrowCursorStream);
4440
                                }
4441
                                else
4442
                                {
4443
                                    currentControl = new SymControlN
4444
                                    {
4445
                                        StartPoint = new Point(CanvasDrawingMouseDownPoint.X, CanvasDrawingMouseDownPoint.Y),
4446
                                        Background = new SolidColorBrush(Colors.Black),
4447
                                        STAMP = App.SystemInfo.STAMP,
4448
                                        STAMP_Contents = App.SystemInfo.STAMP_CONTENTS,
4449
                                        ControlType = ControlType.Stamp
4450
                                    };
4451

    
4452
                                    currentControl.IsNew = true;
4453
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
4454
                                    currentControl.CommentID = Commons.shortGuid();
4455
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
4456
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정
4457
                                    (currentControl as SymControlN).CommentAngle -= rotate.Angle;
4458
                                }
4459
                                //}
4460
                            }
4461
                        }
4462
                        break;
4463

    
4464
                    case ControlType.PenControl:
4465
                        {
4466
                            if (inkBoard.Tag.ToString() == "Ink")
4467
                            {
4468
                                inkBoard.IsEnabled = true;
4469
                                StartNewStroke(CanvasDrawingMouseDownPoint);
4470
                            }
4471
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
4472
                            {
4473
                                RemovePointStroke(CanvasDrawingMouseDownPoint);
4474
                            }
4475
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
4476
                            {
4477
                                RemoveLineStroke(CanvasDrawingMouseDownPoint);
4478
                            }
4479
                            IsDrawing = true;
4480
                            return;
4481
                        }
4482
                    default:
4483
                        if (currentControl != null)
4484
                        {
4485
                            currentControl.CommentID = null;
4486
                            currentControl.IsNew = false;
4487
                        }
4488
                        break;
4489
                }
4490

    
4491
                try
4492
                {
4493
                    if (currentControl is ITextControl)
4494
                    {
4495
                        var textBox = currentControl.ChildrenOfType<TextBox>().Where(x=> x.Name == "PART_ArrowTextBox" || x.Name == "Base_TextBox" || x.Name == "PART_TextBox");
4496

    
4497
                        if(textBox.Count() > 0)
4498
                        {
4499
                            Behaviors.SpecialcharRemove specialcharRemove = new Behaviors.SpecialcharRemove();
4500
                            specialcharRemove.Attach(textBox.First());
4501
                        }
4502
                        else
4503
                        {
4504

    
4505
                        }
4506

    
4507
                    }
4508
                }
4509
                catch (Exception ex)
4510
                {
4511
                    System.Diagnostics.Debug.WriteLine(ex);
4512

    
4513
                }
4514

    
4515
                if (currentControl is ArrowTextControl)
4516
                {
4517
                    (currentControl as ArrowTextControl).EditEnded += (snd, evt) =>
4518
                    {
4519
                        var control = snd as ArrowTextControl;
4520

    
4521
                        if (string.IsNullOrEmpty(control.ArrowText))
4522
                        {
4523
                            DeleteCommand.Instance.Execute(new [] { control });
4524
                        }
4525
                    };
4526

    
4527
                }
4528

    
4529
                if (Common.ViewerDataModel.Instance.IsMacroCommand)
4530
                {
4531
                    if (currentControl == null && mouseHandlingMode == MouseHandlingMode.Drawing)
4532
                    {
4533
                        MacroHelper.MacroAction();
4534
                    }
4535
                    //if (currentControl.ControlType)
4536
                    //txtBatch.Text = "Draw a TextBox";
4537
                    //controlType = ControlType.ArrowTextBorderControl;
4538
                }
4539

    
4540
                //if (currentControl != null)
4541
                //{
4542
                //    currentControl.PageAngle = pageNavigator.CurrentPage.Angle;
4543
                //}
4544
            }
4545
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
4546
            {
4547
                // MACRO 버튼클릭하여 CLOUD RECT 그린 후
4548
             
4549

    
4550
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
4551
                {
4552
                    bool mouseOff = false;
4553
                    foreach (var item in SelectLayer.Children)
4554
                    {
4555
                        if (item is AdornerFinal)
4556
                        {
4557
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
4558
                            if (over != null)
4559
                            {
4560
                                mouseOff = true;
4561
                            }
4562
                        }
4563
                    }
4564

    
4565
                    if (!mouseOff)
4566
                    {
4567
                        SelectionSet.Instance.UnSelect(this);
4568
                    }
4569
                }
4570
                zoomAndPanControl.CaptureMouse();
4571
                e.Handled = true;
4572
            }
4573
        }
4574

    
4575
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
4576
        {
4577
            ///mouseButtonDown = e.ChangedButton;
4578
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
4579
        }
4580

    
4581
        private void RemoveLineStroke(Point P)
4582
        {
4583
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseEnter).FirstOrDefault();
4584
            if (control != null)
4585
            {
4586
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
4587
            }
4588
        }
4589

    
4590
        private void RemovePointStroke(Point P)
4591
        {
4592
            foreach (Stroke hits in inkBoard.Strokes)
4593
            {
4594
                foreach (StylusPoint sty in hits.StylusPoints)
4595
                {
4596
                }
4597
                if (hits.HitTest(P))
4598
                {
4599
                    inkBoard.Strokes.Remove(hits);
4600
                    return;
4601
                }
4602
            }
4603
        }
4604

    
4605
        private void StartNewStroke(Point P)
4606
        {
4607
            strokePoints = new StylusPointCollection();
4608
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
4609
            strokePoints.Add(segment1Start);
4610
            stroke = new Stroke(strokePoints);
4611

    
4612
            stroke.DrawingAttributes.Color = Colors.Red;
4613
            stroke.DrawingAttributes.Width = 4;
4614
            stroke.DrawingAttributes.Height = 4;
4615

    
4616
            inkBoard.Strokes.Add(stroke);
4617
        }
4618

    
4619
        private async  void btnConsolidate_Click(object sender, RoutedEventArgs e)
4620
        {
4621
            //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4622
            //// update mylist and gridview
4623
            //this.UpdateMyMarkupList();
4624

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

    
4627
            //if (result)
4628
            //{
4629
            btnFinalPDF.IsEnabled = false;
4630
            btnConsolidate.IsEnabled = false;
4631
            await  ConsolidationMethod();
4632
            //}
4633
            //else
4634
            //{
4635
            //    MessageBox.Show("오류");
4636
            //}
4637
        }
4638

    
4639
        /// <summary>
4640
        /// execute TeamConsolidationCommand
4641
        /// </summary>
4642
        public void TeamConsolidationMethod2()
4643
        {
4644
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4645
            {
4646
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4647
            }
4648
            else
4649
            {
4650

    
4651
                ViewerDataModel.Instance.IsConsolidate = true;
4652
                SelectionSet.Instance.UnSelect(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4653
                // update mylist and gridview
4654
        
4655
                Common.ViewerDataModel.Instance.SystemMain.dzTopMenu.ExecuteSaveCommandAsync(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu);
4656
                //this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4657
                ViewerDataModel.Instance.IsConsolidate = false;
4658
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.UpdateMyMarkupList();
4659
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4660
                {
4661
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4662
                    {
4663
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4664
                        return;
4665
                    }
4666
                }
4667
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
4668
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4669
                {
4670
                    MarkupInfoList.Add(item);
4671
                }
4672

    
4673
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
4674
            }
4675
        }
4676
        public async void TeamConsolidationMethod()
4677
        {
4678
            bool result = false;
4679

    
4680
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4681
            {
4682
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4683
            }
4684
            else
4685
            {
4686
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4687
                {
4688
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
4689
                    {
4690
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
4691
                    }
4692
                }
4693

    
4694
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4695

    
4696
                if (isSave)
4697
                {
4698
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4699

    
4700
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4701
                     
4702
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4703
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4704
                    {
4705
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4706
                    }
4707

    
4708
                    TeamConsolidateCommand.Instance.Execute(MySelectItem);
4709
                    result = true;
4710
                }
4711
            }
4712
        }
4713

    
4714
        public async Task<bool> ConsolidationMethod()
4715
        {
4716
            bool result = false;
4717

    
4718
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4719
            {
4720
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4721
            }
4722
            else
4723
            {
4724
                var isSave = await this.ParentOfType<MainWindow>().dzTopMenu.SaveEventAsync();
4725

    
4726
                if (isSave)
4727
                {
4728
                    var token = ViewerDataModel.Instance.NewCancellationToken();
4729
                    await MarkupLoadAsync(pageNavigator.CurrentPage.PageNumber, ViewerDataModel.Instance.PageAngle, token);
4730

    
4731
                    List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
4732
                    foreach (var item in this.gridViewMarkup.SelectedItems)
4733
                    {
4734
                        MySelectItem.Add(item as IKCOM.MarkupInfoItem);
4735
                    }
4736
                    int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
4737

    
4738
                    result = await ConsolidateCommand.Instance.ExecuteAsync(MySelectItem, iPageNo);
4739
                }
4740
            }
4741

    
4742
            return result;
4743
        }
4744

    
4745
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
4746
        {
4747
            if (App.ViewInfo != null)
4748
            {
4749
                btnConsolidate = (sender as RadRibbonButton);
4750
                if (!App.ViewInfo.NewCommentPermission)
4751
                {
4752
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
4753
                }
4754
            }
4755
        }
4756

    
4757
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
4758
        {
4759
            TeamConsolidationMethod();
4760
        }
4761

    
4762
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
4763
        {
4764
            btnTeamConsolidate = sender as RadRibbonButton;
4765
            if (App.ViewInfo != null)
4766
            {
4767
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4768
                {
4769
                    if (btnConsolidate != null)
4770
                    {
4771
                        btnConsolidate.Visibility = Visibility.Collapsed;
4772
                    }
4773

    
4774
                    if (!App.ViewInfo.NewCommentPermission)
4775
                    {
4776
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4777
                    }
4778
                }
4779
                else
4780
                {
4781
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4782
                }
4783
            }
4784
        }
4785

    
4786
        private async void FinalPDFEvent(object sender, RoutedEventArgs e)
4787
        {
4788
            SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4789
            // update mylist and gridview
4790
            this.UpdateMyMarkupList();
4791

    
4792
            var result = await this.ParentOfType<MainWindow>().dzTopMenu.ExecuteSaveCommandAsync(this);
4793

    
4794
            if(!result)
4795
            {
4796

    
4797
            }
4798
            else
4799
            {
4800
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4801

    
4802
                if (item != null)
4803
                {
4804
                    if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID))
4805
                    {
4806
                        //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4807

    
4808
                        BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4809

    
4810
                        ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4811
                    }
4812
                    else
4813
                    {
4814
                        DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4815
                    }
4816
                }
4817
                else
4818
                {
4819
                    //Consolidate 가 없는 경우
4820
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4821
                }
4822
            }
4823

    
4824
        }
4825

    
4826
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4827
        {
4828
            btnFinalPDF = sender as RadRibbonButton;
4829
            if (App.ViewInfo != null)
4830
            {
4831
                //btnFinalPDF.IsEnabled = false;
4832

    
4833
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4834
                {
4835
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4836
                    if (btnConsolidate != null)
4837
                    {
4838
                        btnConsolidate.Visibility = Visibility.Collapsed;
4839
                    }
4840
                }
4841
            }
4842
        }
4843

    
4844
        private async void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4845
        {
4846
            //UpdateMyMarkupList();
4847

    
4848
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4849
            {
4850
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4851
            }
4852
            else
4853
            {
4854
                //if ((App.ViewInfo.CreateFinalPDFPermission || App.ViewInfo.NewCommentPermission))
4855
                //{
4856
                //컨트롤을 그리는 도중일 경우 컨트롤 삭제
4857
                //ViewerDataModel.Instance.MarkupControls_USER.Remove(ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl);
4858
                //ViewerDataModel.Instance.SystemMain.dzMainMenu.currentControl = null;
4859

    
4860
                //SelectionSet.Instance.UnSelect(this.ParentOfType<MainWindow>().dzMainMenu);
4861
                //// update mylist and gridview
4862
                //this.UpdateMyMarkupList();
4863

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

    
4866
                Mouse.SetCursor(Cursors.Wait);
4867

    
4868
                bool result = await ConsolidationMethod();
4869

    
4870
                System.Threading.Thread.Sleep(500);
4871

    
4872
                if (result)
4873
                {
4874
                    var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4875

    
4876
                    var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4877
                    if (item2 != null)
4878
                    {
4879
                        if (BaseClient.FinalPDF_GetFinalPDFStatus(_DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID))
4880
                        {
4881
                            //Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4882

    
4883
                            BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4884
                            BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4885

    
4886
                            ViewerDataModel.Instance.FinalPDFTime = DateTime.Now;
4887

    
4888
                            Mouse.SetCursor(Cursors.Arrow);
4889
                        }
4890
                        else
4891
                        {
4892
                            DialogMessage_Alert("Merged PDF가 수행중입니다. 잠시 후 수행가능합니다.", "안내");
4893
                        }
4894
                    }
4895
                    else
4896
                    {
4897
                        DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4898
                    }
4899
                }
4900
                else
4901
                {
4902
                    DialogMessage_Alert("서버가 원활하지 않습니다. 다시 수행 바랍니다.", "안내");
4903
                }
4904

    
4905
                Mouse.SetCursor(Cursors.Arrow);
4906
            }
4907
        }
4908

    
4909
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4910
        {
4911
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4912
#if Hyosung
4913
            btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4914
#else
4915

    
4916
            //btnConsolidateFinalPDF.IsEnabled = false;
4917

    
4918
            if (App.ViewInfo != null)
4919
            {
4920
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4921
                {
4922
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4923
                }
4924
            }
4925
#endif
4926
        }
4927

    
4928
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4929
        {
4930
            SetCompareRect();
4931
        }
4932

    
4933
        private void Sync_Click(object sender, RoutedEventArgs e)
4934
        {
4935
            if (Sync.IsChecked)
4936
            {
4937
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4938
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4939
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4940
            }
4941
        }
4942

    
4943
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4944
        {
4945
            if (UserList.IsChecked)
4946
            {
4947
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4948
            }
4949
            else
4950
            {
4951
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4952
            }
4953
        }
4954

    
4955
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4956
        {
4957
            if (BalanceMode.IsChecked)
4958
            {
4959
                ViewerDataModel.Instance.PageBalanceMode = true;
4960
            }
4961
            else
4962
            {
4963
                ViewerDataModel.Instance.PageBalanceMode = false;
4964
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4965
            }
4966
        }
4967

    
4968
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4969
        {
4970
            //초기화
4971
            testPanel2.IsHidden = true;
4972
            ViewerDataModel.Instance.PageBalanceMode = false;
4973
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4974
            ViewerDataModel.Instance.SyncPageNumber = 0;
4975
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4976
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4977
            UserList.IsChecked = false;
4978
            BalanceMode.IsChecked = false;
4979
        }
4980

    
4981
        private async void SyncPageChange_Click(object sender, RoutedEventArgs e)
4982
        {
4983
            if ((sender as System.Windows.Controls.Control).Tag != null)
4984
            {
4985
                //Compare 초기화
4986
                CompareMode.IsChecked = false;
4987
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4988
                
4989
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
4990
                {
4991
                    ViewerDataModel.Instance.SyncPageNumber = 1;
4992
                }
4993

    
4994
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4995
                {
4996
                }
4997
                else
4998
                {
4999
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
5000
                }
5001

    
5002
                if (ViewerDataModel.Instance.SyncPageNumber == pageNavigator.PageCount && balancePoint > 0)
5003
                {
5004
                }
5005
                else if ((ViewerDataModel.Instance.SyncPageNumber + balancePoint) >= 1)
5006
                {
5007
                    ViewerDataModel.Instance.SyncPageNumber += balancePoint;
5008
                }
5009

    
5010
                //pageNavigator.GotoPage(ViewerDataModel.Instance.PageNumber);
5011

    
5012
                if (!testPanel2.IsHidden)
5013
                {
5014
                    if (IsSyncPDFMode)
5015
                    {
5016
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
5017
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber)));
5018

    
5019
                        if (pdfpath.IsDownloading)
5020
                        {
5021
                            pdfpath.DownloadCompleted += (ex, arg) =>
5022
                            {
5023
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5024
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5025
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5026
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5027
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5028
                            };
5029
                        }
5030
                        else
5031
                        {
5032
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
5033
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
5034
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
5035

    
5036
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5037
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5038
                        }
5039
                    }
5040
                    else
5041
                    {
5042
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5043

    
5044
                        var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5045
                        ComparePageLoad(uri, isOriginalSize);
5046
                    }
5047
                   
5048
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
5049
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
5050
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
5051

    
5052
                    foreach (var item in gridSelectionRevItem)
5053
                    {
5054
                        var markupitems = item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.SyncPageNumber).ToList();
5055
                        foreach (var markupitem in markupitems)
5056
                        {
5057
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync,0, item.DisplayColor, "", item.MarkupInfoID);
5058
                        }
5059
                    }
5060

    
5061
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.SyncPageNumber);
5062
                }
5063
            }
5064
        }
5065

    
5066
        private void SyncRotation_Click(object sender,RoutedEventArgs e)
5067
        {
5068
            var direction = int.Parse((sender as Telerik.Windows.Controls.RadPathButton).Tag.ToString());
5069

    
5070
            double translateX = 0;
5071
            double translateY = 0;
5072
            double angle = rotate2.Angle;
5073

    
5074
            if (direction == 1)
5075
            {
5076
                if (angle < 270)
5077
                {
5078
                    angle += 90;
5079
                }
5080
                else
5081
                {
5082
                    angle = 0;
5083
                }
5084
            }
5085
            else
5086
            {
5087
                if (angle > 0)
5088
                {
5089
                    angle -= 90;
5090
                }
5091
                else
5092
                {
5093
                    angle = 270;
5094
                }
5095
            }
5096
            zoomAndPanControl2.RotationAngle = angle;
5097
            zoomAndPanControl2.ScaleToFit();
5098

    
5099
            //if (angle == 90 || angle == 270)
5100
            //{
5101
                double emptySize = zoomAndPanCanvas2.Width;
5102
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
5103
                zoomAndPanCanvas2.Height = emptySize;
5104
            //}
5105

    
5106
            if (angle == 90)
5107
            {
5108
                translateX = zoomAndPanCanvas2.Width;
5109
                translateY = 0;
5110
            }
5111
            else if (angle == 180)
5112
            {
5113
                translateX = zoomAndPanCanvas2.Width;
5114
                translateY = zoomAndPanCanvas2.Height;
5115
            }
5116
            else if (angle == 270)
5117
            {
5118
                translateX = 0;
5119
                translateY = zoomAndPanCanvas2.Height;
5120
            }
5121
            zoomAndPanControl2.ContentViewportWidth = zoomAndPanCanvas2.Width;
5122
            zoomAndPanControl2.ContentViewportHeight = zoomAndPanCanvas2.Height;
5123
            translate2.X = translateX;
5124
            translate2.Y = translateY;
5125
            rotate2.Angle = angle;
5126
            //translate2CompareBorder.X = translateX;
5127
            //translate2CompareBorder.Y = translateY;
5128
            //rotate2CompareBorder.Angle = angle;
5129

    
5130
        }
5131

    
5132
        private void SyncChange_Click(object sender, RoutedEventArgs e)
5133
        {
5134
            if (MarkupMode.IsChecked)
5135
            {
5136
                IsSyncPDFMode = true;
5137

    
5138
                var uri = CurrentRev.TO_VENDOR;
5139

    
5140
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5141
                {
5142
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5143
                }
5144

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

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

    
5166
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
5167
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
5168
                }
5169
            }
5170
            else
5171
            {
5172
                IsSyncPDFMode = false;
5173
                string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5174

    
5175
                ComparePageLoad(uri,false);
5176

    
5177
                zoomAndPanControl2.ApplyTemplate();
5178
                zoomAndPanControl2.UpdateLayout();
5179
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5180
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5181
            }
5182
        }
5183

    
5184
        /// <summary>
5185
        /// Compare된 영역을 초기화
5186
        /// </summary>
5187
        private void ClearCompareRect()
5188
        {
5189
            da.From = 1;
5190
            da.To = 1;
5191
            da.Duration = new Duration(TimeSpan.FromSeconds(9999));
5192
            da.AutoReverse = false;
5193
            canvas_compareBorder.Children.Clear();
5194
            canvas_compareBorder.BeginAnimation(OpacityProperty, da);
5195
        }
5196

    
5197
        /// <summary>
5198
        /// 문서 Comprare
5199
        /// </summary>
5200
        private void SetCompareRect()
5201
        {
5202
            canvas_compareBorder.Children.Clear();
5203

    
5204
            if (CompareMode.IsChecked)
5205
            {
5206
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
5207
                {
5208
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
5209
                }
5210
                if (ViewerDataModel.Instance.SyncPageNumber == 0)
5211
                {
5212
                    ViewerDataModel.Instance.SyncPageNumber = 1;
5213
                }
5214

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

    
5217
                /// 비교대상원본, 비교할 대상
5218
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,  CurrentRev.DOCUMENT_ID,  ViewerDataModel.Instance.SyncPageNumber.ToString(), pageNavigator.CurrentPage.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
5219
            }
5220
            else
5221
            {
5222
                canvas_compareBorder.Visibility = Visibility.Hidden;
5223
                ClearCompareRect();
5224
            }
5225
        }
5226

    
5227
        private void btnSync_Click(object sender, RoutedEventArgs e)
5228
        {
5229
            gridViewHistory_Busy.IsBusy = true;
5230

    
5231
            RadButton instance = sender as RadButton;
5232
            if (instance.CommandParameter != null)
5233
            {
5234
                CurrentRev = instance.CommandParameter as VPRevision;
5235
                System.EventHandler<ServiceDeepView.GetSyncMarkupInfoItemsCompletedEventArgs> GetSyncMarkupInfoItemshandler = null;
5236

    
5237
                GetSyncMarkupInfoItemshandler = (sen, ea) =>
5238
                {
5239
                    if (ea.Error == null && ea.Result != null)
5240
                    {
5241
                        testPanel2.IsHidden = false;
5242

    
5243
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
5244
                        foreach (var info in ea.Result)
5245
                        {
5246
                            if (info.UserID == App.ViewInfo.UserID)
5247
                            {
5248
                                info.userDelete = true;
5249
                                info.DisplayColor = "#FFFF0000";
5250
                            }
5251
                            else
5252
                            {
5253
                                info.userDelete = false;
5254
                            }
5255
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
5256
                        }
5257
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5258

    
5259
                        string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5260
                        ComparePageLoad(uri,false);
5261

    
5262
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5263

    
5264
                        zoomAndPanControl2.ApplyTemplate();
5265
                        zoomAndPanControl2.UpdateLayout();
5266

    
5267
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5268
                        {
5269
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5270
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5271
                        }
5272

    
5273
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
5274
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
5275
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
5276

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

    
5280
                        zoomAndPanControl.ScaleToFit();
5281
                        zoomAndPanControl2.ScaleToFit();
5282

    
5283
                        gridViewHistory_Busy.IsBusy = false;
5284
                    }
5285

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

    
5288
                    if (GetSyncMarkupInfoItemshandler != null)
5289
                    {
5290
                        BaseClient.GetSyncMarkupInfoItemsCompleted -= GetSyncMarkupInfoItemshandler;
5291
                    }
5292

    
5293
                    //ClearCompareRect();
5294
                    SetCompareRect();
5295
                };
5296

    
5297
                /// 중복 실행이 발생하여 수정함.
5298
                BaseClient.GetSyncMarkupInfoItemsCompleted += GetSyncMarkupInfoItemshandler;
5299
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5300

    
5301
                //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5302
            }
5303
        }
5304

    
5305
        private void OriginalSizeMode_Click(object sender,RoutedEventArgs e)
5306
        {
5307
            string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.SyncPageNumber);
5308
            var isOriginalSize = !(ViewerDataModel.Instance.SyncPageNumber == pageNavigator.CurrentPage.PageNumber);
5309

    
5310
            ComparePageLoad(uri, OriginalSizeMode.IsChecked);
5311
        }
5312

    
5313
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
5314
        {
5315
            try
5316
            {
5317
                if (sender is RadButton)
5318
                {
5319
                    if ((sender as RadButton).Tag != null)
5320
                    {
5321
                        var url = (sender as RadButton).Tag.ToString();
5322
                        System.Diagnostics.Process.Start(url);
5323
                    }
5324
                    else
5325
                    {
5326
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
5327
                    }
5328
                }
5329
            }
5330
            catch (Exception ex)
5331
            {
5332
                //Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
5333
            }
5334
        }
5335

    
5336
        public void Sync_Event(VPRevision Currnet_Rev)
5337
        {
5338
            CurrentRev = Currnet_Rev;
5339

    
5340
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
5341
            {
5342
                if (ea.Error == null && ea.Result != null)
5343
                {
5344
                    testPanel2.IsHidden = false;
5345

    
5346
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
5347
                    foreach (var info in ea.Result)
5348
                    {
5349
                        if (info.UserID == App.ViewInfo.UserID)
5350
                        {
5351
                            info.userDelete = true;
5352
                            info.DisplayColor = "#FFFF0000";
5353
                        }
5354
                        else
5355
                        {
5356
                            info.userDelete = false;
5357
                        }
5358
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
5359
                    }
5360
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
5361

    
5362
                    string uri = this.GetImageURL(CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
5363

    
5364
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
5365

    
5366
                    ComparePageLoad(uri,false);
5367

    
5368
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
5369
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
5370
                    zoomAndPanControl2.ApplyTemplate();
5371
                    zoomAndPanControl2.UpdateLayout();
5372

    
5373
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
5374
                    {
5375
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
5376
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
5377
                    }
5378
                    //}
5379
                    
5380
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
5381
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
5382
                    gridViewHistory_Busy.IsBusy = false;
5383
                }
5384
                //Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
5385
            };
5386
            //Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
5387
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
5388
        }
5389

    
5390
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
5391
        {
5392
            if (sender is Image)
5393
            {
5394
                if ((sender as Image).Tag != null)
5395
                {
5396
                    var pdfUrl = (sender as Image).Tag.ToString();
5397
                    System.Diagnostics.Process.Start(pdfUrl);
5398
                }
5399
                else
5400
                {
5401
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
5402
                }
5403
            }
5404
        }
5405

    
5406
        private void Create_Symbol(object sender, RoutedEventArgs e)
5407
        {
5408
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
5409

    
5410
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
5411
            {
5412
                DialogMessage_Alert("Please Select Controls", "Alert");
5413
            }
5414
            else //선택된 것이 있으면
5415
            {
5416
                string MarkupData = "";
5417
                adorner_ = new AdornerFinal();
5418

    
5419
                foreach (var item in SelectLayer.Children)
5420
                {
5421
                    if (item.GetType().Name == "AdornerFinal")
5422
                    {
5423
                        adorner_ = (item as Controls.AdornerFinal);
5424
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
5425
                        {
5426
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
5427
                            {
5428
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
5429
                                MarkupData += markupReturn.ConvertData;
5430
                            }
5431
                        }
5432
                    }
5433
                }
5434
                DialogParameters parameters = new DialogParameters()
5435
                {
5436
                    Owner = Application.Current.MainWindow,
5437
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
5438
                    DefaultPromptResultValue = "Custom State",
5439
                    Content = "Name :",
5440
                    Header = "Insert Custom Symbol Name",
5441
                    Theme = new VisualStudio2013Theme(),
5442
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5443
                };
5444
                RadWindow.Prompt(parameters);
5445
            }
5446
        }
5447

    
5448
        public int symbolselectindex = 0;
5449

    
5450
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
5451
        {
5452
            //Save save = new Save();
5453
            try
5454
            {
5455
                string svgfilename = null;
5456
                if (symbolname != null)
5457
                {
5458
                    if (symbolpng == true || symbolsvg == true)
5459
                    {
5460
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5461
                        string guid = Commons.shortGuid();
5462

    
5463
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
5464
                        //Check_Uri.UriCheck();
5465
                        fileUploader.RunCompleted += (ex, arg) =>
5466
                        {
5467
                            filename = arg.Result;
5468
                            if (symbolpng == true)
5469
                            {
5470
                                if (filename != null)
5471
                                {
5472
                                    if (symbolselectindex == 0)
5473
                                    {
5474
                                        SymbolSave(symbolname, filename, data);
5475
                                    }
5476
                                    else
5477
                                    {
5478
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5479
                                    }
5480
                                    DataBind();
5481
                                }
5482
                            }
5483

    
5484
                            if (symbolsvg == true)
5485
                            {
5486
                                try
5487
                                {
5488
                                    var defaultBitmapImage = new BitmapImage();
5489
                                    defaultBitmapImage.BeginInit();
5490
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
5491
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
5492
                                    Check_Uri.UriCheck(filename);
5493
                                    defaultBitmapImage.UriSource = new Uri(filename);
5494
                                    defaultBitmapImage.EndInit();
5495

    
5496
                                    System.Drawing.Bitmap image;
5497

    
5498
                                    if (defaultBitmapImage.IsDownloading)
5499
                                    {
5500
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
5501
                                        {
5502
                                            defaultBitmapImage.Freeze();
5503
                                            image = GetBitmap(defaultBitmapImage);
5504
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
5505
                                            Process potrace = new Process
5506
                                            {
5507
                                                StartInfo = new ProcessStartInfo
5508
                                                {
5509
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
5510
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
5511
                                                    RedirectStandardInput = true,
5512
                                                    RedirectStandardOutput = true,
5513
                                                    RedirectStandardError = true,
5514
                                                    UseShellExecute = false,
5515
                                                    CreateNoWindow = true,
5516
                                                    WindowStyle = ProcessWindowStyle.Hidden
5517
                                                },
5518
                                            };
5519

    
5520
                                            StringBuilder svgBuilder = new StringBuilder();
5521
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
5522
                                            {
5523
                                                svgBuilder.AppendLine(e2.Data);
5524
                                            };
5525

    
5526
                                            potrace.EnableRaisingEvents = true;
5527
                                            potrace.Start();
5528
                                            potrace.Exited += (sender, e) =>
5529
                                            {
5530
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
5531
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
5532
                                                Check_Uri.UriCheck(svgfilename);
5533
                                                if (symbolselectindex == 0)
5534
                                                {
5535
                                                    SymbolSave(symbolname, svgfilename, data);
5536
                                                }
5537
                                                else
5538
                                                {
5539
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5540
                                                }
5541

    
5542
                                                DataBind();
5543
                                            };
5544
                                            potrace.WaitForExit();
5545
                                        };
5546
                                    }
5547
                                    else
5548
                                    {
5549
                                        //GC.Collect();
5550
                                    }
5551
                                }
5552
                                catch (Exception ee)
5553
                                {
5554
                                    DialogMessage_Alert("" + ee, "Alert");
5555
                                }
5556
                            }
5557
                        };
5558
                    }
5559
                }
5560
            }
5561
            catch (Exception e)
5562
            {
5563
                //DialogMessage_Alert(e + "", "Alert");
5564
            }
5565
        }
5566

    
5567
        public void SymbolSave(string Name, string Url, string Data)
5568
        {
5569
            try
5570
            {
5571
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
5572
                {
5573
                    ID = Commons.shortGuid(),
5574
                    MEMBER_USER_ID = App.ViewInfo.UserID,
5575
                    NAME = Name,
5576
                    IMAGE_URL = Url,
5577
                    DATA = Data
5578
                };
5579

    
5580
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
5581
                //Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
5582
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
5583
            }
5584
            catch (Exception)
5585
            {
5586
                throw;
5587
            }
5588
        }
5589

    
5590
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
5591
        {
5592
            try
5593
            {
5594
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
5595
                {
5596
                    ID = Commons.shortGuid(),
5597
                    DEPARTMENT = Department,
5598
                    NAME = Name,
5599
                    IMAGE_URL = Url,
5600
                    DATA = Data
5601
                };
5602
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
5603
                //Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
5604
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
5605
            }
5606
            catch (Exception)
5607
            {
5608
                throw;
5609
            }
5610
        }
5611

    
5612
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
5613
        {
5614
            //Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5615
            DataBind();
5616
        }
5617

    
5618
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
5619
        {
5620
            //Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
5621
            DataBind();
5622
        }
5623

    
5624
        private void DataBind()
5625
        {
5626
            try
5627
            {
5628
                Symbol_Custom Custom = new Symbol_Custom();
5629
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
5630

    
5631
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
5632
                foreach (var item in symbol_Private)
5633
                {
5634
                    Custom.Name = item.NAME;
5635
                    Custom.ImageUri = item.IMAGE_URL;
5636
                    Custom.ID = item.ID;
5637
                    Custom_List.Add(Custom);
5638
                    Custom = new Symbol_Custom();
5639
                }
5640
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
5641

    
5642
                Custom = new Symbol_Custom();
5643
                Custom_List = new List<Symbol_Custom>();
5644

    
5645
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
5646

    
5647
                List<SYMBOL_PUBLIC> symbol_Public;
5648

    
5649
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
5650
                {
5651
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
5652
                }
5653
                else
5654
                {
5655
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
5656
                }
5657
                foreach (var item in symbol_Public)
5658
                {
5659
                    Custom.Name = item.NAME;
5660
                    Custom.ImageUri = item.IMAGE_URL;
5661
                    Custom.ID = item.ID;
5662
                    Custom_List.Add(Custom);
5663
                    Custom = new Symbol_Custom();
5664
                }
5665
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
5666
                BaseClient.Close();
5667
            }
5668
            catch (Exception e)
5669
            {
5670
                //DialogMessage_Alert("DataBind", "Alert");
5671
            }
5672
        }
5673

    
5674
        private async void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
5675
        {
5676
            try
5677
            {
5678
                if (args.PromptResult != null)
5679
                {
5680
                    if (args.DialogResult.Value)
5681
                    {
5682
                        PngBitmapEncoder _Encoder = await symImageAsync(data);
5683

    
5684
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
5685
                        _Encoder.Save(fs);
5686
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
5687

    
5688
                        byte[] Img_byte = fs.ToArray();
5689

    
5690
                        kr.co.devdoftech.cloud.FileUpload fileUploader = App.FileUploader;
5691
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
5692
                        Check_Uri.UriCheck(filename);
5693
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
5694
                        {
5695
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
5696
                        }
5697
                        else
5698
                        {
5699
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
5700
                        }
5701
                        DataBind();
5702
                    }
5703
                }
5704
            }
5705
            catch (Exception ex)
5706
            {
5707
                DialogMessage_Alert("" + ex, "Alert");
5708
            }
5709
        }
5710

    
5711
        public async Task<PngBitmapEncoder> symImageAsync(string data)
5712
        {
5713
            Canvas _canvas = new Canvas();
5714
            _canvas.Background = Brushes.White;
5715
            _canvas.Width = adorner_.BorderSize.Width;
5716
            _canvas.Height = adorner_.BorderSize.Height;
5717
            await MarkupParser.ParseAsync(App.BaseAddress, App.ViewInfo.ProjectNO, data, _canvas,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "", ViewerDataModel.Instance.CancellationToken());
5718

    
5719
            BitmapEncoder encoder = new PngBitmapEncoder();
5720

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

    
5723
            DrawingVisual dv = new DrawingVisual();
5724

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

    
5728
            using (DrawingContext ctx = dv.RenderOpen())
5729
            {
5730
                VisualBrush vb = new VisualBrush(_canvas);
5731
                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)));
5732
            }
5733

    
5734
            try
5735
            {
5736
                renderBitmap.Render(dv);
5737

    
5738
                GC.Collect(2);
5739
                GC.WaitForPendingFinalizers();
5740
                //GC.Collect();
5741
                // encode png data
5742
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
5743
                // puch rendered bitmap into it
5744
                pngEncoder.Interlace = PngInterlaceOption.Off;
5745
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
5746
                return pngEncoder;
5747
            }
5748
            catch //(Exception ex)
5749
            {
5750
                return null;
5751
            }
5752
        }
5753

    
5754
        public void DialogMessage_Alert(string content, string header)
5755
        {
5756
            App.splashScreen.Close();
5757
            App.FileLogger.Error(content + " " + header);
5758

    
5759
            DialogParameters parameters = new DialogParameters()
5760
            {
5761
                Owner = this.ParentOfType<MainWindow>(),
5762
                Content = new TextBlock()
5763
                {
5764
                    MinWidth = 400,
5765
                    FontSize = 11,
5766
                    Text = content,
5767
                    TextWrapping = System.Windows.TextWrapping.Wrap
5768
                },
5769
                DialogStartupLocation = WindowStartupLocation.CenterOwner,
5770
                Header = header,
5771
                Theme = new VisualStudio2013Theme(),
5772
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5773
            };
5774
            RadWindow.Alert(parameters);
5775
        }
5776

    
5777
        #region 캡쳐 기능
5778

    
5779
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
5780
        {
5781
            if (x < 0)
5782
            {
5783
                width += x;
5784
                x = 0;
5785
            }
5786
            if (y < 0)
5787
            {
5788
                height += y;
5789
                y = 0;
5790

    
5791
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5792
            }
5793
            if (x + width > zoomAndPanCanvas.ActualWidth)
5794
            {
5795
                width = (int)zoomAndPanCanvas.ActualWidth - x;
5796
            }
5797
            if (y + height > zoomAndPanCanvas.ActualHeight)
5798
            {
5799
                height = (int)zoomAndPanCanvas.ActualHeight - y;
5800
            }
5801

    
5802
            byte[] pixels = CopyPixels(x, y, width, height);
5803

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

    
5806
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
5807
        }
5808

    
5809
        public byte[] CopyPixels(int x, int y, int width, int height)
5810
        {
5811
            byte[] pixels = new byte[width * height * 4];
5812
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5813

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

    
5817
            return pixels;
5818
        }
5819

    
5820
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5821
        {
5822
            DrawingVisual drawingVisual = new DrawingVisual();
5823
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5824

    
5825
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5826
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5827
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5828
            drawingContext.Close();
5829

    
5830
            // 비트맵으로 변환합니다.
5831
            RenderTargetBitmap target =
5832
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5833
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5834

    
5835
            target.Render(drawingVisual);
5836
            return target;
5837
        }
5838

    
5839
        private System.Drawing.Bitmap GetBitmap(BitmapSource source)
5840
        {
5841
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5842
            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);
5843
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5844
            bmp.UnlockBits(data);
5845
            return bmp;
5846
        }
5847

    
5848
        public string symbolname = null;
5849
        public bool symbolsvg = true;
5850
        public bool symbolpng = true;
5851

    
5852
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5853
        {
5854
            System.Drawing.Bitmap image = GetBitmap(source);
5855
            //흰색 제거
5856
            //image.MakeTransparent(System.Drawing.Color.White);
5857

    
5858
            var imageStream = new System.IO.MemoryStream();
5859
            byte[] imageBytes = null;
5860
            using (imageStream)
5861
            {
5862
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5863
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5864
                imageStream.Position = 0;
5865
                imageBytes = imageStream.ToArray();
5866
            }
5867

    
5868
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5869

    
5870
            RadWindow CheckPop = new RadWindow();
5871
            //Alert check = new Alert(Msg);
5872

    
5873
            CheckPop = new RadWindow
5874
            {
5875
                MinWidth = 400,
5876
                MinHeight = 100,
5877
                // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5878
                Header = "Alert",
5879
                Content = symbolPrompt,
5880
                //DialogResult =
5881
                ResizeMode = System.Windows.ResizeMode.NoResize,
5882
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5883
                IsTopmost = true,
5884
            };
5885
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5886
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5887
            CheckPop.ShowDialog();
5888

    
5889
            /*
5890
            DialogParameters parameters = new DialogParameters()
5891
            {
5892
                Owner = Application.Current.MainWindow,
5893
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5894
                DefaultPromptResultValue = "Custom State",
5895
                Content = "Name :",
5896
                Header = "Insert Custom Symbol Name",
5897
                Theme = new VisualStudio2013Theme(),
5898
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5899
            };
5900
            RadWindow.Prompt(parameters);
5901
            */
5902
        }
5903

    
5904
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5905
        {
5906
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5907
            KCOMDataModel.DataModel.CHECK_LIST check_;
5908
            string Result = streamToBase64.ImageToBase64(source);
5909
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5910
            string projectno = App.ViewInfo.ProjectNO;
5911
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5912

    
5913
            //Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5914
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5915
            if (Item != null)
5916
            {
5917
                //Logger.sendResLog("GetCheckList", "TRUE", 1);
5918
            }
5919
            else
5920
            {
5921
                //Logger.sendResLog("GetCheckList", "FALSE", 1);
5922
            }
5923

    
5924
            if (Item == null)
5925
            {
5926
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5927
                {
5928
                    ID = Commons.shortGuid(),
5929
                    USER_ID = App.ViewInfo.UserID,
5930
                    IMAGE_URL = Result,
5931
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5932
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5933
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5934
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5935
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5936
                    STATUS = "False",
5937
                    CREATE_TIME = DateTime.Now,
5938
                    UPDATE_TIME = DateTime.Now,
5939
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5940
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5941
                };
5942
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5943
                //Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5944
                this.BaseClient.AddCheckList(projectno, check_);
5945
            }
5946
            else
5947
            {
5948
                Item.IMAGE_URL = Result;
5949
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5950
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5951
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5952
                //Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5953
                this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5954
            }
5955
        }
5956

    
5957
        public void Set_Capture()
5958
        {
5959
            double x = CanvasDrawingMouseDownPoint.X;
5960
            double y = CanvasDrawingMouseDownPoint.Y;
5961
            double width = dragCaptureBorder.Width;
5962
            double height = dragCaptureBorder.Height;
5963

    
5964
            if (width > 5 || height > 5)
5965
            {
5966
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5967
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5968
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5969
            }
5970
        }
5971

    
5972
        #endregion 캡쳐 기능
5973

    
5974
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5975
        {
5976
            multi_Undo_Data = new Multi_Undo_data();
5977

    
5978
            multi_Undo_Data.Markup = control;
5979

    
5980
            if ((control as IShapeControl) != null)
5981
            {
5982
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5983
            }
5984
            if ((control as IDashControl) != null)
5985
            {
5986
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5987
            }
5988
            if ((control as IPath) != null)
5989
            {
5990
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5991
            }
5992
            if ((control as UIElement) != null)
5993
            {
5994
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5995
            }
5996

    
5997
            return multi_Undo_Data;
5998
        }
5999

    
6000
        private async void Comment_Move(object sender, MouseButtonEventArgs e)
6001
        {
6002
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).MarkupInfoID;
6003
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
6004
            {
6005
                if (items.MarkupInfoID == Select_ID)
6006
                {
6007
                    foreach (var item in items.MarkupList)
6008
                    {
6009
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
6010
                        {
6011
                            await MarkupParser.ParseExAsync(App.BaseAddress, ViewerDataModel.Instance.CancellationToken(), App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER,ViewerDataModel.Instance.PageAngle, "#FFFF0000", "",
6012
                                 items.MarkupInfoID, Commons.shortGuid());
6013
                        }
6014
                    }
6015
                }
6016
            }
6017
        }
6018

    
6019
        /// <summary>
6020
        /// convert inkcontrol to polygoncontrol
6021
        /// </summary>
6022
        public void ConvertInkControlToPolygon()
6023
        {
6024
            if (inkBoard.Strokes.Count > 0)
6025
            {
6026
                inkBoard.Strokes.ToList().ForEach(stroke =>
6027
                {
6028
                    InkToPath ip = new InkToPath();
6029

    
6030
                    List<Point> inkPointSet = new List<Point>();
6031
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
6032

    
6033
                    PolygonControl pc = new PolygonControl()
6034
                    {
6035
                        CommentAngle = 0,
6036
                        PointSet = inkPointSet,
6037
                        ControlType = ControlType.Ink
6038
                    };
6039
                    pc.StartPoint = inkPointSet[0];
6040
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
6041
                    pc.LineSize = 3;
6042
                    pc.CommentID = Commons.shortGuid();
6043
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
6044

    
6045
                    if (pc.PointSet.Count > 0)
6046
                    {
6047
                        CreateCommand.Instance.Execute(pc);
6048
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
6049
                    }
6050
                });
6051
                inkBoard.Strokes.Clear();
6052
            }
6053
        }
6054

    
6055
        /// <summary>
6056
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
6057
        /// </summary>
6058
        /// <author>ingu</author>
6059
        /// <date>2018.06.05</date>
6060
        /// <param name="getPoint"></param>
6061
        /// <returns></returns>
6062
        private bool IsGetoutpoint(Point getPoint)
6063
        {
6064
            if (getPoint == new Point())
6065
            {
6066
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
6067
                currentControl = null;
6068
                return true;
6069
            }
6070

    
6071
            return false;
6072
        }
6073

    
6074
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
6075
        {
6076
            e.Effects = DragDropEffects.Copy;
6077
        }
6078

    
6079
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
6080
        {
6081
            e.Effects = DragDropEffects.Copy;
6082
        }
6083

    
6084
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
6085
        {
6086
            e.Effects = DragDropEffects.None;
6087
        }
6088

    
6089
        private void ZoomAndPanControl_ScaleChanged(object sender, RoutedEventArgs e)
6090
        {
6091
            var pageWidth = ViewerDataModel.Instance.ImageViewWidth;
6092
            var pageHeight = ViewerDataModel.Instance.ImageViewHeight;
6093

    
6094
            ScaleImage(pageWidth, pageHeight);
6095
        }
6096

    
6097
        /// <summary>
6098
        /// 페이지를 scale의 변화에 맞춰서 DecodePixel을 변경한다.
6099
        /// </summary>
6100
        /// <param name="pageWidth">원본 사이즈</param>
6101
        /// <param name="pageHeight">원본 사이즈</param>
6102
        /// <returns></returns>
6103
        private void ScaleImage(double pageWidth, double pageHeight)
6104
        {
6105
            //mainPanel.Scale = zoomAndPanControl.ContentScale;// (zoomAndPanControl.ContentScale >= 0.1) ? 1 : zoomAndPanControl.ContentScale;
6106
        }
6107

    
6108
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
6109
        {
6110
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
6111
        }
6112

    
6113
        private void gridViewMarkupAllSelect_Click(object sender, RoutedEventArgs e)
6114
        {
6115
            var checkbox = (sender as CheckBox);
6116

    
6117
            if (checkbox != null)
6118
            {
6119
                if (checkbox.IsChecked.GetValueOrDefault())
6120
                {
6121
                    gridViewMarkup.SelectAll();
6122
                }
6123
                else
6124
                {
6125
                    gridViewMarkup.UnselectAll();
6126
                }
6127
            }
6128
        }
6129
        
6130
        /*
6131
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
6132
        {
6133
            try
6134
            {
6135
                if (e.Data.GetDataPresent(typeof(string)))
6136
                {
6137
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
6138
                    string dragData = e.Data.GetData(typeof(string)) as string;
6139
                    Move_Symbol(sender, dragData);
6140
                }
6141
            }
6142
            catch (Exception ex)
6143
            {
6144
                //Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
6145
            }
6146
        }
6147
        */
6148
    }
6149

    
6150
    public class testItem
6151
    {
6152
        public string Title { get; set; }
6153
    }
6154
}
클립보드 이미지 추가 (최대 크기: 500 MB)