프로젝트

일반

사용자정보

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

markus / KCOM / Views / MainMenu.xaml.cs @ 81e3c9f6

이력 | 보기 | 이력해설 | 다운로드 (251 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
using static KCOM.Controls.Sample;
45

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

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

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

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

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

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

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

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

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

    
120
    /// <summary>
121
    /// MainMenu.xaml에 대한 상호 작용 논리
122
    /// </summary>
123
    public partial class MainMenu : UserControl
124
    {
125
        #region 프로퍼티
126
        public CommentUserInfo currentControl { get; set; }
127
        public ControlType controlType { get; set; }
128
        private Move move = new Move();
129
        private double[] rotateValue = { 0, 90, 180, 270 };
130
        public MouseHandlingMode mouseHandlingMode = MouseHandlingMode.None;
131
        private static readonly double DragThreshold = 5;
132
        private System.Windows.Input.Cursor cursor { get; set; }
133
        private Point canvasDrawingMouseDownPoint;
134
        public string filename { get; set; }
135
        private Point canvasZoomPanningMouseDownPoint;
136
        public Point getCurrentPoint;
137
        private Point canvasZoommovingMouseDownPoint;
138
        List<object> ControlList = new List<object>();
139
        private ListBox listBox = new ListBox();
140
        private Dictionary<Geometry, string> selected_item = new Dictionary<Geometry, string>();
141
        private bool isDraggingSelectionRect = false;
142
        DrawingAttributes inkDA = new DrawingAttributes();
143
        private VPRevision CurrentRev { get; set; }
144
        public RadRibbonButton btnConsolidate { get; set; }
145
        public RadRibbonButton btnFinalPDF { get; set; }
146
        public RadRibbonButton btnTeamConsolidate { get; set; }
147
        public RadRibbonButton btnConsolidateFinalPDF { get; set; }
148

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

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

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

    
182
                }
183
            }
184
        }
185

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

    
210
        public bool IsSyncPDFMode { get; set; }
211

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

    
236
        #endregion
237

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

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

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

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

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

    
272
            return false;
273
        }
274

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

    
298
            return false;
299
        }
300

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

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

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

    
315
            ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.MarkupInfoID == item.MarkupInfoID).ToList().ForEach(a =>
316
            {
317
                ViewerDataModel.Instance.MarkupControls_USER.Remove(a);
318
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
319
                null, Event_Type.Delete, a.CommentID, null);
320
            });
321

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

    
329
            gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
330

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

    
362
        /// <summary>
363
        /// delete selected comments
364
        /// </summary>
365
        /// <param name="sender"></param>
366
        /// <param name="e"></param>
367
        public void DeleteCommentEvent(object sender, RoutedEventArgs e)
368
        {
369
            DialogParameters parameters = new DialogParameters()
370
            {
371
                Owner = Application.Current.MainWindow,
372
                Content = new TextBlock()
373
                { 
374
                    MinWidth = 400,
375
                    FontSize = 11,
376
                    Text = "정말 삭제 하시겠습니까?",
377
                    TextWrapping = System.Windows.TextWrapping.Wrap
378
                },
379
                Header = "Confirm",
380
                Theme = new VisualStudio2013Theme(),
381
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
382
                OkButtonContent = "Yes",
383
                CancelButtonContent = "No",
384
                Closed = delegate (object windowSender, WindowClosedEventArgs wc)
385
                {
386
                    if(wc.DialogResult == true)
387
                    {
388
                        //선택된 어도너가 있을시 삭제가 되지 않음
389
                        SelectionSet.Instance.UnSelect(this);
390

    
391
                        Button content = (sender as Button);
392
                        MarkupInfoItem item = content.CommandParameter as MarkupInfoItem;
393

    
394
                        DeleteItem(item);
395
                    }
396
                }
397
            };
398
            RadWindow.Confirm(parameters);
399
        }
400

    
401
        System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation();
402

    
403
        private static Timer timer;
404
        private int InitInterval = KCOM.Properties.Settings.Default.InitInterval;
405
        private void MainMenu_Loaded(object sender, RoutedEventArgs e)
406
        {
407
            InitializeComponent();            
408
            //System.Diagnostics.Debug.WriteLine("MainMenu() : " + sw.ElapsedMilliseconds.ToString() + "ms");
409

    
410
            if (App.ParameterMode)
411
            {
412
                App.splashString(ISplashMessage.MAINMENU_1);
413
                this.pageNavigator.PageChanging += pageNavigator_PageChanging;
414
                this.pageNavigator.PageChanged += PageNavigator_PageChanged;
415
                imageViewer_Compare = new Image();
416
                ViewerDataModel.Instance.Capture_Opacity = 0;
417
                da.From = 0.8;
418
                da.To = 0;
419
                da.Duration = new Duration(TimeSpan.FromSeconds(1));
420
                da.AutoReverse = true;
421
                da.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
422

    
423
                if (!App.ViewInfo.CreateFinalPDFPermission && !App.ViewInfo.NewCommentPermission)
424
                {
425
                    this.SymbolPane.Visibility = Visibility.Collapsed;
426
                    this.FavoritePane.Visibility = Visibility.Collapsed;
427
                    this.drawingRotateCanvas.IsHitTestVisible = false;
428
                }
429
                thumbnailPanel.Width = Convert.ToInt32(CommonLib.Common.GetConfigString("SetThumbnail", "WIDTH", "250"));
430
            }
431
            timer = new Timer(timercallback, null, 0, InitInterval * 60000);
432
        }
433

    
434
        
435

    
436
        private void timercallback(Object o)
437
        {
438
            Stopwatch sw = new Stopwatch();
439
            sw.Start();
440
            TempFile.TempFileAdd();
441
            sw.Stop();
442

    
443
            Dispatcher.InvokeAsync(new Action(delegate
444
            {
445
               if (this.ParentOfType<MainWindow>().dzTopMenu.cbAutoSave.IsChecked == true) //Auto Save Checked?
446
                {
447
                    timer.Change(((int)this.ParentOfType<MainWindow>().dzTopMenu.cbSaveInterval.Value * 60000) / 2, sw.ElapsedMilliseconds); //Timer Setting
448
                }
449
            }));
450

    
451
            ////GC.Collect();
452
        }
453
        
454
        /// <summary>
455
        /// update my markuplist
456
        ///  - update existing markup data if already exist
457
        ///  - add new markup data if control is new
458
        /// </summary>
459
        public void UpdateMyMarkupList()
460
        {
461
            Logger.sendCheckLog("pageNavigator_PageChanging_ChangeCommentReact", 1);
462

    
463
            /// add or update markup list
464
            foreach (var control in ViewerDataModel.Instance.MarkupControls_USER)
465
            {
466
                var root = MarkupParser.MarkupToString(control, App.ViewInfo.UserID);
467

    
468
                var exist = ViewerDataModel.Instance.MyMarkupList.Where(data => data.ID == root.CommentID).FirstOrDefault();
469
                if (exist != null) //신규 추가 된 코멘트
470
                {
471
                    if (exist.Data != root.ConvertData) //코멘트가 같은지
472
                    {
473
                        exist.Data = root.ConvertData;
474
                        exist.IsUpdate = true;
475
                    }
476
                }
477
                else if (root.CommentID != null)
478
                {
479
                    ViewerDataModel.Instance.MyMarkupList.Add(new MarkupItemEx
480
                    {
481
                        ID = control.CommentID,
482
                        Data = root.ConvertData,
483
                        Data_Type = root.DATA_TYPE,
484
                        MarkupInfoID = App.Custom_ViewInfoId,
485
                        PageNumber = this.pageNavigator.CurrentPage.PageNumber,
486
                        Symbol_ID = control.SymbolID,
487
                        //Group_ID = control.GroupID,
488
                    });
489
                }
490
            }
491

    
492
            /// delete markup list
493
            int iPageNo = this.pageNavigator.CurrentPage.PageNumber;
494
            var deleted = (from markup in ViewerDataModel.Instance.MyMarkupList
495
                          where (markup.PageNumber == iPageNo) && (null == ViewerDataModel.Instance.MarkupControls_USER.Where(control => control.CommentID == markup.ID).FirstOrDefault())
496
                          select markup).ToList();
497
            foreach(var markup in deleted) ViewerDataModel.Instance.MyMarkupList.Remove(markup);
498
            /// up to here
499

    
500
            //if (modified)
501
            //{
502
            //    if (ViewerDataModel.Instance._markupInfoList.Where(info => info.UserID == PreviewUserMarkupInfoItem.UserID).FirstOrDefault() == null)
503
            //    {
504
            //        ComingNewBieEnd = true;
505
            //        ViewerDataModel.Instance._markupInfoList.Insert(0, PreviewUserMarkupInfoItem);
506
            //        PreviewUserMarkupInfoItem.IsPreviewUser = false;
507
            //        gridViewMarkup.ItemsSource = null;
508
            //        gridViewMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoList;
509
            //        gridViewMarkup.SelectedItem = PreviewUserMarkupInfoItem;
510

    
511
            //        GroupDescriptor descriptor = new GroupDescriptor();
512
            //        descriptor.Member = "Depatment";
513
            //        descriptor.DisplayContent = "DEPT";
514
            //        descriptor.SortDirection = ListSortDirection.Ascending;
515
            //        gridViewMarkup.GroupDescriptors.Add(descriptor);
516
            //    }
517
            //}
518
        }
519

    
520
        /// <summary>
521
        /// start page changing
522
        ///  - save controls if page is modified
523
        ///  - starting download page image
524
        /// </summary>
525
        /// <param name="sender"></param>
526
        /// <param name="e"></param>
527
        private void pageNavigator_PageChanging(object sender, Controls.Sample.PageChangeEventArgs e)
528
        {
529
            CompareMode.IsChecked = false;
530
            var BalancePoint = ViewerDataModel.Instance.PageBalanceMode == true ? e.PageNumber + ViewerDataModel.Instance.PageBalanceNumber : e.PageNumber;
531

    
532
            #region 페이지가 벗어난 경우
533

    
534
            if (BalancePoint < 1)
535
            {
536
                BalancePoint = 1;
537
                ViewerDataModel.Instance.PageBalanceNumber = 0;
538
            }
539

    
540
            if (pageNavigator.PageCount < BalancePoint)
541
            {
542
                BalancePoint = pageNavigator.PageCount;
543
                ViewerDataModel.Instance.PageBalanceNumber = 0;
544
            }
545

    
546
            #endregion
547

    
548
            ViewerDataModel.Instance.PageNumber = BalancePoint;
549

    
550
            string uri = "";
551
            if (userData.COMPANY != "EXT")
552
            {
553
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, e.PageNumber);
554
            }
555
            else
556
            {
557
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, e.PageNumber);
558
            }
559

    
560
            var pageWidth = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
561
            var pageHeight = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
562

    
563
            var defaultBitmapImage = new BitmapImage();
564
            defaultBitmapImage.BeginInit();
565
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
566
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
567
            defaultBitmapImage.UriSource = new Uri(uri);
568
            defaultBitmapImage.DecodePixelWidth = Convert.ToInt32(pageWidth );
569
            defaultBitmapImage.DecodePixelHeight = Convert.ToInt32(pageHeight);// * zoomAndPanControl.ContentScale
570
            defaultBitmapImage.EndInit();
571

    
572
            ViewerDataModel.Instance.ImageViewPath = null;
573
            Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage Downloading", 1);
574
            if (defaultBitmapImage.IsDownloading)
575
            {
576
                Logger.sendCheckLog("pageNavigator_PageChanging_BitmapImage IsDownloading", 1);
577
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
578
                {                   
579
                    defaultBitmapImage.Freeze();                                        
580
                    ViewerDataModel.Instance.ImageViewPath = defaultBitmapImage;
581
                    ViewerDataModel.Instance.ImageViewWidth = pageWidth;
582
                    ViewerDataModel.Instance.ImageViewHeight = pageHeight;
583
                    mainPanel.UpdateLayout();
584
                    this.pageNavigator.ChangePage(e.PageNumber); 
585
                    
586
                    //image dispose
587
                    defaultBitmapImage = null;
588
                    GC.Collect();
589
                };
590
            }
591

    
592
            zoomAndPanCanvas.Width = Convert.ToDouble(e.CurrentPage.PAGE_WIDTH);
593
            zoomAndPanCanvas.Height = Convert.ToDouble(e.CurrentPage.PAGE_HEIGHT);
594

    
595

    
596
            Common.ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
597
            Common.ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
598
            inkBoard.Width = zoomAndPanCanvas.Width;
599
            inkBoard.Height = zoomAndPanCanvas.Height;
600

    
601

    
602
            if (!testPanel2.IsHidden)
603
            {
604
                Logger.sendCheckLog("pageNavigator_PageChanging_!testPanel2.IsHidden 일 때", 1);
605
                //PDF모드일때 잠시 대기(강인구)
606
                if (IsSyncPDFMode)
607
                {
608
                    Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
609
                    var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
610

    
611
                    Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Downloading", 1);
612
                    if (pdfpath.IsDownloading)
613
                    {
614
                        pdfpath.DownloadCompleted += (ex, arg) =>
615
                        {
616
                            Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image DownloadCompleted", 1);
617
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
618
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
619
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
620
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
621
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
622
                        };
623
                    }
624
                    else
625
                    {
626
                        Logger.sendCheckLog("pageNavigator_PageChanging_pdfpath Image Page Setting", 1);
627
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
628
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
629
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
630

    
631
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
632
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
633
                    }
634
                }
635
                else
636
                {
637
                    Logger.sendCheckLog("pageNavigator_PageChanging_uri2 값 설정", 1);
638
                    string uri2 = "";
639
                    if (userData.COMPANY != "EXT")
640
                    {
641
                        uri2 = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, (Convert.ToUInt32(CurrentRev.DOCUMENT_ID) / 100).ToString(), CurrentRev.DOCUMENT_ID, BalancePoint);
642
                    }
643
                    else
644
                    {
645
                        uri2 = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, BalancePoint);
646
                    }
647

    
648
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare BitmapImage 설정", 1);
649
                    var defaultBitmapImage_Compare = new BitmapImage();
650
                    defaultBitmapImage_Compare.BeginInit();
651
                    defaultBitmapImage_Compare.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
652
                    defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
653
                    defaultBitmapImage_Compare.UriSource = new Uri(uri2);
654
                    //defaultBitmapImage_Compare.DecodePixelWidth = Int32.Parse(e.CurrentPage.PAGE_WIDTH);
655
                    //defaultBitmapImage_Compare.DecodePixelHeight = Int32.Parse(e.CurrentPage.PAGE_HEIGHT);
656
                    defaultBitmapImage_Compare.EndInit();
657

    
658
                    ViewerDataModel.Instance.ImageViewPath_C = null;                    
659

    
660
                    Logger.sendCheckLog("pageNavigator_PageChanging_zoomAndPanControl ZoomTo 설정", 1);
661
                    zoomAndPanControl.ZoomTo(new Rect
662
                    {
663
                        X = 0,
664
                        Y = 0,
665
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
666
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
667
                    });
668

    
669
                    Logger.sendCheckLog("pageNavigator_PageChanging_defaultBitmapImage_Compare Downloading", 1);
670
                    if (defaultBitmapImage_Compare.IsDownloading)
671
                    {
672
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
673
                        {
674
                            defaultBitmapImage_Compare.Freeze();
675
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
676
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
677
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
678
                            ComparePanel.UpdateLayout();
679
                            zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
680
                            zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
681

    
682
                            zoomAndPanControl.ZoomTo(new Rect
683
                            {
684
                                X = 0,
685
                                Y = 0,
686
                                Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
687
                                Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
688
                            });
689

    
690
                            //defaultBitmapImage_Compare dispose
691
                            defaultBitmapImage_Compare = null;
692
                            GC.Collect();
693
                        };
694
                    }
695
                }
696
                tlSyncPageNum.Text = String.Format("Current Page : {0}", BalancePoint);
697
            }
698

    
699
        }
700

    
701
        /// <summary>
702
        /// called after page is changed
703
        /// </summary>
704
        /// <param name="sender"></param>
705
        /// <param name="e"></param>
706
        private void PageNavigator_PageChanged(object sender, Sample.PageChangeEventArgs e)
707
        {
708
            if (zoomAndPanCanvas2.Width.IsNaN())
709
            {
710
                zoomAndPanControl.ZoomTo(new Rect { X = 0, Y = 0, Width = zoomAndPanCanvas.Width, Height = zoomAndPanCanvas.Height });
711
            }
712

    
713
            /// 컨트롤을 새로 생성한다.
714
            Common.ViewerDataModel.Instance.MarkupControls_USER.Clear();    //전체 제거
715
            Common.ViewerDataModel.Instance.MarkupControls.Clear();         //전체 제거
716
            foreach (var markup in ViewerDataModel.Instance.MyMarkupList.Where(param => param.PageNumber == ViewerDataModel.Instance.PageNumber))
717
            { 
718
                var info = ViewerDataModel.Instance._markupInfoList.Where(param => param.MarkupInfoID == markup.MarkupInfoID).First();
719
                if (info != null)
720
                {
721
                    string sColor = (info.UserID == App.ViewInfo.UserID) ? "#FFFF0000" : info.DisplayColor;
722
                    if (info.UserID == App.ViewInfo.UserID)
723
                    {
724
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, sColor, "",
725
                                        markup.MarkupInfoID, markup.ID);
726
                        control.Visibility = Visibility.Hidden;
727
                    }
728
                    else
729
                    {
730
                        var control = MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markup.Data, Common.ViewerDataModel.Instance.MarkupControls, sColor, "",
731
                                                                markup.MarkupInfoID, markup.ID);
732
                        control.Visibility = Visibility.Hidden;
733
                    }
734
                }
735
            };
736
            /// up to here
737

    
738
            /// fire selection event
739
            List<MarkupInfoItem> gridSelectionItem = gridViewMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList(); //선택 된 마크업
740
            this.gridViewMarkup.UnselectAll();
741
            this.gridViewMarkup.Select(gridSelectionItem);
742

    
743
            if (!testPanel2.IsHidden)
744
            {
745
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
746
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
747
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
748

    
749
                Common.ViewerDataModel.Instance.MarkupControls_Sync.Clear();
750
                List<MarkupInfoItem> gridSelectionRevItem = gridViewRevMarkup.SelectedItems.Cast<MarkupInfoItem>().ToList();
751

    
752

    
753
                foreach (var item in gridSelectionRevItem)
754
                {
755
                    item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
756
                    {
757
                        MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
758
                    });
759
                }
760
            }
761

    
762
            var instanceMain = this.ParentOfType<MainWindow>();
763
            instanceMain.dzTopMenu.tlcurrentPage.Text = e.CurrentPage.PAGE_NUMBER.ToString();
764
            instanceMain.dzTopMenu.tlcurrentPage_readonly.Text = e.CurrentPage.PAGE_NUMBER.ToString();
765

    
766
            instanceMain.dzTopMenu.rotateOffSet = 0;
767
            var pageinfo = this.CurrentDoc.docInfo.DOCPAGE.Where(p => p.PAGE_NUMBER == e.CurrentPage.PAGE_NUMBER).FirstOrDefault();
768
            drawingPannelRotate(pageinfo.PAGE_ANGLE);
769

    
770
            SetCommentPages(true);
771
        }
772

    
773
        private void SetCommentPages(bool onlyMe = false)
774
        {
775
            Logger.sendCheckLog("pageNavigator_PageChanging_SetCommentPages Setting", 1);
776
            List<UsersCommentPagesMember> _pages = new List<UsersCommentPagesMember>();
777
            foreach (var item in ViewerDataModel.Instance._markupInfoList)
778
            {
779
                //Comment 가 존재할 경우에만 Thumbnail 에 추가
780
                if(item.MarkupList != null)
781
                {
782
                    UsersCommentPagesMember instance = new UsersCommentPagesMember();
783
                    instance.UserName = item.UserName;
784
                    instance.Depart = item.Depatment;
785
                    instance.MarkupInfoID = item.MarkupInfoID;
786
                    instance.IsSelected = true;
787
                    instance.isConSolidation = item.Consolidate;
788
                    instance.SetColor = item.DisplayColor;
789
                    if (item.UserID == App.ViewInfo.UserID && item.MarkupInfoID == item.MarkupInfoID)
790
                    {
791
                        instance.PageNumber = ViewerDataModel.Instance.MyMarkupList.Select(d => d.PageNumber).ToList();
792
                    }
793
                    else
794
                    {
795
                        instance.PageNumber = ViewerDataModel.Instance.MarkupList_Pre.Where(data => data.MarkupInfoID == item.MarkupInfoID).Select(d => d.PageNumber).ToList();
796
                    }
797
                    _pages.Add(instance);
798
                }                
799
            }
800
            this.pageNavigator.SetCommentList(_pages.ToList());
801
        }
802

    
803
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e)
804
        {
805
            if (e.MiddleButton == MouseButtonState.Pressed)
806
            {
807

    
808
            }
809
            e.Handled = true;
810
            if (e.Delta > 0)
811
            {
812
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
813
                ZoomIn(currentContentMousePoint);
814
            }
815
            else
816
            {
817
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas);
818
                ZoomOut(currentContentMousePoint);
819
            }
820
        }
821

    
822
        private void zoomAndPanControl2_MouseWheel(object sender, MouseWheelEventArgs e)
823
        {
824
            e.Handled = true;
825
            if (e.Delta > 0)
826
            {
827
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
828
                ZoomIn_Sync(currentContentMousePoint);
829
            }
830
            else
831
            {
832
                Point currentContentMousePoint = e.GetPosition(zoomAndPanCanvas2);
833
                ZoomOut_Sync(currentContentMousePoint);
834
            }
835
        }
836

    
837
        #region ZoomIn & ZoomOut
838

    
839
        private void ZoomOut_Executed(object sender, ExecutedRoutedEventArgs e)
840
        {
841
            ZoomOut(new Point(zoomAndPanControl.ContentZoomFocusX,
842
                zoomAndPanControl.ContentZoomFocusY));
843
        }
844

    
845
        private void ZoomIn_Executed(object sender, ExecutedRoutedEventArgs e)
846
        {
847
            ZoomIn(new Point(zoomAndPanControl.ContentZoomFocusX,
848
                zoomAndPanControl.ContentZoomFocusY));
849
        }
850

    
851

    
852
        //강인구 추가 (줌 인아웃 수치 변경)
853
        //큰해상도의 문서일 경우 줌 인 아웃시 사이즈 변동이 큼
854
        private void ZoomOut(Point contentZoomCenter)
855
        {
856
            if (zoomAndPanControl.ContentScale > 0.39)
857
            {
858
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale - 0.2, contentZoomCenter);
859
            }
860
            else
861
            {
862
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale / 2, contentZoomCenter);
863
            }
864

    
865
            if (zoomAndPanControl2 != null && Sync.IsChecked)
866
            {
867
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
868
            }
869
        }
870

    
871
        private void ZoomIn(Point contentZoomCenter)
872
        {
873
            if (zoomAndPanControl.ContentScale > 0.19)
874
            {
875
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, contentZoomCenter);
876
            }
877
            else
878
            {
879
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale * 2, contentZoomCenter);
880
            }
881

    
882
            if (zoomAndPanControl2 != null && Sync.IsChecked)
883
            {
884
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl.ContentScale, contentZoomCenter);
885
            }
886

    
887
        }
888

    
889
        private void ZoomOut_Sync(Point contentZoomCenter)
890
        {
891
            if (zoomAndPanControl2.ContentScale > 0.39)
892
            {
893
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale - 0.2, contentZoomCenter);
894
            }
895
            else
896
            {
897
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale / 2, contentZoomCenter);
898
            }
899

    
900
            if (Sync.IsChecked)
901
            {
902
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
903
            }
904
        }
905

    
906
        private void ZoomIn_Sync(Point contentZoomCenter)
907
        {
908
            if (zoomAndPanControl2.ContentScale > 0.19)
909
            {
910
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale + 0.2, contentZoomCenter);
911
            }
912
            else
913
            {
914
                zoomAndPanControl2.ZoomAboutPoint(zoomAndPanControl2.ContentScale * 2, contentZoomCenter);
915
            }
916

    
917
            if (Sync.IsChecked)
918
            {
919
                zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl2.ContentScale, contentZoomCenter);
920
            }
921
        }
922

    
923
        private void ZoomOut()
924
        {
925
            zoomAndPanControl.ContentScale -= 0.1;
926
            //if (zoomAndPanControl2 != null)
927
            //{
928
            //    zoomAndPanControl2.ContentScale -= 0.1;
929
            //}
930
        }
931

    
932
        private void ZoomIn()
933
        {
934
            zoomAndPanControl.ContentScale += 0.1;
935
            //if (zoomAndPanControl2 != null)
936
            //{
937
            //    zoomAndPanControl2.ContentScale += 0.1;
938
            //}
939
        }
940

    
941
        #endregion
942

    
943
        private void init()
944
        {
945
            foreach (var item in ViewerDataModel.Instance.MarkupControls)
946
            {
947

    
948
                ControlList.Clear();
949
                listBox.Items.Clear();
950
                selected_item.Clear();
951

    
952
                (item as IMarkupCommonData).IsSelected = false;
953
            }
954

    
955
        }
956

    
957
        private HitTestResultBehavior MyCallback(HitTestResult result)
958
        {
959
            //this.cursor = Cursors.UpArrow;
960
            var element = result.VisualHit;
961
            while (element != null && !(element is CommentUserInfo))
962
                element = VisualTreeHelper.GetParent(element);
963

    
964
            if (element == null)
965
            {
966
                return HitTestResultBehavior.Stop;
967
            }
968
            else
969
            {
970
                if (element is CommentUserInfo)
971
                {
972
                    if (!hitList.Contains(element))
973
                    {
974
                        hitList.Add((CommentUserInfo)element);
975
                    }
976
                    else
977
                    {
978
                        return HitTestResultBehavior.Stop;
979
                    }
980
                }
981
            }
982
            return HitTestResultBehavior.Continue;
983
        }
984

    
985
        public void ReleaseSelectPath()
986
        {
987
            if (SelectionPath == null)
988
            {
989
                SelectionPath = new Path();
990
                SelectionPath.Name = "";
991
            }
992
            if (SelectionPath.Name != "")
993
            {
994
                SelectionPath.Name = "None";
995
            }
996
            SelectionPath.Opacity = 0.01;
997
            SelectionPath.RenderTransform = null;
998
            SelectionPath.RenderTransformOrigin = new Point(0, 0);
999
        }
1000

    
1001
        #region 컨트롤 초기화 
1002
        public void Control_Init(object control)
1003
        {
1004
            if (L_Size != 0 && (control as IPath) != null)
1005
            {
1006
                (control as IPath).LineSize = L_Size;
1007
                L_Size = 0;
1008
            }
1009

    
1010
            switch (control.GetType().Name)
1011
            {
1012
                case "RectangleControl":
1013
                    {
1014
                        (control as RectangleControl).StrokeColor = Brushes.Red;
1015
                    }
1016
                    break;
1017
                case "CircleControl":
1018
                    {
1019
                        (control as CircleControl).StrokeColor = Brushes.Red;
1020
                    }
1021
                    break;
1022
                case "TriControl":
1023
                    {
1024
                        (control as TriControl).StrokeColor = Brushes.Red;
1025
                    }
1026
                    break;
1027
                case "RectCloudControl":
1028
                    {
1029
                        (control as RectCloudControl).StrokeColor = Brushes.Red;
1030
                    }
1031
                    break;
1032
                case "CloudControl":
1033
                    {
1034
                        (control as CloudControl).StrokeColor = Brushes.Red;
1035
                    }
1036
                    break;
1037
                case "PolygonControl":
1038
                    {
1039
                        (control as PolygonControl).StrokeColor = Brushes.Red;
1040
                    }
1041
                    break;
1042
                case "ArcControl":
1043
                    {
1044
                        (control as ArcControl).StrokeColor = Brushes.Red;
1045
                    }
1046
                    break;
1047
                case "ArrowArcControl":
1048
                    {
1049
                        (control as ArrowArcControl).StrokeColor = Brushes.Red;
1050
                    }
1051
                    break;
1052
                case "LineControl":
1053
                    {
1054
                        (control as LineControl).StrokeColor = Brushes.Red;
1055
                    }
1056
                    break;
1057
                case "ArrowControl_Multi":
1058
                    {
1059
                        (control as ArrowControl_Multi).StrokeColor = Brushes.Red;
1060
                    }
1061
                    break;
1062
                case "TextControl":
1063
                    {
1064
                        (control as TextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1065
                    }
1066
                    break;
1067
                case "ArrowTextControl":
1068
                    {
1069
                        (control as ArrowTextControl).BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1070
                    }
1071
                    break;
1072
                case "InsideWhiteControl":
1073
                    {
1074
                        (control as InsideWhiteControl).StrokeColor = Brushes.White;
1075
                    }
1076
                    break;
1077
                case "OverlapWhiteControl":
1078
                    {
1079
                        (control as OverlapWhiteControl).StrokeColor = Brushes.White;
1080
                    }
1081
                    break;
1082
                case "ClipWhiteControl":
1083
                    {
1084
                        (control as ClipWhiteControl).StrokeColor = Brushes.White;
1085
                    }
1086
                    break;
1087
                case "CoordinateControl":
1088
                    {
1089
                        (control as CoordinateControl).StrokeColor = Brushes.Black;
1090
                    }
1091
                    break;
1092
            }
1093
        }
1094
        #endregion
1095

    
1096
        public void firstCondition_MouseLeave(object sender, MouseEventArgs e)
1097
        {
1098
            //Control_Init(e.Source);
1099
        }
1100
        //private Window _dragdropWindow = null;
1101

    
1102
        [DllImport("user32.dll")]
1103
        [return: MarshalAs(UnmanagedType.Bool)]
1104
        internal static extern bool GetCursorPos(ref Win32Point pt);
1105

    
1106
        [StructLayout(LayoutKind.Sequential)]
1107
        internal struct Win32Point
1108
        {
1109
            public Int32 X;
1110
            public Int32 Y;
1111
        };
1112
        /*
1113
       public string symbol_id = null;
1114
       public long symbol_group_id;
1115
       public int symbol_SelectedIndex;
1116
       public ImageSource symbol_img;
1117
       public string symbol_Data = null;
1118
       public void symboldata(string id, long group_id, int SelectedIndex, string Data_, ImageSource img)
1119
       {
1120
           PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, new Point(zoomAndPanCanvas.ActualWidth / 2,
1121
               zoomAndPanCanvas.ActualHeight / 2));
1122

    
1123

    
1124
               if (this._dragdropWindow != null)
1125
               {
1126
                   this._dragdropWindow.Close();
1127
                   this._dragdropWindow = null;
1128
               }
1129

    
1130
               symbol_id = id;
1131
               symbol_group_id = group_id;
1132
               symbol_SelectedIndex = SelectedIndex;
1133
               symbol_Data = Data_;
1134
               symbol_img = img;
1135

    
1136

    
1137
               CreateDragDropWindow2(img);
1138
              
1139
    }
1140

    
1141
    private void CreateDragDropWindow2(ImageSource image)
1142
        {
1143
            this._dragdropWindow = new Window();
1144
            _dragdropWindow.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1145
            _dragdropWindow.WindowStyle = WindowStyle.None;
1146
            _dragdropWindow.AllowsTransparency = true;           
1147
            _dragdropWindow.AllowDrop = false;
1148
            _dragdropWindow.Background = null;
1149
            _dragdropWindow.IsHitTestVisible = false;
1150
            _dragdropWindow.SizeToContent = SizeToContent.WidthAndHeight;
1151
            _dragdropWindow.Topmost = true;
1152
            _dragdropWindow.ShowInTaskbar = false;
1153
            
1154
            Rectangle r = new Rectangle();
1155
            r.Width = image.Width;
1156
            r.Height = image.Height;
1157
            r.Opacity = 0.5;            
1158
            r.Fill = new ImageBrush(image);
1159
            this._dragdropWindow.Content = r;
1160

    
1161
            Win32Point w32Mouse = new Win32Point();
1162
            GetCursorPos(ref w32Mouse);
1163

    
1164
            //w32Mouse.X = getCurrentPoint.X;
1165
            this._dragdropWindow.Left = w32Mouse.X - (image.Width / 2);
1166
            this._dragdropWindow.Top = w32Mouse.Y - (image.Height / 2); 
1167
            this._dragdropWindow.Show();
1168
        }
1169
         */
1170
        private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e)
1171
        {
1172
            if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
1173
            {
1174
                if (!floatingTip.IsOpen) { floatingTip.IsOpen = true; }
1175

    
1176
                Point currentPos = e.GetPosition(rect);
1177

    
1178
                floatingTip.HorizontalOffset = currentPos.X + 20;
1179
                floatingTip.VerticalOffset = currentPos.Y;
1180
            }
1181

    
1182
            getCurrentPoint = e.GetPosition(drawingRotateCanvas);
1183
            
1184
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1185
            {
1186
                SetCursor();
1187
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1188
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1189

    
1190
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1191
                zoomAndPanControl.ContentOffsetX -= dragOffset.X;
1192
                zoomAndPanControl.ContentOffsetY -= dragOffset.Y;
1193

    
1194
                if (Sync.IsChecked)
1195
                {
1196
                    ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
1197
                    ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
1198
                }
1199
            }
1200

    
1201
            if (mouseHandlingMode == MouseHandlingMode.Drawing && currentControl != null)
1202
            {
1203
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1204
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1205
                SetCursor();
1206

    
1207
                if (currentControl != null)
1208
                {
1209
                    double moveX = currentCanvasDrawingMouseMovePoint.X - canvasDrawingMouseDownPoint.X;
1210
                    double moveY = currentCanvasDrawingMouseMovePoint.Y - canvasDrawingMouseDownPoint.Y;
1211
                    //강인구 추가
1212
                    currentControl.Opacity = ViewerDataModel.Instance.ControlOpacity;
1213

    
1214
                    if ((currentControl as IPath) != null)
1215
                    {
1216
                        (currentControl as IPath).LineSize = ViewerDataModel.Instance.LineSize;
1217
                    }
1218
                    if ((currentControl as LineControl) != null)
1219
                    {
1220
                        (currentControl as LineControl).Interval = ViewerDataModel.Instance.Interval;
1221
                    }
1222

    
1223
                    if ((currentControl as IShapeControl) != null)
1224
                    {
1225
                        (currentControl as IShapeControl).Paint = ViewerDataModel.Instance.paintSet;
1226
                    }
1227
                    if ((currentControl as TextControl) != null)
1228
                    {
1229
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1230
                        {
1231
                            (currentControl as TextControl).TextStyle = FontStyles.Italic;
1232
                        }
1233
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1234
                        {
1235
                            (currentControl as TextControl).TextWeight = FontWeights.Bold;
1236
                        }
1237
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1238
                        {
1239
                            (currentControl as TextControl).UnderLine = TextDecorations.Underline;
1240
                        }
1241
                    }
1242
                    else if ((currentControl as ArrowTextControl) != null)
1243
                    {
1244
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnItalic.IsChecked == true)
1245
                        {
1246
                            (currentControl as ArrowTextControl).TextStyle = FontStyles.Italic;
1247
                        }
1248
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnBold.IsChecked == true)
1249
                        {
1250
                            (currentControl as ArrowTextControl).TextWeight = FontWeights.Bold;
1251
                        }
1252
                        if (this.ParentOfType<MainWindow>().dzTopMenu.btnUnderLine.IsChecked == true)
1253
                        {
1254
                            (currentControl as ArrowTextControl).UnderLine = TextDecorations.Underline;
1255
                        }
1256
                    }
1257
                    else if ((currentControl as RectCloudControl) != null)
1258
                    {
1259
                        (currentControl as RectCloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1260
                    }
1261
                    else if ((currentControl as CloudControl) != null)
1262
                    {
1263
                        (currentControl as CloudControl).ArcLength = ViewerDataModel.Instance.ArcLength;
1264
                    }
1265

    
1266
                    switch (controlType)
1267
                    {
1268
                        case (ControlType.Coordinate):
1269
                            {
1270
                                var control = currentControl as CoordinateControl;
1271
                                if (control != null)
1272
                                {
1273
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1274
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1275
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1276
                                }
1277
                            }
1278
                            break;
1279
                        case (ControlType.InsideWhite):
1280
                            {
1281
                                var control = currentControl as InsideWhiteControl;
1282
                                if (control != null)
1283
                                {
1284
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1285
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1286
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1287
                                    control.Paint = PaintSet.Fill;
1288
                                }
1289
                            }
1290
                            break;
1291
                        case ControlType.OverlapWhite:
1292
                            {
1293
                                var control = currentControl as OverlapWhiteControl;
1294
                                if (control != null)
1295
                                {
1296
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1297
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1298
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1299
                                    control.Paint = PaintSet.Fill;
1300
                                }
1301
                            }
1302
                            break;
1303
                        case ControlType.ClipWhite:
1304
                            {
1305
                                var control = currentControl as ClipWhiteControl;
1306
                                if (control != null)
1307
                                {
1308
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1309
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1310
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1311
                                    control.Paint = PaintSet.Fill;
1312
                                }
1313
                            }
1314
                            break;
1315
                        case ControlType.RectCloud:
1316
                            {
1317
                                var control = currentControl as RectCloudControl;
1318
                                if (control != null)
1319
                                {
1320
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1321
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1322
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1323
                                }
1324
                            }
1325
                            break;
1326
                        case ControlType.SingleLine:
1327
                        case ControlType.CancelLine:
1328
                        case ControlType.ArrowLine:
1329
                        case ControlType.TwinLine:
1330
                        case ControlType.DimLine:
1331
                            {
1332
                                var control = currentControl as LineControl;
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.ArcLine:
1342
                            {
1343
                                var control = currentControl as ArcControl;
1344
                                if (control != null)
1345
                                {
1346
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1347
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1348
                                }
1349
                            }
1350
                            break;
1351

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

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

    
1374
                        case ControlType.Circle:
1375
                            {
1376
                                if (currentControl != null)
1377
                                {
1378
                                    currentControl.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1379
                                    (currentControl as CircleControl).DashSize = ViewerDataModel.Instance.DashSize;
1380
                                    (currentControl as CircleControl).Paint = ViewerDataModel.Instance.paintSet;
1381
                                }
1382
                            }
1383
                            break;
1384

    
1385
                        case ControlType.PolygonCloud:
1386
                            {
1387
                                var control = currentControl as CloudControl;
1388
                                if (control != null)
1389
                                {
1390
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1391
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1392
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1393
                                }
1394
                            }
1395
                            break;
1396

    
1397
                        case ControlType.Triangle:
1398
                            {
1399
                                var control = currentControl as TriControl;
1400
                                if (control != null)
1401
                                {
1402
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1403
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1404
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1405
                                }
1406
                            }
1407
                            break;
1408

    
1409
                        case ControlType.ImgControl:
1410
                            {
1411
                                var control = currentControl as ImgControl;
1412
                                if (control != null)
1413
                                {
1414
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1415
                                }
1416
                            }
1417
                            break;
1418

    
1419
                        case ControlType.Date:
1420
                            {
1421
                                var control = currentControl as DateControl;
1422
                                if (control != null)
1423
                                {
1424
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1425
                                }
1426
                            }
1427
                            break;
1428

    
1429
                        case ControlType.ArrowTextControl:
1430
                        case ControlType.ArrowTransTextControl:
1431
                        case ControlType.ArrowTextBorderControl:
1432
                        case ControlType.ArrowTransTextBorderControl:
1433
                        case ControlType.ArrowTextCloudControl:
1434
                        case ControlType.ArrowTransTextCloudControl:
1435
                            {
1436
                                var control = currentControl as ArrowTextControl;
1437
                                if (control != null)
1438
                                {
1439
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1440
                                }
1441
                            }
1442
                            break;
1443
                        case ControlType.PolygonControl:
1444
                        case ControlType.ChainLine:
1445
                            {
1446
                                var control = currentControl as PolygonControl;
1447
                                if (control != null)
1448
                                {
1449
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1450
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1451
                                    control.Paint = ViewerDataModel.Instance.paintSet;
1452
                                }
1453
                            }
1454
                            break;
1455
                        case ControlType.Sign:
1456
                            {
1457
                                var control = currentControl as SignControl;
1458
                                if (control != null)
1459
                                {
1460
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1461
                                }
1462
                            }
1463
                            break;
1464
                        case ControlType.Symbol:
1465
                            {
1466
                                var control = currentControl as SymControl;
1467
                                if (control != null)
1468
                                {
1469
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1470
                                }
1471
                            }
1472
                            break;
1473
                        case ControlType.Stamp:
1474
                            {
1475
                                var control = currentControl as SymControlN;
1476
                                if (control != null)
1477
                                {
1478
                                    if (control.STAMP != null)
1479
                                    {
1480
                                        control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1481
                                    }
1482
                                    else
1483
                                    {
1484
                                        currentControl = null;
1485
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1486
                                        DialogMessage_Alert("Approved Stamp 가 등록되어 있지 않습니다. \n관리자에게 문의하세요.", "안내");
1487
                                    }
1488
                                }                                    
1489
                            }
1490
                            break;
1491
                        case ControlType.Rectangle:
1492
                        case ControlType.Mark:
1493
                            {
1494
                                var control = currentControl as RectangleControl;
1495
                                if (control != null)
1496
                                {
1497
                                    control.OnCreatingMouseMove(currentCanvasDrawingMouseMovePoint, ViewerDataModel.Instance.checkAxis, ViewerDataModel.Instance.IsPressShift);
1498
                                    if(control.ControlType == ControlType.Mark) control.Paint = PaintSet.Fill;
1499
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
1500
                                }
1501
                            }
1502
                            break;
1503
                        case ControlType.PenControl:
1504
                            {
1505
                                stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1506
                                //inkBoard.Strokes.Add(stroke);
1507
                            }
1508
                            break;
1509
                        default:
1510
                            break;
1511
                    }
1512
                }
1513
            }
1514
            else if(mouseHandlingMode == MouseHandlingMode.Drawing && e.LeftButton == MouseButtonState.Pressed)
1515
            {
1516
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas);
1517
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas);
1518
                SetCursor();
1519
                if (currentControl == null)
1520
                {
1521
                    switch (controlType)
1522
                    {
1523
                        case ControlType.PenControl:
1524
                            {
1525
                                if (inkBoard.Tag.ToString() == "Ink")
1526
                                {
1527
                                    stroke.StylusPoints.Add(new StylusPoint(currentCanvasDrawingMouseMovePoint.X, currentCanvasDrawingMouseMovePoint.Y));
1528
                                }
1529
                                else if (inkBoard.Tag.ToString() == "EraseByPoint")
1530
                                {
1531
                                    RemovePointStroke(currentCanvasDrawingMouseMovePoint);
1532
                                }
1533
                                else if (inkBoard.Tag.ToString() == "EraseByStroke")
1534
                                {
1535
                                    RemoveLineStroke(currentCanvasDrawingMouseMovePoint);
1536
                                }
1537

    
1538
                                //inkBoard.Strokes.Add(stroke);
1539
                            }
1540
                            break;
1541
                    }
1542
                    return;
1543
                }
1544
            }
1545
            else if (((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Selecting) || 
1546
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.Capture) || 
1547
                ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragZoom))
1548
            {
1549
                Point curMouseDownPoint = e.GetPosition(drawingRotateCanvas);
1550

    
1551
                if (isDraggingSelectionRect)
1552
                {
1553
                    UpdateDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1554
                    e.Handled = true;
1555
                }
1556
                else if (isLeftMouseButtonDownOnWindow)
1557
                {
1558
                    var dragDelta = curMouseDownPoint - canvasDrawingMouseDownPoint;
1559
                    double dragDistance = Math.Abs(dragDelta.Length);
1560

    
1561
                    if (dragDistance > DragThreshold)
1562
                    {
1563
                        isDraggingSelectionRect = true;
1564
                        InitDragSelectionRect(canvasDrawingMouseDownPoint, curMouseDownPoint);
1565
                    }
1566

    
1567
                    e.Handled = true;
1568
                }
1569

    
1570
                if (canvasDrawingMouseDownPoint == curMouseDownPoint)
1571
                {
1572
                }
1573
                else
1574
                {
1575
                    e.Handled = true;
1576
                }
1577
            }
1578
            /*
1579
            else if ((e.LeftButton == MouseButtonState.Pressed) && mouseHandlingMode == MouseHandlingMode.DragSymbol)
1580
            { //symbol      
1581
                if(_dragdropWindow != null)
1582
                {
1583
                    Win32Point w32Mouse = new Win32Point();
1584
                    GetCursorPos(ref w32Mouse);
1585

    
1586
                    this._dragdropWindow.Left = w32Mouse.X - (symbol_img.Width / 2);
1587
                    this._dragdropWindow.Top = w32Mouse.Y - (symbol_img.Height / 2);
1588
                }                
1589
            }
1590
            */
1591
            else if ((e.LeftButton == MouseButtonState.Released) && (e.MiddleButton == MouseButtonState.Released) && 
1592
                (e.RightButton == MouseButtonState.Released) && ViewerDataModel.Instance.MarkupControls_USER.Count > 0)
1593
            {
1594
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
1595
                if(control != null)
1596
                {
1597
                    this.cursor = Cursors.Hand;
1598
                    SetCursor();
1599
                }
1600
                else
1601
                {
1602
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1603
                    SetCursor();
1604
                }
1605
            }
1606
            else
1607
            {
1608
            }
1609
        }
1610

    
1611
        private void zoomAndPanControl2_MouseMove(object sender, MouseEventArgs e)
1612
        {
1613
            if ((e.MiddleButton == MouseButtonState.Pressed) || (e.RightButton == MouseButtonState.Pressed))
1614
            {
1615
                SetCursor();
1616
                Point currentCanvasDrawingMouseMovePoint = e.GetPosition(drawingRotateCanvas2);
1617
                Point currentCanvasZoomPanningMouseMovePoint = e.GetPosition(zoomAndPanCanvas2);
1618

    
1619
                Vector dragOffset = currentCanvasZoomPanningMouseMovePoint - canvasZoommovingMouseDownPoint;
1620

    
1621
                ViewerDataModel.Instance.Sync_ContentOffsetX -= dragOffset.X;
1622
                ViewerDataModel.Instance.Sync_ContentOffsetY -= dragOffset.Y;
1623

    
1624
                if (Sync.IsChecked)
1625
                {
1626
                    zoomAndPanControl.ContentOffsetX = ViewerDataModel.Instance.Sync_ContentOffsetX;
1627
                    zoomAndPanControl.ContentOffsetY = ViewerDataModel.Instance.Sync_ContentOffsetY;
1628
                }
1629
            }
1630
        }
1631

    
1632
        private List<CommentUserInfo> hitList = new List<CommentUserInfo>();
1633

    
1634
        private EllipseGeometry hitArea = new EllipseGeometry();
1635

    
1636
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
1637
        {
1638
            IsDrawing = false;
1639

    
1640
            if (mouseHandlingMode != MouseHandlingMode.None)
1641
            {
1642
                if (mouseHandlingMode == MouseHandlingMode.Drawing)
1643
                {
1644
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1645

    
1646
                    SetCursor();
1647

    
1648
                    switch (controlType)
1649
                    {
1650
                        case ControlType.None:
1651
                            break;
1652
                        case ControlType.Rectangle:
1653
                            {
1654

    
1655
                            }
1656
                            break;
1657
                        case ControlType.PenControl:
1658
                            {
1659

    
1660
                            }
1661
                            break;
1662
                        default:
1663
                            break;
1664
                    }                    
1665
                }
1666
                else if (mouseHandlingMode == MouseHandlingMode.Selecting && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.Capture && e.ChangedButton == MouseButton.Left || mouseHandlingMode == MouseHandlingMode.DragZoom && e.ChangedButton == MouseButton.Left)
1667
                {
1668
                    if (isLeftMouseButtonDownOnWindow)
1669
                    {
1670
                        bool wasDragSelectionApplied = false;
1671

    
1672
                        if (isDraggingSelectionRect)
1673
                        {
1674
                            if (mouseHandlingMode == MouseHandlingMode.Capture && controlType == ControlType.ImgControl)
1675
                            {
1676
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1677
                                mouseHandlingMode = MouseHandlingMode.None;
1678
                                Point endPoint = e.GetPosition(zoomAndPanCanvas);
1679
                                symbolselectindex = symbolPanel_Instance.RadTab.SelectedIndex;
1680
                                Set_Symbol_Capture(endPoint);
1681
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1682
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;                                
1683
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1684
                            }
1685
                            else if (mouseHandlingMode == MouseHandlingMode.Capture)
1686
                            {
1687
                                dragCaptureBorder.Visibility = Visibility.Collapsed;
1688
                                mouseHandlingMode = MouseHandlingMode.None;
1689
                                Set_Capture();
1690

    
1691
                                ViewerDataModel.Instance.ViewVisible = Visibility.Collapsed;
1692
                                ViewerDataModel.Instance.ViewVisible = Visibility.Visible;
1693
                                ViewerDataModel.Instance.Capture_Opacity = 0;
1694
                            }
1695
                            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1696
                            {
1697
                                ApplyDragSelectionRect();
1698
                            }
1699
                            else
1700
                            {
1701
                                double x = Canvas.GetLeft(dragZoomBorder);
1702
                                double y = Canvas.GetTop(dragZoomBorder);
1703
                                double width = dragZoomBorder.Width;
1704
                                double height = dragZoomBorder.Height;
1705
                                Rect dragRect = new Rect(x, y, width, height);
1706

    
1707
                                ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ZoomTo(dragRect);
1708

    
1709
                                dragZoomBorder.Visibility = Visibility.Collapsed;
1710
                            }
1711

    
1712
                            isDraggingSelectionRect = false;
1713
                            e.Handled = true;
1714
                            wasDragSelectionApplied = true;
1715
                        }
1716

    
1717
                        if (isLeftMouseButtonDownOnWindow)
1718
                        {
1719
                            isLeftMouseButtonDownOnWindow = false;
1720
                            this.ReleaseMouseCapture();
1721
                            e.Handled = true;
1722
                        }
1723

    
1724
                        if (!wasDragSelectionApplied)
1725
                        {
1726
                            init();
1727
                        }
1728
                    }
1729
                }
1730
                else if (e.RightButton == MouseButtonState.Pressed)
1731
                {
1732
                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1733
                    SetCursor();
1734
                }
1735

    
1736
                zoomAndPanControl.ReleaseMouseCapture();
1737

    
1738

    
1739
                e.Handled = true;
1740
            }
1741
            else
1742
            {
1743
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1744
                SetCursor();
1745
            }
1746

    
1747
            ///mouseButtonDown = MouseButton.Left;
1748
            //controlType = ControlType.SingleLine;
1749
        }
1750

    
1751
        public void Set_Symbol_Capture(Point endPoint)
1752
        {       
1753
            double x = canvasDrawingMouseDownPoint.X;
1754
            double y = canvasDrawingMouseDownPoint.Y;
1755
            if(x > endPoint.X)
1756
            {
1757
                x = endPoint.X;
1758
                y = endPoint.Y;
1759
            }
1760

    
1761
            double width = dragCaptureBorder.Width;
1762
            double height = dragCaptureBorder.Height;
1763

    
1764
            canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
1765

    
1766
            if (x < 0)
1767
            {
1768
                width += x;
1769
                x = 0;
1770
            }
1771
            if (y < 0)
1772
            {
1773
                height += y;
1774
                y = 0;
1775

    
1776
                width = (int)canvasImage.PixelWidth - x;
1777
            }
1778
            if (x + width > canvasImage.PixelWidth)
1779
            {
1780
                width = (int)canvasImage.PixelWidth - x;
1781
            }
1782
            if (y + height > canvasImage.PixelHeight)
1783
            {
1784
                height = (int)canvasImage.PixelHeight - y;
1785
            }
1786
            var rect = new Int32Rect((int)x, (int)y, (int)width, (int)height);
1787

    
1788
            string uri = "";
1789
            if (userData.COMPANY != "EXT")
1790
            {
1791
                uri = String.Format(CommonLib.Common.GetConfigString("mainServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO,
1792
                    (Convert.ToInt32(_ViewInfo.DocumentItemID) / 100).ToString(), _ViewInfo.DocumentItemID, Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1793
            }
1794
            else
1795
            {
1796
                uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, _ViewInfo.DocumentItemID,
1797
                    Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber);
1798
            }
1799

    
1800
            var defaultBitmapImage = new BitmapImage();
1801
            defaultBitmapImage.BeginInit();
1802
            defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
1803
            defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
1804
            defaultBitmapImage.UriSource = new Uri(uri);
1805
            defaultBitmapImage.EndInit();
1806

    
1807
            //GC.Collect();
1808

    
1809
            if (defaultBitmapImage.IsDownloading)
1810
            {
1811
                defaultBitmapImage.DownloadCompleted += (ex, arg) =>
1812
                {
1813
                    defaultBitmapImage.Freeze();
1814
                    //GC.Collect();
1815
                    BitmapSource bs = new CroppedBitmap(defaultBitmapImage, rect);
1816
                    Save_Symbol_Capture(bs, (int)x, (int)y, (int)width, (int)height);
1817
                };
1818
            }
1819
        }
1820

    
1821
        private void zoomAndPanControl2_MouseUp(object sender, MouseButtonEventArgs e)
1822
        {
1823
            ///mouseButtonDown = MouseButton.Left;
1824
        }
1825

    
1826
        private void zoomAndPanControl_MouseLeave(object sender, MouseEventArgs e)
1827
        {
1828
            ///mouseButtonDown = MouseButton.Left;
1829
            //this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1830
        }
1831

    
1832
        private void zoomAndPanControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1833
        {
1834

    
1835
        }
1836

    
1837
        /// <summary>
1838
        /// select items by dragging
1839
        /// </summary>
1840
        private void ApplyDragSelectionRect()
1841
        {
1842
            dragSelectionBorder.Visibility = Visibility.Collapsed;
1843

    
1844
            double x = Canvas.GetLeft(dragSelectionBorder);
1845
            double y = Canvas.GetTop(dragSelectionBorder);
1846
            double width = dragSelectionBorder.Width;
1847
            double height = dragSelectionBorder.Height;
1848
            Boolean Flag = false;
1849
            List<MarkupToPDF.Common.CommentUserInfo> adornerSet = new List<MarkupToPDF.Common.CommentUserInfo>();
1850
            var Items = ViewerDataModel.Instance.MarkupControls_USER.Where(d => d.Visibility != Visibility.Hidden).ToList();
1851

    
1852
            Rect dragRect = new Rect(x, y, width, height);
1853
            ///dragRect.Inflate(width / 10, height / 10);
1854

    
1855
            foreach (var item in Items)
1856
            {
1857
                Flag = SelectionSet.Instance.SelectControl(item, dragRect);
1858

    
1859
                if (Flag)
1860
                {
1861
                    adornerSet.Add(item);
1862
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
1863
                    Control_Style(item);
1864
                }
1865
            }
1866
            if (adornerSet.Count > 0)
1867
            {
1868
                Controls.AdornerFinal final = new Controls.AdornerFinal(adornerSet);
1869
                SelectLayer.Children.Add(final);
1870
            }
1871
        }
1872

    
1873
        private void InitDragSelectionRect(Point pt1, Point pt2)
1874
        {
1875
            //캡쳐 중
1876
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1877
            {
1878
                dragCaptureBorder.Visibility = Visibility.Visible;
1879
            }
1880
            //선택 중
1881
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1882
            {
1883

    
1884
                dragSelectionBorder.Visibility = Visibility.Visible;
1885
            }
1886
            else
1887
            {
1888
                dragZoomBorder.Visibility = Visibility.Visible;
1889
            }
1890
            UpdateDragSelectionRect(pt1, pt2);
1891
        }
1892

    
1893
        /// <summary>
1894
        /// Update the position and size of the rectangle used for drag selection.
1895
        /// </summary>
1896
        private void UpdateDragSelectionRect(Point pt1, Point pt2)
1897
        {
1898
            double x, y, width, height;
1899

    
1900
            //
1901
            // Determine x,y,width and height of the rect inverting the points if necessary.
1902
            // 
1903

    
1904
            if (pt2.X < pt1.X)
1905
            {
1906
                x = pt2.X;
1907
                width = pt1.X - pt2.X;
1908
            }
1909
            else
1910
            {
1911
                x = pt1.X;
1912
                width = pt2.X - pt1.X;
1913
            }
1914

    
1915
            if (pt2.Y < pt1.Y)
1916
            {
1917
                y = pt2.Y;
1918
                height = pt1.Y - pt2.Y;
1919
            }
1920
            else
1921
            {
1922
                y = pt1.Y;
1923
                height = pt2.Y - pt1.Y;
1924
            }
1925

    
1926
            //
1927
            // Update the coordinates of the rectangle used for drag selection.
1928
            //
1929
            //캡쳐 중
1930
            if (mouseHandlingMode == MouseHandlingMode.Capture)
1931
            {
1932
                Canvas.SetLeft(dragCaptureBorder, x);
1933
                Canvas.SetTop(dragCaptureBorder, y);
1934
                dragCaptureBorder.Width = width;
1935
                dragCaptureBorder.Height = height;
1936
            }
1937
            //선택 중
1938
            else if (mouseHandlingMode == MouseHandlingMode.Selecting)
1939
            {
1940
                Canvas.SetLeft(dragSelectionBorder, x);
1941
                Canvas.SetTop(dragSelectionBorder, y);
1942
                dragSelectionBorder.Width = width;
1943
                dragSelectionBorder.Height = height;
1944
            }
1945
            else
1946
            {
1947
                Canvas.SetLeft(dragZoomBorder, x);
1948
                Canvas.SetTop(dragZoomBorder, y);
1949
                dragZoomBorder.Width = width;
1950
                dragZoomBorder.Height = height;
1951
            }
1952
        }
1953

    
1954
        private void drawingPannelRotate(double angle)
1955
        {
1956
            Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
1957
            rotate.Angle = angle;
1958
            var rotationNum = Math.Abs((rotate.Angle / 90));
1959

    
1960
            if (angle == 90 || angle == 270)
1961
            {
1962
                double emptySize = zoomAndPanCanvas.Width;
1963
                zoomAndPanCanvas.Width = zoomAndPanCanvas.Height;
1964
                zoomAndPanCanvas.Height = emptySize;
1965
            }
1966
            if (angle == 0)
1967
            {
1968
                translate.X = 0;
1969
                translate.Y = 0;
1970
            }
1971
            else if (angle == 90)
1972
            {
1973
                translate.X = zoomAndPanCanvas.Width;
1974
                translate.Y = 0;
1975
            }
1976
            else if (angle == 180)
1977
            {
1978
                translate.X = zoomAndPanCanvas.Width;
1979
                translate.Y = zoomAndPanCanvas.Height;
1980
            }
1981
            else
1982
            {
1983
                translate.X = 0;
1984
                translate.Y = zoomAndPanCanvas.Height;
1985
            }
1986

    
1987
            zoomAndPanControl.RotationAngle = rotate.Angle;
1988

    
1989

    
1990
            if (!testPanel2.IsHidden)
1991
            {
1992
                zoomAndPanControl2.RotationAngle = rotate.Angle;
1993
                zoomAndPanCanvas2.Width = zoomAndPanCanvas.Width;
1994
                zoomAndPanCanvas2.Height = zoomAndPanCanvas.Height;
1995
            }
1996

    
1997
            ViewerDataModel.Instance.ContentWidth = zoomAndPanCanvas.Width;
1998
            ViewerDataModel.Instance.ContentHeight = zoomAndPanCanvas.Height;
1999
            ViewerDataModel.Instance.AngleOffsetX = translate.X;
2000
            ViewerDataModel.Instance.AngleOffsetY = translate.Y;
2001
            ViewerDataModel.Instance.Angle = rotate.Angle;
2002
        }
2003

    
2004
        private void syncPannelRotate(double angle)
2005
        {
2006
            //Logger.sendCheckLog("pageNavigator_PageChanging_drawingPannelRotate Setting", 1);
2007
            rotate.Angle = angle;
2008
            var rotationNum = Math.Abs((rotate.Angle / 90));
2009

    
2010
            if (angle == 90 || angle == 270)
2011
            {
2012
                double emptySize = zoomAndPanCanvas2.Width;
2013
                zoomAndPanCanvas2.Width = zoomAndPanCanvas2.Height;
2014
                zoomAndPanCanvas2.Height = emptySize;
2015
            }
2016
            if (angle == 0)
2017
            {
2018
                translate2.X = 0;
2019
                translate2.Y = 0;
2020
            }
2021
            else if (angle == 90)
2022
            {
2023
                translate2.X = zoomAndPanCanvas2.Width;
2024
                translate2.Y = 0;
2025
            }
2026
            else if (angle == 180)
2027
            {
2028
                translate2.X = zoomAndPanCanvas2.Width;
2029
                translate2.Y = zoomAndPanCanvas2.Height;
2030
            }
2031
            else
2032
            {
2033
                translate2.X = 0;
2034
                translate2.Y = zoomAndPanCanvas2.Height;
2035
            }
2036

    
2037
            zoomAndPanControl2.RotationAngle = rotate.Angle;
2038
        }
2039

    
2040
        public void PlaceImageSymbol(string id, long group_id, int SelectedIndex, Point canvasZoomPanningMouseDownPoint)
2041
        {
2042
            string Data_ = "";
2043

    
2044
            try
2045
            {
2046
                Logger.sendReqLog("GetSymbolImageURL: ", id + "," + SelectedIndex, 1);
2047
                Data_ = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetSymbolImageURL(id, SelectedIndex);
2048
                if (Data_ != null || Data_ != "")
2049
                {
2050
                    Logger.sendResLog("GetSymbolImageURL", "TRUE", 1);
2051
                }
2052
                else
2053
                {
2054
                    Logger.sendResLog("GetSymbolImageURL", "FALSE", 1);
2055
                }
2056

    
2057
                //MARKUP_DATA_GROUP mARKUP_DATA_GROUP = new MARKUP_DATA_GROUP
2058
                //{
2059
                //    SYMBOL_ID = id,//InnerItem.Symbol_ID
2060
                //    STATE = 0,
2061
                //};
2062
                if (Data_ != null)
2063
                {
2064
                    Image img = new Image();
2065
                    //img.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(Data_));
2066
                    if (Data_.Contains(".svg"))
2067
                    {
2068
                        byte[] imageData = null;
2069
                        DrawingImage image = null;
2070
                        using (System.Net.WebClient web = new System.Net.WebClient())
2071
                        {
2072
                            imageData = web.DownloadData(new Uri(Data_));
2073
                            System.IO.Stream stream = new System.IO.MemoryStream(imageData);
2074
                            image = SvgReader.Load(stream);
2075
                        }
2076
                        img.Source = image;
2077
                    }
2078
                    else
2079
                    {
2080
                        img.Source = new BitmapImage(new Uri(Data_));
2081
                    }
2082

    
2083
                    var currentControl = new MarkupToPDF.Controls.Etc.ImgControl
2084
                    {
2085
                        PointSet = new List<Point>(),
2086
                        FilePath = Data_,
2087
                        ImageData = img.Source,
2088
                        StartPoint = canvasZoomPanningMouseDownPoint,
2089
                        EndPoint = new Point(canvasZoomPanningMouseDownPoint.X + img.Source.Width, 
2090
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height),
2091
                        TopRightPoint = new Point(canvasZoomPanningMouseDownPoint.X+img.Source.Width,
2092
                        canvasZoomPanningMouseDownPoint.Y),
2093
                        LeftBottomPoint = new Point(canvasZoomPanningMouseDownPoint.X,
2094
                        canvasZoomPanningMouseDownPoint.Y + img.Source.Height)
2095
                    };
2096

    
2097
                    currentControl.PointSet = new List<Point>
2098
                                        {
2099
                                            currentControl.StartPoint,
2100
                                            currentControl.LeftBottomPoint,
2101
                                            currentControl.EndPoint,
2102
                                            currentControl.TopRightPoint,
2103
                                        };
2104
                    Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2105
                    UndoData = new Undo_data()
2106
                    {
2107
                        IsUndo = false,
2108
                        Event = Event_Type.Create,
2109
                        EventTime = DateTime.Now,
2110
                        Markup_List = new List<Multi_Undo_data>()
2111
                    };
2112
                    ViewerDataModel.Instance.UndoDataList.Where(data1 => data1.IsUndo == true).ToList().ForEach(i =>
2113
                    {
2114
                        ViewerDataModel.Instance.UndoDataList.Remove(i);
2115
                    });
2116

    
2117
                    //multi_Undo_Data = dzMainMenu.Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2118
                    multi_Undo_Data = Control_Style(currentControl as MarkupToPDF.Common.CommentUserInfo);
2119
                    UndoData.Markup_List.Add(multi_Undo_Data);
2120
                    ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2121

    
2122
                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl as MarkupToPDF.Common.CommentUserInfo);
2123
                    currentControl.CommentID = Commons.shortGuid();
2124
                    currentControl.SymbolID = id;
2125
                    currentControl.GroupID = group_id;
2126
                    currentControl.ApplyTemplate();
2127
                    currentControl.SetImage();
2128

    
2129
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl as MarkupToPDF.Common.CommentUserInfo);
2130
                    Controls.AdornerFinal final = new Controls.AdornerFinal(currentControl as MarkupToPDF.Common.CommentUserInfo);
2131
                    SelectLayer.Children.Add(final);
2132
                }
2133
            }
2134
            catch (Exception ex)
2135
            {
2136
                this.ParentOfType<MainWindow>().dzMainMenu.DialogMessage_Alert(ex.Message, "Error");
2137
            }
2138
        }
2139

    
2140
        private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e)
2141
        {            
2142
            var set_option = this.ParentOfType<MainWindow>().dzTopMenu.Parent.ChildrenOfType<RadNumericUpDown>().Where(item => item.IsKeyboardFocusWithin).FirstOrDefault();
2143
            if (set_option != null && !string.IsNullOrEmpty(set_option.ContentText))
2144
            {
2145
                set_option.Value = double.Parse(set_option.ContentText);
2146
            }
2147

    
2148
            ConvertInkControlToPolygon();
2149

    
2150
            ///TODO:
2151
            var text_item = ViewerDataModel.Instance.MarkupControls_USER.Where(data =>
2152
            (data as TextControl) != null && (data as TextControl).Text == "" || (data as ArrowTextControl) != null && (data as ArrowTextControl).ArrowText == "").FirstOrDefault();
2153

    
2154
            if (text_item != null && (currentControl as ArrowTextControl) == null)
2155
            {
2156
                ViewerDataModel.Instance.MarkupControls_USER.Remove(text_item);
2157
            }
2158
            /// up to here
2159

    
2160
            foreach (var arrow_text in ViewerDataModel.Instance.MarkupControls_USER)
2161
            {
2162
                if (arrow_text as ArrowTextControl != null)
2163
                {
2164
                    (arrow_text as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
2165
                }
2166
            }
2167

    
2168
            //if (currentControl != null)
2169
            {
2170
                var text_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as TextControl) != null && (data as TextControl).Base_TextBox.Visibility == Visibility.Visible).FirstOrDefault();
2171
                if (text_item_ != null)
2172
                {
2173
                    (text_item_ as TextControl).Base_TextBlock.Visibility = Visibility.Visible;
2174
                    (text_item_ as TextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2175
                    (text_item_ as TextControl).EnableEditing = false;
2176
                    currentControl = null;
2177
                }
2178

    
2179
                var Arrowtext_item_ = ViewerDataModel.Instance.MarkupControls_USER.Where(data => (data as ArrowTextControl) != null && (data as ArrowTextControl).IsEditingMode == true).FirstOrDefault();
2180
                if (Arrowtext_item_ != null && ((Arrowtext_item_ as ArrowTextControl).IsNew == false))
2181
                {
2182
                    (Arrowtext_item_ as ArrowTextControl).IsEditingMode = false;
2183
                    (Arrowtext_item_ as ArrowTextControl).Base_TextBox.Focusable = false;
2184
                    currentControl = null;
2185
                }
2186
            }
2187

    
2188
            double Ang = 0;                                          
2189
            if (rotate.Angle != 0)
2190
            {
2191
                Ang = 360 - rotate.Angle;
2192
            }
2193

    
2194
            if (e.OriginalSource is System.Windows.Controls.Image)
2195
            {
2196
                (e.OriginalSource as System.Windows.Controls.Image).Focus();
2197
            }
2198
            /*
2199
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.LeftButton == MouseButtonState.Pressed)
2200
            {                
2201
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2202
                if(symbol_id != null)
2203
                {
2204
                    PlaceImageSymbol(symbol_id, symbol_group_id, symbol_SelectedIndex, canvasZoomPanningMouseDownPoint);
2205
                }                
2206
            }
2207

    
2208
            if (mouseHandlingMode == MouseHandlingMode.DragSymbol && e.RightButton == MouseButtonState.Pressed)
2209
            {
2210
                if (this._dragdropWindow != null)
2211
                {
2212
                    this._dragdropWindow.Close();
2213
                    this._dragdropWindow = null;
2214
                    symbol_id = null;
2215
                }
2216
            }
2217
            */
2218

    
2219
            if (e.LeftButton == MouseButtonState.Pressed)
2220
            {
2221
                canvasDrawingMouseDownPoint = e.GetPosition(drawingRotateCanvas);
2222
                canvasZoomPanningMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2223

    
2224
                this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2225
                SetCursor();
2226

    
2227
                if (!ViewerDataModel.Instance.IsPressCtrl) SelectionSet.Instance.UnSelect(this);
2228
            }
2229

    
2230
            if (e.MiddleButton == MouseButtonState.Pressed)
2231
            {
2232
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2233
                cursor = Cursors.SizeAll;
2234
                SetCursor();
2235
            }
2236
            if (e.RightButton == MouseButtonState.Pressed)
2237
            {
2238
                canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas);
2239
                cursor = Cursors.SizeAll;
2240
                SetCursor();
2241
            }
2242
            else if (e.XButton1 == MouseButtonState.Pressed)
2243
            {
2244
                if (this.pageNavigator.CurrentPage.PageNumber + 1 <= this.pageNavigator.PageCount)
2245
                {
2246
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber + 1);
2247
                }
2248

    
2249
                //this.pageNavigator.GotoPage(this.pageNavigator._NextPage.PageNumber);
2250

    
2251
            }
2252
            else if (e.XButton2 == MouseButtonState.Pressed)
2253
            {
2254
                if (this.pageNavigator.CurrentPage.PageNumber > 1)
2255
                {
2256
                    this.pageNavigator.GotoPage(this.pageNavigator.CurrentPage.PageNumber - 1);
2257
                }
2258
            }
2259

    
2260
            if (e.LeftButton == MouseButtonState.Pressed && mouseHandlingMode != MouseHandlingMode.Drawing && currentControl == null)
2261
            {
2262
                if (mouseHandlingMode == MouseHandlingMode.Selecting)
2263
                {
2264
                    if (SelectLayer.Children.Count == 0)
2265
                    {
2266
                        isLeftMouseButtonDownOnWindow = true;
2267
                        mouseHandlingMode = MouseHandlingMode.Selecting;
2268
                    }
2269

    
2270
                    if (controlType == ControlType.None)
2271
                    {
2272
                        isLeftMouseButtonDownOnWindow = true;
2273
                    }
2274
                }
2275

    
2276
                /// 캡쳐 모드 설정
2277
                if (mouseHandlingMode == MouseHandlingMode.Capture)
2278
                {
2279
                    dragCaptureBorder.Visibility = Visibility.Visible;
2280
                    isLeftMouseButtonDownOnWindow = true;
2281
                }
2282

    
2283
                /// 줌 모드 설정
2284
                if (mouseHandlingMode == MouseHandlingMode.DragZoom)
2285
                {
2286
                    isLeftMouseButtonDownOnWindow = true;
2287
                }
2288

    
2289
                var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
2290
                if (control != null)
2291
                {
2292
                    AdornerFinal final = null;
2293

    
2294
                    if (!ViewerDataModel.Instance.IsPressCtrl)
2295
                    {
2296
                        /// 기존 selection 해제
2297
                        SelectionSet.Instance.UnSelect(this);
2298

    
2299
                        final = new AdornerFinal(control);
2300

    
2301
                        this.Control_Style(control);
2302

    
2303
                        if ((control as IPath) != null)
2304
                        {
2305
                            if ((control as IPath).LineSize != 0)
2306
                            {
2307
                                ViewerDataModel.Instance.LineSize = (control as IPath).LineSize;
2308
                            }
2309
                        }
2310
                        if ((control as IShapeControl) != null)
2311
                        {
2312
                            if ((control as IShapeControl).Paint == PaintSet.Hatch)
2313
                            {
2314
                                ViewerDataModel.Instance.checkHatchShape = true;
2315
                            }
2316
                            else if ((control as IShapeControl).Paint == PaintSet.Fill)
2317
                            {
2318
                                ViewerDataModel.Instance.checkFillShape = true;
2319
                            }
2320
                            else
2321
                            {
2322
                                ViewerDataModel.Instance.checkHatchShape = false;
2323
                                ViewerDataModel.Instance.checkFillShape = false;
2324
                            }
2325
                            ViewerDataModel.Instance.paintSet = (control as IShapeControl).Paint;
2326
                        }
2327

    
2328
                        ViewerDataModel.Instance.ControlOpacity = control.Opacity;
2329

    
2330
                        if ((control as TextControl) != null)
2331
                        {
2332
                            if(!((control as TextControl).EnableEditing)) {
2333
                                (control as TextControl).EnableEditing = true;
2334
                            }
2335

    
2336
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2337
                            {
2338
                                ViewerDataModel.Instance.checkTextStyle = true;
2339
                            }
2340
                            else
2341
                            {
2342
                                ViewerDataModel.Instance.checkTextStyle = false;
2343
                            }
2344

    
2345
                            if ((control as TextControl).TextStyle == FontStyles.Italic)
2346
                            {
2347
                                ViewerDataModel.Instance.checkTextStyle = true;
2348
                            }
2349
                            else
2350
                            {
2351
                                ViewerDataModel.Instance.checkTextStyle = false;
2352
                            }
2353
                            if ((control as TextControl).TextWeight == FontWeights.Bold)
2354
                            {
2355
                                ViewerDataModel.Instance.checkTextWeight = true;
2356
                            }
2357
                            else
2358
                            {
2359
                                ViewerDataModel.Instance.checkTextWeight = false;
2360
                            }
2361
                            if ((control as TextControl).UnderLine == TextDecorations.Underline)
2362
                            {
2363
                                ViewerDataModel.Instance.checkUnderLine = true;
2364
                            }
2365
                            else
2366
                            {
2367
                                ViewerDataModel.Instance.checkUnderLine = false;
2368
                            }
2369
                            ViewerDataModel.Instance.TextSize = (control as TextControl).TextSize;
2370
                            ViewerDataModel.Instance.checkHighlight = (control as TextControl).IsHighLight;
2371

    
2372
                        }
2373
                        else if ((control as ArrowTextControl) != null)
2374
                        {
2375
                            if (!((control as ArrowTextControl).EnableEditing))
2376
                            {
2377
                                (control as ArrowTextControl).EnableEditing = true;
2378
                            }
2379
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2380
                            {
2381
                                ViewerDataModel.Instance.checkTextStyle = true;
2382
                            }
2383
                            else
2384
                            {
2385
                                ViewerDataModel.Instance.checkTextStyle = false;
2386
                            }
2387

    
2388
                            if ((control as ArrowTextControl).TextStyle == FontStyles.Italic)
2389
                            {
2390
                                ViewerDataModel.Instance.checkTextStyle = true;
2391
                            }
2392
                            else
2393
                            {
2394
                                ViewerDataModel.Instance.checkTextStyle = false;
2395
                            }
2396
                            if ((control as ArrowTextControl).TextWeight == FontWeights.Bold)
2397
                            {
2398
                                ViewerDataModel.Instance.checkTextWeight = true;
2399
                            }
2400
                            else
2401
                            {
2402
                                ViewerDataModel.Instance.checkTextWeight = false;
2403
                            }
2404
                            if ((control as ArrowTextControl).UnderLine == TextDecorations.Underline)
2405
                            {
2406
                                ViewerDataModel.Instance.checkUnderLine = true;
2407
                            }
2408
                            else
2409
                            {
2410
                                ViewerDataModel.Instance.checkUnderLine = false;
2411
                            }
2412
                            ViewerDataModel.Instance.checkHighlight = (control as ArrowTextControl).isHighLight;
2413
                            ViewerDataModel.Instance.TextSize = (control as ArrowTextControl).TextSize;
2414
                        }
2415
                        else if ((control as RectCloudControl) != null)
2416
                        {
2417
                            ViewerDataModel.Instance.ArcLength = (control as RectCloudControl).ArcLength;
2418
                        }
2419
                        else if ((control as CloudControl) != null)
2420
                        {
2421
                            ViewerDataModel.Instance.ArcLength = (control as CloudControl).ArcLength;
2422
                        }
2423
                    }
2424
                    else
2425
                    {
2426
                        List<CommentUserInfo> comment = SelectionSet.Instance.SelectedItems;
2427
                        SelectionSet.Instance.UnSelect(this);
2428
                        comment.Add(control);
2429

    
2430
                        Control_Style(control);
2431

    
2432
                        final = new AdornerFinal(comment);
2433
                    }
2434

    
2435
                    if (final != null)
2436
                    {
2437
                        this.SelectLayer.Children.Add(final);
2438
                    }
2439
                }              
2440
            }
2441
            else if (mouseHandlingMode == MouseHandlingMode.Drawing)
2442
            {               
2443
                init();
2444
                //강인구 추가(우 클릭 일 경우 커서 변경 하지 않음)
2445
                if (cursor != Cursors.SizeAll)
2446
                {
2447
                    cursor = Cursors.Cross;
2448
                    SetCursor();
2449
                }
2450
                bool init_user = false;
2451
                foreach (var user in gridViewMarkup.Items)
2452
                {
2453
                    if ((user as MarkupInfoItem).UserID == App.ViewInfo.UserID)
2454
                    {
2455
                        init_user = true;
2456
                    }
2457
                }
2458
                if (init_user && gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() == null && e.LeftButton == MouseButtonState.Pressed)
2459
                {
2460
                    RadWindow.Alert(new DialogParameters
2461
                    {
2462
                        Owner = Application.Current.MainWindow,
2463
                        Theme = new VisualStudio2013Theme(),
2464
                        Header = "안내",
2465
                        Content = "기존의 코멘트가 존재합니다. 사용자 리스트에서 먼저 선택해주세요",
2466
                    });
2467
                    return;
2468
                }
2469
                else
2470
                {
2471
                    var item = gridViewMarkup.SelectedItems.Where(d => (d as MarkupInfoItem).UserID == App.ViewInfo.UserID).FirstOrDefault() as MarkupInfoItem;
2472
                    if (item != null)
2473
                    {
2474
                        App.Custom_ViewInfoId = item.MarkupInfoID;
2475
                    }
2476
                }
2477

    
2478
                switch (controlType)
2479
                {
2480
                    case ControlType.Coordinate:
2481
                        {
2482
                            if (e.LeftButton == MouseButtonState.Pressed)
2483
                            {
2484
                                if (currentControl is CoordinateControl)
2485
                                {
2486
                                    if (IsGetoutpoint((currentControl as CoordinateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2487
                                    {
2488
                                        return;
2489
                                    }
2490

    
2491
                                    CreateCommand.Instance.Execute(currentControl);
2492

    
2493
                                    currentControl = null;
2494
                                    this.cursor = Cursors.Arrow;
2495
                                }
2496
                                else
2497
                                {
2498
                                    this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
2499
                                    if (ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
2500
                                     && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).Count() > 0)
2501
                                    {
2502
                                        currentControl = null;
2503
                                        this.cursor = Cursors.Arrow;
2504
                                        Common.ViewerDataModel.Instance.SystemMain.DialogMessage_Alert("이미 해당 페이지의 도면 영역을 설정하셨습니다.", "Notice");
2505
                                        return;
2506
                                    }
2507
                                    else
2508
                                    {
2509
                                        currentControl = new CoordinateControl
2510
                                        {
2511
                                            Background = new SolidColorBrush(Colors.Black),
2512
                                            StartPoint = this.canvasDrawingMouseDownPoint,
2513
                                            ControlType = ControlType.Coordinate
2514
                                        };
2515

    
2516
                                        currentControl.CommentID = Commons.shortGuid();
2517
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2518
                                        currentControl.IsNew = true;
2519

    
2520
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2521

    
2522
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
2523
                                    }
2524
                                }
2525
                            }
2526
                        }
2527
                        break;
2528
                    case ControlType.InsideWhite:
2529
                        {
2530
                            if (e.LeftButton == MouseButtonState.Pressed)
2531
                            {
2532
                                if (currentControl is InsideWhiteControl)
2533
                                {
2534
                                    if (IsGetoutpoint((currentControl as InsideWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2535
                                    {
2536
                                        return;
2537
                                    }
2538

    
2539
                                    CreateCommand.Instance.Execute(currentControl);
2540

    
2541
                                    currentControl = null;
2542
                                    this.cursor = Cursors.Arrow;
2543
                                }
2544
                                else
2545
                                {
2546
                                    currentControl = new InsideWhiteControl
2547
                                    {
2548
                                        Background = new SolidColorBrush(Colors.Black),
2549
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2550
                                        ControlType = ControlType.InsideWhite
2551
                                    };
2552

    
2553
                                    currentControl.CommentID = Commons.shortGuid();
2554
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2555
                                    currentControl.IsNew = true;
2556
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2557

    
2558
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2559
                                }
2560
                            }
2561
                        }
2562
                        break;
2563
                    case ControlType.OverlapWhite:
2564
                        {
2565
                            if (e.LeftButton == MouseButtonState.Pressed)
2566
                            {
2567
                                if (currentControl is OverlapWhiteControl)
2568
                                {
2569
                                    if (IsGetoutpoint((currentControl as OverlapWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2570
                                    {
2571
                                        return;
2572
                                    }
2573

    
2574
                                    CreateCommand.Instance.Execute(currentControl);
2575

    
2576
                                    currentControl = null;
2577
                                    this.cursor = Cursors.Arrow;
2578
                                }
2579
                                else
2580
                                {
2581
                                    currentControl = new OverlapWhiteControl
2582
                                    {
2583
                                        Background = new SolidColorBrush(Colors.Black),
2584
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2585
                                        ControlType = ControlType.OverlapWhite
2586
                                    };
2587

    
2588
                                    currentControl.CommentID = Commons.shortGuid();
2589
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2590
                                    currentControl.IsNew = true;
2591
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2592

    
2593
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2594
                                }
2595
                            }
2596
                        }
2597
                        break;
2598
                    case ControlType.ClipWhite:
2599
                        {
2600
                            if (e.LeftButton == MouseButtonState.Pressed)
2601
                            {
2602
                                if (currentControl is ClipWhiteControl)
2603
                                {
2604
                                    if (IsGetoutpoint((currentControl as ClipWhiteControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2605
                                    {
2606
                                        return;
2607
                                    }
2608

    
2609
                                    CreateCommand.Instance.Execute(currentControl);
2610

    
2611
                                    currentControl = null;
2612
                                    this.cursor = Cursors.Arrow;
2613
                                }
2614
                                else
2615
                                {
2616
                                    currentControl = new ClipWhiteControl
2617
                                    {
2618
                                        Background = new SolidColorBrush(Colors.Black),
2619
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2620
                                        ControlType = ControlType.ClipWhite
2621
                                    };
2622

    
2623
                                    currentControl.CommentID = Commons.shortGuid();
2624
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2625
                                    currentControl.IsNew = true;
2626
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2627

    
2628
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2629
                                }
2630
                            }
2631
                        }
2632
                        break;
2633
                    case ControlType.Rectangle:
2634
                        {
2635
                            if (e.LeftButton == MouseButtonState.Pressed)
2636
                            {
2637
                                if (currentControl is RectangleControl)
2638
                                {
2639
                                    //20180906 LJY TEST IsRotationDrawingEnable
2640
                                    if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2641
                                    {
2642
                                        return;
2643
                                    }
2644

    
2645
                                    CreateCommand.Instance.Execute(currentControl);
2646
                                    currentControl = null;
2647
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2648
                                }
2649
                                else
2650
                                {
2651
                                    currentControl = new RectangleControl
2652
                                    {
2653
                                        Background = new SolidColorBrush(Colors.Black),
2654
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2655
                                        ControlType = ControlType.Rectangle
2656
                                    };
2657

    
2658
                                    currentControl.CommentID = Commons.shortGuid();
2659
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2660
                                    currentControl.IsNew = true;
2661
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2662

    
2663
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
2664
                                }
2665
                            }
2666
                        }
2667
                        break;
2668
                    case ControlType.RectCloud:
2669
                        {
2670
                            if (e.LeftButton == MouseButtonState.Pressed)
2671
                            {
2672
                                if (currentControl is RectCloudControl)
2673
                                {
2674
                                    //20180906 LJY TEST IsRotationDrawingEnable
2675
                                    if (IsGetoutpoint((currentControl as RectCloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2676
                                    {
2677
                                        return;
2678
                                    }
2679

    
2680
                                    CreateCommand.Instance.Execute(currentControl);
2681

    
2682
                                    currentControl = null;
2683
                                
2684
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2685
                                }
2686
                                else
2687
                                {
2688
                                    currentControl = new RectCloudControl
2689
                                    {
2690
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2691
                                        ControlType = ControlType.RectCloud,
2692
                                        Background = new SolidColorBrush(Colors.Black)
2693
                                    };
2694

    
2695
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2696
                                    currentControl.CommentID = Commons.shortGuid();
2697
                                    currentControl.IsNew = true;
2698
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2699
                                }
2700
                            }
2701
                        }
2702
                        break;
2703
                    case ControlType.Circle:
2704
                        {
2705
                            if (e.LeftButton == MouseButtonState.Pressed)
2706
                            {
2707
                                if (currentControl is CircleControl)
2708
                                {
2709
                                    //20180906 LJY TEST IsRotationDrawingEnable
2710
                                    if (IsGetoutpoint((currentControl as CircleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2711
                                    {
2712
                                        return;
2713
                                    }
2714

    
2715
                                    CreateCommand.Instance.Execute(currentControl);
2716

    
2717
                                    currentControl = null;
2718
                                }
2719
                                else
2720
                                {
2721
                                    currentControl = new CircleControl
2722
                                    {
2723
                                        StartPoint = this.canvasDrawingMouseDownPoint,
2724
                                        LeftBottomPoint = this.canvasDrawingMouseDownPoint,
2725
                                        Background = new SolidColorBrush(Colors.Black)
2726
                                    };
2727

    
2728
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2729
                                    currentControl.CommentID = Commons.shortGuid();
2730
                                    currentControl.IsNew = true;
2731
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2732
                                }
2733
                            }
2734
                        }
2735
                        break;
2736
                    case ControlType.Triangle:
2737
                        {
2738
                            if (e.LeftButton == MouseButtonState.Pressed)
2739
                            {
2740
                                if (currentControl is TriControl)
2741
                                {
2742
                                    var content = currentControl as TriControl;
2743
                                    if (content.MidPoint == new Point(0, 0))
2744
                                    {
2745
                                        content.MidPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
2746
                                    }
2747
                                    else
2748
                                    {
2749
                                        //20180906 LJY TEST IsRotationDrawingEnable
2750
                                        if (IsGetoutpoint((currentControl as TriControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2751
                                        {
2752
                                            return;
2753
                                        }
2754

    
2755
                                        CreateCommand.Instance.Execute(currentControl);
2756

    
2757
                                        currentControl = null;
2758
                                    }
2759
                                }
2760
                                else
2761
                                {
2762
                                    currentControl = new TriControl
2763
                                    {
2764
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2765
                                        Background = new SolidColorBrush(Colors.Black),
2766
                                    };
2767

    
2768
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2769
                                    currentControl.CommentID = Commons.shortGuid();
2770
                                    currentControl.IsNew = true;
2771
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2772
                                }
2773
                            }
2774
                        }
2775
                        break;
2776
                    case ControlType.CancelLine:
2777
                    case ControlType.SingleLine:
2778
                    case ControlType.ArrowLine:
2779
                    case ControlType.TwinLine:
2780
                    case ControlType.DimLine:
2781
                        {
2782
                            if (e.LeftButton == MouseButtonState.Pressed)
2783
                            {
2784
                                if (currentControl is LineControl)
2785
                                {
2786
                                    //20180906 LJY TEST IsRotationDrawingEnable
2787
                                    if (IsGetoutpoint((currentControl as LineControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2788
                                    {
2789
                                        return;
2790
                                    }
2791

    
2792
                                    CreateCommand.Instance.Execute(currentControl);
2793
                                    currentControl = null;
2794
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2795
                                }
2796
                                else
2797
                                {
2798
                                    currentControl = new LineControl
2799
                                    {
2800
                                        ControlType = this.controlType,
2801
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2802
                                        Background = new SolidColorBrush(Colors.Black)
2803
                                    };
2804

    
2805
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2806
                                    currentControl.CommentID = Commons.shortGuid();
2807
                                    currentControl.IsNew = true;
2808
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2809
                                    this.MainAngle.Visibility = Visibility.Visible;
2810
                                }
2811
                            }
2812
                        }
2813
                        break;
2814
                    case ControlType.PolygonControl:
2815
                        {
2816
                            if (currentControl is PolygonControl)
2817
                            {
2818
                                var control = currentControl as PolygonControl;
2819

    
2820
                                if (e.RightButton == MouseButtonState.Pressed)
2821
                                {
2822
                                    control.IsCompleted = true;
2823
                                }
2824

    
2825
                                if (!control.IsCompleted)
2826
                                {
2827
                                    control.PointSet.Add(control.EndPoint);
2828
                                }
2829
                                else
2830
                                {
2831
                                    //20180906 LJY TEST IsRotationDrawingEnable
2832
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2833
                                    {
2834
                                        return;
2835
                                    }
2836

    
2837
                                    var firstPoint = control.PointSet.First();
2838
                                    control.DashSize = ViewerDataModel.Instance.DashSize;
2839
                                    control.LineSize = ViewerDataModel.Instance.LineSize;
2840
                                    control.PointSet.Add(firstPoint);
2841

    
2842
                                    control.ApplyOverViewData();
2843

    
2844
                                    CreateCommand.Instance.Execute(currentControl);
2845
                                    control.UpdateControl();
2846
                                    currentControl = null;
2847
                                }
2848
                            }
2849
                            else
2850
                            {
2851
                                if (e.LeftButton == MouseButtonState.Pressed)
2852
                                {
2853
                                    currentControl = new PolygonControl
2854
                                    {
2855
                                        PointSet = new List<Point>(),
2856
                                    };
2857

    
2858
                                    var polygonControl = (currentControl as PolygonControl);
2859
                                    currentControl.CommentID = Commons.shortGuid();
2860
                                    currentControl.IsNew = true;
2861
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2862
                                    polygonControl.StartPoint = canvasDrawingMouseDownPoint;
2863
                                    polygonControl.EndPoint = canvasDrawingMouseDownPoint;
2864
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2865
                                    polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2866
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2867
                                    polygonControl.ApplyTemplate();
2868
                                    polygonControl.Visibility = Visibility.Visible;
2869
                                }
2870
                            }
2871
                        }
2872
                        break;
2873
                    case ControlType.ChainLine:
2874
                        {
2875
                            if (currentControl is PolygonControl)
2876
                            {
2877
                                var control = currentControl as PolygonControl;
2878

    
2879
                                if (e.RightButton == MouseButtonState.Pressed)
2880
                                {
2881
                                    //20180906 LJY TEST IsRotationDrawingEnable
2882
                                    if (IsGetoutpoint((currentControl as PolygonControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2883
                                    {
2884
                                        return;
2885
                                    }
2886

    
2887
                                    CreateCommand.Instance.Execute(currentControl);
2888

    
2889
                                    currentControl = null;
2890
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2891
                                    return;
2892
                                }
2893

    
2894
                                if (!control.IsCompleted)
2895
                                {
2896
                                    control.PointSet.Add(control.EndPoint);
2897
                                    this.MainAngle.Visibility = Visibility.Visible;
2898
                                }
2899
                            }
2900
                            else
2901
                            {
2902
                                if (e.LeftButton == MouseButtonState.Pressed)
2903
                                {
2904
                                    MainAngle.Visibility = Visibility.Visible;
2905
                                    currentControl = new PolygonControl
2906
                                    {
2907
                                        PointSet = new List<Point>(),
2908
                                        //강인구 추가(ChainLine일때는 채우기 스타일을 주지 않기 위해 설정)
2909
                                        ControlType = ControlType.ChainLine,
2910
                                        DashSize = ViewerDataModel.Instance.DashSize,
2911
                                        LineSize = ViewerDataModel.Instance.LineSize,
2912
                                        //PointC = new StylusPointSet()
2913
                                    };
2914

    
2915
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
2916
                                    //{
2917
                                        var polygonControl = (currentControl as PolygonControl);
2918
                                        currentControl.CommentID = Commons.shortGuid();
2919
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
2920
                                        currentControl.IsNew = true;
2921
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
2922
                                        //currentControl.OnApplyTemplate();
2923
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2924
                                        //polygonControl.PointC.pointSet.Add(canvasDrawingMouseDownPoint);
2925
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2926
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
2927
                                    //}
2928
                                }
2929
                            }
2930
                        }
2931
                        break;
2932
                    case ControlType.ArcLine:
2933
                        {
2934
                            if (e.LeftButton == MouseButtonState.Pressed)
2935
                            {
2936
                                if (currentControl is ArcControl)
2937
                                {
2938
                                    //20180906 LJY TEST IsRotationDrawingEnable
2939
                                    if (IsGetoutpoint((currentControl as ArcControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
2940
                                    {
2941
                                        return;
2942
                                    }
2943

    
2944
                                    CreateCommand.Instance.Execute(currentControl);
2945

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

    
2987
                                    CreateCommand.Instance.Execute(currentControl);
2988

    
2989
                                    currentControl = null;
2990
                                    this.MainAngle.Visibility = Visibility.Collapsed;
2991
                                }
2992
                                else
2993
                                {
2994
                                    currentControl = new ArrowArcControl
2995
                                    {
2996
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
2997
                                        Background = new SolidColorBrush(Colors.Black)
2998
                                    };
2999
                                    currentControl.CommentID = Commons.shortGuid();
3000
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3001
                                    currentControl.IsNew = true;
3002
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3003
                                    this.MainAngle.Visibility = Visibility.Visible;
3004
                                }
3005
                                //}
3006
                            }
3007
                            else if (e.RightButton == MouseButtonState.Pressed)
3008
                            {
3009
                                if (currentControl != null)
3010
                                {
3011
                                    (currentControl as ArrowArcControl).setClock();
3012
                                    (currentControl as ArrowArcControl).MidPoint = new Point(0, 0);
3013
                                    //(currentControl as ArcControl).ApplyTemplate();
3014
                                }
3015
                            }
3016
                        }
3017
                        break;
3018
                    case ControlType.ArrowMultiLine:
3019
                        {
3020
                            if (e.LeftButton == MouseButtonState.Pressed)
3021
                            {
3022
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3023
                                //{
3024

    
3025
                                    if (currentControl is ArrowControl_Multi)
3026
                                    {
3027
                                        var content = currentControl as ArrowControl_Multi;
3028
                                        if (content.MiddlePoint == new Point(0, 0))
3029
                                        {
3030
                                            if (ViewerDataModel.Instance.checkAxis || ViewerDataModel.Instance.IsPressShift)
3031
                                            {
3032
                                                content.MiddlePoint = content.EndPoint;
3033
                                            }
3034
                                            else
3035
                                            {
3036
                                                content.MiddlePoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y);
3037
                                            }
3038
                                        }
3039
                                        else
3040
                                        {
3041
                                            //20180906 LJY TEST IsRotationDrawingEnable
3042
                                            if (IsGetoutpoint((currentControl as ArrowControl_Multi).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3043
                                            {
3044
                                                return;
3045
                                            }
3046

    
3047
                                            CreateCommand.Instance.Execute(currentControl);
3048

    
3049
                                            currentControl = null;
3050
                                            this.MainAngle.Visibility = Visibility.Collapsed;
3051
                                        }
3052
                                    }
3053
                                    else
3054
                                    {
3055
                                        currentControl = new ArrowControl_Multi
3056
                                        {
3057
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3058
                                            Background = new SolidColorBrush(Colors.Black)
3059
                                        };
3060
                                        currentControl.CommentID = Commons.shortGuid();
3061
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3062
                                        currentControl.IsNew = true;
3063
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3064
                                        this.MainAngle.Visibility = Visibility.Visible;
3065
                                    }
3066
                                //}
3067
                            }
3068
                        }
3069
                        break;
3070
                    case ControlType.PolygonCloud:
3071
                        {
3072
                            if (currentControl is CloudControl)
3073
                            {
3074
                                var control = currentControl as CloudControl;
3075
                                if (e.RightButton == MouseButtonState.Pressed)
3076
                                {
3077
                                    control.IsCompleted = true;
3078
                                }
3079

    
3080
                                if (!control.IsCompleted)
3081
                                {
3082
                                    control.PointSet.Add(control.EndPoint);
3083
                                }
3084
                                else
3085
                                {
3086
                                    //20180906 LJY TEST IsRotationDrawingEnable
3087
                                    if (IsGetoutpoint((currentControl as CloudControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3088
                                    {
3089
                                        return;
3090
                                    }
3091

    
3092
                                    CreateCommand.Instance.Execute(currentControl);
3093

    
3094
                                    control.isTransOn = true;
3095
                                    var firstPoint = control.PointSet.First();
3096

    
3097
                                    control.PointSet.Add(firstPoint);
3098
                                    control.DrawingCloud();
3099
                                    control.ApplyOverViewData();
3100

    
3101
                                    currentControl = null;
3102
                                }
3103
                            }
3104
                            else
3105
                            {
3106
                                if (e.LeftButton == MouseButtonState.Pressed)
3107
                                {
3108
                                    currentControl = new CloudControl
3109
                                    {
3110
                                        PointSet = new List<Point>(),
3111
                                        PointC = new StylusPointSet()
3112
                                    };
3113

    
3114
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3115
                                    //{
3116
                                        var polygonControl = (currentControl as CloudControl);
3117
                                        currentControl.CommentID = Commons.shortGuid();
3118
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3119
                                        currentControl.IsNew = true;
3120
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3121

    
3122
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3123
                                        polygonControl.PointSet.Add(canvasDrawingMouseDownPoint);
3124
                                    
3125
                                    //}
3126
                                }
3127
                            }
3128
                        }
3129
                        break;
3130
                    case ControlType.ImgControl:
3131
                        {
3132
                            if (e.LeftButton == MouseButtonState.Pressed)
3133
                            {
3134
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3135
                                //{
3136
                                    if (currentControl is ImgControl)
3137
                                    {
3138
                                        //20180906 LJY TEST IsRotationDrawingEnable
3139
                                        if (IsGetoutpoint((currentControl as ImgControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3140
                                        {
3141
                                            return;
3142
                                        }
3143

    
3144
                                        CreateCommand.Instance.Execute(currentControl);
3145
                                        controlType = ControlType.ImgControl;
3146
                                        currentControl = null;
3147
                                    }
3148
                                    else
3149
                                    {
3150
                                        
3151
                                        string extension = System.IO.Path.GetExtension(filename).ToUpper();
3152
                                        if (extension == ".PNG" || extension == ".JPEG" || extension == ".GIF" || extension == ".BMP" || extension == ".JPG" || extension == ".SVG")
3153
                                        {
3154
                                            Image img = new Image();
3155
                                            if (filename.Contains(".svg"))
3156
                                            {
3157
                                                byte[] imageData = null;
3158
                                                DrawingImage image = null;
3159
                                                using (System.Net.WebClient web = new System.Net.WebClient())
3160
                                                {
3161
                                                    imageData = web.DownloadData(new Uri(filename));
3162
                                                    System.IO.Stream stream = new System.IO.MemoryStream(imageData);
3163
                                                    image = SvgReader.Load(stream);
3164
                                                }
3165
                                                img.Source = image;
3166
                                            }
3167
                                            else
3168
                                            {
3169
                                                img.Source = new BitmapImage(new Uri(filename));
3170
                                            }
3171

    
3172
                                            currentControl = new ImgControl
3173
                                            {
3174
                                                    Background = new SolidColorBrush(Colors.Black),
3175
                                                    PointSet = new List<Point>(),
3176
                                                    FilePath = filename,
3177
                                                    ImageData = img.Source,
3178
                                                    StartPoint = canvasDrawingMouseDownPoint,
3179
                                                    EndPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y + 100),
3180
                                                    TopRightPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y + 100),
3181
                                                    LeftBottomPoint = new Point(canvasDrawingMouseDownPoint.X + 100, canvasDrawingMouseDownPoint.Y),
3182
                                                    ControlType = ControlType.ImgControl
3183
                                                };
3184

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

    
3191
                                                //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3192
                                                (currentControl as ImgControl).Angle -= rotate.Angle;
3193
                                        }
3194
                                    }
3195
                                //}
3196
                            }
3197
                        }
3198
                        break;
3199
                    case ControlType.Date:
3200
                        {
3201
                            if (e.LeftButton == MouseButtonState.Pressed)
3202
                            {
3203
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3204
                                //{
3205
                                    if (currentControl is DateControl)
3206
                                    {
3207
                                        //20180906 LJY TEST IsRotationDrawingEnable
3208
                                        if (IsGetoutpoint((currentControl as DateControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3209
                                        {
3210
                                            return;
3211
                                        }
3212

    
3213
                                        CreateCommand.Instance.Execute(currentControl);
3214
                                        currentControl = null;
3215

    
3216
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3217
                                        {
3218
                                            controlType = ControlType.None;
3219
                                            IsSwingMode = false;
3220
                                            Common.ViewerDataModel.Instance.SelectedControl = "";
3221
                                            Common.ViewerDataModel.Instance.ControlTag = null;
3222
                                            mouseHandlingMode = MouseHandlingMode.None;
3223
                                            this.ParentOfType<MainWindow>().dzTopMenu.btn_Batch.IsChecked = false;
3224
                                            txtBatch.Visibility = Visibility.Collapsed;
3225

    
3226
                                        }
3227
                                    }
3228
                                    else
3229
                                    {
3230
                                        currentControl = new DateControl
3231
                                        {
3232
                                            StartPoint = canvasDrawingMouseDownPoint,
3233
                                            Background = new SolidColorBrush(Colors.Black)
3234
                                        };
3235
                                        currentControl.CommentID = Commons.shortGuid();
3236
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3237
                                        currentControl.IsNew = true;
3238
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3239

    
3240
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3241
                                        (currentControl as DateControl).Angle -= rotate.Angle;
3242
                                }
3243
                                //}
3244
                            }
3245
                        }
3246
                        break;
3247
                    case ControlType.TextControl:
3248
                        {
3249
                            if (e.LeftButton == MouseButtonState.Pressed)
3250
                            {
3251
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3252
                                {
3253
                                    currentControl = new TextControl
3254
                                    {
3255
                                        ControlType = controlType
3256
                                    };
3257
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3258
                                    currentControl.CommentID = Commons.shortGuid();
3259
                                    currentControl.IsNew = true;
3260
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3261
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3262
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3263

    
3264
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3265
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3266
                                    
3267
                                    (currentControl as TextControl).ControlType_No = 0;
3268
                                    (currentControl as TextControl).Angle -= rotate.Angle;
3269
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3270
                                    (currentControl as TextControl).ApplyTemplate();
3271
                                    (currentControl as TextControl).Base_TextBox.Focus();
3272

    
3273
                                    CreateCommand.Instance.Execute(currentControl);
3274
                                }
3275
                            }
3276
                        }
3277
                        break;
3278
                    case ControlType.TextBorder:
3279
                        {
3280
                            if (e.LeftButton == MouseButtonState.Pressed)
3281
                            {
3282
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3283
                                {
3284
                                    currentControl = new TextControl
3285
                                    {
3286
                                        ControlType = controlType
3287
                                    };
3288

    
3289
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3290
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3291
                                    currentControl.CommentID = Commons.shortGuid();
3292
                                    currentControl.IsNew = true;
3293
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3294
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3295
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3296
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);
3297
                                    
3298
                                    (currentControl as TextControl).ControlType_No = 1;
3299
                                    (currentControl as TextControl).Angle = Ang;
3300
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3301
                                    (currentControl as TextControl).ApplyTemplate();
3302
                                    (currentControl as TextControl).Base_TextBox.Focus();
3303
                                    CreateCommand.Instance.Execute(currentControl);
3304
                                }
3305
                            }
3306
                        }
3307
                        break;
3308
                    case ControlType.TextCloud:
3309
                        {
3310
                            if (e.LeftButton == MouseButtonState.Pressed)
3311
                            {
3312
                                if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3313
                                {
3314
                                    currentControl = new TextControl
3315
                                    {
3316
                                        ControlType = controlType
3317
                                    };
3318

    
3319
                                    (currentControl as TextControl).TextSize = ViewerDataModel.Instance.TextSize;
3320
                                    currentControl.CommentID = Commons.shortGuid();
3321
                                    currentControl.IsNew = true;
3322
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3323
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3324

    
3325
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3326
                                    currentControl.SetValue(TextControl.CanvasXProperty, canvasDrawingMouseDownPoint.X);
3327
                                    currentControl.SetValue(TextControl.CanvasYProperty, canvasDrawingMouseDownPoint.Y);                                    
3328

    
3329
                                    (currentControl as TextControl).Angle = Ang;
3330
                                    (currentControl as TextControl).ControlType_No = 2;
3331
                                    (currentControl as TextControl).IsHighLight = ViewerDataModel.Instance.checkHighShape;
3332
                                    (currentControl as TextControl).ApplyTemplate();
3333
                                    (currentControl as TextControl).Base_TextBox.Focus();
3334
                                    CreateCommand.Instance.Execute(currentControl);
3335
                                    //currentControl = null;
3336
                                }
3337
                            }
3338
                        }
3339
                        break;
3340
                    case ControlType.ArrowTextControl:
3341
                         {
3342
                            if (e.LeftButton == MouseButtonState.Pressed)
3343
                            {
3344
                                if (currentControl is ArrowTextControl)
3345
                                {
3346
                                    //20180906 LJY TEST IsRotationDrawingEnable
3347
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3348
                                    {
3349
                                        return;
3350
                                    }
3351

    
3352
                                    CreateCommand.Instance.Execute(currentControl);
3353

    
3354
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3355
                                    (currentControl as ArrowTextControl).EnableEditing = false;
3356
                                    (currentControl as ArrowTextControl).IsNew = false;
3357
                                    currentControl = null;
3358
                                }
3359
                                else
3360
                                {
3361
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3362
                                    //{
3363
                                        currentControl = new ArrowTextControl();
3364
                                        currentControl.CommentID = Commons.shortGuid();
3365
                                        currentControl.IsNew = true;
3366
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3367
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3368

    
3369
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3370
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3371
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3372
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3373
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3374

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

    
3378
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3379
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3380
                                        this.MainAngle.Visibility = Visibility.Visible;
3381

    
3382
                                    
3383
                                    //}
3384
                                }
3385
                            }
3386
                        }
3387
                        break;
3388
                    case ControlType.ArrowTransTextControl:
3389
                        {
3390
                            if (e.LeftButton == MouseButtonState.Pressed)
3391
                            {
3392
                                if (currentControl is ArrowTextControl)
3393
                                {
3394
                                    //20180906 LJY TEST IsRotationDrawingEnable
3395
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3396
                                    {
3397
                                        return;
3398
                                    }
3399

    
3400
                                    CreateCommand.Instance.Execute(currentControl);
3401
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3402
                                    currentControl.IsNew = false;
3403
                                    currentControl = null;
3404
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3405
                                }
3406
                                else
3407
                                {
3408
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3409
                                    //{
3410
                                    currentControl = new ArrowTextControl()
3411
                                    {
3412
                                        ControlType = ControlType.ArrowTransTextControl
3413
                                    };
3414
                                    currentControl.CommentID = Commons.shortGuid();
3415
                                    currentControl.IsNew = true;
3416
                                    currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3417
                                    ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3418
                                    currentControl.SetValue(Canvas.ZIndexProperty, 3);
3419
                                    currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3420
                                    currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                  
3421
                                    (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3422
                                    (currentControl as ArrowTextControl).isFixed = true;
3423
                                    (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3424

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

    
3428
                                    (currentControl as ArrowTextControl).ApplyTemplate();
3429
                                    (currentControl as ArrowTextControl).Base_TextBox.Focus();
3430
                                    (currentControl as ArrowTextControl).isTrans = true;
3431
                                }
3432
                            }
3433
                        }
3434
                        break;
3435
                    case ControlType.ArrowTextBorderControl:
3436
                         {
3437
                            if (e.LeftButton == MouseButtonState.Pressed)
3438
                            {
3439
                                if (currentControl is ArrowTextControl)
3440
                                {
3441
                                    //20180906 LJY TEST IsRotationDrawingEnable
3442
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3443
                                    {
3444
                                        return;
3445
                                    }
3446

    
3447
                                    CreateCommand.Instance.Execute(currentControl);
3448
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3449
                                    currentControl.IsNew = false;
3450
                                    currentControl = null;
3451
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3452
                                }
3453
                                else
3454
                                {
3455
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3456
                                    //{
3457
                                        currentControl = new ArrowTextControl()
3458
                                        {
3459
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect
3460
                                        };
3461
                                        currentControl.CommentID = Commons.shortGuid();
3462
                                        currentControl.IsNew = true;
3463
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3464
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3465

    
3466
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3467

    
3468
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3469

    
3470
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);
3471
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3472
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3473

    
3474
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3475
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3476
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3477
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3478
                                        this.MainAngle.Visibility = Visibility.Visible;                                    
3479
                                    //}
3480
                                }
3481
                            }
3482
                        }
3483
                        break;
3484
                    case ControlType.ArrowTransTextBorderControl:
3485
                        {
3486
                            if (e.LeftButton == MouseButtonState.Pressed)
3487
                            {
3488
                                if (currentControl is ArrowTextControl)
3489
                                {
3490
                                    //20180906 LJY TEST IsRotationDrawingEnable
3491
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3492
                                    {
3493
                                        return;
3494
                                    }
3495
                                    CreateCommand.Instance.Execute(currentControl);
3496
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3497
                                    currentControl.IsNew = false;
3498
                                    currentControl = null;
3499
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3500
                                }
3501
                                else
3502
                                {
3503
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3504
                                    //{
3505
                                    
3506

    
3507
                                    currentControl = new ArrowTextControl()
3508
                                    {
3509
                                        ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Rect,
3510
                                        ControlType = ControlType.ArrowTransTextBorderControl
3511

    
3512
                                    };
3513
                                        currentControl.CommentID = Commons.shortGuid();
3514
                                        currentControl.IsNew = true;
3515
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3516
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3517

    
3518
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3519

    
3520
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3521
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                    
3522
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3523
                                        (currentControl as ArrowTextControl).isFixed = true;
3524
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3525
                                     
3526
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3527
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3528
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3529

    
3530
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();                                 
3531
                                        this.MainAngle.Visibility = Visibility.Visible;
3532
                                    
3533
                                    //20180911 LJY
3534
                                        (currentControl as ArrowTextControl).isTrans = true;
3535
                                    
3536

    
3537
                                    //}
3538
                                }
3539
                            }
3540
                        }
3541
                        break;
3542
                    case ControlType.ArrowTextCloudControl:
3543
                        {
3544
                            if (e.LeftButton == MouseButtonState.Pressed)
3545
                            {
3546
                                if (currentControl is ArrowTextControl)
3547
                                {
3548
                                    //20180906 LJY TEST IsRotationDrawingEnable
3549
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3550
                                    {
3551
                                        return;
3552
                                    }
3553
                                    CreateCommand.Instance.Execute(currentControl);
3554
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3555
                                    currentControl.IsNew = false;
3556
                                    currentControl = null;
3557
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3558
                                }
3559
                                else
3560
                                {
3561
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3562
                                    //{
3563
                                        currentControl = new ArrowTextControl()
3564
                                        {
3565
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud
3566
                                        };
3567
                                        currentControl.CommentID = Commons.shortGuid();
3568
                                        currentControl.IsNew = true;
3569
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3570
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3571

    
3572
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3573
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3574
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                 
3575
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3576
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3577

    
3578
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3579
                                        (currentControl as ArrowTextControl).Angle -= rotate.Angle;
3580
                                    
3581
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3582
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3583
                                        this.MainAngle.Visibility = Visibility.Visible;                                        
3584
                                    //}
3585
                                }
3586
                            }
3587
                        }
3588
                        break;
3589
                    case ControlType.ArrowTransTextCloudControl:
3590
                        {
3591
                            if (e.LeftButton == MouseButtonState.Pressed)
3592
                            {
3593
                                if (currentControl is ArrowTextControl)
3594
                                {
3595
                                    //20180906 LJY TEST IsRotationDrawingEnable
3596
                                    if (IsGetoutpoint((currentControl as ArrowTextControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3597
                                    {
3598
                                        return;
3599
                                    }
3600
                                    CreateCommand.Instance.Execute(currentControl);
3601
                                    (currentControl as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
3602
                                    currentControl.IsNew = false;
3603
                                    currentControl = null;
3604
                                    this.MainAngle.Visibility = Visibility.Collapsed;
3605
                                }
3606
                                else
3607
                                {
3608
                                    //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3609
                                    //{
3610
                                        currentControl = new ArrowTextControl()
3611
                                        {
3612
                                            ArrowTextStyle = MarkupToPDF.Controls.Text.ArrowTextControl.ArrowTextStyleSet.Cloud,
3613
                                            ControlType = ControlType.ArrowTransTextCloudControl
3614

    
3615
                                        };
3616
                                        currentControl.CommentID = Commons.shortGuid();
3617
                                        currentControl.IsNew = true; 
3618
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3619
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3620
                                        currentControl.SetValue(Canvas.ZIndexProperty, 3);
3621

    
3622
                                        currentControl.SetValue(ArrowTextControl.StartPointProperty, canvasDrawingMouseDownPoint);
3623
                                        currentControl.SetValue(ArrowTextControl.EndPointProperty, canvasDrawingMouseDownPoint);                                        
3624
                                        (currentControl as ArrowTextControl).TextSize = ViewerDataModel.Instance.TextSize;
3625
                                        (currentControl as ArrowTextControl).isFixed = true;
3626
                                        (currentControl as ArrowTextControl).isHighLight = ViewerDataModel.Instance.checkHighShape;
3627

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

    
3631
                                        (currentControl as ArrowTextControl).ApplyTemplate();
3632
                                        (currentControl as ArrowTextControl).Base_TextBox.Focus();
3633
                                        this.MainAngle.Visibility = Visibility.Visible;  
3634
                                    
3635
                                    //20180911 LJY
3636
                                        (currentControl as ArrowTextControl).isTrans = true;
3637
                                    //}
3638
                                }
3639
                            }
3640
                        }
3641
                        break;
3642
                    //강인구 추가
3643
                    case ControlType.Sign:
3644
                        {
3645
                            if (e.LeftButton == MouseButtonState.Pressed)
3646
                            {
3647
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3648
                                //{
3649
                                    var _sign = GetUserSign.GetSign(App.ViewInfo.UserID, App.ViewInfo.ProjectNO);
3650

    
3651
                                    if (_sign == null)
3652
                                    {
3653
                                        txtBatch.Visibility = Visibility.Collapsed;
3654
                                        mouseHandlingMode = IKCOM.MouseHandlingMode.None;
3655
                                        controlType = ControlType.None;
3656

    
3657
                                        this.ParentOfType<MainWindow>().DialogMessage_Alert("등록된 Sign이 없습니다.", "Alert");
3658
                                        this.ParentOfType<MainWindow>().ChildrenOfType<RadToggleButton>().Where(data => data.IsChecked == true).FirstOrDefault().IsChecked = false;
3659
                                        return;
3660
                                    }
3661

    
3662
                                    if (currentControl is SignControl)
3663
                                    {
3664
                                        //20180906 LJY TEST IsRotationDrawingEnable
3665
                                        if (IsGetoutpoint((currentControl as SignControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3666
                                        {
3667
                                            return;
3668
                                        }
3669

    
3670
                                        CreateCommand.Instance.Execute(currentControl);
3671
                                        currentControl = null;
3672
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3673
                                        {
3674
                                            txtBatch.Text = "Place Date";
3675
                                            controlType = ControlType.Date;
3676
                                        }
3677
                                    }
3678
                                    else
3679
                                    {
3680
                                        currentControl = new SignControl
3681
                                        {
3682
                                            Background = new SolidColorBrush(Colors.Black),
3683
                                            UserNumber = App.ViewInfo.UserID,
3684
                                            ProjectNO = App.ViewInfo.ProjectNO,
3685
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3686
                                            EndPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3687
                                            ControlType = ControlType.Sign
3688
                                        };
3689

    
3690
                                        currentControl.CommentID = Commons.shortGuid();
3691
                                        currentControl.IsNew = true;
3692
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3693
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3694

    
3695
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정 
3696
                                        (currentControl as SignControl).Angle -= rotate.Angle;                                    
3697
                                }
3698
                                //}
3699
                            }
3700
                        }
3701
                        break;
3702
                    case ControlType.Mark:
3703
                        {
3704
                            if (e.LeftButton == MouseButtonState.Pressed)
3705
                            {
3706
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3707
                                //{
3708
                                    if (currentControl is RectangleControl)
3709
                                    {
3710
                                        //20180906 LJY TEST IsRotationDrawingEnable
3711
                                        if (IsGetoutpoint((currentControl as RectangleControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3712
                                        {
3713
                                            return;
3714
                                        }
3715

    
3716
                                        CreateCommand.Instance.Execute(currentControl);
3717
                                        (currentControl as RectangleControl).ApplyOverViewData();
3718
                                        currentControl = null;
3719
                                    
3720
                                        this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3721

    
3722
                                        if (Common.ViewerDataModel.Instance.SelectedControl == "Batch")
3723
                                        {
3724
                                            txtBatch.Text = "Place Signature";
3725
                                            controlType = ControlType.Sign;
3726
                                        }
3727
                                    }
3728
                                    else
3729
                                    {
3730
                                        currentControl = new RectangleControl
3731
                                        {
3732
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3733
                                            Background = new SolidColorBrush(Colors.Black),
3734
                                            ControlType = ControlType.Mark ,
3735
                                            Paint = PaintSet.Fill
3736
                                        };
3737

    
3738
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3739
                                        currentControl.CommentID = Commons.shortGuid();
3740
                                        currentControl.IsNew = true;
3741
                                        (currentControl as RectangleControl).DashSize = ViewerDataModel.Instance.DashSize;
3742
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3743
                                    }
3744
                                //}
3745
                            }
3746
                        }
3747
                        break;
3748
                    case ControlType.Symbol:
3749
                        {
3750
                            if (e.LeftButton == MouseButtonState.Pressed)
3751
                            {
3752
                                if (currentControl is SymControl)
3753
                                {
3754
                                    //20180906 LJY TEST IsRotationDrawingEnable
3755
                                    if (IsGetoutpoint((currentControl as SymControl).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3756
                                    {
3757
                                        return;
3758
                                    }
3759
                                    CreateCommand.Instance.Execute(currentControl);
3760
                                    currentControl = null;
3761
                                
3762
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3763
                                }
3764
                                else
3765
                                {
3766
                                    currentControl = new SymControl
3767
                                    {
3768
                                        StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3769
                                        Background = new SolidColorBrush(Colors.Black),
3770
                                        LineSize = ViewerDataModel.Instance.LineSize + 3,
3771
                                        ControlType = ControlType.Symbol
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

    
3779
                                    //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3780
                                    (currentControl as SymControl).Angle -= rotate.Angle;
3781
                                }
3782
                                //}
3783
                            }
3784
                        }
3785
                        break;
3786
                    case ControlType.Stamp:
3787
                        {
3788
                            if (e.LeftButton == MouseButtonState.Pressed)
3789
                            {
3790
                                //if (IsDrawingEnable(canvasZoomPanningMouseDownPoint))
3791
                                //{
3792
                                    if (currentControl is SymControlN)
3793
                                    {
3794
                                        //20180906 LJY TEST IsRotationDrawingEnable
3795
                                        if (IsGetoutpoint((currentControl as SymControlN).PointSet.Where(data => IsRotationDrawingEnable(data) == true).FirstOrDefault()))
3796
                                        {
3797
                                            return;
3798
                                        }
3799

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

    
3804
                                    this.cursor = new Cursor(MainWindow.CursorChange().StreamSource);
3805
                                    }
3806
                                    else
3807
                                    {
3808
                                        currentControl = new SymControlN
3809
                                        {
3810
                                            StartPoint = new Point(canvasDrawingMouseDownPoint.X, canvasDrawingMouseDownPoint.Y),
3811
                                            Background = new SolidColorBrush(Colors.Black),
3812
                                            STAMP = App.SystemInfo.STAMP,                                            
3813
                                            ControlType = ControlType.Stamp
3814
                                        };
3815

    
3816
                                        currentControl.IsNew = true;
3817
                                        currentControl.MarkupInfoID = App.Custom_ViewInfoId;
3818
                                        currentControl.CommentID = Commons.shortGuid();
3819
                                        ViewerDataModel.Instance.MarkupControls_USER.Add(currentControl);
3820
                                        //20180903 LJY 회전된 방향으로 화면에 출력되지 않는 문제 수정  
3821
                                        (currentControl as SymControlN).Angle -= rotate.Angle;
3822
                                }                                    
3823
                                //}
3824
                            }
3825
                        }
3826
                        break;
3827
                    case ControlType.PenControl:
3828
                        {
3829
                            if (inkBoard.Tag.ToString() == "Ink")
3830
                            {
3831
                                inkBoard.IsEnabled = true;
3832
                                StartNewStroke(canvasDrawingMouseDownPoint);
3833
                            }
3834
                            else if (inkBoard.Tag.ToString() == "EraseByPoint")
3835
                            {
3836
                                RemovePointStroke(canvasDrawingMouseDownPoint);
3837
                            }
3838
                            else if (inkBoard.Tag.ToString() == "EraseByStroke")
3839
                            {
3840
                                RemoveLineStroke(canvasDrawingMouseDownPoint);
3841
                            }
3842
                            IsDrawing = true;
3843
                            return;
3844
                        }
3845
                    default:
3846
                        if (currentControl != null)
3847
                        {
3848
                            currentControl.CommentID = null;
3849
                            currentControl.IsNew = false;
3850
                        }
3851
                        break;
3852
                }
3853
            }
3854
            if (mouseHandlingMode != MouseHandlingMode.None && e.LeftButton == MouseButtonState.Pressed)
3855
            {
3856
                if (mouseHandlingMode == MouseHandlingMode.Adorner && SelectLayer.Children.Count > 0)
3857
                {
3858
                    bool mouseOff = false;
3859
                    foreach (var item in SelectLayer.Children)
3860
                    {
3861
                        if (item is AdornerFinal)
3862
                        {
3863

    
3864
                            var over = (item as AdornerFinal).Members.Where(data => data.DrawingData.IsMouseOver).FirstOrDefault();
3865
                            if (over != null)
3866
                            {
3867
                                mouseOff = true;
3868
                            }
3869
                        }
3870
                    }
3871

    
3872
                    if (!mouseOff)
3873
                    {
3874
                        SelectionSet.Instance.UnSelect(this);
3875
                    }
3876
                }
3877
                zoomAndPanControl.CaptureMouse();
3878
                e.Handled = true;
3879
            }
3880
        }
3881

    
3882
        private void zoomAndPanControl2_MouseDown(object sender, MouseButtonEventArgs e)
3883
        {
3884
            ///mouseButtonDown = e.ChangedButton;
3885
            canvasZoommovingMouseDownPoint = e.GetPosition(zoomAndPanCanvas2);
3886
        }
3887

    
3888
        private void RemoveLineStroke(Point P)
3889
        {
3890
            var control = ViewerDataModel.Instance.MarkupControls_USER.Where(data => data.IsMouseOver).FirstOrDefault();
3891
            if (control != null)
3892
            {
3893
                DeleteCommand.Instance.Execute(new List<CommentUserInfo>() { control });
3894
            }
3895
        }
3896

    
3897
        private void RemovePointStroke(Point P)
3898
        {
3899
            foreach (Stroke hits in inkBoard.Strokes)
3900
            {
3901
                foreach (StylusPoint sty in hits.StylusPoints)
3902
                {
3903

    
3904
                }
3905
                if (hits.HitTest(P))
3906
                {
3907
                    inkBoard.Strokes.Remove(hits);
3908
                    return;
3909
                }
3910
            }
3911
        }
3912

    
3913
        private void StartNewStroke(Point P)
3914
        {
3915
            strokePoints = new StylusPointCollection();
3916
            StylusPoint segment1Start = new StylusPoint(P.X, P.Y);
3917
            strokePoints.Add(segment1Start);
3918
            stroke = new Stroke(strokePoints);
3919

    
3920
            stroke.DrawingAttributes.Color = Colors.Red;
3921
            stroke.DrawingAttributes.Width = 4;
3922
            stroke.DrawingAttributes.Height = 4;
3923

    
3924
            inkBoard.Strokes.Add(stroke);
3925
        }
3926

    
3927
        private void btnConsolidate_Click(object sender, RoutedEventArgs e)
3928
        {
3929
            ConsolidationMethod();
3930
        }
3931

    
3932
        /// <summary>
3933
        /// execute TeamConsolidationCommand
3934
        /// </summary>
3935
        public void TeamConsolidationMethod()
3936
        {
3937
            this.UpdateMyMarkupList();
3938
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3939
            {
3940
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3941
            }
3942
            else
3943
            {
3944

    
3945
                ViewerDataModel.Instance.IsConsolidate = true;
3946
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
3947

    
3948
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3949
                {
3950
                    if (!this.userData.DEPARTMENT.Equals(item.Depatment))
3951
                    {
3952
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at your department", "Alert");
3953
                        return;
3954
                    }                    
3955
                }
3956
                List<MarkupInfoItem> MarkupInfoList = new List<MarkupInfoItem>();
3957
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
3958
                {
3959
                    MarkupInfoList.Add(item);
3960
                }
3961
                TeamConsolidateCommand.Instance.Execute(MarkupInfoList);
3962
            }
3963
        }
3964

    
3965
        public void ConsolidationMethod()
3966
        {
3967
            if (this.gridViewMarkup.SelectedItems.Count == 0)
3968
            {
3969
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
3970
            }
3971
            else
3972
            {
3973
                List<IKCOM.MarkupInfoItem> MySelectItem = new List<IKCOM.MarkupInfoItem>();
3974
                foreach (var item in this.gridViewMarkup.SelectedItems)
3975
                {
3976
                    MySelectItem.Add(item as IKCOM.MarkupInfoItem);
3977
                }
3978
                int iPageNo = Convert.ToInt32(this.ParentOfType<MainWindow>().dzTopMenu.tlcurrentPage.Text);
3979
                
3980
                ConsolidateCommand.Instance.Execute(MySelectItem, iPageNo);
3981
            }
3982
        }
3983

    
3984
        private void btnConsolidate_Loaded(object sender, RoutedEventArgs e)
3985
        {
3986
            if (App.ViewInfo != null)
3987
            {
3988
                btnConsolidate = (sender as RadRibbonButton);
3989
                if (!App.ViewInfo.NewCommentPermission)
3990
                {
3991
                    (sender as RadRibbonButton).Visibility = System.Windows.Visibility.Collapsed;
3992
                }
3993
            }
3994
        }
3995

    
3996
        private void btnTeamConsolidate_Click(object sender, RoutedEventArgs e)
3997
        {
3998
            TeamConsolidationMethod();
3999
        }
4000

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

    
4013
                    if (!App.ViewInfo.NewCommentPermission)
4014
                    {
4015
                        btnTeamConsolidate.Visibility = Visibility.Collapsed;
4016
                    }
4017
                }
4018
                else
4019
                {
4020
                    btnTeamConsolidate.Visibility = Visibility.Collapsed;
4021
                }
4022
            }
4023
        }
4024

    
4025
        private void FinalPDFEvent(object sender, RoutedEventArgs e)
4026
        {
4027
            if(btnFinalPDF.IsEnabled == true)
4028
            {
4029
                var item = gridViewMarkup.Items.Cast<MarkupInfoItem>().Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4030
                if (item != null)
4031
                {
4032
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4033

    
4034
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item.MarkupInfoID, _ViewInfo.UserID);
4035
                    btnFinalPDF.IsEnabled = false;
4036
                }
4037
                else
4038
                {
4039
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4040
                }
4041
            }
4042
            else
4043
            {
4044
                DialogMessage_Alert("Merged PDF가 수행중입니다", "안내");
4045
            }
4046
        }
4047

    
4048
        private void btnFinalPDF_Loaded(object sender, RoutedEventArgs e)
4049
        {
4050
            btnFinalPDF = sender as RadRibbonButton;
4051
            if (App.ViewInfo != null)
4052
            {
4053
                if (!App.ViewInfo.CreateFinalPDFPermission) //파이널이 True가 아니면
4054
                {
4055
                    btnFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4056
                    if (btnConsolidate != null)
4057
                    {
4058
                        btnConsolidate.Visibility = Visibility.Collapsed;
4059
                    }
4060
                }
4061
            }
4062
        }
4063

    
4064
        private void ConsolidateFinalPDFEvent(object sender, RoutedEventArgs e)
4065
        {
4066
            UpdateMyMarkupList();
4067

    
4068
            if (this.gridViewMarkup.SelectedItems.Count == 0)
4069
            {
4070
                this.ParentOfType<MainWindow>().DialogMessage_Alert("Please select at least one user", "Alert");
4071
            }
4072
            else
4073
            {
4074
                ViewerDataModel.Instance.IsConsolidate = true;
4075
                this.ParentOfType<MainWindow>().dzTopMenu._SaveEvent(null, null);
4076
                List<KCOMDataModel.DataModel.MARKUP_DATA> instanceDataSet = new List<KCOMDataModel.DataModel.MARKUP_DATA>();
4077

    
4078
                string project_no = App.ViewInfo.ProjectNO;
4079
                string doc_id = _DocInfo.ID;
4080
                string user_id = App.ViewInfo.UserID;
4081
                List<MarkupInfoItem> markupInfoItems = new List<MarkupInfoItem>();
4082
                foreach (MarkupInfoItem item in this.gridViewMarkup.SelectedItems)
4083
                {
4084
                    markupInfoItems.Add(item);
4085
                }
4086
                Logger.sendReqLog("Consolidate", project_no + "," + user_id + "," + doc_id + "," + markupInfoItems, 1);
4087
                Logger.sendResLog("Consolidate", this.BaseClient.Consolidate(project_no, user_id, doc_id, markupInfoItems).ToString(), 1);
4088
                Logger.sendReqLog("GetMarkupInfoItemsAsync", App.ViewInfo.ProjectNO + "," + _DocInfo.ID, 1);
4089
                var items = this.BaseClient.GetMarkupInfoItems(App.ViewInfo.ProjectNO, _DocInfo.ID);
4090

    
4091
                var item2 = items.Where(d => d.Consolidate == 1 && d.AvoidConsolidate == 0).FirstOrDefault();
4092
                if (item2 != null)
4093
                {
4094
                    Logger.sendReqLog("SetFinalPDFAsync", _ViewInfo.ProjectNO + "," + _DocInfo.ID + "," + item2.MarkupInfoID + "," + _ViewInfo.UserID, 1);
4095

    
4096
                    BaseClient.SetFinalPDFAsync(_ViewInfo.ProjectNO, _DocInfo.ID, item2.MarkupInfoID, _ViewInfo.UserID);
4097
                    BaseClient.GetMarkupInfoItemsAsync(App.ViewInfo.ProjectNO, _DocInfo.ID);
4098
                }
4099
                else
4100
                {
4101
                    DialogMessage_Alert("Consolidation 된 코멘트가 존재하지 않습니다", "안내");
4102
                }
4103
            }
4104
        }
4105

    
4106
        private void btnConsolidateFinalPDF_Loaded(object sender, RoutedEventArgs e)
4107
        {
4108
            btnConsolidateFinalPDF = (sender as RadRibbonButton);
4109

    
4110
            if (App.ViewInfo != null)
4111
            {
4112
                if (!App.ViewInfo.NewCommentPermission || !App.ViewInfo.CreateFinalPDFPermission)
4113
                {
4114
                    btnConsolidateFinalPDF.Visibility = System.Windows.Visibility.Collapsed;
4115
                }
4116
            }
4117
        }
4118

    
4119
        private void SyncCompare_Click(object sender, RoutedEventArgs e)
4120
        {
4121
            if (CompareMode.IsChecked)
4122
            {
4123
                if (ViewerDataModel.Instance.PageBalanceMode && ViewerDataModel.Instance.PageBalanceNumber == 0)
4124
                {
4125
                    ViewerDataModel.Instance.PageBalanceNumber = 1;
4126
                }
4127
                if (ViewerDataModel.Instance.PageNumber == 0)
4128
                {
4129
                    ViewerDataModel.Instance.PageNumber = 1;
4130
                }
4131

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

    
4136
                BaseClient.GetCompareRectAsync(_ViewInfo.ProjectNO, _ViewInfo.DocumentItemID, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber.ToString(), ViewerDataModel.Instance.PageNumber.ToString(), userData.COMPANY != "EXT" ? "true" : "false");
4137
            }
4138
            else
4139
            {
4140
                da.From = 1;
4141
                da.To = 1;
4142
                da.Duration = new Duration(TimeSpan.FromSeconds(9999));
4143
                da.AutoReverse = false;
4144
                canvas_compareBorder.Children.Clear();
4145
                canvas_compareBorder.BeginAnimation(OpacityProperty, da);
4146
            }
4147
        }
4148

    
4149
        private void Sync_Click(object sender, RoutedEventArgs e)
4150
        {
4151
            if (Sync.IsChecked)
4152
            {
4153
                ViewerDataModel.Instance.Sync_ContentOffsetX = zoomAndPanControl.ContentOffsetX;
4154
                ViewerDataModel.Instance.Sync_ContentOffsetY = zoomAndPanControl.ContentOffsetY;
4155
                ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4156
            }
4157
        }
4158

    
4159
        private void SyncUserListExpender_Click(object sender, RoutedEventArgs e)
4160
        {
4161
            if (UserList.IsChecked)
4162
            {
4163
                this.gridViewRevMarkup.Visibility = Visibility.Visible;
4164
            }
4165
            else
4166
            {
4167
                this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4168
            }
4169
        }
4170

    
4171
        private void SyncPageBalance_Click(object sender, RoutedEventArgs e)
4172
        {
4173

    
4174
            if (BalanceMode.IsChecked)
4175
            {
4176
                ViewerDataModel.Instance.PageBalanceMode = true;
4177
            }
4178
            else
4179
            {
4180
                ViewerDataModel.Instance.PageBalanceMode = false;
4181
                ViewerDataModel.Instance.PageBalanceNumber = 0;
4182
            }
4183
        }
4184

    
4185
        private void SyncExit_Click(object sender, RoutedEventArgs e)
4186
        {
4187
            //초기화
4188
            testPanel2.IsHidden = true;
4189
            ViewerDataModel.Instance.PageBalanceMode = false;
4190
            ViewerDataModel.Instance.PageBalanceNumber = 0;
4191
            ViewerDataModel.Instance.PageNumber = 0;
4192
            ViewerDataModel.Instance.MarkupControls_Sync.Clear();
4193
            this.gridViewRevMarkup.Visibility = Visibility.Collapsed;
4194
            UserList.IsChecked = false;
4195
            BalanceMode.IsChecked = false;
4196
        }
4197

    
4198
        private void SyncPageChange_Click(object sender, RoutedEventArgs e)
4199
        {
4200
            if ((sender as System.Windows.Controls.Control).Tag != null)
4201
            {
4202
                //Compare 초기화
4203
                CompareMode.IsChecked = false;
4204
                var balancePoint = Convert.ToInt32((sender as System.Windows.Controls.Control).Tag);
4205

    
4206
                if (ViewerDataModel.Instance.PageNumber == 0)
4207
                {
4208
                    ViewerDataModel.Instance.PageNumber = 1;
4209
                }
4210

    
4211
                if (ViewerDataModel.Instance.PageBalanceNumber == pageNavigator.PageCount)
4212
                {
4213
                }
4214
                else
4215
                {
4216
                    ViewerDataModel.Instance.PageBalanceNumber += balancePoint;
4217
                }
4218

    
4219
                if (ViewerDataModel.Instance.PageNumber == pageNavigator.PageCount && balancePoint > 0)
4220
                {
4221

    
4222
                }
4223
                else if ((ViewerDataModel.Instance.PageNumber + balancePoint) >= 1)
4224
                {
4225
                    ViewerDataModel.Instance.PageNumber += balancePoint;
4226
                }
4227

    
4228
                if (!testPanel2.IsHidden)
4229
                {
4230
                    if (IsSyncPDFMode)
4231
                    {
4232
                        Get_FinalImage.Get_PdfImage get_PdfImage = new Get_FinalImage.Get_PdfImage();
4233
                        var pdfpath = new BitmapImage(new Uri(get_PdfImage.Run(CurrentRev.TO_VENDOR, App.ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber)));
4234

    
4235
                        if (pdfpath.IsDownloading)
4236
                        {
4237
                            pdfpath.DownloadCompleted += (ex, arg) =>
4238
                            {
4239
                                ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4240
                                ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4241
                                ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4242
                                zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4243
                                zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4244
                            };
4245
                        }
4246
                        else
4247
                        {
4248
                            ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4249
                            ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4250
                            ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4251

    
4252
                            zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4253
                            zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4254
                        }
4255

    
4256
                    }
4257
                    else
4258
                    {
4259
                        string uri = "";
4260

    
4261
                        if (userData.COMPANY != "EXT")
4262
                        {
4263
                            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);
4264
                        }
4265
                        else
4266
                        {
4267
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, ViewerDataModel.Instance.PageNumber);
4268
                        }
4269

    
4270
                        var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4271

    
4272
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4273
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4274
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4275

    
4276
                        zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4277
                        zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4278

    
4279
                        if (defaultBitmapImage_Compare.IsDownloading)
4280
                        {
4281
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4282
                            {
4283
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4284
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4285
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4286

    
4287
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4288
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4289
                            };
4290
                        }
4291
                    }
4292

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

    
4297
                    foreach (var item in gridSelectionRevItem)
4298
                    {
4299
                        item.MarkupList.Where(pageItem => pageItem.PageNumber == ViewerDataModel.Instance.PageNumber).ToList().ForEach(delegate (MarkupItem markupitem)
4300
                        {
4301
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, markupitem.Data, Common.ViewerDataModel.Instance.MarkupControls_Sync, item.DisplayColor, "", item.MarkupInfoID);
4302
                        });
4303
                    }
4304

    
4305
                    //강인구 추가
4306
                    zoomAndPanControl2.ZoomTo(new Rect
4307
                    {
4308
                        X = 0,
4309
                        Y = 0,
4310
                        Width = Math.Max(zoomAndPanCanvas.Width, zoomAndPanCanvas2.Width),
4311
                        Height = Math.Max(zoomAndPanCanvas.Height, zoomAndPanCanvas2.Height),
4312
                    });
4313

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

    
4316
                }
4317
            }
4318
        }
4319

    
4320
        private void SyncChange_Click(object sender, RoutedEventArgs e)
4321
        {
4322
            if (MarkupMode.IsChecked)
4323
            {
4324
                IsSyncPDFMode = true;
4325

    
4326
                var uri = CurrentRev.TO_VENDOR;
4327

    
4328
                if (ViewerDataModel.Instance.PageNumber == 0)
4329
                {
4330
                    ViewerDataModel.Instance.PageNumber = 1;
4331
                }
4332

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

    
4337
                if (pdfpath.IsDownloading)
4338
                {
4339
                    pdfpath.DownloadCompleted += (ex, arg) =>
4340
                    {
4341
                        ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4342
                        ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4343
                        ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4344
                        zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4345
                        zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4346
                    };
4347
                }
4348
                else
4349
                {
4350
                    ViewerDataModel.Instance.ImageViewPath_C = pdfpath;
4351
                    ViewerDataModel.Instance.ImageViewWidth_C = pdfpath.PixelWidth;
4352
                    ViewerDataModel.Instance.ImageViewHeight_C = pdfpath.PixelHeight;
4353

    
4354
                    zoomAndPanCanvas2.Width = pdfpath.PixelWidth;
4355
                    zoomAndPanCanvas2.Height = pdfpath.PixelHeight;
4356
                }
4357
            }
4358
            else
4359
            {
4360
                IsSyncPDFMode = false;
4361
                string uri = "";
4362
                if (userData.COMPANY != "EXT")
4363
                {
4364
                    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);
4365
                }
4366
                else
4367
                {
4368
                    uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4369
                }
4370

    
4371
                var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4372

    
4373
                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4374
                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4375
                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4376

    
4377
                if (defaultBitmapImage_Compare.IsDownloading)
4378
                {
4379
                    defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4380
                    {
4381
                        ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4382
                        ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4383
                        ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4384
                    };
4385
                }
4386
                zoomAndPanControl2.ApplyTemplate();
4387
                zoomAndPanControl2.UpdateLayout();
4388
                zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4389
                zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4390
            }
4391
        }
4392

    
4393
        private void RadButton_Click(object sender, RoutedEventArgs e)
4394
        {
4395
            gridViewHistory_Busy.IsBusy = true;
4396

    
4397
            RadButton instance = sender as RadButton;
4398
            if (instance.CommandParameter != null)
4399
            {
4400
                CurrentRev = instance.CommandParameter as VPRevision;
4401
                BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4402
                {
4403
                    if (ea.Error == null && ea.Result != null)
4404
                    {
4405
                        testPanel2.IsHidden = false;
4406

    
4407
                        ViewerDataModel.Instance._markupInfoRevList.Clear();
4408
                        foreach(var info in ea.Result)
4409
                        {
4410
                            if(info.UserID == App.ViewInfo.UserID)
4411
                            {
4412
                                info.userDelete = true;
4413
                                info.DisplayColor = "FFFF0000";
4414
                            }
4415
                            else
4416
                            {
4417
                                info.userDelete = false;
4418
                            }
4419
                            ViewerDataModel.Instance._markupInfoRevList.Add(info);
4420
                        }
4421
                        gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4422

    
4423
                        string uri = "";
4424
                        if (userData.COMPANY != "EXT")
4425
                        {
4426
                            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);
4427
                        }
4428
                        else
4429
                        {
4430
                            uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4431
                        }
4432

    
4433
                        Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4434

    
4435
                        var defaultBitmapImage_Compare = new BitmapImage();
4436
                        defaultBitmapImage_Compare.BeginInit();
4437
                        defaultBitmapImage_Compare.CacheOption = BitmapCacheOption.OnLoad;
4438
                        defaultBitmapImage_Compare.UriSource = new Uri(uri);
4439
                        defaultBitmapImage_Compare.EndInit();
4440

    
4441
                        if (defaultBitmapImage_Compare.IsDownloading)
4442
                        {
4443
                            defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4444
                            {
4445
                                defaultBitmapImage_Compare.Freeze();
4446
                                ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4447
                                ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4448
                                ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4449
                                zoomAndPanCanvas2.Width = defaultBitmapImage_Compare.PixelWidth;
4450
                                zoomAndPanCanvas2.Height = defaultBitmapImage_Compare.PixelHeight;
4451
                            };
4452
                        }                        
4453
                        zoomAndPanControl2.ApplyTemplate();
4454
                        zoomAndPanControl2.UpdateLayout();
4455
                        //syncPannelRotate(zoomAndPanControl.RotationAngle);
4456
                        if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4457
                        {
4458
                            zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4459
                            zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4460
                        }
4461

    
4462
                        ViewerDataModel.Instance.Sync_ContentOffsetX = Sync_Offset_Point.X;
4463
                        ViewerDataModel.Instance.Sync_ContentOffsetY = Sync_Offset_Point.Y;
4464
                        ViewerDataModel.Instance.Sync_ContentScale = zoomAndPanControl.ContentScale;
4465

    
4466
                        tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4467
                        tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4468
                        gridViewHistory_Busy.IsBusy = false;
4469
                    }
4470

    
4471
                    Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4472
                };
4473
                BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4474
                Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4475
            }
4476
        }
4477

    
4478
        private void EnsembleLink_Button_Click(object sender, RoutedEventArgs e)
4479
        {
4480
            try
4481
            {
4482
                if (sender is RadButton)
4483
                {
4484
                    if ((sender as RadButton).Tag != null)
4485
                    {
4486
                        var url = (sender as RadButton).Tag.ToString();
4487
                        System.Diagnostics.Process.Start(url);
4488
                    }
4489
                    else
4490
                    {
4491
                        this.ParentOfType<MainWindow>().DialogMessage_Alert("Link 정보가 잘못 되었습니다", "안내");
4492
                    }
4493
                }
4494
            }
4495
            catch (Exception ex)
4496
            {
4497
                Logger.sendResLog("EnsembleLink_Button_Click", ex.Message, 0);
4498
            }
4499
        }
4500

    
4501
        public void Sync_Event(VPRevision Currnet_Rev)
4502
        {
4503
            CurrentRev = Currnet_Rev;
4504

    
4505
            BaseClient.GetSyncMarkupInfoItemsCompleted += (sen, ea) =>
4506
            {
4507
                if (ea.Error == null && ea.Result != null)
4508
                {
4509
                    testPanel2.IsHidden = false;
4510

    
4511
                    ViewerDataModel.Instance._markupInfoRevList.Clear();
4512
                    foreach(var info in ea.Result)
4513
                    {
4514
                        if(info.UserID == App.ViewInfo.UserID)
4515
                        {
4516
                            info.userDelete = true;
4517
                            info.DisplayColor = "FFFF0000";
4518
                        }
4519
                        else
4520
                        {
4521
                            info.userDelete = false;
4522
                        }
4523
                        ViewerDataModel.Instance._markupInfoRevList.Add(info);
4524
                    }
4525
                    gridViewRevMarkup.ItemsSource = ViewerDataModel.Instance._markupInfoRevList;
4526

    
4527
                    string uri = "";
4528
                    if (userData.COMPANY != "EXT")
4529
                    {
4530
                        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);
4531
                    }
4532
                    else
4533
                    {
4534
                        uri = String.Format(CommonLib.Common.GetConfigString("subServerImageWebPath", "URL", "", App.isExternal), _ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, pageNavigator.CurrentPage.PageNumber);
4535
                    }
4536

    
4537
                    Sync_Offset_Point = new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY);
4538

    
4539
                    var defaultBitmapImage_Compare = new BitmapImage(new Uri(uri));
4540

    
4541
                    ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4542
                    ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4543
                    ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4544

    
4545
                    if (defaultBitmapImage_Compare.IsDownloading)
4546
                    {
4547
                        defaultBitmapImage_Compare.DownloadCompleted += (ex, arg) =>
4548
                        {
4549
                            ViewerDataModel.Instance.ImageViewPath_C = defaultBitmapImage_Compare;
4550
                            ViewerDataModel.Instance.ImageViewWidth_C = defaultBitmapImage_Compare.PixelWidth;
4551
                            ViewerDataModel.Instance.ImageViewHeight_C = defaultBitmapImage_Compare.PixelHeight;
4552
                        };
4553
                    }
4554

    
4555

    
4556
                    zoomAndPanCanvas2.Width = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentWidth);
4557
                    zoomAndPanCanvas2.Height = Convert.ToDouble(Common.ViewerDataModel.Instance.ContentHeight);
4558
                    zoomAndPanControl2.ApplyTemplate();
4559
                    zoomAndPanControl2.UpdateLayout();
4560

    
4561
                    if (Sync_Offset_Point != new Point(zoomAndPanControl.ContentOffsetX, zoomAndPanControl.ContentOffsetY))
4562
                    {
4563
                        zoomAndPanControl.ContentOffsetX = Sync_Offset_Point.X;
4564
                        zoomAndPanControl.ContentOffsetY = Sync_Offset_Point.Y;
4565
                    }
4566
                    //}
4567

    
4568
                    tlSyncRev.Text = String.Format("Rev. {0}", CurrentRev.RevNo);
4569
                    tlSyncPageNum.Text = String.Format("Current Page : {0}", pageNavigator.CurrentPage.PageNumber);
4570
                    gridViewHistory_Busy.IsBusy = false;
4571
                }
4572
                Logger.sendResLog("GetSyncMarkupInfoItemsCompleted", "UserState : " + ea.UserState + "\r Result :" + ea.Result + "\r Cancelled :" + ea.Cancelled + "\r Error :" + ea.Error, 1);
4573

    
4574
            };
4575
            Logger.sendReqLog("GetSyncMarkupInfoItemsAsync", _ViewInfo.ProjectNO + "," + CurrentRev.DOCUMENT_ID + "," + _ViewInfo.UserID, 1);
4576
            BaseClient.GetSyncMarkupInfoItemsAsync(_ViewInfo.ProjectNO, CurrentRev.DOCUMENT_ID, _ViewInfo.UserID);
4577
        }
4578

    
4579
        private void PdfLink_ButtonDown(object sender, MouseButtonEventArgs e)
4580
        {
4581
            if (sender is Image)
4582
            {
4583
                if ((sender as Image).Tag != null)
4584
                {
4585
                    var pdfUrl = (sender as Image).Tag.ToString();
4586
                    System.Diagnostics.Process.Start(pdfUrl);
4587
                }
4588
                else
4589
                {
4590
                    this.ParentOfType<MainWindow>().DialogMessage_Alert("문서 정보가 잘못 되었습니다", "안내");
4591
                }
4592
            }
4593
        }
4594

    
4595
        private void Create_Symbol(object sender, RoutedEventArgs e)
4596
        {
4597
            MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn markupReturn = new MarkupToPDF.Controls.Parsing.MarkupParser.MarkupReturn();
4598

    
4599
            if (SelectLayer.Children.Count < 1) //선택된 것이 없으면
4600
            {
4601
                DialogMessage_Alert("Please Select Controls", "Alert");
4602
            }
4603
            else //선택된 것이 있으면
4604
            {
4605
                string MarkupData = "";
4606
                adorner_ = new AdornerFinal();
4607

    
4608
                foreach (var item in SelectLayer.Children)
4609
                {
4610
                    if (item.GetType().Name == "AdornerFinal")
4611
                    {
4612
                        adorner_ = (item as Controls.AdornerFinal);
4613
                        foreach (var InnerItem in (item as Controls.AdornerFinal).Members.Cast<Controls.AdornerMember>())
4614
                        {
4615
                            if (!ViewerDataModel.Instance.MarkupControls.Contains(InnerItem.DrawingData))
4616
                            {
4617
                                markupReturn = MarkupParser.MarkupToString(InnerItem.DrawingData as MarkupToPDF.Common.CommentUserInfo, App.ViewInfo.UserID);
4618
                                MarkupData += markupReturn.ConvertData;
4619
                            }
4620
                        }
4621
                    }
4622
                }
4623
                DialogParameters parameters = new DialogParameters()
4624
                {
4625
                    Owner = Application.Current.MainWindow,
4626
                    Closed = (obj, args) => this.MarkupNamePromptClose(MarkupData, args),
4627
                    DefaultPromptResultValue = "Custom State",
4628
                    Content = "Name :",
4629
                    Header = "Insert Custom Symbol Name",
4630
                    Theme = new VisualStudio2013Theme(),
4631
                    ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4632
                };
4633
                RadWindow.Prompt(parameters);
4634
            }
4635

    
4636
        }
4637
        public int symbolselectindex = 0;
4638
        private void SymbolMarkupNamePromptClose(byte[] Img_byte, string data, WindowClosedEventArgs args)
4639
        {
4640
            //Save save = new Save();
4641
            try
4642
            {
4643
                string svgfilename = null;
4644
                if (symbolname != null)
4645
                {
4646
                    if (symbolpng == true || symbolsvg == true)
4647
                    {
4648
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4649
                        string guid = Commons.shortGuid();
4650

    
4651
                        fileUploader.RunAsync(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".png", Img_byte);
4652
                        //Check_Uri.UriCheck();
4653
                        fileUploader.RunCompleted += (ex, arg) =>
4654
                        {
4655
                            filename = arg.Result;
4656
                            if (symbolpng == true)
4657
                            {
4658
                                if (filename != null)
4659
                                { 
4660
                                    if (symbolselectindex == 0)
4661
                                    {
4662
                                        SymbolSave(symbolname, filename, data);
4663
                                    }
4664
                                    else
4665
                                    {
4666
                                        SymbolSave_Public(symbolname, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4667
                                    }
4668
                                    DataBind();
4669
                                }                                
4670
                            }
4671

    
4672
                            if (symbolsvg == true)
4673
                            {
4674
                                try
4675
                                {
4676
                                    var defaultBitmapImage = new BitmapImage();
4677
                                    defaultBitmapImage.BeginInit();
4678
                                    defaultBitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
4679
                                    defaultBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
4680
                                    Check_Uri.UriCheck(filename);
4681
                                    defaultBitmapImage.UriSource = new Uri(filename);
4682
                                    defaultBitmapImage.EndInit();
4683

    
4684
                                    System.Drawing.Bitmap image;
4685

    
4686
                                    if (defaultBitmapImage.IsDownloading)
4687
                                    {
4688
                                        defaultBitmapImage.DownloadCompleted += (ex2, arg2) =>
4689
                                        {
4690
                                            defaultBitmapImage.Freeze();
4691
                                            image = GetBitmap(defaultBitmapImage);
4692
                                            image.Save(@AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
4693
                                            Process potrace = new Process
4694
                                            {
4695
                                                StartInfo = new ProcessStartInfo
4696
                                                {
4697
                                                    FileName = @AppDomain.CurrentDomain.BaseDirectory + "potrace.exe",
4698
                                                    Arguments = "-b svg " + @AppDomain.CurrentDomain.BaseDirectory + "potrace.bmp",
4699
                                                    RedirectStandardInput = true,
4700
                                                    RedirectStandardOutput = true,
4701
                                                    RedirectStandardError = true,
4702
                                                    UseShellExecute = false,
4703
                                                    CreateNoWindow = true,
4704
                                                    WindowStyle = ProcessWindowStyle.Hidden
4705
                                                },
4706
                                            };
4707

    
4708
                                            StringBuilder svgBuilder = new StringBuilder();
4709
                                            potrace.OutputDataReceived += (object sender2, DataReceivedEventArgs e2) =>
4710
                                            {
4711
                                                svgBuilder.AppendLine(e2.Data);
4712
                                            };
4713

    
4714
                                            potrace.EnableRaisingEvents = true;
4715
                                            potrace.Start();
4716
                                            potrace.Exited += (sender, e) =>
4717
                                            {
4718
                                                byte[] bytes = System.IO.File.ReadAllBytes(@AppDomain.CurrentDomain.BaseDirectory + "potrace.svg");
4719
                                                svgfilename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, guid + ".svg", bytes);
4720
                                                Check_Uri.UriCheck(svgfilename);
4721
                                                if (symbolselectindex == 0)
4722
                                                {
4723
                                                    SymbolSave(symbolname, svgfilename, data);
4724
                                                }
4725
                                                else
4726
                                                {
4727
                                                    SymbolSave_Public(symbolname, svgfilename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4728
                                                }
4729

    
4730
                                                DataBind();
4731
                                            };
4732
                                            potrace.WaitForExit();
4733
                                        };
4734
                                    }
4735
                                    else
4736
                                    {
4737
                                        //GC.Collect();
4738
                                    }
4739
                                }
4740
                                catch(Exception ee)
4741
                                {
4742
                                    DialogMessage_Alert("" + ee, "Alert");
4743
                                }
4744
                            }
4745
                        };                                             
4746
                    }
4747
                }
4748
            }
4749
            catch (Exception e)
4750
            {
4751
                //DialogMessage_Alert(e + "", "Alert");
4752
            }            
4753
        }
4754

    
4755
        public void SymbolSave(string Name, string Url, string Data)
4756
        {
4757
            try
4758
            {
4759
                SYMBOL_PRIVATE symbol_private = new SYMBOL_PRIVATE
4760
                {
4761
                    ID = Commons.shortGuid(),
4762
                    MEMBER_USER_ID = App.ViewInfo.UserID,
4763
                    NAME = Name,
4764
                    IMAGE_URL = Url,
4765
                    DATA = Data
4766
                };
4767

    
4768
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolCompleted += BaseClient_SaveSymbolCompleted;
4769
                Logger.sendReqLog("SaveSymbolAsync: ", symbol_private.ID + "," + symbol_private.MEMBER_USER_ID + "," + symbol_private.NAME + "," + symbol_private.IMAGE_URL + "," + symbol_private.DATA, 1);
4770
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.SaveSymbolAsync(symbol_private);
4771
            }
4772
            catch (Exception)
4773
            {
4774
                throw;
4775
            }
4776
        }
4777

    
4778
        public void SymbolSave_Public(string Name, string Url, string Data, string Department)
4779
        {
4780
            try
4781
            {
4782
                SYMBOL_PUBLIC symbol_public = new SYMBOL_PUBLIC
4783
                {
4784
                    ID = Commons.shortGuid(),
4785
                    DEPARTMENT = Department,
4786
                    NAME = Name,
4787
                    IMAGE_URL = Url,
4788
                    DATA = Data
4789
                };
4790
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbolCompleted += BaseClient_AddPublicSymbolCompleted;
4791
                Logger.sendReqLog("AddPublicSymbol: ", symbol_public.ID + "," + symbol_public.DEPARTMENT + "," + symbol_public.NAME + "," + symbol_public.IMAGE_URL + "," + symbol_public.DATA, 1);
4792
                Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.AddPublicSymbol(symbol_public);
4793
            }
4794
            catch (Exception)
4795
            {
4796
                throw;
4797
            }
4798
        }
4799

    
4800
        private void BaseClient_AddPublicSymbolCompleted(object sender, ServiceDeepView.AddPublicSymbolCompletedEventArgs e)
4801
        {           
4802
            Logger.sendResLog("AddPublicSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4803
            DataBind();
4804
        }
4805

    
4806
        private void BaseClient_SaveSymbolCompleted(object sender, ServiceDeepView.SaveSymbolCompletedEventArgs e)
4807
        {
4808
            Logger.sendResLog("RenameSymbolCompleted", "UserState : " + e.UserState + "\r Result :" + e.Result + "\r Cancelled :" + e.Cancelled + "\r Error :" + e.Error, 1);
4809
            DataBind();
4810
        }
4811
        private void DataBind()
4812
        {
4813
            try
4814
            {
4815
                Symbol_Custom Custom = new Symbol_Custom();
4816
                List<Symbol_Custom> Custom_List = new List<Symbol_Custom>();
4817
                
4818
                var symbol_Private = BaseClient.GetSymbolList(App.ViewInfo.UserID);
4819
                foreach (var item in symbol_Private)
4820
                {
4821
                    Custom.Name = item.NAME;
4822
                    Custom.ImageUri = item.IMAGE_URL;
4823
                    Custom.ID = item.ID;
4824
                    Custom_List.Add(Custom);
4825
                    Custom = new Symbol_Custom();
4826
                }
4827
                symbolPanel_Instance.lstSymbolPrivate.ItemsSource = Custom_List;
4828
                
4829
                Custom = new Symbol_Custom();
4830
                Custom_List = new List<Symbol_Custom>();
4831

    
4832
                symbolPanel_Instance.deptlist.ItemsSource = BaseClient.GetPublicSymbolDeptList();
4833

    
4834
                List<SYMBOL_PUBLIC> symbol_Public;
4835

    
4836
                if (symbolPanel_Instance.deptlist.SelectedValue != null)
4837
                {
4838
                    symbol_Public = BaseClient.GetPublicSymbolList(symbolPanel_Instance.deptlist.SelectedValue.ToString());
4839
                }
4840
                else
4841
                {
4842
                    symbol_Public = BaseClient.GetPublicSymbolList(null);
4843
                }
4844
                foreach (var item in symbol_Public)
4845
                {
4846
                    Custom.Name = item.NAME;
4847
                    Custom.ImageUri = item.IMAGE_URL;
4848
                    Custom.ID = item.ID;
4849
                    Custom_List.Add(Custom);
4850
                    Custom = new Symbol_Custom();
4851
                }
4852
                symbolPanel_Instance.lstSymbolPublic.ItemsSource = Custom_List;
4853
                BaseClient.Close();                
4854
            }
4855
            catch(Exception e)
4856
            {
4857
                //DialogMessage_Alert("DataBind", "Alert");
4858
            }
4859
            
4860
        }
4861
        private void MarkupNamePromptClose(string data, WindowClosedEventArgs args)
4862
        {
4863
            try
4864
            {
4865
                if (args.PromptResult != null)
4866
                {
4867
                    if (args.DialogResult.Value)
4868
                    {
4869
                        PngBitmapEncoder _Encoder = symImage(data);
4870

    
4871
                        System.IO.MemoryStream fs = new System.IO.MemoryStream();
4872
                        _Encoder.Save(fs);
4873
                        System.Drawing.Image ImgOut = System.Drawing.Image.FromStream(fs);
4874

    
4875
                        byte[] Img_byte = fs.ToArray();
4876

    
4877
                        kr.co.devdoftech.cloud.FileUpload fileUploader = new kr.co.devdoftech.cloud.FileUpload();
4878
                        filename = fileUploader.Run(App.ViewInfo.ProjectNO, _DocItem.DOCUMENT_NO, App.ViewInfo.UserID, Commons.shortGuid() + ".png", Img_byte);
4879
                        Check_Uri.UriCheck(filename);
4880
                        if (symbolPanel_Instance.RadTab.SelectedIndex == 0)
4881
                        {
4882
                            SaveCommand.Instance.SymbolSave(args.PromptResult, filename, data);
4883
                        }
4884
                        else
4885
                        {
4886
                            SaveCommand.Instance.SymbolSave_Public(args.PromptResult, filename, data, ViewerDataModel.Instance.SystemMain.dzMainMenu.userData.DEPARTMENT);
4887
                        }
4888
                        DataBind();
4889
                    }
4890
                }
4891
            }
4892
            catch(Exception ex)
4893
            {
4894
                DialogMessage_Alert("" + ex, "Alert");
4895
            }
4896
        }
4897

    
4898
        public PngBitmapEncoder symImage(string data)
4899
        {
4900

    
4901
            Canvas _canvas = new Canvas();
4902
            _canvas.Background = Brushes.White;
4903
            _canvas.Width = adorner_.BorderSize.Width;
4904
            _canvas.Height = adorner_.BorderSize.Height;
4905
            MarkupParser.Parse(App.ViewInfo.ProjectNO, data, _canvas, "#FFFF0000", "");
4906

    
4907
            BitmapEncoder encoder = new PngBitmapEncoder();
4908

    
4909

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

    
4912
            DrawingVisual dv = new DrawingVisual();
4913

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

    
4917
            using (DrawingContext ctx = dv.RenderOpen())
4918
            {
4919
                VisualBrush vb = new VisualBrush(_canvas);
4920
                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)));
4921
            }
4922

    
4923
            try
4924
            {
4925
                renderBitmap.Render(dv);
4926

    
4927
                //GC.Collect();
4928
                GC.WaitForPendingFinalizers();
4929
                //GC.Collect();
4930
                // encode png data
4931
                PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
4932
                // puch rendered bitmap into it
4933
                pngEncoder.Interlace = PngInterlaceOption.Off;
4934
                pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
4935
                return pngEncoder;
4936

    
4937
            }
4938
            catch //(Exception ex)
4939
            {
4940
                return null;
4941
            }
4942

    
4943
        }
4944

    
4945
        public void DialogMessage_Alert(string content, string header)
4946
        {
4947
            DialogParameters parameters = new DialogParameters()
4948
            {
4949
                Owner = Application.Current.MainWindow,
4950
                Content = new TextBlock()
4951
                { 
4952
                    MinWidth = 400,
4953
                    FontSize = 11,
4954
                    Text = content,
4955
                    TextWrapping = System.Windows.TextWrapping.Wrap
4956
                },
4957
                Header = header,
4958
                Theme = new VisualStudio2013Theme(),
4959
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
4960
            };            
4961
            RadWindow.Alert(parameters);
4962
        }
4963

    
4964
        #region 캡쳐 기능
4965

    
4966
        public BitmapSource CutAreaToImage(int x, int y, int width, int height)
4967
        {
4968
            if (x < 0)
4969
            {
4970
                width += x;
4971
                x = 0;
4972
            }
4973
            if (y < 0)
4974
            {
4975
                height += y;
4976
                y = 0;
4977

    
4978
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4979
            }
4980
            if (x + width > zoomAndPanCanvas.ActualWidth)
4981
            {
4982
                width = (int)zoomAndPanCanvas.ActualWidth - x;
4983
            }
4984
            if (y + height > zoomAndPanCanvas.ActualHeight)
4985
            {
4986
                height = (int)zoomAndPanCanvas.ActualHeight - y;
4987
            }
4988

    
4989
            byte[] pixels = CopyPixels(x, y, width, height);
4990

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

    
4993
            return BitmapSource.Create(width, height, 96, 96, PixelFormats.Pbgra32, null, pixels, stride);
4994
        }
4995

    
4996
        public byte[] CopyPixels(int x, int y, int width, int height)
4997
        {
4998
            byte[] pixels = new byte[width * height * 4];
4999
            int stride = (width * canvasImage.Format.BitsPerPixel + 7) / 8;
5000

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

    
5004
            return pixels;
5005
        }
5006

    
5007
        public RenderTargetBitmap ConverterBitmapImage(FrameworkElement element)
5008
        {
5009
            DrawingVisual drawingVisual = new DrawingVisual();
5010
            DrawingContext drawingContext = drawingVisual.RenderOpen();
5011

    
5012
            // 해당 객체의 그래픽요소로 사각형의 그림을 그립니다.
5013
            drawingContext.DrawRectangle(new VisualBrush(element), null,
5014
                new Rect(new Point(0, 0), new Point(element.ActualWidth, element.ActualHeight)));
5015
            drawingContext.Close();
5016

    
5017
            // 비트맵으로 변환합니다.
5018
            RenderTargetBitmap target =
5019
                new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight,
5020
                96, 96, System.Windows.Media.PixelFormats.Pbgra32);
5021

    
5022
            target.Render(drawingVisual);
5023
            return target;
5024
        }
5025

    
5026
        System.Drawing.Bitmap GetBitmap(BitmapSource source)
5027
        {
5028
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
5029
            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);
5030
            source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
5031
            bmp.UnlockBits(data);
5032
            return bmp;
5033
        }
5034
        public string symbolname = null;
5035
        public bool symbolsvg = true;
5036
        public bool symbolpng = true;
5037

    
5038
        public void Save_Symbol_Capture(BitmapSource source, int x, int y, int width, int height)
5039
        {
5040
            System.Drawing.Bitmap image = GetBitmap(source);
5041
            //흰색 제거
5042
            //image.MakeTransparent(System.Drawing.Color.White);
5043

    
5044
            var imageStream = new System.IO.MemoryStream();
5045
            byte[] imageBytes = null;
5046
            using (imageStream)
5047
            {
5048
                image.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
5049
                // test.Save(@"E:\test.png", System.Drawing.Imaging.ImageFormat.Png);
5050
                imageStream.Position = 0;
5051
                imageBytes = imageStream.ToArray();
5052
            }
5053

    
5054
            SymbolPrompt symbolPrompt = new SymbolPrompt();
5055

    
5056
            RadWindow CheckPop = new RadWindow();
5057
            //Alert check = new Alert(Msg);
5058

    
5059
            CheckPop = new RadWindow
5060
            {
5061
                MinWidth = 400,
5062
                MinHeight = 100,
5063
               // Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5064
                Header = "Alert",
5065
                Content = symbolPrompt,
5066
                //DialogResult = 
5067
                ResizeMode = System.Windows.ResizeMode.NoResize,
5068
                WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen,
5069
                IsTopmost = true,
5070
            };
5071
            CheckPop.Closed += (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args);
5072
            StyleManager.SetTheme(CheckPop, new Office2013Theme());
5073
            CheckPop.ShowDialog();
5074

    
5075
            /*
5076
            DialogParameters parameters = new DialogParameters()
5077
            {
5078
                Owner = Application.Current.MainWindow,
5079
                Closed = (obj, args) => this.SymbolMarkupNamePromptClose(imageBytes, "", args),
5080
                DefaultPromptResultValue = "Custom State",
5081
                Content = "Name :",
5082
                Header = "Insert Custom Symbol Name",
5083
                Theme = new VisualStudio2013Theme(),
5084
                ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 },
5085
            };            
5086
            RadWindow.Prompt(parameters);
5087
            */
5088
        }
5089

    
5090
        public void Save_Capture(BitmapSource source, int x, int y, int width, int height)
5091
        {
5092
            KCOM.Common.Converter.FileStreamToBase64 streamToBase64 = new Common.Converter.FileStreamToBase64();
5093
            KCOMDataModel.DataModel.CHECK_LIST check_;
5094
            string Result = streamToBase64.ImageToBase64(source);
5095
            KCOMDataModel.DataModel.CHECK_LIST Item = new KCOMDataModel.DataModel.CHECK_LIST();
5096
            string projectno = App.ViewInfo.ProjectNO;
5097
            string checklist_id = ViewerDataModel.Instance.CheckList_ID;
5098

    
5099
            Logger.sendReqLog("GetCheckList", projectno + "," + checklist_id, 1);
5100
            Item = this.BaseClient.GetCheckList(projectno, checklist_id);
5101
            if (Item != null)
5102
            {
5103
                Logger.sendResLog("GetCheckList", "TRUE", 1);
5104
            }
5105
            else
5106
            {
5107
                Logger.sendResLog("GetCheckList", "FALSE", 1);
5108
            }
5109

    
5110
            if (Item == null)
5111
            {
5112
                check_ = new KCOMDataModel.DataModel.CHECK_LIST
5113
                {
5114
                    ID = Commons.shortGuid(),
5115
                    USER_ID = App.ViewInfo.UserID,
5116
                    IMAGE_URL = Result,
5117
                    IMAGE_ANCHOR = x + "," + y + "," + width + "," + height,
5118
                    PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber,
5119
                    REVISION = ViewerDataModel.Instance.SystemMain.dzMainMenu.CurrentDoc.Revision,
5120
                    DOCUMENT_ID = App.ViewInfo.DocumentItemID,
5121
                    PROJECT_NO = App.ViewInfo.ProjectNO,
5122
                    STATUS = "False",
5123
                    CREATE_TIME = DateTime.Now,
5124
                    UPDATE_TIME = DateTime.Now,
5125
                    DOCUMENT_NO = _DocItem.DOCUMENT_NO,
5126
                    STATUS_DESC_OPEN = "Vendor 반영 필요",
5127
                };
5128
                Logger.sendReqLog("AddCheckList", projectno + "," + check_, 1);
5129
                Logger.sendResLog("AddCheckList", this.BaseClient.AddCheckList(projectno, check_).ToString(), 1);
5130
                //this.BaseClient.AddCheckList(projectno, check_);
5131
            }
5132
            else
5133
            {
5134
                Item.IMAGE_URL = Result;
5135
                Item.IMAGE_ANCHOR = x + "," + y + "," + width + "," + height;
5136
                Item.PAGENUMBER = this.pageNavigator.CurrentPage.PageNumber;
5137
                Logger.sendReqLog("SaveCheckList", projectno + "," + checklist_id + "," + Item, 1);
5138
                Logger.sendResLog("SaveCheckList", this.BaseClient.SaveCheckList(projectno, checklist_id, Item).ToString(), 1);
5139
                //this.BaseClient.SaveCheckList(projectno, checklist_id, Item);
5140
            }
5141

    
5142
        }
5143

    
5144
        public void Set_Capture()
5145
        {
5146
            double x = canvasDrawingMouseDownPoint.X;
5147
            double y = canvasDrawingMouseDownPoint.Y;
5148
            double width = dragCaptureBorder.Width;
5149
            double height = dragCaptureBorder.Height;
5150

    
5151
            if (width > 5 || height > 5)
5152
            {
5153
                canvasImage = ConverterBitmapImage(zoomAndPanCanvas);
5154
                BitmapSource source = CutAreaToImage((int)x, (int)y, (int)width, (int)height);
5155
                Save_Capture(source, (int)x, (int)y, (int)width, (int)height);
5156
            }
5157
        }
5158
        #endregion
5159

    
5160
        public Multi_Undo_data Control_Style(CommentUserInfo control)
5161
        {
5162
            multi_Undo_Data = new Multi_Undo_data();
5163

    
5164
            multi_Undo_Data.Markup = control;
5165

    
5166
            if ((control as IShapeControl) != null)
5167
            {
5168
                multi_Undo_Data.paint = (control as IShapeControl).Paint;
5169
            }
5170
            if ((control as IDashControl) != null)
5171
            {
5172
                multi_Undo_Data.DashSize = (control as IDashControl).DashSize;
5173
            }
5174
            if ((control as IPath) != null)
5175
            {
5176
                multi_Undo_Data.LineSize = (control as IPath).LineSize;
5177
            }
5178
            if ((control as UIElement) != null)
5179
            {
5180
                multi_Undo_Data.Opacity = (control as UIElement).Opacity;
5181
            }
5182

    
5183
            return multi_Undo_Data;
5184
        }
5185

    
5186
        private void Comment_Move(object sender, MouseButtonEventArgs e)
5187
        {
5188
            string Select_ID = (((e.Source as Telerik.Windows.Controls.RadButton).DataContext) as IKCOM.MarkupInfoItem).UserID;
5189
            foreach (var items in ViewerDataModel.Instance._markupInfoRevList)
5190
            {
5191
                if (items.UserID == Select_ID)
5192
                {
5193
                    foreach (var item in items.MarkupList)
5194
                    {
5195
                        if (item.PageNumber == pageNavigator.CurrentPage.PageNumber)
5196
                        {
5197
                            MarkupParser.ParseEx(App.ViewInfo.ProjectNO, item.Data, Common.ViewerDataModel.Instance.MarkupControls_USER, "#FFFF0000", "", 
5198
                                items.MarkupInfoID, Commons.shortGuid());
5199
                        }
5200
                    }
5201
                }
5202
            }
5203
        }
5204

    
5205
        /// <summary>
5206
        /// convert inkcontrol to polygoncontrol
5207
        /// </summary>
5208
        public void ConvertInkControlToPolygon()
5209
        {
5210
            if (inkBoard.Strokes.Count > 0)
5211
            {
5212
                inkBoard.Strokes.ToList().ForEach(stroke =>
5213
                {
5214
                    InkToPath ip = new InkToPath();
5215

    
5216
                    List<Point> inkPointSet = new List<Point>();
5217
                    inkPointSet.AddRange(ip.GetPointsFrom(stroke));
5218

    
5219
                    PolygonControl pc = new PolygonControl()
5220
                    {
5221
                        Angle = 0,
5222
                        PointSet = inkPointSet,
5223
                        ControlType = ControlType.Ink
5224
                    };
5225
                    pc.StartPoint = inkPointSet[0];
5226
                    pc.EndPoint = inkPointSet[inkPointSet.Count - 1];
5227
                    pc.LineSize = 3;
5228
                    pc.CommentID = Commons.shortGuid();
5229
                    pc.StrokeColor = new SolidColorBrush(Colors.Red);
5230

    
5231
                    if (pc.PointSet.Count > 0)
5232
                    {
5233
                        CreateCommand.Instance.Execute(pc);
5234
                        ViewerDataModel.Instance.MarkupControls_USER.Add(pc);
5235
                    }
5236
                });
5237
                inkBoard.Strokes.Clear();
5238
            }
5239
        }
5240

    
5241
        /// <summary>
5242
        /// 캔버스에 그릴때 모든 포인트가 캔버스를 벗어 났는지 체크하여 넘겨줌
5243
        /// </summary>
5244
        /// <author>ingu</author>
5245
        /// <date>2018.06.05</date>
5246
        /// <param name="getPoint"></param>
5247
        /// <returns></returns>
5248
        private bool IsGetoutpoint(Point getPoint)
5249
        {
5250
            if (getPoint == new Point())
5251
            {
5252
                ViewerDataModel.Instance.MarkupControls_USER.Remove(currentControl);
5253
                currentControl = null;
5254
                return true;
5255
            }
5256

    
5257
            return false;
5258
        }
5259

    
5260
        private void zoomAndPanControl_DragOver(object sender, DragEventArgs e)
5261
        {
5262
            e.Effects = DragDropEffects.Copy;
5263
        }
5264

    
5265
        private void zoomAndPanControl_DragEnter(object sender, DragEventArgs e)
5266
        {
5267
            e.Effects = DragDropEffects.Copy;
5268
        }
5269

    
5270
        private void zoomAndPanControl_DragLeave(object sender, DragEventArgs e)
5271
        {
5272
            e.Effects = DragDropEffects.None;
5273
        }
5274

    
5275
        private void thumbnailPanel_SizeChanged(object sender, SizeChangedEventArgs e)
5276
        {
5277
            CommonLib.Common.WriteConfigString("SetThumbnail", "WIDTH", thumbnailPanel.Width.ToString());
5278
        }
5279

    
5280
        /*
5281
        private void zoomAndPanControl_Drop(object sender, DragEventArgs e)
5282
        {
5283
            try
5284
            {
5285
                if (e.Data.GetDataPresent(typeof(string)))
5286
                {
5287
                    this.getCurrentPoint = e.GetPosition(drawingRotateCanvas);
5288
                    string dragData = e.Data.GetData(typeof(string)) as string;
5289
                    Move_Symbol(sender, dragData);
5290
                }
5291
            }
5292
            catch (Exception ex)
5293
            {
5294
                Logger.sendResLog("zoomAndPanControl_Drop", ex.ToString(), 0);
5295
            }            
5296
        }
5297
        */
5298
    }
5299
}
클립보드 이미지 추가 (최대 크기: 500 MB)