프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 129ca191

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

1

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

    
45
namespace KCOM.Views
46
{
47
    public static class ControlExtensions
48
    {
49
        public static T Clone<T>(this T controlToClone)
50
            where T : System.Windows.Controls.Control
51
        {
52
            System.Reflection.PropertyInfo[] controlProperties = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
53

    
54
            T instance = Activator.CreateInstance<T>();
55

    
56
            foreach (PropertyInfo propInfo in controlProperties)
57
            {
58
                if (propInfo.CanWrite)
59
                {
60
                    if (propInfo.Name != "WindowTarget")
61
                        propInfo.SetValue(instance, propInfo.GetValue(controlToClone, null), null);
62
                }
63
            }
64
            return instance;
65
        }
66
    }
67

    
68
    public class MyConsole
69
    {
70
        private readonly System.Threading.ManualResetEvent _readLineSignal;
71
        private string _lastLine;
72
        public MyConsole()
73
        {
74
            _readLineSignal = new System.Threading.ManualResetEvent(false);
75
            Gui = new TextBox();
76
            Gui.AcceptsReturn = true;
77
            Gui.KeyUp += OnKeyUp;
78
        }
79

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

    
92
        public TextBox Gui { get; private set; }
93

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

    
107
        public void WriteLine(string line)
108
        {
109
            if (!Gui.Dispatcher.CheckAccess())
110
            {
111
                Gui.Dispatcher.Invoke(new Action(() => WriteLine(line)));
112
                return;
113
            }
114

    
115
            Gui.Text += line + Environment.NewLine;
116
        }
117
    }
118

    
119
    /// <summary>
120
    /// MainMenu.xaml에 대한 상호 작용 논리
121
    /// </summary>
122
    public partial class MainMenu : UserControl
123
    {
124
        #region 프로퍼티
125
        public CommentUserInfo currentControl { get; set; }
126
        public ControlType controlType { get; set; }
127
        private Move move = new Move();
128
        private double[] rotateValue = { 0, 90, 180, 270 };
129
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
130
        private static readonly double DragThreshold = 5;
131
        private System.Windows.Input.Cursor cursor { get; set; }
132
        private Point canvasDrawingMouseDownPoint;
133
        public string filename { get; set; }
134
        private Point canvasZoomPanningMouseDownPoint;
135
        public Point getCurrentPoint;
136
        private Point canvasZoommovingMouseDownPoint;
137
        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
        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
        /// <summary>
154
        /// Set to 'true' when the left mouse-button is down.
155
        /// </summary>
156
        public bool isLeftMouseButtonDownOnWindow = false;
157

    
158
        public InkPresenter _InkBoard = null;
159
        Stroke stroke;
160
        Boolean IsDrawing = false;
161
        StylusPointCollection strokePoints;
162
        //StylusPointCollection erasePoints;
163
        RenderTargetBitmap canvasImage;
164
        Point Sync_Offset_Point;
165

    
166
        //강인구 테스트
167
        private Path _SelectionPath { get; set; }
168
        public Path SelectionPath
169
        {
170
            get
171
            {
172
                return _SelectionPath;
173
            }
174
            set
175
            {
176
                if (_SelectionPath != value)
177
                {
178
                    _SelectionPath = value;
179
                    RaisePropertyChanged("SelectionPath");
180

    
181
                }
182
            }
183
        }
184

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

    
209
        public bool IsSyncPDFMode { get; set; }
210

    
211
        private System.Windows.Controls.Image _imageViewer_Compare { get; set; }
212
        public System.Windows.Controls.Image imageViewer_Compare
213
        {
214
            get
215
            {
216
                if (_imageViewer_Compare == null)
217
                {
218
                    _imageViewer_Compare = new System.Windows.Controls.Image();
219
                    return _imageViewer_Compare;
220
                }
221
                else
222
                {
223
                    return _imageViewer_Compare;
224
                }
225
            }
226
            set
227
            {
228
                if (_imageViewer_Compare != value)
229
                {
230
                    _imageViewer_Compare = value;
231
                }
232
            }
233
        }
234

    
235
        #endregion
236

    
237
        public MainMenu()
238
        {
239
            App.splashString(ISplashMessage.MAINMENU_0);            
240
            //InitializeComponent();    
241
            this.Loaded += MainMenu_Loaded;
242
        }
243

    
244
        public class TempDt
245
        {
246
            public int PageNumber { get; set; }
247
            public string CommentID { get; set; }
248
            public string ConvertData { get; set; }
249
            public int DATA_TYPE { get; set; }
250
            public string MarkupInfoID { get; set; }
251
            public int IsUpdate { get; set; }
252
        }
253

    
254
        List<TempDt> tempDtList = new List<TempDt>();
255

    
256
        private void SetCursor()
257
        {
258
            this.Cursor = cursor;
259
        }
260

    
261
        private bool IsDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
262
        {
263
            if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
264
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
265
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
266
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
267
            {
268
                return true;
269
            }
270

    
271
            return false;
272
        }
273

    
274
        private bool IsRotationDrawingEnable(Point _canvasZoomPanningMouseDownPoint)
275
        {
276
            if (rotate.Angle == 90 || rotate.Angle == 270)
277
            {
278
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
279
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.X) &&
280
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
281
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.Y))
282
                {
283
                    return true;
284
                }
285
            }
286
            else
287
            {
288
                if ((_canvasZoomPanningMouseDownPoint.X > 0 &&
289
                zoomAndPanCanvas.ActualWidth > _canvasZoomPanningMouseDownPoint.X) &&
290
                (_canvasZoomPanningMouseDownPoint.Y > 0 &&
291
                zoomAndPanCanvas.ActualHeight > _canvasZoomPanningMouseDownPoint.Y))
292
                {
293
                    return true;
294
                }
295
            }
296

    
297
            return false;
298
        }
299

    
300
        public void DeleteItem(MarkupInfoItem item)
301
        {
302
            if (PreviewUserMarkupInfoItem != null && item.Consolidate == 1 && item.AvoidConsolidate == 0)
303
            {
304
                App.Custom_ViewInfoId = PreviewUserMarkupInfoItem.MarkupInfoID;
305
            }
306

    
307
            ViewerDataModel.Instance._markupInfoList.Remove(item);
308

    
309
            ViewerDataModel.Instance.MarkupControls.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
310
            {
311
                ViewerDataModel.Instance.MarkupControls.Remove(a);
312
            });
313

    
314
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
315
            {
316
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
317
            });
318

    
319
            ViewerDataModel.Instance.MyMarkupList.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
320
            {
321
                ViewerDataModel.Instance.MyMarkupList.Remove(a);
322
                //임시파일에서도 삭제
323
                TempFile.DelTemp(a.ID, this.ParentOfType<MainWindow>().dzMainMenu.pageNavigator.CurrentPage.PageNumber.ToString());
324
            });
325

    
326
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
327

    
328
            if (PreviewUserMarkupInfoItem == null && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null)
329
            {
330
                if (gridViewMarkup.Items.Cast<MarkupInfoItem>().ToList().Where(d => d.UserID == App.ViewInfo.UserID).Count() == 0)
331
                {
332
                    var infoId = Commons.shortGuid();
333
                    PreviewUserMarkupInfoItem = new MarkupInfoItem
334
                    {
335
                        CreateTime = DateTime.Now,
336
                        Depatment = userData.DEPARTMENT,
337
                        UpdateTime = DateTime.Now,
338
                        DisplayColor = "#FFFF0000",
339
                        UserID = userData.ID,
340
                        UserName = userData.NAME,
341
                        PageCount = 1,
342
                        Description = "",
343
                        MarkupInfoID = infoId,
344
                        MarkupList = null,
345
                        MarkupVersionID = Commons.shortGuid(),
346
                        Consolidate = 0,
347
                        PartConsolidate = 0,
348
                        userDelete = true,
349
                        AvoidConsolidate = 0,
350
                        IsPreviewUser = true
351
                    };
352
                    App.Custom_ViewInfoId = infoId;
353
                }
354
            }
355
            Logger.sendReqLog("DeleteMarkupAsync", App.ViewInfo.ProjectNO + "," + item.MarkupInfoID, 1);
356
            BaseClient.DeleteMarkupAsync(App.ViewInfo.ProjectNO, item.MarkupInfoID);
357
        }
358

    
359
        /// <summary>
360
        /// delete selected comments
361
        /// </summary>
362
        /// <param name="sender"></param>
363
        /// <param name="e"></param>
364
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
365
        {
366
            //선택된 어도너가 있을시 삭제가 되지 않음(강인구 추가)
367
            SelectionSet.Instance.UnSelect(this);
368

    
369
            Button content = (sender as Button);
370
            MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
371

    
372
            DeleteItem(item);
373
        }
374

    
375
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
376

    
377
        private static Timer timer;
378
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
379
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
380
        {
381
            InitializeComponent();            
382
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
383

    
384
            if (App.ParameterMode)
385
            {
386
                App.splashString(ISplashMessage.MAINMENU_1);
387
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
388
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
389
                imageViewer_Compare = new Image();
390
                ViewerDataModel.Instance.Capture_Opacity = 0;
391
                da.From = 0.8;
392
                da.To = 0;
393
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
394
                da.AutoReverse = true;
395
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
396

    
397
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
398
                {
399
                    this.SymbolPane.Visibility = Visibility.Collapsed;
400
                    this.FavoritePane.Visibility = Visibility.Collapsed;
401
                    this.drawingRotateCanvas.IsHitTestVisible = false;
402
                }
403
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
404
            }
405
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
406
        }
407

    
408
        
409

    
410
        private void timercallback(Object o)
411
        {
412
            Stopwatch sw = new Stopwatch();
413
            sw.Start();
414
            TempFile.TempFileAdd();
415
            sw.Stop();
416

    
417
            Dispatcher.InvokeAsync(new Action(delegate
418
            {
419
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
420
                {
421
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
422
                }
423
            }));
424

    
425
            ////GC.Collect();
426
        }
427
        
428
        /// <summary>
429
        /// update my markuplist
430
        ///  - update existing markup data if already exist
431
        ///  - add new markup data if control is new
432
        /// </summary>
433
        public void UpdateMyMarkupList()
434
        {
435
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
436

    
437
            /// add or update markup list
438
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
439
            {
440
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
441

    
442
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
443
                if (exist != null) //신규 추가 된 코멘트
444
                {
445
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
446
                    {
447
                        exist.Data = root.ConvertData;
448
                        exist.IsUpdate = true;
449
                    }
450
                }
451
                else if (root.CommentID != null)
452
                {
453
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
454
                    {
455
                        ID = control.CommentID,
456
                        Data = root.ConvertData,
457
                        Data_Type = root.DATA_TYPE,
458
                        MarkupInfoID = App.Custom_ViewInfoId,
459
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
460
                        Symbol_ID = control.SymbolID,
461
                        //Group_ID = control.GroupID,
462
                    });
463
                }
464
            }
465

    
466
            /// delete markup list
467
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
468
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
469
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
470
                          select markup).ToList();
471
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
472
            /// up to here
473

    
474
            //if (modified)
475
            //{
476
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
477
            //    {
478
            //        ComingNewBieEnd = true;
479
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
480
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
481
            //        gridViewMarkup.ItemsSource = null;
482
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
483
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
484

    
485
            //        GroupDescriptor descriptor = new GroupDescriptor();
486
            //        descriptor.Member = "Depatment";
487
            //        descriptor.DisplayContent = "DEPT";
488
            //        descriptor.SortDirection = ListSortDirection.Ascending;
489
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
490
            //    }
491
            //}
492
        }
493

    
494
        /// <summary>
495
        /// start page changing
496
        ///  - save controls if page is modified
497
        ///  - starting download page image
498
        /// </summary>
499
        /// <param name="sender"></param>
500
        /// <param name="e"></param>
501
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
502
        {
503
            CompareMode.IsChecked = false;
504
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
505

    
506
            #region 페이지가 벗어난 경우
507

    
508
            if (BalancePoint < 1)
509
            {
510
                BalancePoint = 1;
511
                ViewerDataModel.Instance.PageBalanceNumber = 0;
512
            }
513

    
514
            if (pageNavigator.PageCount < BalancePoint)
515
            {
516
                BalancePoint = pageNavigator.PageCount;
517
                ViewerDataModel.Instance.PageBalanceNumber = 0;
518
            }
519

    
520
            #endregion
521

    
522
            ViewerDataModel.Instance.PageNumber = BalancePoint;
523

    
524
            string uri = "";
525
            if (userData.COMPANY != "EXT")
526
            {
527
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
528
            }
529
            else
530
            {
531
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
532
            }
533

    
534
            var defaultBitmapImage = new BitmapImage();
535
            defaultBitmapImage.BeginInit();
536
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
537
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
538
            defaultBitmapImage.UriSource = new Uri(uri);
539
            defaultBitmapImage.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
540
            defaultBitmapImage.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
541
            defaultBitmapImage.EndInit();
542

    
543
            ViewerDataModel.Instance.ImageViewPath = null;
544
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
545
            if (defaultBitmapImage.IsDownloading)
546
            {
547
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
548
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
549
                {                   
550
                    defaultBitmapImage.Freeze();                                        
551
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
552
                    ViewerDataModel.Instance.ImageViewWidth = defaultBitmapImage.PixelWidth;
553
                    ViewerDataModel.Instance.ImageViewHeight = defaultBitmapImage.PixelHeight;
554
                    mainPanel.UpdateLayout();
555
                    this.pageNavigator.ChangePage(e.PageNumber); 
556
                    
557
                    //image dispose
558
                    defaultBitmapImage = null;
559
                    GC.Collect();
560
                };
561
            }
562

    
563
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
564
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
565

    
566

    
567
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
568
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
569
            inkBoard.Width = zoomAndPanCanvas.Width;
570
            inkBoard.Height = zoomAndPanCanvas.Height;
571

    
572

    
573
            if (!testPanel2.IsHidden)
574
            {
575
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
576
                //PDF모드일때 잠시 대기(강인구)
577
                if (IsSyncPDFMode)
578
                {
579
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
580
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
581

    
582
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
583
                    if (pdfpath.IsDownloading)
584
                    {
585
                        pdfpath.DownloadCompleted += (ex, arg) =>
586
                        {
587
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
588
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
589
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
590
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
591
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
592
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
593
                        };
594
                    }
595
                    else
596
                    {
597
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
598
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
599
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
600
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
601

    
602
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
603
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
604
                    }
605
                }
606
                else
607
                {
608
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
609
                    string uri2 = "";
610
                    if (userData.COMPANY != "EXT")
611
                    {
612
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
613
                    }
614
                    else
615
                    {
616
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
617
                    }
618

    
619
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
620
                    var defaultBitmapImage_Compare = new BitmapImage();
621
                    defaultBitmapImage_Compare.BeginInit();
622
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
623
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
624
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
625
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
626
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
627
                    defaultBitmapImage_Compare.EndInit();
628

    
629
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
630

    
631
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
632
                    zoomAndPanControl.ZoomTo(new Rect
633
                    {
634
                        X = 0,
635
                        Y = 0,
636
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
637
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
638
                    });
639

    
640
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
641
                    if (defaultBitmapImage_Compare.IsDownloading)
642
                    {
643
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
644
                        {
645
                            defaultBitmapImage_Compare.Freeze();
646
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
647
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
648
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
649
                            ComparePanel.UpdateLayout();
650
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
651
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
652

    
653
                            zoomAndPanControl.ZoomTo(new Rect
654
                            {
655
                                X = 0,
656
                                Y = 0,
657
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
658
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
659
                            });
660

    
661
                            //defaultBitmapImage_Compare dispose
662
                            defaultBitmapImage_Compare = null;
663
                            GC.Collect();
664
                        };
665
                    }
666
                }
667
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
668
            }
669

    
670
        }
671

    
672
        /// <summary>
673
        /// called after page is changed
674
        /// </summary>
675
        /// <param name="sender"></param>
676
        /// <param name="e"></param>
677
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
678
        {
679
            if (zoomAndPanCanvas2.Width.IsNaN())
680
            {
681
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
682
            }
683

    
684
            /// 컨트롤을 새로 생성한다.
685
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
686
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
687
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
688
            { 
689
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).First();
690
                if (info != null)
691
                {
692
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
693
                    if (info.UserID == App.ViewInfo.UserID)
694
                    {
695
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
696
                                        markup.MarkupInfoID, markup.ID);
697
                        control.Visibility = Visibility.Hidden;
698
                    }
699
                    else
700
                    {
701
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
702
                                                                markup.MarkupInfoID, markup.ID);
703
                        control.Visibility = Visibility.Hidden;
704
                    }
705
                }
706
            };
707
            /// up to here
708

    
709
            /// fire selection event
710
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
711
            this.gridViewMarkup.UnselectAll();
712
            this.gridViewMarkup.Select(gridSelectionItem);
713

    
714
            if (!testPanel2.IsHidden)
715
            {
716
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
717
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
718
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
719

    
720
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
721
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
722

    
723

    
724
                foreach (var item in gridSelectionRevItem)
725
                {
726
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
727
                    {
728
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
729
                    });
730
                }
731
            }
732

    
733
            var instanceMain = this.ParentOfType<MainWindow>();
734
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
735
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
736

    
737
            instanceMain.dzTopMenu.rotateOffSet = 0;
738
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
739
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
740

    
741
            SetCommentPages(true);
742
        }
743

    
744
        private void SetCommentPages(bool onlyMe = false)
745
        {
746
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
747
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
748
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
749
            {
750
                UsersCommentPagesMember instance = new UsersCommentPagesMember();
751
                instance.UserName = item.UserName;
752
                instance.Depart = item.Depatment;
753
                instance.MarkupInfoID = item.MarkupInfoID;
754
                instance.IsSelected = true;
755
                instance.isConSolidation = item.Consolidate;
756
                instance.SetColor = item.DisplayColor;
757
                if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
758
                {
759
                    instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
760
                }
761
                else
762
                {
763
                    instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
764
                }
765
                _pages.Add(instance);
766
            }
767
            this.pageNavigator.SetCommentList(_pages.ToList());
768
        }
769

    
770
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
771
        {
772
            if (e.MiddleButton == MouseButtonState.Pressed)
773
            {
774

    
775
            }
776
            e.Handled = true;
777
            if (e.Delta > 0)
778
            {
779
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
780
                ZoomIn(currentContentMousePoint);
781
            }
782
            else
783
            {
784
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
785
                ZoomOut(currentContentMousePoint);
786
            }
787
        }
788

    
789
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
790
        {
791
            e.Handled = true;
792
            if (e.Delta > 0)
793
            {
794
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
795
                ZoomIn_Sync(currentContentMousePoint);
796
            }
797
            else
798
            {
799
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
800
                ZoomOut_Sync(currentContentMousePoint);
801
            }
802
        }
803

    
804
        #region ZoomIn & ZoomOut
805

    
806
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
807
        {
808
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
809
                zoomAndPanControl.ContentZoomFocusY));
810
        }
811

    
812
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
813
        {
814
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
815
                zoomAndPanControl.ContentZoomFocusY));
816
        }
817

    
818

    
819
        //강인구 추가 (줌 인아웃 수치 변경)
820
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
821
        private void ZoomOut(Point contentZoomCenter)
822
        {
823
            if (zoomAndPanControl.ContentScale > 0.39)
824
            {
825
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
826
            }
827
            else
828
            {
829
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
830
            }
831

    
832
            if (zoomAndPanControl2 != null && Sync.IsChecked)
833
            {
834
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
835
            }
836
        }
837

    
838
        private void ZoomIn(Point contentZoomCenter)
839
        {
840
            if (zoomAndPanControl.ContentScale > 0.19)
841
            {
842
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
843
            }
844
            else
845
            {
846
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
847
            }
848

    
849
            if (zoomAndPanControl2 != null && Sync.IsChecked)
850
            {
851
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
852
            }
853

    
854
        }
855

    
856
        private void ZoomOut_Sync(Point contentZoomCenter)
857
        {
858
            if (zoomAndPanControl2.ContentScale > 0.39)
859
            {
860
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
861
            }
862
            else
863
            {
864
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
865
            }
866

    
867
            if (Sync.IsChecked)
868
            {
869
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
870
            }
871
        }
872

    
873
        private void ZoomIn_Sync(Point contentZoomCenter)
874
        {
875
            if (zoomAndPanControl2.ContentScale > 0.19)
876
            {
877
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
878
            }
879
            else
880
            {
881
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
882
            }
883

    
884
            if (Sync.IsChecked)
885
            {
886
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
887
            }
888
        }
889

    
890
        private void ZoomOut()
891
        {
892
            zoomAndPanControl.ContentScale -= 0.1;
893
            //if (zoomAndPanControl2 != null)
894
            //{
895
            //    zoomAndPanControl2.ContentScale -= 0.1;
896
            //}
897
        }
898

    
899
        private void ZoomIn()
900
        {
901
            zoomAndPanControl.ContentScale += 0.1;
902
            //if (zoomAndPanControl2 != null)
903
            //{
904
            //    zoomAndPanControl2.ContentScale += 0.1;
905
            //}
906
        }
907

    
908
        #endregion
909

    
910
        private void init()
911
        {
912
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
913
            {
914

    
915
                ControlList.Clear();
916
                listBox.Items.Clear();
917
                selected_item.Clear();
918

    
919
                (item as IMarkupCommonData).IsSelected = false;
920
            }
921

    
922
        }
923

    
924
        private HitTestResultBehavior MyCallback(HitTestResult result)
925
        {
926
            //this.cursor = Cursors.UpArrow;
927
            var element = result.VisualHit;
928
            while (element != null && !(element is CommentUserInfo))
929
                element = VisualTreeHelper.GetParent(element);
930

    
931
            if (element == null)
932
            {
933
                return HitTestResultBehavior.Stop;
934
            }
935
            else
936
            {
937
                if (element is CommentUserInfo)
938
                {
939
                    if (!hitList.Contains(element))
940
                    {
941
                        hitList.Add((CommentUserInfo)element);
942
                    }
943
                    else
944
                    {
945
                        return HitTestResultBehavior.Stop;
946
                    }
947
                }
948
            }
949
            return HitTestResultBehavior.Continue;
950
        }
951

    
952
        public void ReleaseSelectPath()
953
        {
954
            if (SelectionPath == null)
955
            {
956
                SelectionPath = new Path();
957
                SelectionPath.Name = "";
958
            }
959
            if (SelectionPath.Name != "")
960
            {
961
                SelectionPath.Name = "None";
962
            }
963
            SelectionPath.Opacity = 0.01;
964
            SelectionPath.RenderTransform = null;
965
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
966
        }
967

    
968
        #region 컨트롤 초기화 
969
        public void Control_Init(object control)
970
        {
971
            if (L_Size != 0 && (control as IPath) != null)
972
            {
973
                (control as IPath).LineSize = L_Size;
974
                L_Size = 0;
975
            }
976

    
977
            switch (control.GetType().Name)
978
            {
979
                case "RectangleControl":
980
                    {
981
                        (control as RectangleControl).StrokeColor = Brushes.Red;
982
                    }
983
                    break;
984
                case "CircleControl":
985
                    {
986
                        (control as CircleControl).StrokeColor = Brushes.Red;
987
                    }
988
                    break;
989
                case "TriControl":
990
                    {
991
                        (control as TriControl).StrokeColor = Brushes.Red;
992
                    }
993
                    break;
994
                case "RectCloudControl":
995
                    {
996
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
997
                    }
998
                    break;
999
                case "CloudControl":
1000
                    {
1001
                        (control as CloudControl).StrokeColor = Brushes.Red;
1002
                    }
1003
                    break;
1004
                case "PolygonControl":
1005
                    {
1006
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1007
                    }
1008
                    break;
1009
                case "ArcControl":
1010
                    {
1011
                        (control as ArcControl).StrokeColor = Brushes.Red;
1012
                    }
1013
                    break;
1014
                case "ArrowArcControl":
1015
                    {
1016
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1017
                    }
1018
                    break;
1019
                case "LineControl":
1020
                    {
1021
                        (control as LineControl).StrokeColor = Brushes.Red;
1022
                    }
1023
                    break;
1024
                case "ArrowControl_Multi":
1025
                    {
1026
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1027
                    }
1028
                    break;
1029
                case "TextControl":
1030
                    {
1031
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1032
                    }
1033
                    break;
1034
                case "ArrowTextControl":
1035
                    {
1036
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1037
                    }
1038
                    break;
1039
                case "InsideWhiteControl":
1040
                    {
1041
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1042
                    }
1043
                    break;
1044
                case "OverlapWhiteControl":
1045
                    {
1046
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1047
                    }
1048
                    break;
1049
                case "ClipWhiteControl":
1050
                    {
1051
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1052
                    }
1053
                    break;
1054
                case "CoordinateControl":
1055
                    {
1056
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1057
                    }
1058
                    break;
1059
            }
1060
        }
1061
        #endregion
1062

    
1063
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1064
        {
1065
            //Control_Init(e.Source);
1066
        }
1067
        //private Window _dragdropWindow = null;
1068

    
1069
        [DllImport("user32.dll")]
1070
        [return: MarshalAs(UnmanagedType.Bool)]
1071
        internal static extern bool GetCursorPos(ref Win32Point pt);
1072

    
1073
        [StructLayout(LayoutKind.Sequential)]
1074
        internal struct Win32Point
1075
        {
1076
            public Int32 X;
1077
            public Int32 Y;
1078
        };
1079
        /*
1080
       public string symbol_id = null;
1081
       public long symbol_group_id;
1082
       public int symbol_SelectedIndex;
1083
       public ImageSource symbol_img;
1084
       public string symbol_Data = null;
1085
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1086
       {
1087
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1088
               zoomAndPanCanvas.ActualHeight / 2));
1089

    
1090

    
1091
               if (this._dragdropWindow != null)
1092
               {
1093
                   this._dragdropWindow.Close();
1094
                   this._dragdropWindow = null;
1095
               }
1096

    
1097
               symbol_id = id;
1098
               symbol_group_id = group_id;
1099
               symbol_SelectedIndex = SelectedIndex;
1100
               symbol_Data = Data_;
1101
               symbol_img = img;
1102

    
1103

    
1104
               CreateDragDropWindow2(img);
1105
              
1106
    }
1107

    
1108
    private void CreateDragDropWindow2(ImageSource image)
1109
        {
1110
            this._dragdropWindow = new Window();
1111
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1112
            _dragdropWindow.WindowStyle = WindowStyle.None;
1113
            _dragdropWindow.AllowsTransparency = true;           
1114
            _dragdropWindow.AllowDrop = false;
1115
            _dragdropWindow.Background = null;
1116
            _dragdropWindow.IsHitTestVisible = false;
1117
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1118
            _dragdropWindow.Topmost = true;
1119
            _dragdropWindow.ShowInTaskbar = false;
1120
            
1121
            Rectangle r = new Rectangle();
1122
            r.Width = image.Width;
1123
            r.Height = image.Height;
1124
            r.Opacity = 0.5;            
1125
            r.Fill = new ImageBrush(image);
1126
            this._dragdropWindow.Content = r;
1127

    
1128
            Win32Point w32Mouse = new Win32Point();
1129
            GetCursorPos(ref w32Mouse);
1130

    
1131
            //w32Mouse.X = getCurrentPoint.X;
1132
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1133
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1134
            this._dragdropWindow.Show();
1135
        }
1136
         */
1137
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1138
        {
1139
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1140
            {
1141
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1142

    
1143
                Point currentPos = e.GetPosition(rect);
1144

    
1145
                floatingTip.HorizontalOffset = currentPos.X + 20;
1146
                floatingTip.VerticalOffset = currentPos.Y;
1147
            }
1148

    
1149
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1150
            
1151
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1152
            {
1153
                SetCursor();
1154
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1155
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1156

    
1157
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1158
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1159
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1160

    
1161
                if (Sync.IsChecked)
1162
                {
1163
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1164
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1165
                }
1166
            }
1167

    
1168
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1169
            {
1170
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1171
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1172
                SetCursor();
1173

    
1174
                if (currentControl != null)
1175
                {
1176
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1177
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1178
                    //강인구 추가
1179
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1180

    
1181
                    if ((currentControl as IPath) != null)
1182
                    {
1183
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1184
                    }
1185
                    if ((currentControl as LineControl) != null)
1186
                    {
1187
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1188
                    }
1189

    
1190
                    if ((currentControl as IShapeControl) != null)
1191
                    {
1192
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1193
                    }
1194
                    if ((currentControl as TextControl) != null)
1195
                    {
1196
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1197
                        {
1198
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1199
                        }
1200
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1201
                        {
1202
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1203
                        }
1204
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1205
                        {
1206
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1207
                        }
1208
                    }
1209
                    else if ((currentControl as ArrowTextControl) != null)
1210
                    {
1211
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1212
                        {
1213
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1214
                        }
1215
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1216
                        {
1217
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1218
                        }
1219
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1220
                        {
1221
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1222
                        }
1223
                    }
1224
                    else if ((currentControl as RectCloudControl) != null)
1225
                    {
1226
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1227
                    }
1228
                    else if ((currentControl as CloudControl) != null)
1229
                    {
1230
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1231
                    }
1232

    
1233
                    switch (controlType)
1234
                    {
1235
                        case (ControlType.Coordinate):
1236
                            {
1237
                                var control = currentControl as CoordinateControl;
1238
                                if (control != null)
1239
                                {
1240
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1241
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1242
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1243
                                }
1244
                            }
1245
                            break;
1246
                        case (ControlType.InsideWhite):
1247
                            {
1248
                                var control = currentControl as InsideWhiteControl;
1249
                                if (control != null)
1250
                                {
1251
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1252
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1253
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1254
                                    control.Paint = PaintSet.Fill;
1255
                                }
1256
                            }
1257
                            break;
1258
                        case ControlType.OverlapWhite:
1259
                            {
1260
                                var control = currentControl as OverlapWhiteControl;
1261
                                if (control != null)
1262
                                {
1263
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1264
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1265
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1266
                                    control.Paint = PaintSet.Fill;
1267
                                }
1268
                            }
1269
                            break;
1270
                        case ControlType.ClipWhite:
1271
                            {
1272
                                var control = currentControl as ClipWhiteControl;
1273
                                if (control != null)
1274
                                {
1275
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1276
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1277
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1278
                                    control.Paint = PaintSet.Fill;
1279
                                }
1280
                            }
1281
                            break;
1282
                        case ControlType.RectCloud:
1283
                            {
1284
                                var control = currentControl as RectCloudControl;
1285
                                if (control != null)
1286
                                {
1287
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1288
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1289
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1290
                                }
1291
                            }
1292
                            break;
1293
                        case ControlType.SingleLine:
1294
                        case ControlType.CancelLine:
1295
                        case ControlType.ArrowLine:
1296
                        case ControlType.TwinLine:
1297
                        case ControlType.DimLine:
1298
                            {
1299
                                var control = currentControl as LineControl;
1300
                                if (control != null)
1301
                                {
1302
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1303
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1304
                                }
1305
                            }
1306
                            break;
1307

    
1308
                        case ControlType.ArcLine:
1309
                            {
1310
                                var control = currentControl as ArcControl;
1311
                                if (control != null)
1312
                                {
1313
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1314
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1315
                                }
1316
                            }
1317
                            break;
1318

    
1319
                        case ControlType.ArcArrow:
1320
                            {
1321
                                var control = currentControl as ArrowArcControl;
1322
                                if (control != null)
1323
                                {
1324
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1325
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1326
                                }
1327
                            }
1328
                            break;
1329

    
1330
                        case ControlType.ArrowMultiLine:
1331
                            {
1332
                                var control = currentControl as ArrowControl_Multi;
1333
                                if (control != null)
1334
                                {
1335
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1336
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1337
                                }
1338
                            }
1339
                            break;
1340

    
1341
                        case ControlType.Circle:
1342
                            {
1343
                                if (currentControl != null)
1344
                                {
1345
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1346
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1347
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1348
                                }
1349
                            }
1350
                            break;
1351

    
1352
                        case ControlType.PolygonCloud:
1353
                            {
1354
                                var control = currentControl as CloudControl;
1355
                                if (control != null)
1356
                                {
1357
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1358
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1359
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1360
                                }
1361
                            }
1362
                            break;
1363

    
1364
                        case ControlType.Triangle:
1365
                            {
1366
                                var control = currentControl as TriControl;
1367
                                if (control != null)
1368
                                {
1369
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1370
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1371
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1372
                                }
1373
                            }
1374
                            break;
1375

    
1376
                        case ControlType.ImgControl:
1377
                            {
1378
                                var control = currentControl as ImgControl;
1379
                                if (control != null)
1380
                                {
1381
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1382
                                }
1383
                            }
1384
                            break;
1385

    
1386
                        case ControlType.Date:
1387
                            {
1388
                                var control = currentControl as DateControl;
1389
                                if (control != null)
1390
                                {
1391
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1392
                                }
1393
                            }
1394
                            break;
1395

    
1396
                        case ControlType.ArrowTextControl:
1397
                        case ControlType.ArrowTransTextControl:
1398
                        case ControlType.ArrowTextBorderControl:
1399
                        case ControlType.ArrowTransTextBorderControl:
1400
                        case ControlType.ArrowTextCloudControl:
1401
                        case ControlType.ArrowTransTextCloudControl:
1402
                            {
1403
                                var control = currentControl as ArrowTextControl;
1404
                                if (control != null)
1405
                                {
1406
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1407
                                }
1408
                            }
1409
                            break;
1410
                        case ControlType.PolygonControl:
1411
                        case ControlType.ChainLine:
1412
                            {
1413
                                var control = currentControl as PolygonControl;
1414
                                if (control != null)
1415
                                {
1416
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1417
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1418
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1419
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1420
                                }
1421
                            }
1422
                            break;
1423
                        case ControlType.Sign:
1424
                            {
1425
                                var control = currentControl as SignControl;
1426
                                if (control != null)
1427
                                {
1428
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1429
                                }
1430
                            }
1431
                            break;
1432
                        case ControlType.Symbol:
1433
                            {
1434
                                var control = currentControl as SymControl;
1435
                                if (control != null)
1436
                                {
1437
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1438
                                }
1439
                            }
1440
                            break;
1441
                        case ControlType.Stamp:
1442
                            {
1443
                                var control = currentControl as SymControlN;
1444
                                if (control != null)
1445
                                {
1446
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1447
                                }
1448
                            }
1449
                            break;
1450
                        case ControlType.Rectangle:
1451
                        case ControlType.Mark:
1452
                            {
1453
                                var control = currentControl as RectangleControl;
1454
                                if (control != null)
1455
                                {
1456
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1457
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1458
                                }
1459
                            }
1460
                            break;
1461
                        case ControlType.PenControl:
1462
                            {
1463
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1464
                                //inkBoard.Strokes.Add(stroke);
1465
                            }
1466
                            break;
1467
                        default:
1468
                            break;
1469
                    }
1470
                }
1471
            }
1472
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1473
            {
1474
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1475
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1476
                SetCursor();
1477
                if (currentControl == null)
1478
                {
1479
                    switch (controlType)
1480
                    {
1481
                        case ControlType.PenControl:
1482
                            {
1483
                                if (inkBoard.Tag.ToString() == "Ink")
1484
                                {
1485
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1486
                                }
1487
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1488
                                {
1489
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1490
                                }
1491
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1492
                                {
1493
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1494
                                }
1495

    
1496
                                //inkBoard.Strokes.Add(stroke);
1497
                            }
1498
                            break;
1499
                    }
1500
                    return;
1501
                }
1502
            }
1503
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1504
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1505
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1506
            {
1507
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1508

    
1509
                if (isDraggingSelectionRect)
1510
                {
1511
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1512
                    e.Handled = true;
1513
                }
1514
                else if (isLeftMouseButtonDownOnWindow)
1515
                {
1516
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1517
                    double dragDistance = Math.Abs(dragDelta.Length);
1518

    
1519
                    if (dragDistance > DragThreshold)
1520
                    {
1521
                        isDraggingSelectionRect = true;
1522
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1523
                    }
1524

    
1525
                    e.Handled = true;
1526
                }
1527

    
1528
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1529
                {
1530
                }
1531
                else
1532
                {
1533
                    e.Handled = true;
1534
                }
1535
            }
1536
            /*
1537
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1538
            { //symbol      
1539
                if(_dragdropWindow != null)
1540
                {
1541
                    Win32Point w32Mouse = new Win32Point();
1542
                    GetCursorPos(ref w32Mouse);
1543

    
1544
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1545
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1546
                }                
1547
            }
1548
            */
1549
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1550
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1551
            {
1552
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1553
                if(control != null)
1554
                {
1555
                    this.cursor = Cursors.Hand;
1556
                    SetCursor();
1557
                }
1558
                else
1559
                {
1560
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1561
                    SetCursor();
1562
                }
1563
            }
1564
            else
1565
            {
1566
            }
1567
        }
1568

    
1569
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1570
        {
1571
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1572
            {
1573
                SetCursor();
1574
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1575
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1576

    
1577
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1578

    
1579
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1580
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1581

    
1582
                if (Sync.IsChecked)
1583
                {
1584
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1585
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1586
                }
1587
            }
1588
        }
1589

    
1590
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1591

    
1592
        private EllipseGeometry hitArea = new EllipseGeometry();
1593

    
1594
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1595
        {
1596
            IsDrawing = false;
1597

    
1598
            if (mouseHandlingMode != MouseHandlingMode.None)
1599
            {
1600
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1601
                {
1602
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1603

    
1604
                    SetCursor();
1605

    
1606
                    switch (controlType)
1607
                    {
1608
                        case ControlType.None:
1609
                            break;
1610
                        case ControlType.Rectangle:
1611
                            {
1612

    
1613
                            }
1614
                            break;
1615
                        case ControlType.PenControl:
1616
                            {
1617

    
1618
                            }
1619
                            break;
1620
                        default:
1621
                            break;
1622
                    }
1623
                }
1624
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1625
                {
1626
                    if (isLeftMouseButtonDownOnWindow)
1627
                    {
1628
                        bool wasDragSelectionApplied = false;
1629

    
1630
                        if (isDraggingSelectionRect)
1631
                        {
1632
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1633
                            {
1634
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1635
                                mouseHandlingMode = MouseHandlingMode.None;
1636
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1637
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1638
                                Set_Symbol_Capture(endPoint);
1639
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1640
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1641
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1642
                            }
1643
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1644
                            {
1645
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1646
                                mouseHandlingMode = MouseHandlingMode.None;
1647
                                Set_Capture();
1648

    
1649
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1650
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1651
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1652
                            }
1653
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1654
                            {
1655
                                ApplyDragSelectionRect();
1656
                            }
1657
                            else
1658
                            {
1659
                                double x = Canvas.GetLeft(dragZoomBorder);
1660
                                double y = Canvas.GetTop(dragZoomBorder);
1661
                                double width = dragZoomBorder.Width;
1662
                                double height = dragZoomBorder.Height;
1663
                                Rect dragRect = new Rect(x, y, width, height);
1664

    
1665
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1666

    
1667
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1668
                            }
1669

    
1670
                            isDraggingSelectionRect = false;
1671
                            e.Handled = true;
1672
                            wasDragSelectionApplied = true;
1673
                        }
1674

    
1675
                        if (isLeftMouseButtonDownOnWindow)
1676
                        {
1677
                            isLeftMouseButtonDownOnWindow = false;
1678
                            this.ReleaseMouseCapture();
1679
                            e.Handled = true;
1680
                        }
1681

    
1682
                        if (!wasDragSelectionApplied)
1683
                        {
1684
                            init();
1685
                        }
1686
                    }
1687
                }
1688
                else if (e.RightButton == MouseButtonState.Pressed)
1689
                {
1690
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1691
                    SetCursor();
1692
                }
1693

    
1694
                zoomAndPanControl.ReleaseMouseCapture();
1695

    
1696

    
1697
                e.Handled = true;
1698
            }
1699
            else
1700
            {
1701
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1702
                SetCursor();
1703
            }
1704

    
1705
            ///mouseButtonDown = MouseButton.Left;
1706
            //controlType = ControlType.SingleLine;
1707
        }
1708

    
1709
        public void Set_Symbol_Capture(Point endPoint)
1710
        {       
1711
            double x = canvasDrawingMouseDownPoint.X;
1712
            double y = canvasDrawingMouseDownPoint.Y;
1713
            if(x > endPoint.X)
1714
            {
1715
                x = endPoint.X;
1716
                y = endPoint.Y;
1717
            }
1718

    
1719
            double width = dragCaptureBorder.Width;
1720
            double height = dragCaptureBorder.Height;
1721

    
1722
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1723

    
1724
            if (x < 0)
1725
            {
1726
                width += x;
1727
                x = 0;
1728
            }
1729
            if (y < 0)
1730
            {
1731
                height += y;
1732
                y = 0;
1733

    
1734
                width = (int)canvasImage.PixelWidth - x;
1735
            }
1736
            if (x + width > canvasImage.PixelWidth)
1737
            {
1738
                width = (int)canvasImage.PixelWidth - x;
1739
            }
1740
            if (y + height > canvasImage.PixelHeight)
1741
            {
1742
                height = (int)canvasImage.PixelHeight - y;
1743
            }
1744
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1745

    
1746
            string uri = "";
1747
            if (userData.COMPANY != "EXT")
1748
            {
1749
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1750
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1751
            }
1752
            else
1753
            {
1754
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1755
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1756
            }
1757

    
1758
            var defaultBitmapImage = new BitmapImage();
1759
            defaultBitmapImage.BeginInit();
1760
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1761
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1762
            defaultBitmapImage.UriSource = new Uri(uri);
1763
            defaultBitmapImage.EndInit();
1764

    
1765
            //GC.Collect();
1766

    
1767
            if (defaultBitmapImage.IsDownloading)
1768
            {
1769
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1770
                {
1771
                    defaultBitmapImage.Freeze();
1772
                    //GC.Collect();
1773
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1774
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1775
                };
1776
            }
1777
        }
1778

    
1779
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1780
        {
1781
            ///mouseButtonDown = MouseButton.Left;
1782
        }
1783

    
1784
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1785
        {
1786
            ///mouseButtonDown = MouseButton.Left;
1787
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1788
        }
1789

    
1790
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1791
        {
1792

    
1793
        }
1794

    
1795
        /// <summary>
1796
        /// select items by dragging
1797
        /// </summary>
1798
        private void ApplyDragSelectionRect()
1799
        {
1800
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1801

    
1802
            double x = Canvas.GetLeft(dragSelectionBorder);
1803
            double y = Canvas.GetTop(dragSelectionBorder);
1804
            double width = dragSelectionBorder.Width;
1805
            double height = dragSelectionBorder.Height;
1806
            Boolean Flag = false;
1807
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1808
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1809

    
1810
            Rect dragRect = new Rect(x, y, width, height);
1811
            ///dragRect.Inflate(width / 10, height / 10);
1812

    
1813
            foreach (var item in Items)
1814
            {
1815
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1816

    
1817
                if (Flag)
1818
                {
1819
                    adornerSet.Add(item);
1820
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1821
                    Control_Style(item);
1822
                }
1823
            }
1824
            if (adornerSet.Count > 0)
1825
            {
1826
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1827
                SelectLayer.Children.Add(final);
1828
            }
1829
        }
1830

    
1831
        private void InitDragSelectionRect(Point pt1, Point pt2)
1832
        {
1833
            //캡쳐 중
1834
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1835
            {
1836
                dragCaptureBorder.Visibility = Visibility.Visible;
1837
            }
1838
            //선택 중
1839
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1840
            {
1841

    
1842
                dragSelectionBorder.Visibility = Visibility.Visible;
1843
            }
1844
            else
1845
            {
1846
                dragZoomBorder.Visibility = Visibility.Visible;
1847
            }
1848
            UpdateDragSelectionRect(pt1, pt2);
1849
        }
1850

    
1851
        /// <summary>
1852
        /// Update the position and size of the rectangle used for drag selection.
1853
        /// </summary>
1854
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1855
        {
1856
            double x, y, width, height;
1857

    
1858
            //
1859
            // Determine x,y,width and height of the rect inverting the points if necessary.
1860
            // 
1861

    
1862
            if (pt2.X < pt1.X)
1863
            {
1864
                x = pt2.X;
1865
                width = pt1.X - pt2.X;
1866
            }
1867
            else
1868
            {
1869
                x = pt1.X;
1870
                width = pt2.X - pt1.X;
1871
            }
1872

    
1873
            if (pt2.Y < pt1.Y)
1874
            {
1875
                y = pt2.Y;
1876
                height = pt1.Y - pt2.Y;
1877
            }
1878
            else
1879
            {
1880
                y = pt1.Y;
1881
                height = pt2.Y - pt1.Y;
1882
            }
1883

    
1884
            //
1885
            // Update the coordinates of the rectangle used for drag selection.
1886
            //
1887
            //캡쳐 중
1888
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1889
            {
1890
                Canvas.SetLeft(dragCaptureBorder, x);
1891
                Canvas.SetTop(dragCaptureBorder, y);
1892
                dragCaptureBorder.Width = width;
1893
                dragCaptureBorder.Height = height;
1894
            }
1895
            //선택 중
1896
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1897
            {
1898
                Canvas.SetLeft(dragSelectionBorder, x);
1899
                Canvas.SetTop(dragSelectionBorder, y);
1900
                dragSelectionBorder.Width = width;
1901
                dragSelectionBorder.Height = height;
1902
            }
1903
            else
1904
            {
1905
                Canvas.SetLeft(dragZoomBorder, x);
1906
                Canvas.SetTop(dragZoomBorder, y);
1907
                dragZoomBorder.Width = width;
1908
                dragZoomBorder.Height = height;
1909
            }
1910
        }
1911

    
1912
        private void drawingPannelRotate(double angle)
1913
        {
1914
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1915
            rotate.Angle = angle;
1916
            var rotationNum = Math.Abs((rotate.Angle / 90));
1917

    
1918
            if (angle == 90 || angle == 270)
1919
            {
1920
                double emptySize = zoomAndPanCanvas.Width;
1921
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1922
                zoomAndPanCanvas.Height = emptySize;
1923
            }
1924
            if (angle == 0)
1925
            {
1926
                translate.X = 0;
1927
                translate.Y = 0;
1928
            }
1929
            else if (angle == 90)
1930
            {
1931
                translate.X = zoomAndPanCanvas.Width;
1932
                translate.Y = 0;
1933
            }
1934
            else if (angle == 180)
1935
            {
1936
                translate.X = zoomAndPanCanvas.Width;
1937
                translate.Y = zoomAndPanCanvas.Height;
1938
            }
1939
            else
1940
            {
1941
                translate.X = 0;
1942
                translate.Y = zoomAndPanCanvas.Height;
1943
            }
1944

    
1945
            zoomAndPanControl.RotationAngle = rotate.Angle;
1946

    
1947

    
1948
            if (!testPanel2.IsHidden)
1949
            {
1950
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1951
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1952
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1953
            }
1954

    
1955
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1956
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1957
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
1958
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
1959
            ViewerDataModel.Instance.Angle = rotate.Angle;
1960
        }
1961

    
1962
        private void syncPannelRotate(double angle)
1963
        {
1964
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1965
            rotate.Angle = angle;
1966
            var rotationNum = Math.Abs((rotate.Angle / 90));
1967

    
1968
            if (angle == 90 || angle == 270)
1969
            {
1970
                double emptySize = zoomAndPanCanvas2.Width;
1971
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
1972
                zoomAndPanCanvas2.Height = emptySize;
1973
            }
1974
            if (angle == 0)
1975
            {
1976
                translate2.X = 0;
1977
                translate2.Y = 0;
1978
            }
1979
            else if (angle == 90)
1980
            {
1981
                translate2.X = zoomAndPanCanvas2.Width;
1982
                translate2.Y = 0;
1983
            }
1984
            else if (angle == 180)
1985
            {
1986
                translate2.X = zoomAndPanCanvas2.Width;
1987
                translate2.Y = zoomAndPanCanvas2.Height;
1988
            }
1989
            else
1990
            {
1991
                translate2.X = 0;
1992
                translate2.Y = zoomAndPanCanvas2.Height;
1993
            }
1994

    
1995
            zoomAndPanControl2.RotationAngle = rotate.Angle;
1996
        }
1997

    
1998
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
1999
        {
2000
            string Data_ = "";
2001

    
2002
            try
2003
            {
2004
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2005
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2006
                if (Data_ != null || Data_ != "")
2007
                {
2008
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2009
                }
2010
                else
2011
                {
2012
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2013
                }
2014

    
2015
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2016
                //{
2017
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2018
                //    STATE = 0,
2019
                //};
2020
                if (Data_ != null)
2021
                {
2022
                    Image img = new Image();
2023
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2024
                    if (Data_.Contains(".svg"))
2025
                    {
2026
                        byte[] imageData = null;
2027
                        DrawingImage image = null;
2028
                        using (System.Net.WebClient web = new System.Net.WebClient())
2029
                        {
2030
                            imageData = web.DownloadData(new Uri(Data_));
2031
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2032
                            image = SvgReader.Load(stream);
2033
                        }
2034
                        img.Source = image;
2035
                    }
2036
                    else
2037
                    {
2038
                        img.Source = new BitmapImage(new Uri(Data_));
2039
                    }
2040

    
2041
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2042
                    {
2043
                        PointSet = new List<Point>(),
2044
                        FilePath = Data_,
2045
                        ImageData = img.Source,
2046
                        StartPoint = canvasZoomPanningMouseDownPoint,
2047
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2048
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2049
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2050
                        canvasZoomPanningMouseDownPoint.Y),
2051
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2052
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2053
                    };
2054

    
2055
                    currentControl.PointSet = new List<Point>
2056
                                        {
2057
                                            currentControl.StartPoint,
2058
                                            currentControl.LeftBottomPoint,
2059
                                            currentControl.EndPoint,
2060
                                            currentControl.TopRightPoint,
2061
                                        };
2062
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2063
                    UndoData = new Undo_data()
2064
                    {
2065
                        IsUndo = false,
2066
                        Event = Event_Type.Create,
2067
                        EventTime = DateTime.Now,
2068
                        Markup_List = new List<Multi_Undo_data>()
2069
                    };
2070
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2071
                    {
2072
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2073
                    });
2074

    
2075
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2076
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2077
                    UndoData.Markup_List.Add(multi_Undo_Data);
2078
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2079

    
2080
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2081
                    currentControl.CommentID = Commons.shortGuid();
2082
                    currentControl.SymbolID = id;
2083
                    currentControl.GroupID = group_id;
2084
                    currentControl.ApplyTemplate();
2085
                    currentControl.SetImage();
2086

    
2087
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2088
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2089
                    SelectLayer.Children.Add(final);
2090
                }
2091
            }
2092
            catch (Exception ex)
2093
            {
2094
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2095
            }
2096
        }
2097

    
2098
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2099
        {            
2100
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2101
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2102
            {
2103
                set_option.Value = double.Parse(set_option.ContentText);
2104
            }
2105

    
2106
            ConvertInkControlToPolygon();
2107

    
2108
            ///TODO:
2109
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2110
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2111

    
2112
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2113
            {
2114
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2115
            }
2116
            /// up to here
2117

    
2118
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2119
            {
2120
                if (arrow_text as ArrowTextControl != null)
2121
                {
2122
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2123
                }
2124
            }
2125

    
2126
            //if (currentControl != null)
2127
            {
2128
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2129
                if (text_item_ != null)
2130
                {
2131
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2132
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2133
                    (text_item_ as TextControl).EnableEditing = false;
2134
                    currentControl = null;
2135
                }
2136

    
2137
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2138
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2139
                {
2140
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2141
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2142
                    currentControl = null;
2143
                }
2144
            }
2145

    
2146
            double Ang = 0;                                          
2147
            if (rotate.Angle != 0)
2148
            {
2149
                Ang = 360 - rotate.Angle;
2150
            }
2151

    
2152
            if (e.OriginalSource is System.Windows.Controls.Image)
2153
            {
2154
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2155
            }
2156
            /*
2157
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2158
            {                
2159
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2160
                if(symbol_id != null)
2161
                {
2162
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2163
                }                
2164
            }
2165

    
2166
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2167
            {
2168
                if (this._dragdropWindow != null)
2169
                {
2170
                    this._dragdropWindow.Close();
2171
                    this._dragdropWindow = null;
2172
                    symbol_id = null;
2173
                }
2174
            }
2175
            */
2176

    
2177
            if (e.LeftButton == MouseButtonState.Pressed)
2178
            {
2179
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2180
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2181

    
2182
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2183
                SetCursor();
2184

    
2185
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2186
            }
2187

    
2188
            if (e.MiddleButton == MouseButtonState.Pressed)
2189
            {
2190
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2191
                cursor = Cursors.SizeAll;
2192
                SetCursor();
2193
            }
2194
            if (e.RightButton == MouseButtonState.Pressed)
2195
            {
2196
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2197
                cursor = Cursors.SizeAll;
2198
                SetCursor();
2199
            }
2200
            else if (e.XButton1 == MouseButtonState.Pressed)
2201
            {
2202
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2203
                {
2204
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2205
                }
2206

    
2207
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2208

    
2209
            }
2210
            else if (e.XButton2 == MouseButtonState.Pressed)
2211
            {
2212
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2213
                {
2214
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2215
                }
2216
            }
2217

    
2218
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2219
            {
2220
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2221
                {
2222
                    if (SelectLayer.Children.Count == 0)
2223
                    {
2224
                        isLeftMouseButtonDownOnWindow = true;
2225
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2226
                    }
2227

    
2228
                    if (controlType == ControlType.None)
2229
                    {
2230
                        isLeftMouseButtonDownOnWindow = true;
2231
                    }
2232
                }
2233

    
2234
                /// 캡쳐 모드 설정
2235
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2236
                {
2237
                    dragCaptureBorder.Visibility = Visibility.Visible;
2238
                    isLeftMouseButtonDownOnWindow = true;
2239
                }
2240

    
2241
                /// 줌 모드 설정
2242
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2243
                {
2244
                    isLeftMouseButtonDownOnWindow = true;
2245
                }
2246

    
2247
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2248
                if (control != null)
2249
                {
2250
                    AdornerFinal final = null;
2251

    
2252
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2253
                    {
2254
                        /// 기존 selection 해제
2255
                        SelectionSet.Instance.UnSelect(this);
2256

    
2257
                        final = new AdornerFinal(control);
2258

    
2259
                        this.Control_Style(control);
2260

    
2261
                        if ((control as IPath) != null)
2262
                        {
2263
                            if ((control as IPath).LineSize != 0)
2264
                            {
2265
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2266
                            }
2267
                        }
2268
                        if ((control as IShapeControl) != null)
2269
                        {
2270
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2271
                            {
2272
                                ViewerDataModel.Instance.checkHatchShape = true;
2273
                            }
2274
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2275
                            {
2276
                                ViewerDataModel.Instance.checkFillShape = true;
2277
                            }
2278
                            else
2279
                            {
2280
                                ViewerDataModel.Instance.checkHatchShape = false;
2281
                                ViewerDataModel.Instance.checkFillShape = false;
2282
                            }
2283
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2284
                        }
2285

    
2286
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2287

    
2288
                        if ((control as TextControl) != null)
2289
                        {
2290
                            if(!((control as TextControl).EnableEditing)) {
2291
                                (control as TextControl).EnableEditing = true;
2292
                            }
2293

    
2294
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2295
                            {
2296
                                ViewerDataModel.Instance.checkTextStyle = true;
2297
                            }
2298
                            else
2299
                            {
2300
                                ViewerDataModel.Instance.checkTextStyle = false;
2301
                            }
2302

    
2303
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2304
                            {
2305
                                ViewerDataModel.Instance.checkTextStyle = true;
2306
                            }
2307
                            else
2308
                            {
2309
                                ViewerDataModel.Instance.checkTextStyle = false;
2310
                            }
2311
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2312
                            {
2313
                                ViewerDataModel.Instance.checkTextWeight = true;
2314
                            }
2315
                            else
2316
                            {
2317
                                ViewerDataModel.Instance.checkTextWeight = false;
2318
                            }
2319
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2320
                            {
2321
                                ViewerDataModel.Instance.checkUnderLine = true;
2322
                            }
2323
                            else
2324
                            {
2325
                                ViewerDataModel.Instance.checkUnderLine = false;
2326
                            }
2327
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2328
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2329

    
2330
                        }
2331
                        else if ((control as ArrowTextControl) != null)
2332
                        {
2333
                            if (!((control as ArrowTextControl).EnableEditing))
2334
                            {
2335
                                (control as ArrowTextControl).EnableEditing = true;
2336
                            }
2337
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2338
                            {
2339
                                ViewerDataModel.Instance.checkTextStyle = true;
2340
                            }
2341
                            else
2342
                            {
2343
                                ViewerDataModel.Instance.checkTextStyle = false;
2344
                            }
2345

    
2346
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2347
                            {
2348
                                ViewerDataModel.Instance.checkTextStyle = true;
2349
                            }
2350
                            else
2351
                            {
2352
                                ViewerDataModel.Instance.checkTextStyle = false;
2353
                            }
2354
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2355
                            {
2356
                                ViewerDataModel.Instance.checkTextWeight = true;
2357
                            }
2358
                            else
2359
                            {
2360
                                ViewerDataModel.Instance.checkTextWeight = false;
2361
                            }
2362
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2363
                            {
2364
                                ViewerDataModel.Instance.checkUnderLine = true;
2365
                            }
2366
                            else
2367
                            {
2368
                                ViewerDataModel.Instance.checkUnderLine = false;
2369
                            }
2370
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2371
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2372
                        }
2373
                        else if ((control as RectCloudControl) != null)
2374
                        {
2375
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2376
                        }
2377
                        else if ((control as CloudControl) != null)
2378
                        {
2379
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2380
                        }
2381
                    }
2382
                    else
2383
                    {
2384
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2385
                        SelectionSet.Instance.UnSelect(this);
2386
                        comment.Add(control);
2387

    
2388
                        Control_Style(control);
2389

    
2390
                        final = new AdornerFinal(comment);
2391
                    }
2392

    
2393
                    if (final != null)
2394
                    {
2395
                        this.SelectLayer.Children.Add(final);
2396
                    }
2397
                }              
2398
            }
2399
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2400
            {               
2401
                init();
2402
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2403
                if (cursor != Cursors.SizeAll)
2404
                {
2405
                    cursor = Cursors.Cross;
2406
                    SetCursor();
2407
                }
2408
                bool init_user = false;
2409
                foreach (var user in gridViewMarkup.Items)
2410
                {
2411
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2412
                    {
2413
                        init_user = true;
2414
                    }
2415
                }
2416
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2417
                {
2418
                    RadWindow.Alert(new DialogParameters
2419
                    {
2420
                        Owner = Application.Current.MainWindow,
2421
                        Theme = new VisualStudio2013Theme(),
2422
                        Header = "안내",
2423
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2424
                    });
2425
                    return;
2426
                }
2427
                else
2428
                {
2429
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2430
                    if (item != null)
2431
                    {
2432
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2433
                    }
2434
                }
2435

    
2436
                switch (controlType)
2437
                {
2438
                    case ControlType.Coordinate:
2439
                        {
2440
                            if (e.LeftButton == MouseButtonState.Pressed)
2441
                            {
2442
                                if (currentControl is CoordinateControl)
2443
                                {
2444
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2445
                                    {
2446
                                        return;
2447
                                    }
2448

    
2449
                                    CreateCommand.Instance.Execute(currentControl);
2450

    
2451
                                    currentControl = null;
2452
                                    this.cursor = Cursors.Arrow;
2453
                                }
2454
                                else
2455
                                {
2456
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2457
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2458
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2459
                                    {
2460
                                        currentControl = null;
2461
                                        this.cursor = Cursors.Arrow;
2462
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2463
                                        return;
2464
                                    }
2465
                                    else
2466
                                    {
2467
                                        currentControl = new CoordinateControl
2468
                                        {
2469
                                            Background = new SolidColorBrush(Colors.Black),
2470
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2471
                                            ControlType = ControlType.Coordinate
2472
                                        };
2473

    
2474
                                        currentControl.CommentID = Commons.shortGuid();
2475
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2476
                                        currentControl.IsNew = true;
2477

    
2478
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2479

    
2480
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2481
                                    }
2482
                                }
2483
                            }
2484
                        }
2485
                        break;
2486
                    case ControlType.InsideWhite:
2487
                        {
2488
                            if (e.LeftButton == MouseButtonState.Pressed)
2489
                            {
2490
                                if (currentControl is InsideWhiteControl)
2491
                                {
2492
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2493
                                    {
2494
                                        return;
2495
                                    }
2496

    
2497
                                    CreateCommand.Instance.Execute(currentControl);
2498

    
2499
                                    currentControl = null;
2500
                                    this.cursor = Cursors.Arrow;
2501
                                }
2502
                                else
2503
                                {
2504
                                    currentControl = new InsideWhiteControl
2505
                                    {
2506
                                        Background = new SolidColorBrush(Colors.Black),
2507
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2508
                                        ControlType = ControlType.InsideWhite
2509
                                    };
2510

    
2511
                                    currentControl.CommentID = Commons.shortGuid();
2512
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2513
                                    currentControl.IsNew = true;
2514
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2515

    
2516
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2517
                                }
2518
                            }
2519
                        }
2520
                        break;
2521
                    case ControlType.OverlapWhite:
2522
                        {
2523
                            if (e.LeftButton == MouseButtonState.Pressed)
2524
                            {
2525
                                if (currentControl is OverlapWhiteControl)
2526
                                {
2527
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2528
                                    {
2529
                                        return;
2530
                                    }
2531

    
2532
                                    CreateCommand.Instance.Execute(currentControl);
2533

    
2534
                                    currentControl = null;
2535
                                    this.cursor = Cursors.Arrow;
2536
                                }
2537
                                else
2538
                                {
2539
                                    currentControl = new OverlapWhiteControl
2540
                                    {
2541
                                        Background = new SolidColorBrush(Colors.Black),
2542
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2543
                                        ControlType = ControlType.OverlapWhite
2544
                                    };
2545

    
2546
                                    currentControl.CommentID = Commons.shortGuid();
2547
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2548
                                    currentControl.IsNew = true;
2549
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2550

    
2551
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2552
                                }
2553
                            }
2554
                        }
2555
                        break;
2556
                    case ControlType.ClipWhite:
2557
                        {
2558
                            if (e.LeftButton == MouseButtonState.Pressed)
2559
                            {
2560
                                if (currentControl is ClipWhiteControl)
2561
                                {
2562
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2563
                                    {
2564
                                        return;
2565
                                    }
2566

    
2567
                                    CreateCommand.Instance.Execute(currentControl);
2568

    
2569
                                    currentControl = null;
2570
                                    this.cursor = Cursors.Arrow;
2571
                                }
2572
                                else
2573
                                {
2574
                                    currentControl = new ClipWhiteControl
2575
                                    {
2576
                                        Background = new SolidColorBrush(Colors.Black),
2577
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2578
                                        ControlType = ControlType.ClipWhite
2579
                                    };
2580

    
2581
                                    currentControl.CommentID = Commons.shortGuid();
2582
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2583
                                    currentControl.IsNew = true;
2584
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2585

    
2586
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2587
                                }
2588
                            }
2589
                        }
2590
                        break;
2591
                    case ControlType.Rectangle:
2592
                        {
2593
                            if (e.LeftButton == MouseButtonState.Pressed)
2594
                            {
2595
                                if (currentControl is RectangleControl)
2596
                                {
2597
                                    //20180906 LJY TEST IsRotationDrawingEnable
2598
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2599
                                    {
2600
                                        return;
2601
                                    }
2602

    
2603
                                    CreateCommand.Instance.Execute(currentControl);
2604
                                    currentControl = null;
2605
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2606
                                }
2607
                                else
2608
                                {
2609
                                    currentControl = new RectangleControl
2610
                                    {
2611
                                        Background = new SolidColorBrush(Colors.Black),
2612
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2613
                                        ControlType = ControlType.Rectangle
2614
                                    };
2615

    
2616
                                    currentControl.CommentID = Commons.shortGuid();
2617
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2618
                                    currentControl.IsNew = true;
2619
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2620

    
2621
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2622
                                }
2623
                            }
2624
                        }
2625
                        break;
2626
                    case ControlType.RectCloud:
2627
                        {
2628
                            if (e.LeftButton == MouseButtonState.Pressed)
2629
                            {
2630
                                if (currentControl is RectCloudControl)
2631
                                {
2632
                                    //20180906 LJY TEST IsRotationDrawingEnable
2633
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2634
                                    {
2635
                                        return;
2636
                                    }
2637

    
2638
                                    CreateCommand.Instance.Execute(currentControl);
2639

    
2640
                                    currentControl = null;
2641
                                
2642
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2643
                                }
2644
                                else
2645
                                {
2646
                                    currentControl = new RectCloudControl
2647
                                    {
2648
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2649
                                        ControlType = ControlType.RectCloud,
2650
                                        Background = new SolidColorBrush(Colors.Black)
2651
                                    };
2652

    
2653
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2654
                                    currentControl.CommentID = Commons.shortGuid();
2655
                                    currentControl.IsNew = true;
2656
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2657
                                }
2658
                            }
2659
                        }
2660
                        break;
2661
                    case ControlType.Circle:
2662
                        {
2663
                            if (e.LeftButton == MouseButtonState.Pressed)
2664
                            {
2665
                                if (currentControl is CircleControl)
2666
                                {
2667
                                    //20180906 LJY TEST IsRotationDrawingEnable
2668
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2669
                                    {
2670
                                        return;
2671
                                    }
2672

    
2673
                                    CreateCommand.Instance.Execute(currentControl);
2674

    
2675
                                    currentControl = null;
2676
                                }
2677
                                else
2678
                                {
2679
                                    currentControl = new CircleControl
2680
                                    {
2681
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2682
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2683
                                        Background = new SolidColorBrush(Colors.Black)
2684
                                    };
2685

    
2686
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2687
                                    currentControl.CommentID = Commons.shortGuid();
2688
                                    currentControl.IsNew = true;
2689
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2690
                                }
2691
                            }
2692
                        }
2693
                        break;
2694
                    case ControlType.Triangle:
2695
                        {
2696
                            if (e.LeftButton == MouseButtonState.Pressed)
2697
                            {
2698
                                if (currentControl is TriControl)
2699
                                {
2700
                                    var content = currentControl as TriControl;
2701
                                    if (content.MidPoint == new Point(0, 0))
2702
                                    {
2703
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2704
                                    }
2705
                                    else
2706
                                    {
2707
                                        //20180906 LJY TEST IsRotationDrawingEnable
2708
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2709
                                        {
2710
                                            return;
2711
                                        }
2712

    
2713
                                        CreateCommand.Instance.Execute(currentControl);
2714

    
2715
                                        currentControl = null;
2716
                                    }
2717
                                }
2718
                                else
2719
                                {
2720
                                    currentControl = new TriControl
2721
                                    {
2722
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2723
                                        Background = new SolidColorBrush(Colors.Black),
2724
                                    };
2725

    
2726
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2727
                                    currentControl.CommentID = Commons.shortGuid();
2728
                                    currentControl.IsNew = true;
2729
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2730
                                }
2731
                            }
2732
                        }
2733
                        break;
2734
                    case ControlType.CancelLine:
2735
                    case ControlType.SingleLine:
2736
                    case ControlType.ArrowLine:
2737
                    case ControlType.TwinLine:
2738
                    case ControlType.DimLine:
2739
                        {
2740
                            if (e.LeftButton == MouseButtonState.Pressed)
2741
                            {
2742
                                if (currentControl is LineControl)
2743
                                {
2744
                                    //20180906 LJY TEST IsRotationDrawingEnable
2745
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2746
                                    {
2747
                                        return;
2748
                                    }
2749

    
2750
                                    CreateCommand.Instance.Execute(currentControl);
2751
                                    currentControl = null;
2752
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2753
                                }
2754
                                else
2755
                                {
2756
                                    currentControl = new LineControl
2757
                                    {
2758
                                        ControlType = this.controlType,
2759
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2760
                                        Background = new SolidColorBrush(Colors.Black)
2761
                                    };
2762

    
2763
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2764
                                    currentControl.CommentID = Commons.shortGuid();
2765
                                    currentControl.IsNew = true;
2766
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2767
                                    this.MainAngle.Visibility = Visibility.Visible;
2768
                                }
2769
                            }
2770
                        }
2771
                        break;
2772
                    case ControlType.PolygonControl:
2773
                        {
2774
                            if (currentControl is PolygonControl)
2775
                            {
2776
                                var control = currentControl as PolygonControl;
2777

    
2778
                                if (e.RightButton == MouseButtonState.Pressed)
2779
                                {
2780
                                    control.IsCompleted = true;
2781
                                }
2782

    
2783
                                if (!control.IsCompleted)
2784
                                {
2785
                                    control.PointSet.Add(control.EndPoint);
2786
                                }
2787
                                else
2788
                                {
2789
                                    //20180906 LJY TEST IsRotationDrawingEnable
2790
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2791
                                    {
2792
                                        return;
2793
                                    }
2794

    
2795
                                    var firstPoint = control.PointSet.First();
2796
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2797
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2798
                                    control.PointSet.Add(firstPoint);
2799

    
2800
                                    control.ApplyOverViewData();
2801

    
2802
                                    CreateCommand.Instance.Execute(currentControl);
2803
                                    control.UpdateControl();
2804
                                    currentControl = null;
2805
                                }
2806
                            }
2807
                            else
2808
                            {
2809
                                if (e.LeftButton == MouseButtonState.Pressed)
2810
                                {
2811
                                    currentControl = new PolygonControl
2812
                                    {
2813
                                        PointSet = new List<Point>(),
2814
                                    };
2815

    
2816
                                    var polygonControl = (currentControl as PolygonControl);
2817
                                    currentControl.CommentID = Commons.shortGuid();
2818
                                    currentControl.IsNew = true;
2819
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2820
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2821
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2822
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2823
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2824
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2825
                                    polygonControl.ApplyTemplate();
2826
                                    polygonControl.Visibility = Visibility.Visible;
2827
                                }
2828
                            }
2829
                        }
2830
                        break;
2831
                    case ControlType.ChainLine:
2832
                        {
2833
                            if (currentControl is PolygonControl)
2834
                            {
2835
                                var control = currentControl as PolygonControl;
2836

    
2837
                                if (e.RightButton == MouseButtonState.Pressed)
2838
                                {
2839
                                    //20180906 LJY TEST IsRotationDrawingEnable
2840
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2841
                                    {
2842
                                        return;
2843
                                    }
2844

    
2845
                                    CreateCommand.Instance.Execute(currentControl);
2846

    
2847
                                    currentControl = null;
2848
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2849
                                    return;
2850
                                }
2851

    
2852
                                if (!control.IsCompleted)
2853
                                {
2854
                                    control.PointSet.Add(control.EndPoint);
2855
                                    this.MainAngle.Visibility = Visibility.Visible;
2856
                                }
2857
                            }
2858
                            else
2859
                            {
2860
                                if (e.LeftButton == MouseButtonState.Pressed)
2861
                                {
2862
                                    MainAngle.Visibility = Visibility.Visible;
2863
                                    currentControl = new PolygonControl
2864
                                    {
2865
                                        PointSet = new List<Point>(),
2866
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2867
                                        ControlType = ControlType.ChainLine,
2868
                                        DashSize = ViewerDataModel.Instance.DashSize,
2869
                                        LineSize = ViewerDataModel.Instance.LineSize,
2870
                                        //PointC = new StylusPointSet()
2871
                                    };
2872

    
2873
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2874
                                    //{
2875
                                        var polygonControl = (currentControl as PolygonControl);
2876
                                        currentControl.CommentID = Commons.shortGuid();
2877
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2878
                                        currentControl.IsNew = true;
2879
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2880
                                        //currentControl.OnApplyTemplate();
2881
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2882
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2883
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2884
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2885
                                    //}
2886
                                }
2887
                            }
2888
                        }
2889
                        break;
2890
                    case ControlType.ArcLine:
2891
                        {
2892
                            if (e.LeftButton == MouseButtonState.Pressed)
2893
                            {
2894
                                if (currentControl is ArcControl)
2895
                                {
2896
                                    //20180906 LJY TEST IsRotationDrawingEnable
2897
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2898
                                    {
2899
                                        return;
2900
                                    }
2901

    
2902
                                    CreateCommand.Instance.Execute(currentControl);
2903

    
2904
                                    currentControl = null;
2905
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2906
                                }
2907
                                else
2908
                                {
2909
                                    currentControl = new ArcControl
2910
                                    {
2911
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2912
                                        Background = new SolidColorBrush(Colors.Black)
2913
                                    };
2914
                                    currentControl.CommentID = Commons.shortGuid();
2915
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2916
                                    currentControl.IsNew = true;
2917
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2918
                                    this.MainAngle.Visibility = Visibility.Visible;
2919
                                }
2920
                            }
2921
                            else if (e.RightButton == MouseButtonState.Pressed)
2922
                            {
2923
                                if (currentControl != null)
2924
                                {
2925
                                    (currentControl as ArcControl).setClock();
2926
                                    (currentControl as ArcControl).MidPoint = new Point(0, 0);
2927
                                }
2928
                            }
2929
                        }
2930
                        break;
2931
                    case ControlType.ArcArrow:
2932
                        {
2933
                            if (e.LeftButton == MouseButtonState.Pressed)
2934
                            {
2935
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2936
                                //{
2937
                                if (currentControl is ArrowArcControl)
2938
                                {
2939
                                    //20180906 LJY TEST IsRotationDrawingEnable
2940
                                    if (IsGetoutpoint((currentControl as ArrowArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2941
                                    {
2942
                                        return;
2943
                                    }
2944

    
2945
                                    CreateCommand.Instance.Execute(currentControl);
2946

    
2947
                                    currentControl = null;
2948
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2949
                                }
2950
                                else
2951
                                {
2952
                                    currentControl = new ArrowArcControl
2953
                                    {
2954
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2955
                                        Background = new SolidColorBrush(Colors.Black)
2956
                                    };
2957
                                    currentControl.CommentID = Commons.shortGuid();
2958
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2959
                                    currentControl.IsNew = true;
2960
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2961
                                    this.MainAngle.Visibility = Visibility.Visible;
2962
                                }
2963
                                //}
2964
                            }
2965
                            else if (e.RightButton == MouseButtonState.Pressed)
2966
                            {
2967
                                if (currentControl != null)
2968
                                {
2969
                                    (currentControl as ArrowArcControl).setClock();
2970
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
2971
                                    //(currentControl as ArcControl).ApplyTemplate();
2972
                                }
2973
                            }
2974
                        }
2975
                        break;
2976
                    case ControlType.ArrowMultiLine:
2977
                        {
2978
                            if (e.LeftButton == MouseButtonState.Pressed)
2979
                            {
2980
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2981
                                //{
2982

    
2983
                                    if (currentControl is ArrowControl_Multi)
2984
                                    {
2985
                                        var content = currentControl as ArrowControl_Multi;
2986
                                        if (content.MiddlePoint == new Point(0, 0))
2987
                                        {
2988
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
2989
                                            {
2990
                                                content.MiddlePoint = content.EndPoint;
2991
                                            }
2992
                                            else
2993
                                            {
2994
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2995
                                            }
2996
                                        }
2997
                                        else
2998
                                        {
2999
                                            //20180906 LJY TEST IsRotationDrawingEnable
3000
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3001
                                            {
3002
                                                return;
3003
                                            }
3004

    
3005
                                            CreateCommand.Instance.Execute(currentControl);
3006

    
3007
                                            currentControl = null;
3008
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3009
                                        }
3010
                                    }
3011
                                    else
3012
                                    {
3013
                                        currentControl = new ArrowControl_Multi
3014
                                        {
3015
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3016
                                            Background = new SolidColorBrush(Colors.Black)
3017
                                        };
3018
                                        currentControl.CommentID = Commons.shortGuid();
3019
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3020
                                        currentControl.IsNew = true;
3021
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3022
                                        this.MainAngle.Visibility = Visibility.Visible;
3023
                                    }
3024
                                //}
3025
                            }
3026
                        }
3027
                        break;
3028
                    case ControlType.PolygonCloud:
3029
                        {
3030
                            if (currentControl is CloudControl)
3031
                            {
3032
                                var control = currentControl as CloudControl;
3033
                                if (e.RightButton == MouseButtonState.Pressed)
3034
                                {
3035
                                    control.IsCompleted = true;
3036
                                }
3037

    
3038
                                if (!control.IsCompleted)
3039
                                {
3040
                                    control.PointSet.Add(control.EndPoint);
3041
                                }
3042
                                else
3043
                                {
3044
                                    //20180906 LJY TEST IsRotationDrawingEnable
3045
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3046
                                    {
3047
                                        return;
3048
                                    }
3049

    
3050
                                    CreateCommand.Instance.Execute(currentControl);
3051

    
3052
                                    control.isTransOn = true;
3053
                                    var firstPoint = control.PointSet.First();
3054

    
3055
                                    control.PointSet.Add(firstPoint);
3056
                                    control.DrawingCloud();
3057
                                    control.ApplyOverViewData();
3058

    
3059
                                    currentControl = null;
3060
                                }
3061
                            }
3062
                            else
3063
                            {
3064
                                if (e.LeftButton == MouseButtonState.Pressed)
3065
                                {
3066
                                    currentControl = new CloudControl
3067
                                    {
3068
                                        PointSet = new List<Point>(),
3069
                                        PointC = new StylusPointSet()
3070
                                    };
3071

    
3072
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3073
                                    //{
3074
                                        var polygonControl = (currentControl as CloudControl);
3075
                                        currentControl.CommentID = Commons.shortGuid();
3076
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3077
                                        currentControl.IsNew = true;
3078
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3079

    
3080
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3081
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3082
                                    
3083
                                    //}
3084
                                }
3085
                            }
3086
                        }
3087
                        break;
3088
                    case ControlType.ImgControl:
3089
                        {
3090
                            if (e.LeftButton == MouseButtonState.Pressed)
3091
                            {
3092
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3093
                                //{
3094
                                    if (currentControl is ImgControl)
3095
                                    {
3096
                                        //20180906 LJY TEST IsRotationDrawingEnable
3097
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3098
                                        {
3099
                                            return;
3100
                                        }
3101

    
3102
                                        CreateCommand.Instance.Execute(currentControl);
3103
                                        controlType = ControlType.ImgControl;
3104
                                        currentControl = null;
3105
                                    }
3106
                                    else
3107
                                    {
3108
                                        
3109
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3110
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3111
                                        {
3112
                                            Image img = new Image();
3113
                                            if (filename.Contains(".svg"))
3114
                                            {
3115
                                                byte[] imageData = null;
3116
                                                DrawingImage image = null;
3117
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3118
                                                {
3119
                                                    imageData = web.DownloadData(new Uri(filename));
3120
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3121
                                                    image = SvgReader.Load(stream);
3122
                                                }
3123
                                                img.Source = image;
3124
                                            }
3125
                                            else
3126
                                            {
3127
                                                img.Source = new BitmapImage(new Uri(filename));
3128
                                            }
3129

    
3130
                                            currentControl = new ImgControl
3131
                                            {
3132
                                                    Background = new SolidColorBrush(Colors.Black),
3133
                                                    PointSet = new List<Point>(),
3134
                                                    FilePath = filename,
3135
                                                    ImageData = img.Source,
3136
                                                    StartPoint = canvasDrawingMouseDownPoint,
3137
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3138
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3139
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3140
                                                    ControlType = ControlType.ImgControl
3141
                                                };
3142

    
3143
                                        
3144
                                                currentControl.CommentID = Commons.shortGuid();                                            
3145
                                                currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3146
                                                currentControl.IsNew = true;
3147
                                                ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3148

    
3149
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3150
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3151
                                        }
3152
                                    }
3153
                                //}
3154
                            }
3155
                        }
3156
                        break;
3157
                    case ControlType.Date:
3158
                        {
3159
                            if (e.LeftButton == MouseButtonState.Pressed)
3160
                            {
3161
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3162
                                //{
3163
                                    if (currentControl is DateControl)
3164
                                    {
3165
                                        //20180906 LJY TEST IsRotationDrawingEnable
3166
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3167
                                        {
3168
                                            return;
3169
                                        }
3170

    
3171
                                        CreateCommand.Instance.Execute(currentControl);
3172
                                        currentControl = null;
3173

    
3174
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3175
                                        {
3176
                                            controlType = ControlType.None;
3177
                                            IsSwingMode = false;
3178
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3179
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3180
                                            mouseHandlingMode = MouseHandlingMode.None;
3181
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3182
                                            txtBatch.Visibility = Visibility.Collapsed;
3183

    
3184
                                        }
3185
                                    }
3186
                                    else
3187
                                    {
3188
                                        currentControl = new DateControl
3189
                                        {
3190
                                            StartPoint = canvasDrawingMouseDownPoint,
3191
                                            Background = new SolidColorBrush(Colors.Black)
3192
                                        };
3193
                                        currentControl.CommentID = Commons.shortGuid();
3194
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3195
                                        currentControl.IsNew = true;
3196
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3197

    
3198
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3199
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3200
                                }
3201
                                //}
3202
                            }
3203
                        }
3204
                        break;
3205
                    case ControlType.TextControl:
3206
                        {
3207
                            if (e.LeftButton == MouseButtonState.Pressed)
3208
                            {
3209
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3210
                                {
3211
                                    currentControl = new TextControl
3212
                                    {
3213
                                        ControlType = controlType
3214
                                    };
3215
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3216
                                    currentControl.CommentID = Commons.shortGuid();
3217
                                    currentControl.IsNew = true;
3218
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3219
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3220
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3221

    
3222
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3223
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3224
                                    
3225
                                    (currentControl as TextControl).ControlType_No = 0;
3226
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3227
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3228
                                    (currentControl as TextControl).ApplyTemplate();
3229
                                    (currentControl as TextControl).Base_TextBox.Focus();
3230

    
3231
                                    CreateCommand.Instance.Execute(currentControl);
3232
                                }
3233
                            }
3234
                        }
3235
                        break;
3236
                    case ControlType.TextBorder:
3237
                        {
3238
                            if (e.LeftButton == MouseButtonState.Pressed)
3239
                            {
3240
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3241
                                {
3242
                                    currentControl = new TextControl
3243
                                    {
3244
                                        ControlType = controlType
3245
                                    };
3246

    
3247
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3248
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3249
                                    currentControl.CommentID = Commons.shortGuid();
3250
                                    currentControl.IsNew = true;
3251
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3252
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3253
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3254
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3255
                                    
3256
                                    (currentControl as TextControl).ControlType_No = 1;
3257
                                    (currentControl as TextControl).Angle = Ang;
3258
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3259
                                    (currentControl as TextControl).ApplyTemplate();
3260
                                    (currentControl as TextControl).Base_TextBox.Focus();
3261
                                    CreateCommand.Instance.Execute(currentControl);
3262
                                }
3263
                            }
3264
                        }
3265
                        break;
3266
                    case ControlType.TextCloud:
3267
                        {
3268
                            if (e.LeftButton == MouseButtonState.Pressed)
3269
                            {
3270
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3271
                                {
3272
                                    currentControl = new TextControl
3273
                                    {
3274
                                        ControlType = controlType
3275
                                    };
3276

    
3277
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3278
                                    currentControl.CommentID = Commons.shortGuid();
3279
                                    currentControl.IsNew = true;
3280
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3281
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3282

    
3283
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3284
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3285
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3286

    
3287
                                    (currentControl as TextControl).Angle = Ang;
3288
                                    (currentControl as TextControl).ControlType_No = 2;
3289
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3290
                                    (currentControl as TextControl).ApplyTemplate();
3291
                                    (currentControl as TextControl).Base_TextBox.Focus();
3292
                                    CreateCommand.Instance.Execute(currentControl);
3293
                                    //currentControl = null;
3294
                                }
3295
                            }
3296
                        }
3297
                        break;
3298
                    case ControlType.ArrowTextControl:
3299
                         {
3300
                            if (e.LeftButton == MouseButtonState.Pressed)
3301
                            {
3302
                                if (currentControl is ArrowTextControl)
3303
                                {
3304
                                    //20180906 LJY TEST IsRotationDrawingEnable
3305
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3306
                                    {
3307
                                        return;
3308
                                    }
3309

    
3310
                                    CreateCommand.Instance.Execute(currentControl);
3311

    
3312
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3313
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3314
                                    (currentControl as ArrowTextControl).IsNew = false;
3315
                                    currentControl = null;
3316
                                }
3317
                                else
3318
                                {
3319
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3320
                                    //{
3321
                                        currentControl = new ArrowTextControl();
3322
                                        currentControl.CommentID = Commons.shortGuid();
3323
                                        currentControl.IsNew = true;
3324
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3325
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3326

    
3327
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3328
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3329
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3330
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3331
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3332

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

    
3336
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3337
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3338
                                        this.MainAngle.Visibility = Visibility.Visible;
3339

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

    
3358
                                    CreateCommand.Instance.Execute(currentControl);
3359
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3360
                                    currentControl.IsNew = false;
3361
                                    currentControl = null;
3362
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3363
                                }
3364
                                else
3365
                                {
3366
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3367
                                    //{
3368
                                    currentControl = new ArrowTextControl()
3369
                                    {
3370
                                        ControlType = ControlType.ArrowTransTextControl
3371
                                    };
3372
                                    currentControl.CommentID = Commons.shortGuid();
3373
                                    currentControl.IsNew = true;
3374
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3375
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3376
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3377
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3378
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3379
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3380
                                    (currentControl as ArrowTextControl).isFixed = true;
3381
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3382

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

    
3386
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3387
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3388
                                    (currentControl as ArrowTextControl).isTrans = true;
3389
                                }
3390
                            }
3391
                        }
3392
                        break;
3393
                    case ControlType.ArrowTextBorderControl:
3394
                         {
3395
                            if (e.LeftButton == MouseButtonState.Pressed)
3396
                            {
3397
                                if (currentControl is ArrowTextControl)
3398
                                {
3399
                                    //20180906 LJY TEST IsRotationDrawingEnable
3400
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3401
                                    {
3402
                                        return;
3403
                                    }
3404

    
3405
                                    CreateCommand.Instance.Execute(currentControl);
3406
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3407
                                    currentControl.IsNew = false;
3408
                                    currentControl = null;
3409
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3410
                                }
3411
                                else
3412
                                {
3413
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3414
                                    //{
3415
                                        currentControl = new ArrowTextControl()
3416
                                        {
3417
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3418
                                        };
3419
                                        currentControl.CommentID = Commons.shortGuid();
3420
                                        currentControl.IsNew = true;
3421
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3422
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3423

    
3424
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3425

    
3426
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3427

    
3428
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3429
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3430
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3431

    
3432
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3433
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3434
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3435
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3436
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3437
                                    //}
3438
                                }
3439
                            }
3440
                        }
3441
                        break;
3442
                    case ControlType.ArrowTransTextBorderControl:
3443
                        {
3444
                            if (e.LeftButton == MouseButtonState.Pressed)
3445
                            {
3446
                                if (currentControl is ArrowTextControl)
3447
                                {
3448
                                    //20180906 LJY TEST IsRotationDrawingEnable
3449
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3450
                                    {
3451
                                        return;
3452
                                    }
3453
                                    CreateCommand.Instance.Execute(currentControl);
3454
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3455
                                    currentControl.IsNew = false;
3456
                                    currentControl = null;
3457
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3458
                                }
3459
                                else
3460
                                {
3461
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3462
                                    //{
3463
                                    
3464

    
3465
                                    currentControl = new ArrowTextControl()
3466
                                    {
3467
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3468
                                        ControlType = ControlType.ArrowTransTextBorderControl
3469

    
3470
                                    };
3471
                                        currentControl.CommentID = Commons.shortGuid();
3472
                                        currentControl.IsNew = true;
3473
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3474
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3475

    
3476
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3477

    
3478
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3479
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3480
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3481
                                        (currentControl as ArrowTextControl).isFixed = true;
3482
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3483
                                     
3484
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3485
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3486
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3487

    
3488
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3489
                                        this.MainAngle.Visibility = Visibility.Visible;
3490
                                    
3491
                                    //20180911 LJY
3492
                                        (currentControl as ArrowTextControl).isTrans = true;
3493
                                    
3494

    
3495
                                    //}
3496
                                }
3497
                            }
3498
                        }
3499
                        break;
3500
                    case ControlType.ArrowTextCloudControl:
3501
                        {
3502
                            if (e.LeftButton == MouseButtonState.Pressed)
3503
                            {
3504
                                if (currentControl is ArrowTextControl)
3505
                                {
3506
                                    //20180906 LJY TEST IsRotationDrawingEnable
3507
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3508
                                    {
3509
                                        return;
3510
                                    }
3511
                                    CreateCommand.Instance.Execute(currentControl);
3512
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3513
                                    currentControl.IsNew = false;
3514
                                    currentControl = null;
3515
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3516
                                }
3517
                                else
3518
                                {
3519
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3520
                                    //{
3521
                                        currentControl = new ArrowTextControl()
3522
                                        {
3523
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3524
                                        };
3525
                                        currentControl.CommentID = Commons.shortGuid();
3526
                                        currentControl.IsNew = true;
3527
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3528
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3529

    
3530
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3531
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3532
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3533
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3534
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3535

    
3536
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3537
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3538
                                    
3539
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3540
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3541
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3542
                                    //}
3543
                                }
3544
                            }
3545
                        }
3546
                        break;
3547
                    case ControlType.ArrowTransTextCloudControl:
3548
                        {
3549
                            if (e.LeftButton == MouseButtonState.Pressed)
3550
                            {
3551
                                if (currentControl is ArrowTextControl)
3552
                                {
3553
                                    //20180906 LJY TEST IsRotationDrawingEnable
3554
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3555
                                    {
3556
                                        return;
3557
                                    }
3558
                                    CreateCommand.Instance.Execute(currentControl);
3559
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3560
                                    currentControl.IsNew = false;
3561
                                    currentControl = null;
3562
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3563
                                }
3564
                                else
3565
                                {
3566
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3567
                                    //{
3568
                                        currentControl = new ArrowTextControl()
3569
                                        {
3570
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3571
                                            ControlType = ControlType.ArrowTransTextCloudControl
3572

    
3573
                                        };
3574
                                        currentControl.CommentID = Commons.shortGuid();
3575
                                        currentControl.IsNew = true; 
3576
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3577
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3578
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3579

    
3580
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3581
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3582
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3583
                                        (currentControl as ArrowTextControl).isFixed = true;
3584
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3585

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

    
3589
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3590
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3591
                                        this.MainAngle.Visibility = Visibility.Visible;  
3592
                                    
3593
                                    //20180911 LJY
3594
                                        (currentControl as ArrowTextControl).isTrans = true;
3595
                                    //}
3596
                                }
3597
                            }
3598
                        }
3599
                        break;
3600
                    //강인구 추가
3601
                    case ControlType.Sign:
3602
                        {
3603
                            if (e.LeftButton == MouseButtonState.Pressed)
3604
                            {
3605
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3606
                                //{
3607
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3608

    
3609
                                    if (_sign == null)
3610
                                    {
3611
                                        txtBatch.Visibility = Visibility.Collapsed;
3612
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3613
                                        controlType = ControlType.None;
3614

    
3615
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3616
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3617
                                        return;
3618
                                    }
3619

    
3620
                                    if (currentControl is SignControl)
3621
                                    {
3622
                                        //20180906 LJY TEST IsRotationDrawingEnable
3623
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3624
                                        {
3625
                                            return;
3626
                                        }
3627

    
3628
                                        CreateCommand.Instance.Execute(currentControl);
3629
                                        currentControl = null;
3630
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3631
                                        {
3632
                                            txtBatch.Text = "Place Date";
3633
                                            controlType = ControlType.Date;
3634
                                        }
3635
                                    }
3636
                                    else
3637
                                    {
3638
                                        currentControl = new SignControl
3639
                                        {
3640
                                            Background = new SolidColorBrush(Colors.Black),
3641
                                            UserNumber = App.ViewInfo.UserID,
3642
                                            ProjectNO = App.ViewInfo.ProjectNO,
3643
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3644
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3645
                                            ControlType = ControlType.Sign
3646
                                        };
3647

    
3648
                                        currentControl.CommentID = Commons.shortGuid();
3649
                                        currentControl.IsNew = true;
3650
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3651
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3652

    
3653
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3654
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3655
                                }
3656
                                //}
3657
                            }
3658
                        }
3659
                        break;
3660
                    case ControlType.Mark:
3661
                        {
3662
                            if (e.LeftButton == MouseButtonState.Pressed)
3663
                            {
3664
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3665
                                //{
3666
                                    if (currentControl is RectangleControl)
3667
                                    {
3668
                                        //20180906 LJY TEST IsRotationDrawingEnable
3669
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3670
                                        {
3671
                                            return;
3672
                                        }
3673

    
3674
                                        CreateCommand.Instance.Execute(currentControl);
3675
                                        (currentControl as RectangleControl).ApplyOverViewData();
3676
                                        currentControl = null;
3677
                                    
3678
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3679

    
3680
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3681
                                        {
3682
                                            txtBatch.Text = "Place Signature";
3683
                                            controlType = ControlType.Sign;
3684
                                        }
3685
                                    }
3686
                                    else
3687
                                    {
3688
                                        currentControl = new RectangleControl
3689
                                        {
3690
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3691
                                            Background = new SolidColorBrush(Colors.Black),
3692
                                            ControlType = ControlType.Mark ,
3693
                                            Paint = PaintSet.Fill
3694
                                        };
3695

    
3696
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3697
                                        currentControl.CommentID = Commons.shortGuid();
3698
                                        currentControl.IsNew = true;
3699
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3700
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3701
                                    }
3702
                                //}
3703
                            }
3704
                        }
3705
                        break;
3706
                    case ControlType.Symbol:
3707
                        {
3708
                            if (e.LeftButton == MouseButtonState.Pressed)
3709
                            {
3710
                                if (currentControl is SymControl)
3711
                                {
3712
                                    //20180906 LJY TEST IsRotationDrawingEnable
3713
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3714
                                    {
3715
                                        return;
3716
                                    }
3717
                                    CreateCommand.Instance.Execute(currentControl);
3718
                                    currentControl = null;
3719
                                
3720
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3721
                                }
3722
                                else
3723
                                {
3724
                                    currentControl = new SymControl
3725
                                    {
3726
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3727
                                        Background = new SolidColorBrush(Colors.Black),
3728
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3729
                                        ControlType = ControlType.Symbol
3730
                                    };
3731

    
3732
                                    currentControl.IsNew = true;
3733
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3734
                                    currentControl.CommentID = Commons.shortGuid();
3735
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3736

    
3737
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3738
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3739
                                }
3740
                                //}
3741
                            }
3742
                        }
3743
                        break;
3744
                    case ControlType.Stamp:
3745
                        {
3746
                            if (e.LeftButton == MouseButtonState.Pressed)
3747
                            {
3748
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3749
                                //{
3750
                                    if (currentControl is SymControlN)
3751
                                    {
3752
                                        //20180906 LJY TEST IsRotationDrawingEnable
3753
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3754
                                        {
3755
                                            return;
3756
                                        }
3757

    
3758
                                        CreateCommand.Instance.Execute(currentControl);
3759
                                        currentControl = null;
3760
                                   
3761

    
3762
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3763
                                    }
3764
                                    else
3765
                                    {
3766
                                        currentControl = new SymControlN
3767
                                        {
3768
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3769
                                            Background = new SolidColorBrush(Colors.Black),
3770
                                            STAMP = App.SystemInfo.STAMP,
3771
                                            ControlType = ControlType.Stamp
3772
                                        };
3773

    
3774
                                        currentControl.IsNew = true;
3775
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3776
                                        currentControl.CommentID = Commons.shortGuid();
3777
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3778
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3779
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3780
                                }                                    
3781
                                //}
3782
                            }
3783
                        }
3784
                        break;
3785
                    case ControlType.PenControl:
3786
                        {
3787
                            if (inkBoard.Tag.ToString() == "Ink")
3788
                            {
3789
                                inkBoard.IsEnabled = true;
3790
                                StartNewStroke(canvasDrawingMouseDownPoint);
3791
                            }
3792
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3793
                            {
3794
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3795
                            }
3796
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3797
                            {
3798
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3799
                            }
3800
                            IsDrawing = true;
3801
                            return;
3802
                        }
3803
                    default:
3804
                        if (currentControl != null)
3805
                        {
3806
                            currentControl.CommentID = null;
3807
                            currentControl.IsNew = false;
3808
                        }
3809
                        break;
3810
                }
3811
            }
3812
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3813
            {
3814
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3815
                {
3816
                    bool mouseOff = false;
3817
                    foreach (var item in SelectLayer.Children)
3818
                    {
3819
                        if (item is AdornerFinal)
3820
                        {
3821

    
3822
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3823
                            if (over != null)
3824
                            {
3825
                                mouseOff = true;
3826
                            }
3827
                        }
3828
                    }
3829

    
3830
                    if (!mouseOff)
3831
                    {
3832
                        SelectionSet.Instance.UnSelect(this);
3833
                    }
3834
                }
3835
                zoomAndPanControl.CaptureMouse();
3836
                e.Handled = true;
3837
            }
3838
        }
3839

    
3840
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3841
        {
3842
            ///mouseButtonDown = e.ChangedButton;
3843
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3844
        }
3845

    
3846
        private void RemoveLineStroke(Point P)
3847
        {
3848
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3849
            if (control != null)
3850
            {
3851
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3852
            }
3853
        }
3854

    
3855
        private void RemovePointStroke(Point P)
3856
        {
3857
            foreach (Stroke hits in inkBoard.Strokes)
3858
            {
3859
                foreach (StylusPoint sty in hits.StylusPoints)
3860
                {
3861

    
3862
                }
3863
                if (hits.HitTest(P))
3864
                {
3865
                    inkBoard.Strokes.Remove(hits);
3866
                    return;
3867
                }
3868
            }
3869
        }
3870

    
3871
        private void StartNewStroke(Point P)
3872
        {
3873
            strokePoints = new StylusPointCollection();
3874
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3875
            strokePoints.Add(segment1Start);
3876
            stroke = new Stroke(strokePoints);
3877

    
3878
            stroke.DrawingAttributes.Color = Colors.Red;
3879
            stroke.DrawingAttributes.Width = 4;
3880
            stroke.DrawingAttributes.Height = 4;
3881

    
3882
            inkBoard.Strokes.Add(stroke);
3883
        }
3884

    
3885
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3886
        {
3887
            ConsolidationMethod();
3888
        }
3889

    
3890
        /// <summary>
3891
        /// execute TeamConsolidationCommand
3892
        /// </summary>
3893
        public void TeamConsolidationMethod()
3894
        {
3895
            this.UpdateMyMarkupList();
3896
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3897
            {
3898
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3899
            }
3900
            else
3901
            {
3902

    
3903
                ViewerDataModel.Instance.IsConsolidate = true;
3904
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3905

    
3906
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3907
                {
3908
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3909
                    {
3910
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3911
                        return;
3912
                    }                    
3913
                }
3914
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3915
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3916
                {
3917
                    MarkupInfoList.Add(item);
3918
                }
3919
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3920
            }
3921
        }
3922

    
3923
        public void ConsolidationMethod()
3924
        {
3925
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3926
            {
3927
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3928
            }
3929
            else
3930
            {
3931
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3932
                foreach (var item in this.gridViewMarkup.SelectedItems)
3933
                {
3934
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3935
                }
3936
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3937
                
3938
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3939
            }
3940
        }
3941

    
3942
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3943
        {
3944
            if (App.ViewInfo != null)
3945
            {
3946
                btnConsolidate = (sender as RadRibbonButton);
3947
                if (!App.ViewInfo.NewCommentPermission)
3948
                {
3949
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3950
                }
3951
            }
3952
        }
3953

    
3954
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3955
        {
3956
            TeamConsolidationMethod();
3957
        }
3958

    
3959
        private void btnTeamConsolidate_Loaded(object sender, RoutedEventArgs e)
3960
        {
3961
            btnTeamConsolidate = sender as RadRibbonButton;
3962
            if (App.ViewInfo != null)
3963
            {
3964
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
3965
                {
3966
                    if (btnConsolidate != null)
3967
                    {
3968
                        btnConsolidate.Visibility = Visibility.Collapsed;
3969
                    }
3970

    
3971
                    if (!App.ViewInfo.NewCommentPermission)
3972
                    {
3973
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
3974
                    }
3975
                }
3976
                else
3977
                {
3978
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
3979
                }
3980
            }
3981
        }
3982

    
3983
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
3984
        {
3985
            var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
3986
            if (item != null)
3987
            {
3988
                Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
3989

    
3990
                BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
3991
            }
3992
            else
3993
            {
3994
                DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
3995
            }
3996
        }
3997

    
3998
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
3999
        {
4000
            btnFinalPDF = sender as RadRibbonButton;
4001
            if (App.ViewInfo != null)
4002
            {
4003
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4004
                {
4005
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4006
                    if (btnConsolidate != null)
4007
                    {
4008
                        btnConsolidate.Visibility = Visibility.Collapsed;
4009
                    }
4010
                }
4011
            }
4012
        }
4013

    
4014
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4015
        {
4016
            UpdateMyMarkupList();
4017

    
4018
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4019
            {
4020
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4021
            }
4022
            else
4023
            {
4024
                ViewerDataModel.Instance.IsConsolidate = true;
4025
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4026
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4027

    
4028
                string project_no = App.ViewInfo.ProjectNO;
4029
                string doc_id = _DocInfo.ID;
4030
                string user_id = App.ViewInfo.UserID;
4031
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4032
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4033
                {
4034
                    markupInfoItems.Add(item);
4035
                }
4036
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4037
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4038
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4039
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4040

    
4041
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4042
                if (item2 != null)
4043
                {
4044
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4045

    
4046
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4047
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4048
                }
4049
                else
4050
                {
4051
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4052
                }
4053
            }
4054
        }
4055

    
4056
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4057
        {
4058
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4059

    
4060
            if (App.ViewInfo != null)
4061
            {
4062
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4063
                {
4064
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4065
                }
4066
            }
4067
        }
4068

    
4069
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4070
        {
4071
            if (CompareMode.IsChecked)
4072
            {
4073
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4074
                {
4075
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4076
                }
4077
                if (ViewerDataModel.Instance.PageNumber == 0)
4078
                {
4079
                    ViewerDataModel.Instance.PageNumber = 1;
4080
                }
4081

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

    
4086
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4087
            }
4088
            else
4089
            {
4090
                da.From = 1;
4091
                da.To = 1;
4092
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4093
                da.AutoReverse = false;
4094
                canvas_compareBorder.Children.Clear();
4095
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4096
            }
4097
        }
4098

    
4099
        private void Sync_Click(object sender, RoutedEventArgs e)
4100
        {
4101
            if (Sync.IsChecked)
4102
            {
4103
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4104
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4105
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4106
            }
4107
        }
4108

    
4109
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4110
        {
4111
            if (UserList.IsChecked)
4112
            {
4113
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4114
            }
4115
            else
4116
            {
4117
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4118
            }
4119
        }
4120

    
4121
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4122
        {
4123

    
4124
            if (BalanceMode.IsChecked)
4125
            {
4126
                ViewerDataModel.Instance.PageBalanceMode = true;
4127
            }
4128
            else
4129
            {
4130
                ViewerDataModel.Instance.PageBalanceMode = false;
4131
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4132
            }
4133
        }
4134

    
4135
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4136
        {
4137
            //초기화
4138
            testPanel2.IsHidden = true;
4139
            ViewerDataModel.Instance.PageBalanceMode = false;
4140
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4141
            ViewerDataModel.Instance.PageNumber = 0;
4142
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4143
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4144
            UserList.IsChecked = false;
4145
            BalanceMode.IsChecked = false;
4146
        }
4147

    
4148
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4149
        {
4150
            if ((sender as System.Windows.Controls.Control).Tag != null)
4151
            {
4152
                //Compare 초기화
4153
                CompareMode.IsChecked = false;
4154
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4155

    
4156
                if (ViewerDataModel.Instance.PageNumber == 0)
4157
                {
4158
                    ViewerDataModel.Instance.PageNumber = 1;
4159
                }
4160

    
4161
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4162
                {
4163
                }
4164
                else
4165
                {
4166
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4167
                }
4168

    
4169
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4170
                {
4171

    
4172
                }
4173
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4174
                {
4175
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4176
                }
4177

    
4178
                if (!testPanel2.IsHidden)
4179
                {
4180
                    if (IsSyncPDFMode)
4181
                    {
4182
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4183
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4184

    
4185
                        if (pdfpath.IsDownloading)
4186
                        {
4187
                            pdfpath.DownloadCompleted += (ex, arg) =>
4188
                            {
4189
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4190
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4191
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4192
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4193
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4194
                            };
4195
                        }
4196
                        else
4197
                        {
4198
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4199
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4200
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4201

    
4202
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4203
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4204
                        }
4205

    
4206
                    }
4207
                    else
4208
                    {
4209
                        string uri = "";
4210

    
4211
                        if (userData.COMPANY != "EXT")
4212
                        {
4213
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4214
                        }
4215
                        else
4216
                        {
4217
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4218
                        }
4219

    
4220
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4221

    
4222
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4223
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4224
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4225

    
4226
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4227
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4228

    
4229
                        if (defaultBitmapImage_Compare.IsDownloading)
4230
                        {
4231
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4232
                            {
4233
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4234
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4235
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4236

    
4237
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4238
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4239
                            };
4240
                        }
4241
                    }
4242

    
4243
                    //강인구 추가(페이지 이동시 코멘트 재 호출)
4244
                    ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4245
                    List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
4246

    
4247
                    foreach (var item in gridSelectionRevItem)
4248
                    {
4249
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4250
                        {
4251
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4252
                        });
4253
                    }
4254

    
4255
                    //강인구 추가
4256
                    zoomAndPanControl2.ZoomTo(new Rect
4257
                    {
4258
                        X = 0,
4259
                        Y = 0,
4260
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4261
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4262
                    });
4263

    
4264
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", ViewerDataModel.Instance.PageNumber);
4265

    
4266
                }
4267
            }
4268
        }
4269

    
4270
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4271
        {
4272
            if (MarkupMode.IsChecked)
4273
            {
4274
                IsSyncPDFMode = true;
4275

    
4276
                var uri = CurrentRev.TO_VENDOR;
4277

    
4278
                if (ViewerDataModel.Instance.PageNumber == 0)
4279
                {
4280
                    ViewerDataModel.Instance.PageNumber = 1;
4281
                }
4282

    
4283
                //PDF모드 잠시 대기(강인구)
4284
                Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4285
                var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4286

    
4287
                if (pdfpath.IsDownloading)
4288
                {
4289
                    pdfpath.DownloadCompleted += (ex, arg) =>
4290
                    {
4291
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4292
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4293
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4294
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4295
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4296
                    };
4297
                }
4298
                else
4299
                {
4300
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4301
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4302
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4303

    
4304
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4305
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4306
                }
4307
            }
4308
            else
4309
            {
4310
                IsSyncPDFMode = false;
4311
                string uri = "";
4312
                if (userData.COMPANY != "EXT")
4313
                {
4314
                    uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4315
                }
4316
                else
4317
                {
4318
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4319
                }
4320

    
4321
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4322

    
4323
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4324
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4325
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4326

    
4327
                if (defaultBitmapImage_Compare.IsDownloading)
4328
                {
4329
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4330
                    {
4331
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4332
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4333
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4334
                    };
4335
                }
4336
                zoomAndPanControl2.ApplyTemplate();
4337
                zoomAndPanControl2.UpdateLayout();
4338
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4339
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4340
            }
4341
        }
4342

    
4343
        private void RadButton_Click(object sender, RoutedEventArgs e)
4344
        {
4345
            gridViewHistory_Busy.IsBusy = true;
4346

    
4347
            RadButton instance = sender as RadButton;
4348
            if (instance.CommandParameter != null)
4349
            {
4350
                CurrentRev = instance.CommandParameter as VPRevision;
4351
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4352
                {
4353
                    if (ea.Error == null && ea.Result != null)
4354
                    {
4355
                        testPanel2.IsHidden = false;
4356

    
4357
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4358
                        foreach(var info in ea.Result)
4359
                        {
4360
                            if(info.UserID == App.ViewInfo.UserID)
4361
                            {
4362
                                info.userDelete = true;
4363
                                info.DisplayColor = "FFFF0000";
4364
                            }
4365
                            else
4366
                            {
4367
                                info.userDelete = false;
4368
                            }
4369
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4370
                        }
4371
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4372

    
4373
                        string uri = "";
4374
                        if (userData.COMPANY != "EXT")
4375
                        {
4376
                            uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4377
                        }
4378
                        else
4379
                        {
4380
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4381
                        }
4382

    
4383
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4384

    
4385
                        var defaultBitmapImage_Compare = new BitmapImage();
4386
                        defaultBitmapImage_Compare.BeginInit();
4387
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4388
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4389
                        defaultBitmapImage_Compare.EndInit();
4390

    
4391
                        if (defaultBitmapImage_Compare.IsDownloading)
4392
                        {
4393
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4394
                            {
4395
                                defaultBitmapImage_Compare.Freeze();
4396
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4397
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4398
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4399
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4400
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4401
                            };
4402
                        }                        
4403
                        zoomAndPanControl2.ApplyTemplate();
4404
                        zoomAndPanControl2.UpdateLayout();
4405
                        //syncPannelRotate(zoomAndPanControl.RotationAngle);
4406
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4407
                        {
4408
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4409
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4410
                        }
4411

    
4412
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4413
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4414
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4415

    
4416
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4417
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4418
                        gridViewHistory_Busy.IsBusy = false;
4419
                    }
4420

    
4421
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4422
                };
4423
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4424
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4425
            }
4426
        }
4427
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4428
        {
4429
            try
4430
            {
4431
                if (sender is RadButton)
4432
                {
4433
                    if ((sender as RadButton).Tag != null)
4434
                    {
4435
                        var url = (sender as RadButton).Tag.ToString();
4436
                        System.Diagnostics.Process.Start(url);
4437
                    }
4438
                    else
4439
                    {
4440
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4441
                    }
4442
                }
4443
            }
4444
            catch (Exception ex)
4445
            {
4446
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4447
            }
4448
        }
4449

    
4450
        public void Sync_Event(VPRevision Currnet_Rev)
4451
        {
4452
            CurrentRev = Currnet_Rev;
4453

    
4454
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4455
            {
4456
                if (ea.Error == null && ea.Result != null)
4457
                {
4458
                    testPanel2.IsHidden = false;
4459

    
4460
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4461
                    foreach(var info in ea.Result)
4462
                    {
4463
                        if(info.UserID == App.ViewInfo.UserID)
4464
                        {
4465
                            info.userDelete = true;
4466
                            info.DisplayColor = "FFFF0000";
4467
                        }
4468
                        else
4469
                        {
4470
                            info.userDelete = false;
4471
                        }
4472
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4473
                    }
4474
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4475

    
4476
                    string uri = "";
4477
                    if (userData.COMPANY != "EXT")
4478
                    {
4479
                        uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4480
                    }
4481
                    else
4482
                    {
4483
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4484
                    }
4485

    
4486
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4487

    
4488
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4489

    
4490
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4491
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4492
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4493

    
4494
                    if (defaultBitmapImage_Compare.IsDownloading)
4495
                    {
4496
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4497
                        {
4498
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4499
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4500
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4501
                        };
4502
                    }
4503

    
4504

    
4505
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4506
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4507
                    zoomAndPanControl2.ApplyTemplate();
4508
                    zoomAndPanControl2.UpdateLayout();
4509

    
4510
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4511
                    {
4512
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4513
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4514
                    }
4515
                    //}
4516

    
4517
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4518
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4519
                    gridViewHistory_Busy.IsBusy = false;
4520
                }
4521
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4522

    
4523
            };
4524
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4525
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4526
        }
4527

    
4528
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4529
        {
4530
            if (sender is Image)
4531
            {
4532
                if ((sender as Image).Tag != null)
4533
                {
4534
                    var pdfUrl = (sender as Image).Tag.ToString();
4535
                    System.Diagnostics.Process.Start(pdfUrl);
4536
                }
4537
                else
4538
                {
4539
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4540
                }
4541
            }
4542
        }
4543

    
4544
        private void Create_Symbol(object sender, RoutedEventArgs e)
4545
        {
4546
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4547

    
4548
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4549
            {
4550
                DialogMessage_Alert("Please Select Controls", "Alert");
4551
            }
4552
            else //선택된 것이 있으면
4553
            {
4554
                string MarkupData = "";
4555
                adorner_ = new AdornerFinal();
4556

    
4557
                foreach (var item in SelectLayer.Children)
4558
                {
4559
                    if (item.GetType().Name == "AdornerFinal")
4560
                    {
4561
                        adorner_ = (item as Controls.AdornerFinal);
4562
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4563
                        {
4564
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4565
                            {
4566
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4567
                                MarkupData += markupReturn.ConvertData;
4568
                            }
4569
                        }
4570
                    }
4571
                }
4572
                DialogParameters parameters = new DialogParameters()
4573
                {
4574
                    Owner = Application.Current.MainWindow,
4575
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4576
                    DefaultPromptResultValue = "Custom State",
4577
                    Content = "Name :",
4578
                    Header = "Insert Custom Symbol Name",
4579
                    Theme = new VisualStudio2013Theme(),
4580
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4581
                };
4582
                RadWindow.Prompt(parameters);
4583
            }
4584

    
4585
        }
4586
        public int symbolselectindex = 0;
4587
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4588
        {
4589
            //Save save = new Save();
4590
            try
4591
            {
4592
                string svgfilename = null;
4593
                if (symbolname != null)
4594
                {
4595
                    if (symbolpng == true || symbolsvg == true)
4596
                    {
4597
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4598
                        string guid = Commons.shortGuid();
4599

    
4600
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4601
                        //Check_Uri.UriCheck();
4602
                        fileUploader.RunCompleted += (ex, arg) =>
4603
                        {
4604
                            filename = arg.Result;
4605
                            if (symbolpng == true)
4606
                            {
4607
                                if (filename != null)
4608
                                { 
4609
                                    if (symbolselectindex == 0)
4610
                                    {
4611
                                        SymbolSave(symbolname, filename, data);
4612
                                    }
4613
                                    else
4614
                                    {
4615
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4616
                                    }
4617
                                    DataBind();
4618
                                }                                
4619
                            }
4620

    
4621
                            if (symbolsvg == true)
4622
                            {
4623
                                try
4624
                                {
4625
                                    var defaultBitmapImage = new BitmapImage();
4626
                                    defaultBitmapImage.BeginInit();
4627
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4628
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4629
                                    Check_Uri.UriCheck(filename);
4630
                                    defaultBitmapImage.UriSource = new Uri(filename);
4631
                                    defaultBitmapImage.EndInit();
4632

    
4633
                                    System.Drawing.Bitmap image;
4634

    
4635
                                    if (defaultBitmapImage.IsDownloading)
4636
                                    {
4637
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4638
                                        {
4639
                                            defaultBitmapImage.Freeze();
4640
                                            image = GetBitmap(defaultBitmapImage);
4641
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4642
                                            Process potrace = new Process
4643
                                            {
4644
                                                StartInfo = new ProcessStartInfo
4645
                                                {
4646
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4647
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4648
                                                    RedirectStandardInput = true,
4649
                                                    RedirectStandardOutput = true,
4650
                                                    RedirectStandardError = true,
4651
                                                    UseShellExecute = false,
4652
                                                    CreateNoWindow = true,
4653
                                                    WindowStyle = ProcessWindowStyle.Hidden
4654
                                                },
4655
                                            };
4656

    
4657
                                            StringBuilder svgBuilder = new StringBuilder();
4658
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4659
                                            {
4660
                                                svgBuilder.AppendLine(e2.Data);
4661
                                            };
4662

    
4663
                                            potrace.EnableRaisingEvents = true;
4664
                                            potrace.Start();
4665
                                            potrace.Exited += (sender, e) =>
4666
                                            {
4667
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4668
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4669
                                                Check_Uri.UriCheck(svgfilename);
4670
                                                if (symbolselectindex == 0)
4671
                                                {
4672
                                                    SymbolSave(symbolname, svgfilename, data);
4673
                                                }
4674
                                                else
4675
                                                {
4676
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4677
                                                }
4678

    
4679
                                                DataBind();
4680
                                            };
4681
                                            potrace.WaitForExit();
4682
                                        };
4683
                                    }
4684
                                    else
4685
                                    {
4686
                                        //GC.Collect();
4687
                                    }
4688
                                }
4689
                                catch(Exception ee)
4690
                                {
4691
                                    DialogMessage_Alert("" + ee, "Alert");
4692
                                }
4693
                            }
4694
                        };                                             
4695
                    }
4696
                }
4697
            }
4698
            catch (Exception e)
4699
            {
4700
                //DialogMessage_Alert(e + "", "Alert");
4701
            }            
4702
        }
4703

    
4704
        public void SymbolSave(string Name, string Url, string Data)
4705
        {
4706
            try
4707
            {
4708
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4709
                {
4710
                    ID = Commons.shortGuid(),
4711
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4712
                    NAME = Name,
4713
                    IMAGE_URL = Url,
4714
                    DATA = Data
4715
                };
4716

    
4717
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4718
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4719
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4720
            }
4721
            catch (Exception)
4722
            {
4723
                throw;
4724
            }
4725
        }
4726

    
4727
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4728
        {
4729
            try
4730
            {
4731
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4732
                {
4733
                    ID = Commons.shortGuid(),
4734
                    DEPARTMENT = Department,
4735
                    NAME = Name,
4736
                    IMAGE_URL = Url,
4737
                    DATA = Data
4738
                };
4739
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4740
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4741
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4742
            }
4743
            catch (Exception)
4744
            {
4745
                throw;
4746
            }
4747
        }
4748

    
4749
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4750
        {           
4751
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4752
            DataBind();
4753
        }
4754

    
4755
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4756
        {
4757
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4758
            DataBind();
4759
        }
4760
        private void DataBind()
4761
        {
4762
            try
4763
            {
4764
                Symbol_Custom Custom = new Symbol_Custom();
4765
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4766
                
4767
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4768
                foreach (var item in symbol_Private)
4769
                {
4770
                    Custom.Name = item.NAME;
4771
                    Custom.ImageUri = item.IMAGE_URL;
4772
                    Custom.ID = item.ID;
4773
                    Custom_List.Add(Custom);
4774
                    Custom = new Symbol_Custom();
4775
                }
4776
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4777
                
4778
                Custom = new Symbol_Custom();
4779
                Custom_List = new List<Symbol_Custom>();
4780

    
4781
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4782

    
4783
                List<SYMBOL_PUBLIC> symbol_Public;
4784

    
4785
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4786
                {
4787
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4788
                }
4789
                else
4790
                {
4791
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4792
                }
4793
                foreach (var item in symbol_Public)
4794
                {
4795
                    Custom.Name = item.NAME;
4796
                    Custom.ImageUri = item.IMAGE_URL;
4797
                    Custom.ID = item.ID;
4798
                    Custom_List.Add(Custom);
4799
                    Custom = new Symbol_Custom();
4800
                }
4801
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4802
                BaseClient.Close();                
4803
            }
4804
            catch(Exception e)
4805
            {
4806
                //DialogMessage_Alert("DataBind", "Alert");
4807
            }
4808
            
4809
        }
4810
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4811
        {
4812
            try
4813
            {
4814
                if (args.PromptResult != null)
4815
                {
4816
                    if (args.DialogResult.Value)
4817
                    {
4818
                        PngBitmapEncoder _Encoder = symImage(data);
4819

    
4820
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4821
                        _Encoder.Save(fs);
4822
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4823

    
4824
                        byte[] Img_byte = fs.ToArray();
4825

    
4826
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4827
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4828
                        Check_Uri.UriCheck(filename);
4829
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4830
                        {
4831
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4832
                        }
4833
                        else
4834
                        {
4835
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4836
                        }
4837
                        DataBind();
4838
                    }
4839
                }
4840
            }
4841
            catch(Exception ex)
4842
            {
4843
                DialogMessage_Alert("" + ex, "Alert");
4844
            }
4845
        }
4846

    
4847
        public PngBitmapEncoder symImage(string data)
4848
        {
4849

    
4850
            Canvas _canvas = new Canvas();
4851
            _canvas.Background = Brushes.White;
4852
            _canvas.Width = adorner_.BorderSize.Width;
4853
            _canvas.Height = adorner_.BorderSize.Height;
4854
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4855

    
4856
            BitmapEncoder encoder = new PngBitmapEncoder();
4857

    
4858

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

    
4861
            DrawingVisual dv = new DrawingVisual();
4862

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

    
4866
            using (DrawingContext ctx = dv.RenderOpen())
4867
            {
4868
                VisualBrush vb = new VisualBrush(_canvas);
4869
                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)));
4870
            }
4871

    
4872
            try
4873
            {
4874
                renderBitmap.Render(dv);
4875

    
4876
                //GC.Collect();
4877
                GC.WaitForPendingFinalizers();
4878
                //GC.Collect();
4879
                // encode png data
4880
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4881
                // puch rendered bitmap into it
4882
                pngEncoder.Interlace = PngInterlaceOption.Off;
4883
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4884
                return pngEncoder;
4885

    
4886
            }
4887
            catch //(Exception ex)
4888
            {
4889
                return null;
4890
            }
4891

    
4892
        }
4893

    
4894
        public void DialogMessage_Alert(string content, string header)
4895
        {
4896
            var box = new TextBlock();
4897
            box.MinWidth = 400;
4898
            box.FontSize = 11;
4899
            //box.FontSize = 12;
4900
            box.Text = content;
4901
            box.TextWrapping = System.Windows.TextWrapping.Wrap;
4902

    
4903
            DialogParameters parameters = new DialogParameters()
4904
            {
4905
                Owner = Application.Current.MainWindow,
4906
                Content = box,
4907
                Header = header,
4908
                Theme = new VisualStudio2013Theme(),
4909
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4910
            };            
4911
            RadWindow.Alert(parameters);
4912
        }
4913

    
4914
        #region 캡쳐 기능
4915

    
4916
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4917
        {
4918
            if (x < 0)
4919
            {
4920
                width += x;
4921
                x = 0;
4922
            }
4923
            if (y < 0)
4924
            {
4925
                height += y;
4926
                y = 0;
4927

    
4928
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4929
            }
4930
            if (x + width > zoomAndPanCanvas.ActualWidth)
4931
            {
4932
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4933
            }
4934
            if (y + height > zoomAndPanCanvas.ActualHeight)
4935
            {
4936
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4937
            }
4938

    
4939
            byte[] pixels = CopyPixels(x, y, width, height);
4940

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

    
4943
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4944
        }
4945

    
4946
        public byte[] CopyPixels(int x, int y, int width, int height)
4947
        {
4948
            byte[] pixels = new byte[width * height * 4];
4949
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
4950

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

    
4954
            return pixels;
4955
        }
4956

    
4957
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
4958
        {
4959
            DrawingVisual drawingVisual = new DrawingVisual();
4960
            DrawingContext drawingContext = drawingVisual.RenderOpen();
4961

    
4962
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
4963
            drawingContext.DrawRectangle(new VisualBrush(element), null,
4964
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
4965
            drawingContext.Close();
4966

    
4967
            // 비트맵으로 변환합니다.
4968
            RenderTargetBitmap target =
4969
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
4970
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
4971

    
4972
            target.Render(drawingVisual);
4973
            return target;
4974
        }
4975

    
4976
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
4977
        {
4978
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
4979
            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);
4980
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
4981
            bmp.UnlockBits(data);
4982
            return bmp;
4983
        }
4984
        public string symbolname = null;
4985
        public bool symbolsvg = true;
4986
        public bool symbolpng = true;
4987

    
4988
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
4989
        {
4990
            System.Drawing.Bitmap image = GetBitmap(source);
4991
            //흰색 제거
4992
            //image.MakeTransparent(System.Drawing.Color.White);
4993

    
4994
            var imageStream = new System.IO.MemoryStream();
4995
            byte[] imageBytes = null;
4996
            using (imageStream)
4997
            {
4998
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
4999
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5000
                imageStream.Position = 0;
5001
                imageBytes = imageStream.ToArray();
5002
            }
5003

    
5004
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5005

    
5006
            RadWindow CheckPop = new RadWindow();
5007
            //Alert check = new Alert(Msg);
5008

    
5009
            CheckPop = new RadWindow
5010
            {
5011
                MinWidth = 400,
5012
                MinHeight = 100,
5013
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5014
                Header = "Alert",
5015
                Content = symbolPrompt,
5016
                //DialogResult = 
5017
                ResizeMode = System.Windows.ResizeMode.NoResize,
5018
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5019
                IsTopmost = true,
5020
            };
5021
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5022
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5023
            CheckPop.ShowDialog();
5024

    
5025
            /*
5026
            DialogParameters parameters = new DialogParameters()
5027
            {
5028
                Owner = Application.Current.MainWindow,
5029
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5030
                DefaultPromptResultValue = "Custom State",
5031
                Content = "Name :",
5032
                Header = "Insert Custom Symbol Name",
5033
                Theme = new VisualStudio2013Theme(),
5034
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5035
            };            
5036
            RadWindow.Prompt(parameters);
5037
            */
5038
        }
5039

    
5040
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5041
        {
5042
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5043
            KCOMDataModel.DataModel.CHECK_LIST check_;
5044
            string Result = streamToBase64.ImageToBase64(source);
5045
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5046
            string projectno = App.ViewInfo.ProjectNO;
5047
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5048

    
5049
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5050
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5051
            if (Item != null)
5052
            {
5053
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5054
            }
5055
            else
5056
            {
5057
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5058
            }
5059

    
5060
            if (Item == null)
5061
            {
5062
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5063
                {
5064
                    ID = Commons.shortGuid(),
5065
                    USER_ID = App.ViewInfo.UserID,
5066
                    IMAGE_URL = Result,
5067
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5068
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5069
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5070
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5071
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5072
                    STATUS = "False",
5073
                    CREATE_TIME = DateTime.Now,
5074
                    UPDATE_TIME = DateTime.Now,
5075
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5076
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5077
                };
5078
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5079
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5080
                //this.BaseClient.AddCheckList(projectno, check_);
5081
            }
5082
            else
5083
            {
5084
                Item.IMAGE_URL = Result;
5085
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5086
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5087
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5088
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5089
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5090
            }
5091

    
5092
        }
5093

    
5094
        public void Set_Capture()
5095
        {
5096
            double x = canvasDrawingMouseDownPoint.X;
5097
            double y = canvasDrawingMouseDownPoint.Y;
5098
            double width = dragCaptureBorder.Width;
5099
            double height = dragCaptureBorder.Height;
5100

    
5101
            if (width > 5 || height > 5)
5102
            {
5103
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5104
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5105
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5106
            }
5107
        }
5108
        #endregion
5109

    
5110
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5111
        {
5112
            multi_Undo_Data = new Multi_Undo_data();
5113

    
5114
            multi_Undo_Data.Markup = control;
5115

    
5116
            if ((control as IShapeControl) != null)
5117
            {
5118
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5119
            }
5120
            if ((control as IDashControl) != null)
5121
            {
5122
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5123
            }
5124
            if ((control as IPath) != null)
5125
            {
5126
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5127
            }
5128
            if ((control as UIElement) != null)
5129
            {
5130
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5131
            }
5132

    
5133
            return multi_Undo_Data;
5134
        }
5135

    
5136
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5137
        {
5138
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5139
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5140
            {
5141
                if (items.UserID == Select_ID)
5142
                {
5143
                    foreach (var item in items.MarkupList)
5144
                    {
5145
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5146
                        {
5147
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5148
                                items.MarkupInfoID, Commons.shortGuid());
5149
                        }
5150
                    }
5151
                }
5152
            }
5153
        }
5154

    
5155
        /// <summary>
5156
        /// convert inkcontrol to polygoncontrol
5157
        /// </summary>
5158
        public void ConvertInkControlToPolygon()
5159
        {
5160
            if (inkBoard.Strokes.Count > 0)
5161
            {
5162
                inkBoard.Strokes.ToList().ForEach(stroke =>
5163
                {
5164
                    InkToPath ip = new InkToPath();
5165

    
5166
                    List<Point> inkPointSet = new List<Point>();
5167
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5168

    
5169
                    PolygonControl pc = new PolygonControl()
5170
                    {
5171
                        Angle = 0,
5172
                        PointSet = inkPointSet,
5173
                        ControlType = ControlType.Ink
5174
                    };
5175
                    pc.StartPoint = inkPointSet[0];
5176
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5177
                    pc.LineSize = 3;
5178
                    pc.CommentID = Commons.shortGuid();
5179
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5180

    
5181
                    if (pc.PointSet.Count > 0)
5182
                    {
5183
                        CreateCommand.Instance.Execute(pc);
5184
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5185
                    }
5186
                });
5187
                inkBoard.Strokes.Clear();
5188
            }
5189
        }
5190

    
5191
        /// <summary>
5192
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5193
        /// </summary>
5194
        /// <author>ingu</author>
5195
        /// <date>2018.06.05</date>
5196
        /// <param name="getPoint"></param>
5197
        /// <returns></returns>
5198
        private bool IsGetoutpoint(Point getPoint)
5199
        {
5200
            if (getPoint == new Point())
5201
            {
5202
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5203
                currentControl = null;
5204
                return true;
5205
            }
5206

    
5207
            return false;
5208
        }
5209

    
5210
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5211
        {
5212
            e.Effects = DragDropEffects.Copy;
5213
        }
5214

    
5215
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5216
        {
5217
            e.Effects = DragDropEffects.Copy;
5218
        }
5219

    
5220
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5221
        {
5222
            e.Effects = DragDropEffects.None;
5223
        }
5224

    
5225
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5226
        {
5227
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5228
        }
5229

    
5230
        /*
5231
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5232
        {
5233
            try
5234
            {
5235
                if (e.Data.GetDataPresent(typeof(string)))
5236
                {
5237
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5238
                    string dragData = e.Data.GetData(typeof(string)) as string;
5239
                    Move_Symbol(sender, dragData);
5240
                }
5241
            }
5242
            catch (Exception ex)
5243
            {
5244
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5245
            }            
5246
        }
5247
        */
5248
    }
5249
}
클립보드 이미지 추가 (최대 크기: 500 MB)